public abstract class EditorManager extends Service
EditorManager
manages the life cycle of Editor
s.
It is also the registry of information about what editors can be used with
particular documents.
Clients use this class to open an editor on a Document
.
When clients request to open an editor on a specific document, the editor
manager performs the following tasks:
Editor.open(javax.ide.command.Context)
method passing the appropriate
context.
Editor.restore(java.util.prefs.Preferences)
method to restore any previously
saved editor state.
View.setVisible(boolean)
method to display
the editor.
EditorListener.opened(javax.ide.editor.EditorEvent)
event.
closeEditor(javax.ide.editor.Editor)
method should be called
by clients to request closing an editor. When closing an editor the
editor manager performs the following tasks:
Editor.save(java.util.prefs.Preferences)
method to save the editor
current state.
Editor.close()
method.
EditorListener.closed(javax.ide.editor.EditorEvent)
event.
EditorListener
s to the editor manager.
Listener implementations are declared in the editor-listener
section of the extension manifest.IDE service providers must provide a concrete implementation of this class.
Constructor and Description |
---|
EditorManager() |
Modifier and Type | Method and Description |
---|---|
void |
addEditorListener(EditorListener listener,
java.lang.String editorClass)
Add an
EditorListener . |
abstract void |
closeEditor(Editor editor)
Close the specified
Editor . |
protected void |
fireEditorActivated(Editor editor)
Notifies all editor listeners that the specified editor was
activated.
|
protected void |
fireEditorClosed(Editor editor)
Notifies all editor listeners that the specified editor was
closed.
|
protected void |
fireEditorDeactivated(Editor editor)
Notifies all editor listeners that the specified editor was
deactivated.
|
protected void |
fireEditorOpened(Editor editor)
Notifies all editor listeners that the specified editor was
opened.
|
abstract Editor |
getActiveEditor()
Returns the Editor that is currently active.
|
abstract java.util.Set |
getAllOpenEditors()
Returns all currently open editors.
|
static EditorManager |
getEditorManager()
Get the editor manager implementation for this IDE.
|
java.util.Set |
getOpenEditors(Document document)
Get all open editors on a specific document.
|
boolean |
isOpen(Document document)
Get whether the specified document is open.
|
abstract Editor |
openEditor(Context context,
java.lang.String typeID)
Opens a document in the editor identified by the given editor
type identifier.
|
void |
removeEditorListener(EditorListener l,
java.lang.String editorClass)
Remove an
EditorListener . |
cloneLoadedServices, getService, initialize, resetAllServices, setLoadedServices
public abstract Editor getActiveEditor()
public abstract java.util.Set getAllOpenEditors()
public boolean isOpen(Document document)
document
- a document. Must not be null.public java.util.Set getOpenEditors(Document document)
document
- a document instance. Must not be null.public abstract Editor openEditor(Context context, java.lang.String typeID)
type
is null, the IDE will open the
document with the most appropriate editor.If the document is already open using that editor, the editor will be made active.
context
- the context to open an editor for. Must not be null.typeID
- the id of an editor type to open the context document in. If
null, the IDE will open the document with the default editor.java.lang.UnsupportedOperationException
- when the document cannot be
opened by any editor.public abstract void closeEditor(Editor editor)
Editor
.editor
- The editor to be closed. Must not be null.public final void addEditorListener(EditorListener listener, java.lang.String editorClass)
EditorListener
.listener
- the EditorListener
to add. Must not be null.editorClass
- Only events for this class of editor will be dispatched
to the specified listener. May be null, indicating that all editor events
will be dispatched.public final void removeEditorListener(EditorListener l, java.lang.String editorClass)
EditorListener
.l
- The EditorListener
to remove.editorClass
- The class of editors from which listener should be
removed. May be null, indicating that all editor events
will be dispatched.protected final void fireEditorOpened(Editor editor)
editor
- the editor which was opened.protected final void fireEditorClosed(Editor editor)
editor
- the editor which was closed.protected final void fireEditorActivated(Editor editor)
editor
- the editor which was activated.protected final void fireEditorDeactivated(Editor editor)
editor
- the editor which was deactivated.public static EditorManager getEditorManager()