KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.jdt.internal.ui.javaeditor;
12
13
14
15 import org.eclipse.core.resources.IFile;
16
17 import org.eclipse.ui.part.FileEditorInput;
18
19 import org.eclipse.jdt.core.IClassFile;
20 import org.eclipse.jdt.core.JavaCore;
21
22
23 /**
24  * Editor input for .class files on the file system.
25  */

26 public class ExternalClassFileEditorInput extends FileEditorInput implements IClassFileEditorInput {
27
28     private IClassFile fClassFile;
29
30     ExternalClassFileEditorInput(IFile file) {
31         super(file);
32         refresh();
33     }
34
35     /*
36      * @see IClassFileEditorInput#getClassFile()
37      */

38     public IClassFile getClassFile() {
39         return fClassFile;
40     }
41
42     /**
43      * Refreshes this input element. Workaround for non-updating class file elements.
44      */

45     public void refresh() {
46         Object JavaDoc element= JavaCore.create(getFile());
47         if (element instanceof IClassFile)
48             fClassFile= (IClassFile) element;
49     }
50
51     /*
52      * @see IAdaptable#getAdapter(Class)
53      */

54     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
55         if (adapter == IClassFile.class)
56             return fClassFile;
57         return fClassFile.getAdapter(adapter);
58     }
59
60 }
61
Popular Tags