Modelers

org.topcased.modeler.editor
Class Modeler

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.EditorPart
              extended by org.eclipse.gef.ui.parts.GraphicalEditor
                  extended by org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
                      extended by org.topcased.modeler.editor.Modeler
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, IEditingDomainProvider, org.eclipse.gef.commands.CommandStackListener, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.ui.ide.IGotoMarker, org.eclipse.ui.IEditorPart, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISelectionListener, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation, org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor

public abstract class Modeler
extends org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
implements org.eclipse.jface.viewers.ISelectionProvider, IEditingDomainProvider, org.eclipse.ui.ide.IGotoMarker, org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor

Basic EMF modeler.
creation : 30 nov. 2004


Field Summary
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
Modeler()
          Constructor.
 
Method Summary
 void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
          Delegates the method to the graphical viewer
protected  void asyncSave(org.eclipse.core.runtime.IProgressMonitor monitor)
          Effective save action :
Save the diagram state Save the palette state Save the active diagram Check the model integrity Save the models in the right files If one of these tasks fails, the save is cancelled and a message is send to the user.
 void close(boolean save)
          Close the editor
 void commandStackChanged(java.util.EventObject event)
           
protected  void configureGraphicalViewer()
           
protected  void configurePaletteViewer()
           
protected  void createActions()
          Creates actions for the modeler.
protected  ComposedAdapterFactory createAdapterFactory()
          This method creates the ComposedAdapterFactory that groups all the factories used by the editor.
protected  MixedEditDomain createEditDomain()
          Create and initialize the GEF-EMF EditDomain
protected  void createGraphicalViewer(org.eclipse.swt.widgets.Composite parent)
          Creates the GraphicalViewer on the specified Composite.
protected  org.eclipse.ui.views.contentoutline.IContentOutlinePage createOutlinePage()
          Create the outline for this editor.
 void createPartControl(org.eclipse.swt.widgets.Composite parent)
           
 void dispose()
           
 void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void doSaveAs()
           
protected  void doSetInput(org.eclipse.ui.IEditorInput input)
           
 IConfiguration getActiveConfiguration()
          Returns the active diagram configuration, given by the configuration manager.
 Diagram getActiveDiagram()
          Returns the currently edited diagram.
 java.lang.Object getAdapter(java.lang.Class type)
          The modeler can be adapted into a IPropertySheetPage or a IContentOutline.
protected  java.util.List<AdapterFactory> getAdapterFactories()
          This method creates the list of factories used by the editor.
 AdapterFactory getAdapterFactory()
          Returns the global adapter factory used by the editor
protected  ModelerConfigurationManager getConfigurationManager()
          Returns the manager for the different diagram configurations.
protected  org.eclipse.gef.ContextMenuProvider getContextMenuProvider(ModelerGraphicalViewer viewer)
          Subclass should override this method to instantiate their own ContextMenu
 java.lang.String getContributorId()
           
 Diagrams getDiagrams()
          Returns the global edited model.
 EditingDomain getEditingDomain()
           
abstract  java.lang.String getId()
          Return the editorID associated with this Topcased modeler.
 NavigationManager getNavigationManager()
          Returns the diagram navigation
protected  org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
          Returns the current palette root.
 org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
          Get the preference store to use for this modeler.
 org.eclipse.gef.ui.actions.ActionRegistry getPublicActionRegistry()
          Increase the access to the action registry to public
 ResourceSet getResourceSet()
          Get the ResourceSet
 org.eclipse.gef.RootEditPart getRootEditPart()
          Returns the main edit part of the editor
 org.eclipse.jface.viewers.ISelection getSelection()
          Delegates the method to the graphical viewer
 void gotoEObject(EObject eObject)
          Sets the selection state for an editor to reveal the position of the given EObject.
 void gotoMarker(org.eclipse.core.resources.IMarker marker)
           
protected  void initializeGraphicalViewer()
           
 boolean isDirty()
           
 boolean isSaveAsAllowed()
           
protected  boolean needCheckIntegrity()
          Check whether it is necessary to check the model integrity on the ResourceSet.
protected  EObject openFile(org.eclipse.core.resources.IFile file)
          Return the EObject root of a File
protected  EObject openFile(org.eclipse.core.resources.IFile file, boolean resolve)
          Return the EObject root of a File
protected  void registerSelectionChangedActions(org.eclipse.gef.GraphicalViewer viewer)
          Register actions that listen to selection
 void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
          Delegates the method to the graphical viewer
protected  void restoreActiveDiagram()
          Restore the active diagram stored the Diagrams model
protected  void restoreDiagramSettings()
          Restore the settings (viewport, zoom...) for the current diagram
protected  void restorePaletteState()
          Restore the state of the diagram palette (pinned, expanded...)
protected  void safeCommandStackChanged(java.util.EventObject event)
          Handle the event in the UI thread
protected  void saveActiveDiagram()
          Save the active diagram in the Diagrams model
protected  void saveDiagramSettings()
          Save the settings (viewport, zoom...) for the current diagram
protected  void savePaletteState()
          Save the state of the diagram palette (pinned, expanded...)
protected  void saveResources(org.eclipse.core.runtime.IProgressMonitor monitor)
          Save the resources from the current ResourceSet and add UUIDs if the preference is set
 void setActiveDiagram(Diagram diagram)
          Set the currently edited diagram
protected  void setDiagrams(Diagrams diag)
          Sets the Diagrams model
protected  void setInput(org.eclipse.ui.IEditorInput input)
           
 void setSelection(org.eclipse.jface.viewers.ISelection selection)
          Delegates the method to the graphical viewer
protected  void updateConfiguration()
          Notify the configuration manager that the active diagram changed.
protected  void updateEditPartFactory()
          Update the EditPartFactory used by the viewer to map Model element with edit parts.
protected  void updatePaletteRoot()
          Update the palette contents with objects of the model that can be displayed in the current diagram.
 
Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
createPaletteViewer, getInitialPaletteSize, getPaletteViewer, handlePaletteResized, hookPaletteViewer, initializePaletteViewer, setEditDomain, setPaletteViewer
 
Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditor
firePropertyChange, getActionRegistry, getCommandStack, getEditDomain, getGraphicalViewer, getPropertyActions, getSelectionActions, getSelectionSynchronizer, getStackActions, hookGraphicalViewer, init, initializeActionRegistry, selectionChanged, setActionRegistry, setFocus, setGraphicalViewer, updateActions
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInputWithNotify, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
 

Constructor Detail

Modeler

public Modeler()
Constructor. Set the edit domain.

Method Detail

dispose

public void dispose()
Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart
Overrides:
dispose in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
GraphicalEditor.dispose()

commandStackChanged

public void commandStackChanged(java.util.EventObject event)
Specified by:
commandStackChanged in interface org.eclipse.gef.commands.CommandStackListener
Overrides:
commandStackChanged in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
CommandStackListener.commandStackChanged(java.util.EventObject)

safeCommandStackChanged

protected void safeCommandStackChanged(java.util.EventObject event)
Handle the event in the UI thread

Parameters:
event - the command stack event

createGraphicalViewer

protected void createGraphicalViewer(org.eclipse.swt.widgets.Composite parent)
Creates the GraphicalViewer on the specified Composite.

Overrides:
createGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditor
Parameters:
parent - the parent composite
See Also:
GraphicalEditor.createGraphicalViewer(org.eclipse.swt.widgets.Composite)

getContextMenuProvider

protected org.eclipse.gef.ContextMenuProvider getContextMenuProvider(ModelerGraphicalViewer viewer)
Subclass should override this method to instantiate their own ContextMenu

Parameters:
viewer - the GraphicalViewer
Returns:
the ContextMenuProvider

configureGraphicalViewer

protected void configureGraphicalViewer()
Overrides:
configureGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
GraphicalEditor.configureGraphicalViewer()

configurePaletteViewer

protected void configurePaletteViewer()
Overrides:
configurePaletteViewer in class org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
See Also:
GraphicalEditorWithPalette.configurePaletteViewer()

registerSelectionChangedActions

protected void registerSelectionChangedActions(org.eclipse.gef.GraphicalViewer viewer)
Register actions that listen to selection

Parameters:
viewer - the graphical viewer : emitter of the selection changed events

createActions

protected void createActions()
Creates actions for the modeler.

Overrides:
createActions in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
GraphicalEditor.createActions()

getAdapterFactories

protected java.util.List<AdapterFactory> getAdapterFactories()
This method creates the list of factories used by the editor.
Resource, DI, Diagrams and Reflexive factories are added here.
This method could be overridden to added specific factories before those.

Returns:
the factories' list

createAdapterFactory

protected ComposedAdapterFactory createAdapterFactory()
This method creates the ComposedAdapterFactory that groups all the factories used by the editor.

Returns:
the multi-factory

getAdapterFactory

public AdapterFactory getAdapterFactory()
Returns the global adapter factory used by the editor

Returns:
the composed adapter factory

getActiveConfiguration

public IConfiguration getActiveConfiguration()
Returns the active diagram configuration, given by the configuration manager.

Returns:
the active configuration

getDiagrams

public Diagrams getDiagrams()
Returns the global edited model.

Returns:
the diagrams model

getPublicActionRegistry

public org.eclipse.gef.ui.actions.ActionRegistry getPublicActionRegistry()
Increase the access to the action registry to public

Returns:
the action registry

getRootEditPart

public org.eclipse.gef.RootEditPart getRootEditPart()
Returns the main edit part of the editor

Returns:
the root edit part

getAdapter

public java.lang.Object getAdapter(java.lang.Class type)
The modeler can be adapted into a IPropertySheetPage or a IContentOutline.

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
IAdaptable.getAdapter(java.lang.Class)

createOutlinePage

protected org.eclipse.ui.views.contentoutline.IContentOutlinePage createOutlinePage()
Create the outline for this editor.
This method can be overridden by subclasses to customize the outline

Returns:
the outline

getPaletteRoot

protected org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
Returns the current palette root.

Specified by:
getPaletteRoot in class org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
See Also:
GraphicalEditorWithPalette.getPaletteRoot()

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
doSave in interface org.eclipse.ui.ISaveablePart
Specified by:
doSave in class org.eclipse.ui.part.EditorPart
See Also:
ISaveablePart.doSave(org.eclipse.core.runtime.IProgressMonitor)

asyncSave

protected void asyncSave(org.eclipse.core.runtime.IProgressMonitor monitor)
                  throws org.topcased.modeler.internal.exceptions.IntegrityException,
                         java.io.IOException
Effective save action :
  1. Save the diagram state
  2. Save the palette state
  3. Save the active diagram
  4. Check the model integrity
  5. Save the models in the right files
If one of these tasks fails, the save is cancelled and a message is send to the user.

Parameters:
monitor -
Throws:
org.topcased.modeler.internal.exceptions.IntegrityException - The model is not valid
java.io.IOException - An error occurred during save

needCheckIntegrity

protected boolean needCheckIntegrity()
Check whether it is necessary to check the model integrity on the ResourceSet.

Returns:
true if the integrity check is necessary

saveResources

protected void saveResources(org.eclipse.core.runtime.IProgressMonitor monitor)
                      throws java.io.IOException
Save the resources from the current ResourceSet and add UUIDs if the preference is set

Parameters:
monitor - The progress monitor
Throws:
java.io.IOException - throws if a resource cannot be saved

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart
Overrides:
doSaveAs in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
EditorPart.doSaveAs()

initializeGraphicalViewer

protected void initializeGraphicalViewer()
Specified by:
initializeGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
GraphicalEditor.initializeGraphicalViewer()

updatePaletteRoot

protected void updatePaletteRoot()
Update the palette contents with objects of the model that can be displayed in the current diagram.


updateEditPartFactory

protected void updateEditPartFactory()
Update the EditPartFactory used by the viewer to map Model element with edit parts.


updateConfiguration

protected void updateConfiguration()
Notify the configuration manager that the active diagram changed.


setActiveDiagram

public void setActiveDiagram(Diagram diagram)
Set the currently edited diagram

Parameters:
diagram - the diagram to edit

getNavigationManager

public NavigationManager getNavigationManager()
Returns the diagram navigation

Returns:
the navigation

saveActiveDiagram

protected void saveActiveDiagram()
Save the active diagram in the Diagrams model


restoreActiveDiagram

protected void restoreActiveDiagram()
Restore the active diagram stored the Diagrams model


saveDiagramSettings

protected void saveDiagramSettings()
Save the settings (viewport, zoom...) for the current diagram


savePaletteState

protected void savePaletteState()
Save the state of the diagram palette (pinned, expanded...)


restorePaletteState

protected void restorePaletteState()
Restore the state of the diagram palette (pinned, expanded...)


restoreDiagramSettings

protected void restoreDiagramSettings()
Restore the settings (viewport, zoom...) for the current diagram


getActiveDiagram

public Diagram getActiveDiagram()
Returns the currently edited diagram.

Returns:
the edited diagram

isDirty

public boolean isDirty()
Specified by:
isDirty in interface org.eclipse.ui.ISaveablePart
Overrides:
isDirty in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
ISaveablePart.isDirty()

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.ISaveablePart
Overrides:
isSaveAsAllowed in class org.eclipse.gef.ui.parts.GraphicalEditor
See Also:
EditorPart.isSaveAsAllowed()

getResourceSet

public ResourceSet getResourceSet()
Get the ResourceSet

Returns:
ResourceSet

openFile

protected EObject openFile(org.eclipse.core.resources.IFile file)
Return the EObject root of a File

Parameters:
file - the file to read
Returns:
the root EObject the root object

openFile

protected EObject openFile(org.eclipse.core.resources.IFile file,
                           boolean resolve)
Return the EObject root of a File

Parameters:
file - the file to read
resolve - indicates that all the references must be resolved
Returns:
the root EObject the root object

createEditDomain

protected MixedEditDomain createEditDomain()
Create and initialize the GEF-EMF EditDomain

Returns:
the modeler EditDomain

setInput

protected void setInput(org.eclipse.ui.IEditorInput input)
Overrides:
setInput in class org.eclipse.ui.part.EditorPart
See Also:
EditorPart.setInput(org.eclipse.ui.IEditorInput)

doSetInput

protected void doSetInput(org.eclipse.ui.IEditorInput input)
Parameters:
input - the IEditorInput
See Also:
EditorPart.setInput(org.eclipse.ui.IEditorInput)

setDiagrams

protected void setDiagrams(Diagrams diag)
Sets the Diagrams model

Parameters:
diag - the model object Diagrams

close

public void close(boolean save)
Close the editor

Parameters:
save -

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite parent)
Specified by:
createPartControl in interface org.eclipse.ui.IWorkbenchPart
Overrides:
createPartControl in class org.eclipse.gef.ui.parts.GraphicalEditorWithPalette
See Also:
IWorkbenchPart.createPartControl(org.eclipse.swt.widgets.Composite)

addSelectionChangedListener

public void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
Delegates the method to the graphical viewer

Specified by:
addSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)

getSelection

public org.eclipse.jface.viewers.ISelection getSelection()
Delegates the method to the graphical viewer

Specified by:
getSelection in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.getSelection()

removeSelectionChangedListener

public void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
Delegates the method to the graphical viewer

Specified by:
removeSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)

setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection selection)
Delegates the method to the graphical viewer

Specified by:
setSelection in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.setSelection(org.eclipse.jface.viewers.ISelection)

getPreferenceStore

public org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
Get the preference store to use for this modeler.
Clients should overrides this method to provide their specific modeler plugin preference store.
The given preference store is used to store commons preferences as the 'Snap to geometry' , the 'Outline sorters', the 'Outline filters', the 'Delete actions' options.
Default implementation returns null.
Constants to access this preferences can be accessed by the interface ModelerPreferenceConstants.

Returns:
this modeler preference store.

getEditingDomain

public EditingDomain getEditingDomain()
Specified by:
getEditingDomain in interface IEditingDomainProvider
See Also:
IEditingDomainProvider.getEditingDomain()

gotoMarker

public void gotoMarker(org.eclipse.core.resources.IMarker marker)
Specified by:
gotoMarker in interface org.eclipse.ui.ide.IGotoMarker
See Also:
IGotoMarker.gotoMarker(org.eclipse.core.resources.IMarker)

gotoEObject

public void gotoEObject(EObject eObject)
Sets the selection state for an editor to reveal the position of the given EObject.
It searches in the different diagrams the occurrences of the EObject and ask the user to select the destination if the given EObject has several graphical representation.

Parameters:
eObject - the EObject to select

getConfigurationManager

protected ModelerConfigurationManager getConfigurationManager()
Returns the manager for the different diagram configurations.

Returns:
the manager

getContributorId

public java.lang.String getContributorId()
Specified by:
getContributorId in interface org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor
See Also:
ITabbedPropertySheetPageContributor.getContributorId()

getId

public abstract java.lang.String getId()
Return the editorID associated with this Topcased modeler. This ID is the same given in the editor extension.

Returns:
String an ID identifying the editor

Modelers

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.