1 /*******************************************************************************
2  * Copyright (c) 2000, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 
15 package org.eclipse.ui;
16 
17 /**
18  * An editor is a visual component within a workbench page. It is typically used
19  * to edit or browse a document or input object. The input is identified using
20  * an <code>IEditorInput</code>. Modifications made in an editor part follow an
21  * open-save-close lifecycle model (in contrast to a view part, where
22  * modifications are saved to the workbench immediately).
23  * <p>
24  * An editor is document or input-centric. Each editor has an input, and only
25  * one editor can exist for each editor input within a page. This policy has
26  * been designed to simplify part management.
27  * </p>
28  * <p>
29  * An editor should be used in place of a view whenever more than one instance
30  * of a document type can exist.
31  * </p>
32  * <p>
33  * This interface may be implemented directly. For convenience, a base
34  * implementation is defined in <code>EditorPart</code>.
35  * </p>
36  * <p>
37  * An editor part is added to the workbench in two stages:
38  * </p>
39  * <ol>
40  * <li>An editor extension is contributed to the workbench registry. This
41  * extension defines the extension id, extension class, and the file extensions
42  * which are supported by the editor.</li>
43  * <li>An editor part based upon the extension is created and added to the
44  * workbench when the user opens a file with one of the supported file
45  * extensions (or some other suitable form of editor input).</li>
46  * </ol>
47  * <p>
48  * All editor parts implement the <code>IAdaptable</code> interface; extensions
49  * are managed by the platform's adapter manager.
50  * </p>
51  *
52  * @see org.eclipse.ui.IWorkbenchPage#openEditor(IEditorInput, String)
53  * @see org.eclipse.ui.part.EditorPart
54  */
55 public interface IEditorPart extends IWorkbenchPart, ISaveablePart {
56 
57 	/**
58 	 * The property id for <code>isDirty</code>.
59 	 */
60 	int PROP_DIRTY = IWorkbenchPartConstants.PROP_DIRTY;
61 
62 	/**
63 	 * The property id for <code>getEditorInput</code>.
64 	 */
65 	int PROP_INPUT = IWorkbenchPartConstants.PROP_INPUT;
66 
67 	/**
68 	 * Returns the input for this editor. If this value changes the part must fire a
69 	 * property listener event with <code>PROP_INPUT</code>.
70 	 *
71 	 * @return the editor input
72 	 */
getEditorInput()73 	IEditorInput getEditorInput();
74 
75 	/**
76 	 * Returns the site for this editor. This method is equivalent to
77 	 * <code>(IEditorSite) getSite()</code>.
78 	 * <p>
79 	 * The site can be <code>null</code> while the editor is being initialized.
80 	 * After the initialization is complete, this value must be
81 	 * non-<code>null</code> for the remainder of the editor's life cycle.
82 	 * </p>
83 	 *
84 	 * @return the editor site; this value may be <code>null</code> if the editor
85 	 *         has not yet been initialized
86 	 */
getEditorSite()87 	IEditorSite getEditorSite();
88 
89 	/**
90 	 * Initializes this editor with the given editor site and input.
91 	 * <p>
92 	 * This method is automatically called shortly after the part is instantiated.
93 	 * It marks the start of the part's lifecycle. The {@link IWorkbenchPart#dispose
94 	 * IWorkbenchPart.dispose} method will be called automically at the end of the
95 	 * lifecycle. Clients must not call this method.
96 	 * </p>
97 	 * <p>
98 	 * Implementors of this method must examine the editor input object type to
99 	 * determine if it is understood. If not, the implementor must throw a
100 	 * <code>PartInitException</code>
101 	 * </p>
102 	 *
103 	 * @param site  the editor site
104 	 * @param input the editor input
105 	 * @exception PartInitException if this editor was not initialized successfully
106 	 */
init(IEditorSite site, IEditorInput input)107 	void init(IEditorSite site, IEditorInput input) throws PartInitException;
108 }
109