Package org.eclipse.gef.ui.parts
Class GraphicalEditor
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.EditorPart
org.eclipse.gef.ui.parts.GraphicalEditor
- All Implemented Interfaces:
- EventListener,- IAdaptable,- IExecutableExtension,- CommandStackEventListener,- CommandStackListener,- IEditorPart,- ISaveablePart,- ISelectionListener,- IWorkbenchPart,- IWorkbenchPart2,- IWorkbenchPart3,- IWorkbenchPartOrientation
- Direct Known Subclasses:
- GraphicalEditorWithFlyoutPalette,- GraphicalEditorWithPalette
public abstract class GraphicalEditor
extends EditorPart
implements CommandStackListener, CommandStackEventListener, ISelectionListener
This class serves as a quick starting point for clients who are new to GEF.
 It will create an Editor containing a single GraphicalViewer as its control.
 
IMPORTANTThis class should only be used as a reference for creating your own EditorPart implementation. This class will not suit everyone's needs, and may change in the future. Clients may copy the implementation.
- 
Field SummaryFields inherited from interface org.eclipse.ui.IEditorPartPROP_DIRTY, PROP_INPUTFields inherited from interface org.eclipse.ui.IWorkbenchPartPROP_TITLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidcommandStackChanged(EventObject event) Deprecated, for removal: This API element is subject to removal in a future version.protected voidCalled to configure the graphical viewer before it receives its contents.protected voidCreates actions for this editor.protected voidcreateGraphicalViewer(Composite parent) Creates the GraphicalViewer on the specifiedComposite.voidcreatePartControl(Composite parent) Realizes the Editor by creating it's Control.voiddispose()voiddoSaveAs()Does nothing be default.protected voidfirePropertyChange(int property) protected ActionRegistryLazily creates and returns the action registry.<T> TgetAdapter(Class<T> type) Returns the adapter for the specified key.protected CommandStackReturns the command stack.protected DefaultEditDomainReturns the edit domain.protected GraphicalViewerReturns the graphical viewer.Returns the list of IDs of Actions dependent on property changes in the Editor.Returns the list of IDs of Actions that are dependent on changes in the workbench'sISelectionService.protected SelectionSynchronizerReturns the selection synchronizer object.Returns the list of IDs of Actions that are dependent on the CommmandStack's state.protected voidHooks the GraphicalViewer to the rest of the Editor.voidinit(IEditorSite site, IEditorInput input) Sets the site and input for this editor then creates and initializes the actions.protected voidInitializes the ActionRegistry.protected abstract voidOverride to set the contents of the GraphicalViewer after it has been created.booleanisDirty()Returnstrueif the command stack is dirtybooleanReturnsfalseby default.voidselectionChanged(IWorkbenchPart part, ISelection selection) protected voidsetActionRegistry(ActionRegistry registry) Sets the ActionRegistry for this EditorPart.protected voidSets the EditDomain for this EditorPart.voidsetFocus()protected voidsetGraphicalViewer(GraphicalViewer viewer) Sets the graphicalViewer for this EditorPart.voidstackChanged(CommandStackEvent event) When the command stack changes, the actions interested in the command stack are updated.protected voidupdateActions(List<String> actionIds) A convenience method for updating a set of actions defined by the given List of action IDs.Methods inherited from class org.eclipse.ui.part.EditorPartcheckSite, doSave, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartNameMethods inherited from class org.eclipse.ui.part.WorkbenchPartaddPartPropertyListener, addPropertyListener, firePartPropertyChanged, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManageraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.ui.IWorkbenchPartaddPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
- 
Constructor Details- 
GraphicalEditorpublic GraphicalEditor()Constructs the editor part
 
- 
- 
Method Details- 
commandStackChangedDeprecated, for removal: This API element is subject to removal in a future version.UsestackChanged(CommandStackEvent)instead. This method will be removed after the 2027-03 release.When the command stack changes, the actions interested in the command stack are updated.- Specified by:
- commandStackChangedin interface- CommandStackListener
- Parameters:
- event- the change event
 
- 
stackChangedWhen the command stack changes, the actions interested in the command stack are updated.- Specified by:
- stackChangedin interface- CommandStackEventListener
- Parameters:
- event- the change event
 
- 
configureGraphicalViewerprotected void configureGraphicalViewer()Called to configure the graphical viewer before it receives its contents. This is where the root editpart should be configured. Subclasses should extend or override this method as needed.
- 
createActionsprotected void createActions()Creates actions for this editor. Subclasses should override this method to create and register actions with theActionRegistry.
- 
createGraphicalViewerCreates the GraphicalViewer on the specifiedComposite.- Parameters:
- parent- the parent composite
 
- 
createPartControlRealizes the Editor by creating it's Control.WARNING: This method may or may not be called by the workbench prior to dispose().- Specified by:
- createPartControlin interface- IWorkbenchPart
- Specified by:
- createPartControlin class- WorkbenchPart
- Parameters:
- parent- the parent composite
 
- 
disposepublic void dispose()- Specified by:
- disposein interface- IWorkbenchPart
- Overrides:
- disposein class- WorkbenchPart
- See Also:
 
- 
doSaveAspublic void doSaveAs()Does nothing be default. This method should be overridden ifisSaveAsAllowed()has been overridden to returntrue.- Specified by:
- doSaveAsin interface- ISaveablePart
- Specified by:
- doSaveAsin class- EditorPart
- See Also:
 
- 
firePropertyChangeprotected void firePropertyChange(int property) - Overrides:
- firePropertyChangein class- WorkbenchPart
- See Also:
 
- 
getActionRegistryLazily creates and returns the action registry.- Returns:
- the action registry
 
- 
getAdapterReturns the adapter for the specified key.IMPORTANT certain requests, such as the property sheet, may be made before or after createPartControl(Composite)is called. The order is unspecified by the Workbench.- Specified by:
- getAdapterin interface- IAdaptable
- Overrides:
- getAdapterin class- WorkbenchPart
- See Also:
 
- 
getCommandStackReturns the command stack.- Returns:
- the command stack
 
- 
getEditDomainReturns the edit domain.- Returns:
- the edit domain
 
- 
getGraphicalViewerReturns the graphical viewer.- Returns:
- the graphical viewer
 
- 
getPropertyActionsReturns the list of IDs of Actions dependent on property changes in the Editor. These actions should implement theUpdateActioninterface so that they can be updated in response to property changes. An example is the "Save" action.- Returns:
- the list of property-dependant actions
 
- 
getSelectionActionsReturns the list of IDs of Actions that are dependent on changes in the workbench'sISelectionService. The associated Actions can be found in the action registry. Such actions should implement theUpdateActioninterface so that they can be updated in response to selection changes.- Returns:
- the list of selection-dependant action IDs
- See Also:
 
- 
getSelectionSynchronizerReturns the selection synchronizer object. The synchronizer can be used to sync the selection of 2 or more EditPartViewers.- Returns:
- the synchronizer
 
- 
getStackActionsReturns the list of IDs of Actions that are dependent on the CommmandStack's state. The associated Actions can be found in the action registry. These actions should implement theUpdateActioninterface so that they can be updated in response to command stack changes. An example is the "undo" action.- Returns:
- the list of stack-dependant action IDs
 
- 
hookGraphicalViewerprotected void hookGraphicalViewer()Hooks the GraphicalViewer to the rest of the Editor. By default, the viewer is added to the SelectionSynchronizer, which can be used to keep 2 or more EditPartViewers in sync. The viewer is also registered as the ISelectionProvider for the Editor's PartSite.
- 
initSets the site and input for this editor then creates and initializes the actions. Subclasses may extend this method, but should always callsuper.init(site, input).- Specified by:
- initin interface- IEditorPart
- Specified by:
- initin class- EditorPart
- Throws:
- PartInitException
- See Also:
 
- 
initializeActionRegistryprotected void initializeActionRegistry()Initializes the ActionRegistry. This registry may be used byActionBarContributorsand/orContextMenuProviders.This method may be called on Editor creation, or lazily the first time getActionRegistry()is called.
- 
initializeGraphicalViewerprotected abstract void initializeGraphicalViewer()Override to set the contents of the GraphicalViewer after it has been created.- See Also:
 
- 
isDirtypublic boolean isDirty()Returnstrueif the command stack is dirty- Specified by:
- isDirtyin interface- ISaveablePart
- Specified by:
- isDirtyin class- EditorPart
- See Also:
 
- 
isSaveAsAllowedpublic boolean isSaveAsAllowed()- Specified by:
- isSaveAsAllowedin interface- ISaveablePart
- Specified by:
- isSaveAsAllowedin class- EditorPart
- See Also:
 
- 
selectionChanged- Specified by:
- selectionChangedin interface- ISelectionListener
- See Also:
 
- 
setActionRegistrySets the ActionRegistry for this EditorPart.- Parameters:
- registry- the registry
 
- 
setEditDomainSets the EditDomain for this EditorPart.- Parameters:
- ed- the domain
 
- 
setFocuspublic void setFocus()- Specified by:
- setFocusin interface- IWorkbenchPart
- Specified by:
- setFocusin class- WorkbenchPart
- See Also:
 
- 
setGraphicalViewerSets the graphicalViewer for this EditorPart.- Parameters:
- viewer- the graphical viewer
 
- 
updateActionsA convenience method for updating a set of actions defined by the given List of action IDs. The actions are found by looking up the ID in theaction registry. If the corresponding action is anUpdateAction, it will have itsupdate()method called.- Parameters:
- actionIds- the list of IDs to update
 
 
- 
stackChanged(CommandStackEvent)instead.