KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javaeditor > CustomBufferFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.javaeditor;
13
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.resources.IResource;
16
17 import org.eclipse.jdt.core.IBuffer;
18 import org.eclipse.jdt.core.IBufferFactory;
19 import org.eclipse.jdt.core.ICompilationUnit;
20 import org.eclipse.jdt.core.IOpenable;
21
22
23 /**
24  * Creates <code>IBuffer</code>s based on documents.
25  * @deprecated since 3.0 no longer used
26  */

27 public class CustomBufferFactory implements IBufferFactory {
28
29     /*
30      * @see org.eclipse.jdt.core.IBufferFactory#createBuffer(org.eclipse.jdt.core.IOpenable)
31      */

32     public IBuffer createBuffer(IOpenable owner) {
33         if (owner instanceof ICompilationUnit) {
34             ICompilationUnit unit= (ICompilationUnit) owner;
35             ICompilationUnit original= unit.getPrimary();
36             IResource resource= original.getResource();
37             if (resource instanceof IFile) {
38                 return new DocumentAdapter(unit, (IFile) resource);
39             }
40
41         }
42         return DocumentAdapter.NULL;
43     }
44 }
45
Popular Tags