org.eclipse.graphiti.ui.editor
Class DefaultPersistencyBehavior

java.lang.Object
  extended by org.eclipse.graphiti.ui.editor.DefaultPersistencyBehavior

public class DefaultPersistencyBehavior
extends Object

The default implementation for the DiagramEditor behavior extension that controls the persistence behavior of the Graphiti diagram Editor. Clients may subclass to change the behavior; use DiagramEditor.createPersistencyBehavior() to return the instance that shall be used.
Note that there is always a 1:1 relation with a DiagramEditor.

Since:
0.9

Field Summary
protected  DiagramEditor diagramEditor
          The associated DiagramEditor
 
Constructor Summary
DefaultPersistencyBehavior(DiagramEditor diagramEditor)
          Creates a new instance of DefaultPersistencyBehavior that is associated with the given DiagramEditor.
 
Method Summary
protected  IRunnableWithProgress createOperation(Set<Resource> savedResources, Map<Resource,Map<?,?>> saveOptions)
          Creates the runnable to be used to wrap the actual saving of the EMF Resources.
To only modify the actual saving clients should rather override save(TransactionalEditingDomain, Map).
protected  Map<Resource,Map<?,?>> createSaveOptions()
          Returns the EMF save options to be used when saving the EMF Resources.
 Diagram loadDiagram(URI uri)
          This method is called to load the diagram into the editor.
protected  Set<Resource> save(TransactionalEditingDomain editingDomain, Map<Resource,Map<?,?>> saveOptions)
          Saves all resources in the given TransactionalEditingDomain.
 void saveDiagram(IProgressMonitor monitor)
          This method is called to save a diagram.
protected  void setDiagramVersion(Diagram diagram)
          Called in saveDiagram(IProgressMonitor) to update the Graphiti diagram version before saving a diagram.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

diagramEditor

protected final DiagramEditor diagramEditor
The associated DiagramEditor

Constructor Detail

DefaultPersistencyBehavior

public DefaultPersistencyBehavior(DiagramEditor diagramEditor)
Creates a new instance of DefaultPersistencyBehavior that is associated with the given DiagramEditor.

Parameters:
diagramEditor - the associated DiagramEditor
Method Detail

loadDiagram

public Diagram loadDiagram(URI uri)
This method is called to load the diagram into the editor. The default implementation here will use the TransactionalEditingDomain and its ResourceSet to load an EMF Resource that holds the Diagram. It will also enable modification tracking on the diagram Resource.

Parameters:
uri - the URI of the diagram to load
Returns:
the instance of the Diagram as it is resolved within the editor, meaning as it is resolved within the editor's TransactionalEditingDomain.

saveDiagram

public void saveDiagram(IProgressMonitor monitor)
This method is called to save a diagram. The default implementation here saves all changes done to any of the EMF resources loaded within the DiagramEditor so that the complete state of all modified objects will be persisted in the file system.
The default implementation also sets the current version information (currently 0.9.0) to the diagram before saving it and wraps the save operation inside a IRunnableWithProgress that cares about sending only one Resource change event holding all modified files. Besides also all adapters are temporarily switched off (see DiagramEditor.disableAdapters()).
To only modify the actual saving clients should rather override save(TransactionalEditingDomain, Map).

Parameters:
monitor - the Eclipse IProgressMonitor to use to report progress

createSaveOptions

protected Map<Resource,Map<?,?>> createSaveOptions()
Returns the EMF save options to be used when saving the EMF Resources.

Returns:
a Map object holding the used EMF save options.

createOperation

protected IRunnableWithProgress createOperation(Set<Resource> savedResources,
                                                Map<Resource,Map<?,?>> saveOptions)
Creates the runnable to be used to wrap the actual saving of the EMF Resources.
To only modify the actual saving clients should rather override save(TransactionalEditingDomain, Map).

Parameters:
savedResources - this parameter will after the operation has been performed contain all EMF Resources that have really been saved.
saveOptions - the EMF save options to use.
Returns:
an IRunnableWithProgress instance wrapping the actual save process.

save

protected Set<Resource> save(TransactionalEditingDomain editingDomain,
                             Map<Resource,Map<?,?>> saveOptions)
Saves all resources in the given TransactionalEditingDomain. Can be overridden to enable additional (call the super method to save the EMF resources) or other persistencies.

Parameters:
editingDomain - the TransactionalEditingDomain for which all resources will be saved
saveOptions - the EMF save options used for the saving.
Returns:
a Set of all EMF Resources that where actually saved.

setDiagramVersion

protected void setDiagramVersion(Diagram diagram)
Called in saveDiagram(IProgressMonitor) to update the Graphiti diagram version before saving a diagram. Currently the diagram version is set to 0.9.0

Parameters:
diagram - the Diagram to update the version attribute for


Copyright (c) SAP AG 2005, 2010.