Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 824c84f9a8115d0d04af51a95e36da60ad6a18b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*******************************************************************************
 * Copyright (c) 2000, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui;

import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.resource.ImageDescriptor;

/**
 * Registry of editors known to the workbench.
 * <p>
 * An editor can be created in one of two ways:
 * <ul>
 *   <li>An editor can be defined by an extension to the workbench.</li>
 *   <li>The user manually associates an editor with a given resource extension
 *      type. This will override any default workbench or platform association.
 *      </li>
 * </ul>
 * </p>
 * <p>
 * The registry does not keep track of editors that are "implicitly" determined.
 * For example a bitmap (<code>.bmp</code>) file will typically not have a 
 * registered editor. Instead, when no registered editor is found, the 
 * underlying OS is consulted.
 * </p>
 * <p>
 * This interface is not intended to be implemented by clients.
 * </p>
 * 
 * @see org.eclipse.ui.IWorkbench#getEditorRegistry()
 * @noimplement This interface is not intended to be implemented by clients.
 */
public interface IEditorRegistry {

    /**
     * The property identifier for the contents of this registry.
     */
    public static final int PROP_CONTENTS = 0x01;

    /**
     * The identifier for the system external editor descriptor. This descriptor 
     * is always present in the registry on all platforms.
     * This editor requires an input which implements
     * {@link org.eclipse.ui.IPathEditorInput IPathEditorInput}.
     * Use {@link #findEditor findEditor} to access the editor descriptor for
     * this identifier.
     * 
     * @since 3.0
     */
    public static final String SYSTEM_EXTERNAL_EDITOR_ID = "org.eclipse.ui.systemExternalEditor"; //$NON-NLS-1$

    /**
     * The identifier for the system in-place editor descriptor. This descriptor 
     * is only present in the registry on platforms that support in-place editing
     * (for example Win32). This editor requires an input which implements
     * {@link org.eclipse.ui.IInPlaceEditorInput IInPlaceEditorInput}. Use 
     * {@link #findEditor findEditor} to access the editor descriptor for this
     * identifier.
     * 
     * @since 3.0
     */
    public static final String SYSTEM_INPLACE_EDITOR_ID = "org.eclipse.ui.systemInPlaceEditor"; //$NON-NLS-1$

    /**
     * Adds a listener for changes to properties of this registry.
     * Has no effect if an identical listener is already registered.
     * <p>
     * The properties ids are as follows:
     * <ul>
     *   <li><code>PROP_CONTENTS</code>: Triggered when the file editor mappings in
     *       the editor registry change.</li>
     * </ul>
     * </p>
     *
     * @param listener a property listener
     */
    public void addPropertyListener(IPropertyListener listener);

    /**
     * Finds and returns the descriptor of the editor with the given editor id.
     *
     * @param editorId the editor id
     * @return the editor descriptor with the given id, or <code>null</code> if not
     *   found
     */
    public IEditorDescriptor findEditor(String editorId);

    /**
     * Returns the default editor. The default editor always exist.
     *
     * @return the descriptor of the default editor
     * @deprecated The system external editor is the default editor.
     * Use <code>findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)</code>
     * instead.
     */
    public IEditorDescriptor getDefaultEditor();

    /**
	 * Returns the default editor for a given file name. This method assumes an
	 * unknown content type for the given file.
	 * <p>
	 * The default editor is determined by taking the file extension for the
	 * file and obtaining the default editor for that extension.
	 * </p>
	 * 
	 * @param fileName
	 *            the file name in the system
	 * @return the descriptor of the default editor, or <code>null</code> if
	 *         not found
	 */
    public IEditorDescriptor getDefaultEditor(String fileName);
    
    /**
     * Returns the default editor for a given file name and with the given content type.  
     * <p>
     * The default editor is determined by taking the file extension for the
     * file and obtaining the default editor for that extension.
     * </p>
     *
     * @param fileName the file name in the system
     * @param contentType the content type or <code>null</code> for the unknown content type
     * @return the descriptor of the default editor, or <code>null</code> if not
     *   found
     * @since 3.1
     */
    public IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType);

    /**
	 * Returns the list of file editors registered to work against the file with
	 * the given file name. This method assumes an unknown content type for the
	 * given file.
	 * <p>
	 * Note: Use <code>getDefaultEditor(String)</code> if you only the need
	 * the default editor rather than all candidate editors.
	 * </p>
	 * 
	 * @param fileName
	 *            the file name in the system
	 * @return a list of editor descriptors
	 */
    public IEditorDescriptor[] getEditors(String fileName);
 
    /**
	 * Returns the list of file editors registered to work against the file with
	 * the given file name and with the given content type.
	 * <p>
	 * Note: Use <code>getDefaultEditor(String)</code> if you only the need
	 * the default editor rather than all candidate editors.
	 * </p>
	 * 
	 * @param fileName
	 *            the file name in the system
	 * @param contentType
	 *            the content type or <code>null</code> for the unknown
	 *            content type
	 * @return a list of editor descriptors
	 * @since 3.1
	 */
    public IEditorDescriptor[] getEditors(String fileName, IContentType contentType);

    /**
     * Returns a list of mappings from file type to editor.  The resulting list
     * is sorted in ascending order by file extension.
     * <p>
     * Each mapping defines an extension and the set of editors that are 
     * available for that type. The set of editors includes those registered 
     * via plug-ins and those explicitly associated with a type by the user 
     * in the workbench preference pages.
     * </p>
     *
     * @return a list of mappings sorted alphabetically by extension
     */
    public IFileEditorMapping[] getFileEditorMappings();

    /**
	 * Returns the image descriptor associated with a given file. This image is
	 * usually displayed next to the given file. This method assumes an unknown
	 * content type for the given file.
	 * <p>
	 * The image is determined by taking the file extension of the file and
	 * obtaining the image for the default editor associated with that
	 * extension. A default image is returned if no default editor is available.
	 * </p>
	 * 
	 * @param filename
	 *            the file name in the system
	 * @return the descriptor of the image to display next to the file
	 */
    public ImageDescriptor getImageDescriptor(String filename);
	
    /**
	 * Returns the image descriptor associated with a given file. This image is
	 * usually displayed next to the given file.
	 * <p>
	 * The image is determined by taking the file extension of the file and
	 * obtaining the image for the default editor associated with that
	 * extension. A default image is returned if no default editor is available.
	 * </p>
	 * 
	 * @param filename
	 *            the file name in the system
	 * @param contentType
	 *            the content type of the file or <code>null</code> for the
	 *            unknown content type
	 * @return the descriptor of the image to display next to the file
	 * @since 3.1
	 */
    public ImageDescriptor getImageDescriptor(String filename, IContentType contentType);

    /**
     * Removes the given property listener from this registry.
     * Has no affect if an identical listener is not registered.
     *
     * @param listener a property listener
     */
    public void removePropertyListener(IPropertyListener listener);

    /**
     * Sets the default editor id for the files that match that
     * specified file name or extension. The specified editor must be
     * defined as an editor for that file name or extension.
     *
     * @param fileNameOrExtension the file name or extension pattern (e.g. "*.xml");
     * @param editorId the editor id or <code>null</code> for no default
     */
    public void setDefaultEditor(String fileNameOrExtension, String editorId);

    /**
     * Returns whether there is an in-place editor that could handle a file
     * with the given name.
     * 
     * @param filename the file name
     * @return <code>true</code> if an in-place editor is available, and
     * <code>false</code> otherwise
     * @since 3.0
     */
    public boolean isSystemInPlaceEditorAvailable(String filename);

    /**
     * Returns whether the system has an editor that could handle a file
     * with the given name.
     * 
     * @param filename the file name
     * @return <code>true</code> if an external editor available, and
     * <code>false</code> otherwise
     * @since 3.0
     */
    public boolean isSystemExternalEditorAvailable(String filename);

    /**
     * Returns the image descriptor associated with the system editor that
     * would be used to edit this file externally.
     *
     * @param filename the file name
     * @return the descriptor of the external editor image, or <code>null</code>
     * if none
     * @since 3.0
     */
    public ImageDescriptor getSystemExternalEditorImageDescriptor(
            String filename);
}

Back to the top