org.eclipse.ui
Interface IEditorRegistry
-
public interface IEditorRegistry
Registry of editors known to the workbench.
An editor can be created in one of two ways:
- An editor can be defined by an extension to the workbench.
- The user manually associates an editor with a given resource extension
type. This will override any default workbench or platform association.
The registry does not keep track of editors that are "implicitly" determined.
For example a bitmap (.bmp
) file will typically not have a
registered editor. Instead, when no registered editor is found, the
underlying OS is consulted.
This interface is not intended to be implemented by clients.
-
See Also:
-
IWorkbench.getEditorRegistry()
-
Restriction:
- This interface is not intended to be implemented by clients.
PROP_CONTENTS
static final int PROP_CONTENTS
- The property identifier for the contents of this registry.
-
See Also:
-
Constant Field Values
SYSTEM_EXTERNAL_EDITOR_ID
static final
String SYSTEM_EXTERNAL_EDITOR_ID
- 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
IPathEditorInput
.
Use
findEditor
to access the editor descriptor for
this identifier.
-
Since:
- 3.0
-
See Also:
-
Constant Field Values
SYSTEM_INPLACE_EDITOR_ID
static final
String SYSTEM_INPLACE_EDITOR_ID
- 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
IInPlaceEditorInput
. Use
findEditor
to access the editor descriptor for this
identifier.
-
Since:
- 3.0
-
See Also:
-
Constant Field Values
addPropertyListener
void addPropertyListener(
IPropertyListener listener)
- Adds a listener for changes to properties of this registry.
Has no effect if an identical listener is already registered.
The properties ids are as follows:
-
PROP_CONTENTS
: Triggered when the file editor mappings in
the editor registry change.
-
-
Parameters:
-
listener
- a property listener
findEditor
IEditorDescriptor findEditor(
String editorId)
- Finds and returns the descriptor of the editor with the given editor id.
-
-
Parameters:
-
editorId
- the editor id
-
Returns:
- the editor descriptor with the given id, or
null
if not
found
getDefaultEditor
IEditorDescriptor getDefaultEditor()
-
Deprecated. The system external editor is the default editor.
Use
findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)
instead.
- Returns the default editor. The default editor always exist.
-
-
Returns:
- the descriptor of the default editor
getDefaultEditor
IEditorDescriptor getDefaultEditor(
String fileName)
- Returns the default editor for a given file name. This method assumes an
unknown content type for the given file.
The default editor is determined by taking the file extension for the
file and obtaining the default editor for that extension.
-
-
Parameters:
-
fileName
- the file name in the system
-
Returns:
- the descriptor of the default editor, or
null
if
not found
getDefaultEditor
IEditorDescriptor getDefaultEditor(
String fileName,
IContentType contentType)
- Returns the default editor for a given file name and with the given content type.
The default editor is determined by taking the file extension for the
file and obtaining the default editor for that extension.
-
-
Parameters:
-
fileName
- the file name in the system -
contentType
- the content type or null
for the unknown content type
-
Returns:
- the descriptor of the default editor, or
null
if not
found -
Since:
- 3.1
getEditors
IEditorDescriptor[] getEditors(
String fileName)
- 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.
Note: Use getDefaultEditor(String)
if you only the need
the default editor rather than all candidate editors.
-
-
Parameters:
-
fileName
- the file name in the system
-
Returns:
- a list of editor descriptors
getEditors
IEditorDescriptor[] getEditors(
String fileName,
IContentType contentType)
- Returns the list of file editors registered to work against the file with
the given file name and with the given content type.
Note: Use getDefaultEditor(String)
if you only the need
the default editor rather than all candidate editors.
-
-
Parameters:
-
fileName
- the file name in the system -
contentType
- the content type or null
for the unknown
content type
-
Returns:
- a list of editor descriptors
-
Since:
- 3.1
getFileEditorMappings
IFileEditorMapping[] getFileEditorMappings()
- Returns a list of mappings from file type to editor. The resulting list
is sorted in ascending order by file extension.
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.
-
-
Returns:
- a list of mappings sorted alphabetically by extension
getImageDescriptor
ImageDescriptor getImageDescriptor(
String filename)
- 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.
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.
-
-
Parameters:
-
filename
- the file name in the system
-
Returns:
- the descriptor of the image to display next to the file
getImageDescriptor
ImageDescriptor getImageDescriptor(
String filename,
IContentType contentType)
- Returns the image descriptor associated with a given file. This image is
usually displayed next to the given file.
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.
-
-
Parameters:
-
filename
- the file name in the system -
contentType
- the content type of the file or null
for the
unknown content type
-
Returns:
- the descriptor of the image to display next to the file
-
Since:
- 3.1
removePropertyListener
void removePropertyListener(
IPropertyListener listener)
- Removes the given property listener from this registry.
Has no affect if an identical listener is not registered.
-
-
Parameters:
-
listener
- a property listener
setDefaultEditor
void setDefaultEditor(
String fileNameOrExtension,
String editorId)
- 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.
-
-
Parameters:
-
fileNameOrExtension
- the file name or extension pattern (e.g. "*.xml"); -
editorId
- the editor id or null
for no default
isSystemInPlaceEditorAvailable
boolean isSystemInPlaceEditorAvailable(
String filename)
- Returns whether there is an in-place editor that could handle a file
with the given name.
-
-
Parameters:
-
filename
- the file name
-
Returns:
-
true
if an in-place editor is available, and
false
otherwise -
Since:
- 3.0
isSystemExternalEditorAvailable
boolean isSystemExternalEditorAvailable(
String filename)
- Returns whether the system has an editor that could handle a file
with the given name.
-
-
Parameters:
-
filename
- the file name
-
Returns:
-
true
if an external editor available, and
false
otherwise -
Since:
- 3.0
getSystemExternalEditorImageDescriptor
ImageDescriptor getSystemExternalEditorImageDescriptor(
String filename)
- Returns the image descriptor associated with the system editor that
would be used to edit this file externally.
-
-
Parameters:
-
filename
- the file name
-
Returns:
- the descriptor of the external editor image, or
null
if none -
Since:
- 3.0
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.