Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.ui.internal
Class EditorManager  view EditorManager download EditorManager.java

java.lang.Object
  extended byorg.eclipse.ui.internal.EditorManager

public class EditorManager
extends java.lang.Object

Manage a group of element editors. Prevent the creation of two editors on the same element. 06/12/00 - DS - Given the ambiguous editor input type, the manager delegates a number of responsabilities to the editor itself.

  1. The editor should determine its own title.
  2. The editor shoudl listen to resource deltas and close itself if the input is deleted. It may also choose to stay open if the editor has dirty state.
  3. The editor should persist its own state plus editor input.


Nested Class Summary
private  class EditorManager.Editor
           
private  class EditorManager.ImageWrapper
          This class extends ImageDescriptor and only holds on to an Image, it calculates its hash code based on its Image.
 
Field Summary
private  java.util.Map actionCache
           
private  org.eclipse.core.runtime.MultiStatus closingEditorStatus
           
private  EditorAreaHelper editorPresentation
           
private  org.eclipse.jface.util.IPropertyChangeListener editorPropChangeListnener
           
private  java.util.Hashtable imgHashtable
           
private  WorkbenchPage page
           
private static java.lang.String PIN_EDITOR
           
private static java.lang.String PIN_EDITOR_FOLDER
           
private static java.lang.String PIN_EDITOR_KEY
           
private  org.eclipse.ui.commands.HandlerSubmission pinEditorHandlerSubmission
           
private static java.lang.String RESOURCES_TO_SAVE_MESSAGE
           
private static java.lang.String SAVE_RESOURCES_TITLE
           
private  WorkbenchWindow window
           
 
Constructor Summary
EditorManager(WorkbenchWindow window, WorkbenchPage workbenchPage, EditorAreaHelper pres)
          EditorManager constructor comment.
 
Method Summary
 org.eclipse.core.runtime.IStatus busyRestoreEditor(EditorManager.Editor ref)
           
private  void checkCreateEditorPropListener()
          Check to determine if the property change listener for editors should be created
private  void checkCreatePinEditorShortcutKeyHandler()
          Check to determine if the handler for the pin editor keyboard shortcut should be created.
private  void checkDeleteEditorResources()
          Check to determine if the editor resources are no longer needed removes property change listener for editors removes pin editor keyboard shortcut handler disposes cached images and clears the cached images hash table
 void closeAll()
          Closes all of the editors in the workbench.
 void closeEditor(org.eclipse.ui.IEditorReference ref)
          Closes an editor.
private  java.util.List collectDirtyEditors()
          Answer a list of dirty editors.
 boolean containsEditor(org.eclipse.ui.IEditorReference ref)
          Returns whether the manager contains an editor.
private  EditorActionBars createEditorActionBars(org.eclipse.ui.internal.registry.EditorDescriptor desc)
           
private  void createEditorTab(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input, boolean setVisible)
           
private  EditorActionBars createEmptyEditorActionBars()
           
private  org.eclipse.ui.IEditorPart createPart(org.eclipse.ui.internal.registry.EditorDescriptor desc)
           
private  void createSite(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.IEditorPart part, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input)
           
private  void disposeEditorActionBars(EditorActionBars actionBars)
           
 org.eclipse.ui.IEditorPart findEditor(org.eclipse.ui.IEditorInput input)
           
private  org.eclipse.jface.resource.ImageDescriptor findImage(org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.core.runtime.IPath path)
           
private  org.eclipse.ui.IEditorReference findReusableEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc)
           
 org.eclipse.ui.IEditorPart[] getDirtyEditors()
           
private  org.eclipse.swt.widgets.Display getDisplay()
          Returns the SWT Display.
 int getEditorCount()
          Answer the number of editors.
private  org.eclipse.jface.resource.ImageDescriptor getEditorPinImageDesc()
          Method to create the editor's pin ImageDescriptor
private  org.eclipse.ui.IEditorRegistry getEditorRegistry()
           
 org.eclipse.ui.IEditorReference[] getEditors()
           
 org.eclipse.ui.IMemento getMemento(org.eclipse.ui.IEditorReference e)
           
private  org.eclipse.ui.IPathEditorInput getPathEditorInput(org.eclipse.ui.IEditorInput input)
           
 org.eclipse.ui.IEditorPart getVisibleEditor()
           
 boolean isSaveAllNeeded()
          Answer true if save is needed in any one of the editors.
 org.eclipse.ui.IEditorReference openEditor(java.lang.String editorId, org.eclipse.ui.IEditorInput input, boolean setVisible)
           
private  org.eclipse.ui.IEditorReference openEditorFromDescriptor(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input)
           
private  org.eclipse.ui.IEditorReference openExternalEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input)
          Open a specific external editor on an file based on the descriptor.
private  void openInternalEditor(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input, boolean setVisible)
          Open an internal editor on an file.
private  org.eclipse.ui.IEditorReference[] openMultiEditor(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.part.MultiEditor part, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.part.MultiEditorInput input, boolean setVisible)
           
private  org.eclipse.ui.IEditorReference openSystemExternalEditor(org.eclipse.core.runtime.IPath location)
          Open a system external editor on the input path.
private  org.eclipse.ui.IEditorReference openSystemInPlaceEditor(org.eclipse.ui.IEditorReference ref, org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input)
          Opens a system in place editor on the input.
 org.eclipse.core.runtime.IStatus restoreEditor(EditorManager.Editor ref)
           
protected  void restoreEditorState(org.eclipse.ui.IMemento editorMem, java.util.ArrayList visibleEditors, org.eclipse.ui.IEditorPart[] activeEditor, java.util.ArrayList errorWorkbooks, org.eclipse.core.runtime.MultiStatus result)
           
 org.eclipse.core.runtime.IStatus restoreState(org.eclipse.ui.IMemento memento)
           
private  org.eclipse.ui.IEditorReference reuseInternalEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc, org.eclipse.ui.IEditorInput input)
           
 boolean saveAll(boolean confirm, boolean closing)
          Save all of the editors in the workbench.
static boolean saveAll(java.util.List dirtyEditors, boolean confirm, org.eclipse.ui.IWorkbenchWindow window)
           
 boolean saveEditor(org.eclipse.ui.IEditorPart part, boolean confirm)
          Save and close an editor.
protected  void saveEditorState(org.eclipse.ui.IMemento mem, org.eclipse.ui.IEditorReference ed, org.eclipse.core.runtime.MultiStatus res)
           
 boolean savePart(org.eclipse.ui.ISaveablePart saveable, org.eclipse.ui.IWorkbenchPart part, boolean confirm)
           
 org.eclipse.core.runtime.IStatus saveState(org.eclipse.ui.IMemento memento)
           
 boolean setVisibleEditor(org.eclipse.ui.IEditorReference newEd, boolean setFocus)
          Shows an editor.
private  org.eclipse.core.runtime.IStatus unableToCreateEditor(EditorManager.Editor ref, java.lang.Throwable t)
          Returns an error status to be displayed when unable to create an editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

editorPresentation

private EditorAreaHelper editorPresentation

window

private WorkbenchWindow window

page

private WorkbenchPage page

actionCache

private java.util.Map actionCache

PIN_EDITOR_FOLDER

private static final java.lang.String PIN_EDITOR_FOLDER
See Also:
Constant Field Values

PIN_EDITOR_KEY

private static final java.lang.String PIN_EDITOR_KEY
See Also:
Constant Field Values

PIN_EDITOR

private static final java.lang.String PIN_EDITOR
See Also:
Constant Field Values

editorPropChangeListnener

private org.eclipse.jface.util.IPropertyChangeListener editorPropChangeListnener

imgHashtable

private java.util.Hashtable imgHashtable

pinEditorHandlerSubmission

private org.eclipse.ui.commands.HandlerSubmission pinEditorHandlerSubmission

closingEditorStatus

private org.eclipse.core.runtime.MultiStatus closingEditorStatus

RESOURCES_TO_SAVE_MESSAGE

private static final java.lang.String RESOURCES_TO_SAVE_MESSAGE

SAVE_RESOURCES_TITLE

private static final java.lang.String SAVE_RESOURCES_TITLE
Constructor Detail

EditorManager

public EditorManager(WorkbenchWindow window,
                     WorkbenchPage workbenchPage,
                     EditorAreaHelper pres)
EditorManager constructor comment.

Method Detail

closeAll

public void closeAll()
Closes all of the editors in the workbench. The contents are not saved. This method will close the presentation for each editor. The IEditorPart.dispose method must be called at a higher level.


closeEditor

public void closeEditor(org.eclipse.ui.IEditorReference ref)
Closes an editor. The contents are not saved. This method will close the presentation for the editor. The IEditorPart.dispose method must be called at a higher level.


checkDeleteEditorResources

private void checkDeleteEditorResources()
Check to determine if the editor resources are no longer needed removes property change listener for editors removes pin editor keyboard shortcut handler disposes cached images and clears the cached images hash table


checkCreateEditorPropListener

private void checkCreateEditorPropListener()
Check to determine if the property change listener for editors should be created


checkCreatePinEditorShortcutKeyHandler

private void checkCreatePinEditorShortcutKeyHandler()
Check to determine if the handler for the pin editor keyboard shortcut should be created.


getEditorPinImageDesc

private org.eclipse.jface.resource.ImageDescriptor getEditorPinImageDesc()
Method to create the editor's pin ImageDescriptor


collectDirtyEditors

private java.util.List collectDirtyEditors()
Answer a list of dirty editors.


containsEditor

public boolean containsEditor(org.eclipse.ui.IEditorReference ref)
Returns whether the manager contains an editor.


createEditorActionBars

private EditorActionBars createEditorActionBars(org.eclipse.ui.internal.registry.EditorDescriptor desc)

createEmptyEditorActionBars

private EditorActionBars createEmptyEditorActionBars()

disposeEditorActionBars

private void disposeEditorActionBars(EditorActionBars actionBars)

findEditor

public org.eclipse.ui.IEditorPart findEditor(org.eclipse.ui.IEditorInput input)

getDisplay

private org.eclipse.swt.widgets.Display getDisplay()
Returns the SWT Display.


getEditorCount

public int getEditorCount()
Answer the number of editors.


getEditorRegistry

private org.eclipse.ui.IEditorRegistry getEditorRegistry()

getDirtyEditors

public org.eclipse.ui.IEditorPart[] getDirtyEditors()

getEditors

public org.eclipse.ui.IEditorReference[] getEditors()

getVisibleEditor

public org.eclipse.ui.IEditorPart getVisibleEditor()

isSaveAllNeeded

public boolean isSaveAllNeeded()
Answer true if save is needed in any one of the editors.


findReusableEditor

private org.eclipse.ui.IEditorReference findReusableEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc)

openEditor

public org.eclipse.ui.IEditorReference openEditor(java.lang.String editorId,
                                                  org.eclipse.ui.IEditorInput input,
                                                  boolean setVisible)
                                           throws org.eclipse.ui.PartInitException

openEditorFromDescriptor

private org.eclipse.ui.IEditorReference openEditorFromDescriptor(org.eclipse.ui.IEditorReference ref,
                                                                 org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                                 org.eclipse.ui.IEditorInput input)
                                                          throws org.eclipse.ui.PartInitException

openExternalEditor

private org.eclipse.ui.IEditorReference openExternalEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                           org.eclipse.ui.IEditorInput input)
                                                    throws org.eclipse.ui.PartInitException
Open a specific external editor on an file based on the descriptor.


openMultiEditor

private org.eclipse.ui.IEditorReference[] openMultiEditor(org.eclipse.ui.IEditorReference ref,
                                                          org.eclipse.ui.part.MultiEditor part,
                                                          org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                          org.eclipse.ui.part.MultiEditorInput input,
                                                          boolean setVisible)
                                                   throws org.eclipse.ui.PartInitException

createEditorTab

private void createEditorTab(org.eclipse.ui.IEditorReference ref,
                             org.eclipse.ui.internal.registry.EditorDescriptor desc,
                             org.eclipse.ui.IEditorInput input,
                             boolean setVisible)
                      throws org.eclipse.ui.PartInitException

createSite

private void createSite(org.eclipse.ui.IEditorReference ref,
                        org.eclipse.ui.IEditorPart part,
                        org.eclipse.ui.internal.registry.EditorDescriptor desc,
                        org.eclipse.ui.IEditorInput input)
                 throws org.eclipse.ui.PartInitException

reuseInternalEditor

private org.eclipse.ui.IEditorReference reuseInternalEditor(org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                            org.eclipse.ui.IEditorInput input)
                                                     throws org.eclipse.ui.PartInitException

openInternalEditor

private void openInternalEditor(org.eclipse.ui.IEditorReference ref,
                                org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                org.eclipse.ui.IEditorInput input,
                                boolean setVisible)
                         throws org.eclipse.ui.PartInitException
Open an internal editor on an file. Throw up an error dialog if an exception occurs.


createPart

private org.eclipse.ui.IEditorPart createPart(org.eclipse.ui.internal.registry.EditorDescriptor desc)
                                       throws org.eclipse.ui.PartInitException

openSystemExternalEditor

private org.eclipse.ui.IEditorReference openSystemExternalEditor(org.eclipse.core.runtime.IPath location)
                                                          throws org.eclipse.ui.PartInitException
Open a system external editor on the input path.


openSystemInPlaceEditor

private org.eclipse.ui.IEditorReference openSystemInPlaceEditor(org.eclipse.ui.IEditorReference ref,
                                                                org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                                org.eclipse.ui.IEditorInput input)
                                                         throws org.eclipse.ui.PartInitException
Opens a system in place editor on the input.


findImage

private org.eclipse.jface.resource.ImageDescriptor findImage(org.eclipse.ui.internal.registry.EditorDescriptor desc,
                                                             org.eclipse.core.runtime.IPath path)

restoreState

public org.eclipse.core.runtime.IStatus restoreState(org.eclipse.ui.IMemento memento)

restoreEditor

public org.eclipse.core.runtime.IStatus restoreEditor(EditorManager.Editor ref)

busyRestoreEditor

public org.eclipse.core.runtime.IStatus busyRestoreEditor(EditorManager.Editor ref)

unableToCreateEditor

private org.eclipse.core.runtime.IStatus unableToCreateEditor(EditorManager.Editor ref,
                                                              java.lang.Throwable t)
Returns an error status to be displayed when unable to create an editor.


saveAll

public boolean saveAll(boolean confirm,
                       boolean closing)
Save all of the editors in the workbench. Return true if successful. Return false if the user has cancelled the command.


saveAll

public static boolean saveAll(java.util.List dirtyEditors,
                              boolean confirm,
                              org.eclipse.ui.IWorkbenchWindow window)

savePart

public boolean savePart(org.eclipse.ui.ISaveablePart saveable,
                        org.eclipse.ui.IWorkbenchPart part,
                        boolean confirm)

saveEditor

public boolean saveEditor(org.eclipse.ui.IEditorPart part,
                          boolean confirm)
Save and close an editor. Return true if successful. Return false if the user has cancelled the command.


saveState

public org.eclipse.core.runtime.IStatus saveState(org.eclipse.ui.IMemento memento)

setVisibleEditor

public boolean setVisibleEditor(org.eclipse.ui.IEditorReference newEd,
                                boolean setFocus)
Shows an editor. If setFocus == true then give it focus, too.


getPathEditorInput

private org.eclipse.ui.IPathEditorInput getPathEditorInput(org.eclipse.ui.IEditorInput input)

restoreEditorState

protected void restoreEditorState(org.eclipse.ui.IMemento editorMem,
                                  java.util.ArrayList visibleEditors,
                                  org.eclipse.ui.IEditorPart[] activeEditor,
                                  java.util.ArrayList errorWorkbooks,
                                  org.eclipse.core.runtime.MultiStatus result)

saveEditorState

protected void saveEditorState(org.eclipse.ui.IMemento mem,
                               org.eclipse.ui.IEditorReference ed,
                               org.eclipse.core.runtime.MultiStatus res)

getMemento

public org.eclipse.ui.IMemento getMemento(org.eclipse.ui.IEditorReference e)