Package org.eclipse.emfforms.spi.editor
Class GenericEditor
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.ui.part.WorkbenchPart
-
- org.eclipse.ui.part.EditorPart
-
- org.eclipse.emfforms.spi.editor.GenericEditor
-
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable,org.eclipse.core.runtime.IExecutableExtension,org.eclipse.emf.edit.domain.IEditingDomainProvider,org.eclipse.ui.ide.IGotoMarker,org.eclipse.ui.IEditorPart,org.eclipse.ui.ISaveablePart,org.eclipse.ui.IWorkbenchPart,org.eclipse.ui.IWorkbenchPart2,org.eclipse.ui.IWorkbenchPart3,org.eclipse.ui.part.IWorkbenchPartOrientation
- Direct Known Subclasses:
DataTemplateEditor,EcoreEditor,GenModelEditor,RuleRepositoryEditor,TemplateModelEditorPart,ViewModelEditor
public class GenericEditor extends org.eclipse.ui.part.EditorPart implements org.eclipse.emf.edit.domain.IEditingDomainProvider, org.eclipse.ui.ide.IGotoMarkerThe Class GenericEditor it is the generic part for editing any EObject.
-
-
Constructor Summary
Constructors Constructor Description GenericEditor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanadjustErrorMarker(org.eclipse.core.resources.IMarker marker, org.eclipse.emf.common.util.Diagnostic diagnostic)Override this method to set additional attributes on the givenIMarker, e.g.protected DiagnosticCachecreateDiangosticCache(org.eclipse.emf.common.notify.Notifier input)Creates the diagnostic cache.voidcreatePartControl(org.eclipse.swt.widgets.Composite parent)protected TreeMasterDetailCompositecreateRootView(org.eclipse.swt.widgets.Composite parent, java.lang.String editorTitle, java.lang.Object editorInput, java.util.List<org.eclipse.jface.action.Action> toolbarActions, CreateElementCallback createElementCallback)Creates the top area of the editor.protected TreeMasterDetailCompositecreateTreeMasterDetail(org.eclipse.swt.widgets.Composite composite, java.lang.Object editorInput, CreateElementCallback createElementCallback)This method creates a tree master detail.protected TreeViewerBuildercreateTreeViewerBuilder()Create theTreeViewerBuildercustomization which creates the tree for the editor's tree master detail.protected TreeMasterDetailSWTBuildercustomizeTree(TreeMasterDetailSWTBuilder builder)Customize the treebuilder.protected voiddeleteMarkers()Deletes the problem markers created by this Editor.voiddispose()voiddoSave(org.eclipse.core.runtime.IProgressMonitor monitor)voiddoSaveAs()protected booleanenableValidation()protected org.eclipse.emf.common.command.BasicCommandStackgetCommandStack()protected java.lang.StringgetContextId()Returns the context id set for this editor.protected CreateElementCallbackgetCreateElementCallback()Returns the createElementCallback for this editor.protected DiagnosticCachegetDiagnosticCache()org.eclipse.emf.edit.domain.EditingDomaingetEditingDomain()protected java.lang.StringgetEditorTitle()Returns the title for the currently displayed editor.protected org.eclipse.emf.common.notify.NotifiergetNotifierFromEditorInput(java.lang.Object editorInput)Get the Notifier from the tree input.protected java.util.Map<java.lang.Object,java.lang.Object>getResourceLoadOptions()The options to be used when loading the editor's resource.protected java.util.Map<java.lang.Object,java.lang.Object>getResourceSaveOptions()The options to be used when saving the editor's resource.org.eclipse.emf.ecore.resource.ResourceSetgetResourceSet()Returns the ResouceSet of this Editor.protected TreeMasterDetailCompositegetRootView()Returns the root composite containing the tree and the detail view.protected java.util.List<org.eclipse.jface.action.Action>getToolbarActions()Returns the toolbar actions for this editor.voidgotoMarker(org.eclipse.core.resources.IMarker marker)protected voidhandleDetailActivated(ViewModelContext detailContext)React to the rendering or re-activation of a detail context.protected voidhandleResourceChange(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> changedResources, java.util.Collection<org.eclipse.emf.ecore.resource.Resource> removedResources)Handles filesystem changes.protected booleanhasShortcuts()Returns true, if the editor should have shortcuts.voidinit(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)protected booleanisClosing()Returns whether this editor is currently in the process of shutting down.booleanisDirty()protected booleanisEditable(org.eclipse.ui.IEditorInput editorInput)Returns whether the editor input allows editing of its contents.booleanisSaveAsAllowed()protected org.eclipse.emf.ecore.resource.ResourceSetloadResource(org.eclipse.ui.IEditorInput editorInput)Creates a resource set and loads all required resources for the editor input.protected java.lang.ObjectmodifyEditorInput(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)Allows to modify the input object for the editor.protected voidpostSave()Executes the code which needs to be executed after a save, e.g.protected voidpreSave()Executes the code which needs to be executed before a save, e.g.protected java.util.List<org.eclipse.jface.action.Action>readToolbarActions()Read toolbar actions from all extensions.protected voidrefreshTreeAfterResourceChange()Called after a resource change to refresh the tree master detail of the editor.protected voidreloadResources(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)Reloads the given resources and refreshes the tree accordingly.protected voidremoveResources(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)Removes the given Resources from this editor's ResourceSet.voidreveal(org.eclipse.emf.ecore.EObject objectToReveal)The given element will be revealed in the tree of the editor.voidreveal(UniqueSetting setting)Reveal the control that edits asettingof some object.protected voidsetClosing(boolean closing)Set whether this editor is currently in the process of shutting down.voidsetFocus()protected voidverifyEditorResource(org.eclipse.emf.common.util.URI resourceURI, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)Check that the resource was loaded correctly and show any warnings to the user.-
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartName
-
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
-
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
-
-
-
Method Detail
-
getDiagnosticCache
protected DiagnosticCache getDiagnosticCache()
- Returns:
- the
DiagnosticCache. may benull - Since:
- 1.10
-
doSave
public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
- Specified by:
doSavein interfaceorg.eclipse.ui.ISaveablePart- Specified by:
doSavein classorg.eclipse.ui.part.EditorPart
-
preSave
protected void preSave()
Executes the code which needs to be executed before a save, e.g. removing listeners.- Since:
- 1.10
-
postSave
protected void postSave()
Executes the code which needs to be executed after a save, e.g. readding listeners.- Since:
- 1.10
-
handleResourceChange
protected void handleResourceChange(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> changedResources, java.util.Collection<org.eclipse.emf.ecore.resource.Resource> removedResources)Handles filesystem changes.- Parameters:
changedResources- A List of changed ResourcesremovedResources- A List of removed Resources
-
reloadResources
protected void reloadResources(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
Reloads the given resources and refreshes the tree accordingly.- Parameters:
resources- TheResourcesto reload- Since:
- 1.22
-
refreshTreeAfterResourceChange
protected void refreshTreeAfterResourceChange()
Called after a resource change to refresh the tree master detail of the editor. By default only the tree is refreshed. If the tree's input is not this editor's resource but only derived from it, this method should be overridden to reset the tree's input.- Since:
- 1.22
-
doSaveAs
public void doSaveAs()
- Specified by:
doSaveAsin interfaceorg.eclipse.ui.ISaveablePart- Specified by:
doSaveAsin classorg.eclipse.ui.part.EditorPart
-
init
public void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input) throws org.eclipse.ui.PartInitException- Specified by:
initin interfaceorg.eclipse.ui.IEditorPart- Specified by:
initin classorg.eclipse.ui.part.EditorPart- Throws:
org.eclipse.ui.PartInitException
-
getContextId
protected java.lang.String getContextId()
Returns the context id set for this editor.- Returns:
- the context id
-
isDirty
public boolean isDirty()
- Specified by:
isDirtyin interfaceorg.eclipse.ui.ISaveablePart- Specified by:
isDirtyin classorg.eclipse.ui.part.EditorPart
-
isSaveAsAllowed
public boolean isSaveAsAllowed()
- Specified by:
isSaveAsAllowedin interfaceorg.eclipse.ui.ISaveablePart- Specified by:
isSaveAsAllowedin classorg.eclipse.ui.part.EditorPart
-
createPartControl
public void createPartControl(org.eclipse.swt.widgets.Composite parent)
- Specified by:
createPartControlin interfaceorg.eclipse.ui.IWorkbenchPart- Specified by:
createPartControlin classorg.eclipse.ui.part.WorkbenchPart
-
deleteMarkers
protected void deleteMarkers() throws org.eclipse.core.runtime.CoreExceptionDeletes the problem markers created by this Editor. Please take care that this method should be called from aJobto avoid problems with a locked index.- Throws:
org.eclipse.core.runtime.CoreException- if the method fails- Since:
- 1.10
-
getNotifierFromEditorInput
protected org.eclipse.emf.common.notify.Notifier getNotifierFromEditorInput(java.lang.Object editorInput)
Get the Notifier from the tree input.- Parameters:
editorInput- The editor input to transform- Returns:
Notifier- Throws:
java.lang.IllegalStateException- if the editor input is not a Notifier
-
createDiangosticCache
protected DiagnosticCache createDiangosticCache(org.eclipse.emf.common.notify.Notifier input)
Creates the diagnostic cache.- Parameters:
input- the input- Returns:
- the cache
- Since:
- 1.10
-
enableValidation
protected boolean enableValidation()
- Returns:
- whether a diagnostic cache should be managed.
- Since:
- 1.10
-
createRootView
protected TreeMasterDetailComposite createRootView(org.eclipse.swt.widgets.Composite parent, java.lang.String editorTitle, java.lang.Object editorInput, java.util.List<org.eclipse.jface.action.Action> toolbarActions, CreateElementCallback createElementCallback)
Creates the top area of the editor.- Parameters:
parent- The parentCompositeeditorTitle- The title of the editoreditorInput- the editor inputtoolbarActions- The actions shown on the top areacreateElementCallback- a call back if elements are created- Returns:
- a
TreeMasterDetailComposite - Since:
- 1.14
-
getRootView
protected TreeMasterDetailComposite getRootView()
Returns the root composite containing the tree and the detail view. This is null before the editor control is created.- Returns:
- The root
TreeMasterDetailCompositeof this editor - Since:
- 1.20
-
createTreeMasterDetail
protected TreeMasterDetailComposite createTreeMasterDetail(org.eclipse.swt.widgets.Composite composite, java.lang.Object editorInput, CreateElementCallback createElementCallback)
This method creates a tree master detail. Override this method if you want to customize the tree.- Parameters:
composite- the parent compositeeditorInput- the editor inputcreateElementCallback- the create element callback to add- Returns:
- the
TreeMasterDetailComposite
-
createTreeViewerBuilder
protected TreeViewerBuilder createTreeViewerBuilder()
Create theTreeViewerBuildercustomization which creates the tree for the editor's tree master detail.Clients can override this to customize the tree viewer.
- Returns:
- the
TreeViewerBuilderwhich creates the tree viewer for the editor's tree master detail - Since:
- 1.20
-
modifyEditorInput
protected java.lang.Object modifyEditorInput(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Allows to modify the input object for the editor.- Parameters:
resourceSet- the resourceSet which is the default editor input- Returns:
- the object to set as the input
-
loadResource
protected org.eclipse.emf.ecore.resource.ResourceSet loadResource(org.eclipse.ui.IEditorInput editorInput) throws org.eclipse.ui.PartInitExceptionCreates a resource set and loads all required resources for the editor input.- Parameters:
editorInput- the editor input- Returns:
- the resource set
- Throws:
org.eclipse.ui.PartInitException- if the resource could not be loaded
-
isEditable
protected boolean isEditable(org.eclipse.ui.IEditorInput editorInput)
Returns whether the editor input allows editing of its contents.- Parameters:
editorInput- the editor'sIEditorInput- Returns:
trueif the input source allows editing,falseotherwise- Since:
- 1.22
-
verifyEditorResource
protected void verifyEditorResource(org.eclipse.emf.common.util.URI resourceURI, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)Check that the resource was loaded correctly and show any warnings to the user.- Parameters:
resourceSet- the resource setresourceURI- the URI of the resource- Since:
- 1.19
-
getResourceLoadOptions
protected java.util.Map<java.lang.Object,java.lang.Object> getResourceLoadOptions()
The options to be used when loading the editor's resource.- Returns:
- the load options
- Since:
- 1.19
-
getResourceSaveOptions
protected java.util.Map<java.lang.Object,java.lang.Object> getResourceSaveOptions()
The options to be used when saving the editor's resource.- Returns:
- the save options
- Since:
- 1.19
-
setFocus
public void setFocus()
- Specified by:
setFocusin interfaceorg.eclipse.ui.IWorkbenchPart- Specified by:
setFocusin classorg.eclipse.ui.part.WorkbenchPart
-
hasShortcuts
protected boolean hasShortcuts()
Returns true, if the editor should have shortcuts.- Returns:
- true, if the editor has shortcuts
-
getEditorTitle
protected java.lang.String getEditorTitle()
Returns the title for the currently displayed editor. Subclasses should override this function to change the Editor's title- Returns:
- the title
-
getCreateElementCallback
protected CreateElementCallback getCreateElementCallback()
Returns the createElementCallback for this editor. By default, there is none.- Returns:
- the callback
-
getEditingDomain
public org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
- Specified by:
getEditingDomainin interfaceorg.eclipse.emf.edit.domain.IEditingDomainProvider
-
getToolbarActions
protected java.util.List<org.eclipse.jface.action.Action> getToolbarActions()
Returns the toolbar actions for this editor.- Returns:
- A list of actions to show in the Editor's Toolbar
- Since:
- 1.10
-
readToolbarActions
protected java.util.List<org.eclipse.jface.action.Action> readToolbarActions()
Read toolbar actions from all extensions.- Returns:
- the Actions registered via extension point
- Since:
- 1.10
-
getResourceSet
public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
Returns the ResouceSet of this Editor.- Returns:
- The resource set
-
dispose
public void dispose()
- Specified by:
disposein interfaceorg.eclipse.ui.IWorkbenchPart- Overrides:
disposein classorg.eclipse.ui.part.WorkbenchPart
-
gotoMarker
public void gotoMarker(org.eclipse.core.resources.IMarker marker)
- Specified by:
gotoMarkerin interfaceorg.eclipse.ui.ide.IGotoMarker- Since:
- 1.10
- See Also:
IGotoMarker.gotoMarker(org.eclipse.core.resources.IMarker)
-
reveal
public void reveal(org.eclipse.emf.ecore.EObject objectToReveal)
The given element will be revealed in the tree of the editor.- Parameters:
objectToReveal- the object to reveal- Since:
- 1.10
-
reveal
public void reveal(UniqueSetting setting)
Reveal the control that edits asettingof some object.- Parameters:
setting- the feature setting to reveal of object- Since:
- 1.22
-
getCommandStack
protected org.eclipse.emf.common.command.BasicCommandStack getCommandStack()
- Returns:
- the commandStack the {@link import org.eclipse.emf.common.command.CommandStack;}
- Since:
- 1.10
-
adjustErrorMarker
protected boolean adjustErrorMarker(org.eclipse.core.resources.IMarker marker, org.eclipse.emf.common.util.Diagnostic diagnostic) throws org.eclipse.core.runtime.CoreExceptionOverride this method to set additional attributes on the givenIMarker, e.g. location information.- Parameters:
marker- theIMarkerto adjustdiagnostic- theDiagnostic- Returns:
trueif the marker was changed,falseotherwise- Throws:
org.eclipse.core.runtime.CoreException- in case of an error- Since:
- 1.10
-
isClosing
protected boolean isClosing()
Returns whether this editor is currently in the process of shutting down.- Returns:
trueif the editor is currently closing,falseotherwise- Since:
- 1.18
-
setClosing
protected void setClosing(boolean closing)
Set whether this editor is currently in the process of shutting down. Set this flag in case you will close the editor.- Parameters:
closing- Whether the editor is currently closing (shutting down)- Since:
- 1.18
-
removeResources
protected void removeResources(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
Removes the given Resources from this editor's ResourceSet. Thereby the resources are matched by URI.- Parameters:
resources- The Resources to remove from this editor's ResourceSet.- Since:
- 1.18
-
customizeTree
protected TreeMasterDetailSWTBuilder customizeTree(TreeMasterDetailSWTBuilder builder)
Customize the treebuilder. Subclasses are free to add customizations or override default customizations installed by this class, but the latter requires care not to break expected editor behaviour.- Parameters:
builder- the tree builder- Returns:
- the
builderfor convenience of call chaining, or if absolutely necessary an entirely new builder - Since:
- 1.24
-
handleDetailActivated
protected void handleDetailActivated(ViewModelContext detailContext)
React to the rendering or re-activation of a detail context. The default implementation does nothing; subclasses may just override it.- Parameters:
detailContext- the active detail context- Since:
- 1.24
-
-