KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > IEditorInput


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.ui;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.jface.resource.ImageDescriptor;
15
16 /**
17  * <code>IEditorInput</code> is a light weight descriptor of editor input,
18  * like a file name but more abstract. It is not a model. It is a description of
19  * the model source for an <code>IEditorPart</code>.
20  * <p>
21  * Clients implementing this editor input interface should override
22  * <code>Object.equals(Object)</code> to answer true for two inputs that are
23  * the same. The <code>IWorbenchPage.openEditor</code> APIs are dependent on
24  * this to find an editor with the same input.
25  * </p>
26  * <p>
27  * Clients should extend this interface to declare new types of editor inputs.
28  * </p>
29  * <p>
30  * An editor input is passed to an editor via the <code>IEditorPart.init</code>
31  * method. Due to the wide range of valid editor inputs, it is not possible to
32  * define generic methods for getting and setting bytes.
33  * </p>
34  * <p>
35  * Editor input must implement the <code>IAdaptable</code> interface;
36  * extensions are managed by the platform's adapter manager.
37  * </p>
38  * <p>
39  * Please note that it is important that the editor input be light weight.
40  * Within the workbench, the navigation history tends to hold on to editor
41  * inputs as a means of reconstructing the editor at a later time. The
42  * navigation history can hold on to quite a few inputs (i.e., the default is
43  * fifty). The actual data model should probably not be held in the input.
44  * </p>
45  *
46  *
47  * @see org.eclipse.ui.IEditorPart
48  * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String)
49  * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String, boolean)
50  */

51 public interface IEditorInput extends IAdaptable {
52     /**
53      * Returns whether the editor input exists.
54      * <p>
55      * This method is primarily used to determine if an editor input should
56      * appear in the "File Most Recently Used" menu. An editor input will appear
57      * in the list until the return value of <code>exists</code> becomes
58      * <code>false</code> or it drops off the bottom of the list.
59      *
60      * @return <code>true</code> if the editor input exists;
61      * <code>false</code> otherwise
62      */

63     public boolean exists();
64
65     /**
66      * Returns the image descriptor for this input.
67      *
68      * <p>
69      * Note: although a null return value has never been permitted from this
70      * method, there are many known buggy implementations that return null.
71      * Clients that need the image for an editor are advised to use
72      * IWorkbenchPart.getImage() instead of IEditorInput.getImageDescriptor(),
73      * or to recover from a null return value in a manner that records the ID of
74      * the problematic editor input. Implementors that have been returning null
75      * from this method should pick some other default return value (such as
76      * ImageDescriptor.getMissingImageDescriptor()).
77      * </p>
78      *
79      * @return the image descriptor for this input; may be <code>null</code> if
80      * there is no image.
81      */

82     public ImageDescriptor getImageDescriptor();
83
84     /**
85      * Returns the name of this editor input for display purposes.
86      * <p>
87      * For instance, when the input is from a file, the return value would
88      * ordinarily be just the file name.
89      *
90      * @return the name string; never <code>null</code>;
91      */

92     public String JavaDoc getName();
93
94     /**
95      * Returns an object that can be used to save the state of this editor
96      * input.
97      *
98      * @return the persistable element, or <code>null</code> if this editor
99      * input cannot be persisted
100      */

101     public IPersistableElement getPersistable();
102
103     /**
104      * Returns the tool tip text for this editor input. This text is used to
105      * differentiate between two input with the same name. For instance,
106      * MyClass.java in folder X and MyClass.java in folder Y. The format of the
107      * text varies between input types.
108      * </p>
109      *
110      * @return the tool tip text; never <code>null</code>.
111      */

112     public String JavaDoc getToolTipText();
113 }
114
Popular Tags