de.cau.cs.kieler.core.model.handlers
Class AbstractInitDiagramHandler

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.core.commands.AbstractHandler
          extended by de.cau.cs.kieler.core.model.handlers.AbstractInitDiagramHandler
All Implemented Interfaces:
IHandler, IHandler2
Direct Known Subclasses:
AbstractInitGraphitiDiagramHandler, InitKaomDiagramHandler, InitKegDiagramHandler, InitSyncchartsDiagramHandler

public abstract class AbstractInitDiagramHandler
extends AbstractHandler

A command handler that reinitializes a diagram file from a given model file.

Rating proposed yellow
(2010-06-14) soh

Constructor Summary
AbstractInitDiagramHandler()
           
 
Method Summary
protected abstract  TransactionalEditingDomain createEditingDomain()
          Create a new transactional editing domain.
abstract  IEditorPart createNewDiagram(EObject modelRoot, TransactionalEditingDomain editingDomain, IFile diagramPath, IProgressMonitor monitor)
          Create a new diagram file from the given semantics model.
 Object execute(ExecutionEvent event)
          
protected abstract  String getDiagramExtension()
          Provides the file extension for the diagram file.
 IEditorPart initializeDiagram(IFile modelFile, IFile diagramFile, IProgressMonitor monitor)
          Initialize a diagram file from a given model file.
protected  IEditorPart openDiagram(Resource diagramResource, String editorId)
          Utility method for opening an editor on the resource.
protected  void performPostOperationAction(IFile path, List<IFile> partners, IProgressMonitor monitor, IEditorPart newEditor)
          Perform actions after the reinitialization.
protected  void performPreOperationActions(IFile path, List<IFile> partners, IProgressMonitor monitor)
          Perform actions prior to the reinitialization.
protected  void refreshWorkspace()
          Refresh the workspace.
 void reinitialize(IFile file)
          Reinitialize the diagram file.
 
Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, dispose, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled, setEnabled
 
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
 

Constructor Detail

AbstractInitDiagramHandler

public AbstractInitDiagramHandler()
Method Detail

getDiagramExtension

protected abstract String getDiagramExtension()
Provides the file extension for the diagram file.

Returns:
the file extension

execute

public Object execute(ExecutionEvent event)
               throws ExecutionException

Throws:
ExecutionException

refreshWorkspace

protected void refreshWorkspace()
Refresh the workspace.


reinitialize

public void reinitialize(IFile file)
Reinitialize the diagram file. The current diagram file is removed, if present, and replaced by a new diagram file which is initialized from the model.

Parameters:
file - the model file

performPostOperationAction

protected void performPostOperationAction(IFile path,
                                          List<IFile> partners,
                                          IProgressMonitor monitor,
                                          IEditorPart newEditor)
Perform actions after the reinitialization. Default implementation does nothing. Subclasses may override.

Parameters:
path - the file
partners - the partner files
monitor - the progress monitor
newEditor - the newly opened editor

performPreOperationActions

protected void performPreOperationActions(IFile path,
                                          List<IFile> partners,
                                          IProgressMonitor monitor)
Perform actions prior to the reinitialization. Default implementation does nothing. Subclasses may override.

Parameters:
path - the file
partners - the affected partner files
monitor - the progress monitor

initializeDiagram

public IEditorPart initializeDiagram(IFile modelFile,
                                     IFile diagramFile,
                                     IProgressMonitor monitor)
Initialize a diagram file from a given model file.

Parameters:
modelFile - the source file.
diagramFile - the destination file.
monitor - the progress monitor
Returns:
the diagram editor that was opened, may be null

createEditingDomain

protected abstract TransactionalEditingDomain createEditingDomain()
Create a new transactional editing domain. For GMF this is done using
   GMFEditingDomainFactory.INSTANCE.createEditingDomain()
 

Returns:
a new transactional editing domain

createNewDiagram

public abstract IEditorPart createNewDiagram(EObject modelRoot,
                                             TransactionalEditingDomain editingDomain,
                                             IFile diagramPath,
                                             IProgressMonitor monitor)
Create a new diagram file from the given semantics model. Subclasses must override this as it is specific for each different diagram type.

Parameters:
modelRoot - the root element of the domain model.
editingDomain - the editing domain.
diagramPath - the destination file
monitor - the progress monitor
Returns:
the editor that was opened for the diagram, may be null

openDiagram

protected IEditorPart openDiagram(Resource diagramResource,
                                  String editorId)
                           throws PartInitException
Utility method for opening an editor on the resource.

Parameters:
diagramResource - the resource
editorId - the editor id
Returns:
the opened editor
Throws:
PartInitException - if the editor was not opened