Eclipse Platform
2.0

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:

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:
IWorkbenchPlugin#getEditorRegistry

Field Summary
static int PROP_CONTENTS
          The property id for the contents of this registry.
 
Method Summary
 void addPropertyListener(IPropertyListener listener)
          Adds a listener for changes to properties of this registry.
 IEditorDescriptor findEditor(String editorId)
          Finds and returns the descriptor of the editor with the given editor id.
 IEditorDescriptor getDefaultEditor()
          Returns the default editor used for all unmapped resource types.
 IEditorDescriptor getDefaultEditor(IFile file)
          Returns the default editor for a given file.
 IEditorDescriptor getDefaultEditor(String fileName)
          Returns the default editor for a given file name.
 IEditorDescriptor[] getEditors(IFile file)
          Returns the list of file editors registered to work against the given file.
 IEditorDescriptor[] getEditors(String filename)
          Returns the list of file editors registered to work against the file with the given file name.
 IFileEditorMapping[] getFileEditorMappings()
          Returns a list of mappings from file type to editor.
 ImageDescriptor getImageDescriptor(IFile file)
          Returns the image descriptor associated with a given file.
 ImageDescriptor getImageDescriptor(String filename)
          Returns the image descriptor associated with a given file.
 void removePropertyListener(IPropertyListener listener)
          Removes the given property listener from this registry.
 void setDefaultEditor(IFile file, String editorId)
          Sets the default editor id for a given file.
 

Field Detail

PROP_CONTENTS

public static final int PROP_CONTENTS
The property id for the contents of this registry.

See Also:
Constant Field Values
Method Detail

addPropertyListener

public 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:

[Issue: Check handling of identical listeners.]

Parameters:
listener - a property listener

findEditor

public 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

public IEditorDescriptor getDefaultEditor()
Returns the default editor used for all unmapped resource types. There is always a default editor.

Returns:
the descriptor of the default editor

getDefaultEditor

public IEditorDescriptor getDefaultEditor(String fileName)
Returns the default editor for a given file name.

The default editor is determined by taking the file extension for the file and obtaining the default editor for that extension.

Returns:
the descriptor of the default editor, or null if not found

getDefaultEditor

public IEditorDescriptor getDefaultEditor(IFile file)
Returns the default editor for a given file.

A default editor id may be registered for a specific file using setDefaultEditor. If the given file has a registered default editor id the default editor will derived from it. If not, the default editor is determined by taking the file extension for the file and obtaining the default editor for that extension.

Parameters:
file - the file
Returns:
the descriptor of the default editor, or null if not found

getEditors

public IEditorDescriptor[] getEditors(String filename)
Returns the list of file editors registered to work against the file with the given file name.

Note: Use getDefaultEditor if you only the need the default editor rather than all candidate editors.

Parameters:
filename - the file name
Returns:
a list of editor descriptors

getEditors

public IEditorDescriptor[] getEditors(IFile file)
Returns the list of file editors registered to work against the given file.

Note: Use getDefaultEditor if you only the need the default editor rather than all candidate editors.

This is a convenience method for use with IFile's.

Parameters:
file - the file
Returns:
a list of editor descriptors

getFileEditorMappings

public 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

public ImageDescriptor getImageDescriptor(String filename)
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
Returns:
the descriptor of the image to display next to the file

getImageDescriptor

public ImageDescriptor getImageDescriptor(IFile file)
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.

This is a convenience method for use with IFile's.

Parameters:
file - the file
Returns:
the descriptor of the image to display next to the given file

removePropertyListener

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

[Issue: Check handling of identical listeners.]

Parameters:
listener - a property listener

setDefaultEditor

public void setDefaultEditor(IFile file,
                             String editorId)
Sets the default editor id for a given file. This value will be used to determine the default editor descriptor for the file in future calls to getDefaultEditor(IFile).

Parameters:
file - the file
editorId - the editor id

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.