de.cau.cs.kieler.core.model.gmf.handlers
Class AbstractCutCopyPasteHandler

java.lang.Object
  extended by org.eclipse.gmf.runtime.common.ui.services.action.global.AbstractGlobalActionHandler
      extended by org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler
          extended by de.cau.cs.kieler.core.model.gmf.handlers.AbstractCutCopyPasteHandler
All Implemented Interfaces:
IGlobalActionHandler
Direct Known Subclasses:
KEGCutCopyPasteHandler, SyncchartsCutCopyPasteHandler

public abstract class AbstractCutCopyPasteHandler
extends DiagramGlobalActionHandler

Abstract super class for all handlers concerning copy and paste on diagrams. It checks whether the selection can be handled by the given handler and creates the commands corresponding to the requests made by the UI.

Rating yellow
(2010-06-15) msp, cmot

Constructor Summary
AbstractCutCopyPasteHandler()
          Creates a new AbstractCutCopyPasteHandler.
 
Method Summary
 boolean canHandle(IGlobalActionContext cntxt)
          
protected  boolean canKsbaseCopy(IStructuredSelection sel)
          Determine whether the current selection can be copied or cut by Ksbase.
protected  boolean canKsbasePaste(IStructuredSelection sel)
          Determine whether the current selection can be used as a target for pasting by Ksbase.
protected  boolean canPaste(IGlobalActionContext cntxt)
          
protected  org.eclipse.gmf.runtime.diagram.ui.requests.PasteViewRequest createPasteViewRequest()
          
 ICommand getCommand(IGlobalActionContext cntxt)
          
protected abstract  ICutCopyPasteCommandFactory getCommandFactory()
          Getter for the factory producing the commands.
protected  ICommand getCopyCommand(IGlobalActionContext cntxt, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart, boolean isUndoable)
          
protected  ICommand getCutCommand(IGlobalActionContext cntxt, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart)
          
protected  ICommand getKsBaseCopyCommand(IStructuredSelection sel, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
          Gets the KsBase copy command from the registered command factory.
protected  ICommand getKsBaseCutCommand(IStructuredSelection sel, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
          Gets the KsBase cut command from the registered command factory.
protected  ICommand getKsbasePasteCommand(IStructuredSelection sel, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
          Gets the KsBase paste command from the registered command factory.
protected abstract  boolean isValidSelection(IStructuredSelection selection)
          Checks whether the selection contains only valid parts.
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler
canCopy, canCut, canSave, getMapMode, getSelectedViews, selectAddedObject
 
Methods inherited from class org.eclipse.gmf.runtime.common.ui.services.action.global.AbstractGlobalActionHandler
getLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCutCopyPasteHandler

public AbstractCutCopyPasteHandler()
Creates a new AbstractCutCopyPasteHandler.

Method Detail

isValidSelection

protected abstract boolean isValidSelection(IStructuredSelection selection)
Checks whether the selection contains only valid parts. This must be implemented by the subclasses.

Parameters:
selection - the selection
Returns:
true if only valid parts are in the selection

canHandle

public boolean canHandle(IGlobalActionContext cntxt)

Specified by:
canHandle in interface IGlobalActionHandler
Overrides:
canHandle in class DiagramGlobalActionHandler

canKsbaseCopy

protected boolean canKsbaseCopy(IStructuredSelection sel)
Determine whether the current selection can be copied or cut by Ksbase. Subclasses may choose to override if they don't support all selections.

Parameters:
sel - the selection
Returns:
true if the selection can be cut/copied

canKsbasePaste

protected boolean canKsbasePaste(IStructuredSelection sel)
Determine whether the current selection can be used as a target for pasting by Ksbase. Subclasses may choose to override if they don't support all selections.

Parameters:
sel - the selection
Returns:
true if the selection can be used

canPaste

protected boolean canPaste(IGlobalActionContext cntxt)

Overrides:
canPaste in class DiagramGlobalActionHandler

getCopyCommand

protected ICommand getCopyCommand(IGlobalActionContext cntxt,
                                  org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart,
                                  boolean isUndoable)

Overrides:
getCopyCommand in class DiagramGlobalActionHandler

getCutCommand

protected ICommand getCutCommand(IGlobalActionContext cntxt,
                                 org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart)

Overrides:
getCutCommand in class DiagramGlobalActionHandler

getKsBaseCutCommand

protected ICommand getKsBaseCutCommand(IStructuredSelection sel,
                                       org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
Gets the KsBase cut command from the registered command factory.

Parameters:
sel - the selection
part - the editor
Returns:
the cut command

getKsBaseCopyCommand

protected ICommand getKsBaseCopyCommand(IStructuredSelection sel,
                                        org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
Gets the KsBase copy command from the registered command factory.

Parameters:
sel - the selection
part - the editor
Returns:
the copy command

getKsbasePasteCommand

protected ICommand getKsbasePasteCommand(IStructuredSelection sel,
                                         org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart part)
Gets the KsBase paste command from the registered command factory.

Parameters:
sel - the selection
part - the editor
Returns:
the paste command

getCommandFactory

protected abstract ICutCopyPasteCommandFactory getCommandFactory()
Getter for the factory producing the commands.

Returns:
the factory

getCommand

public ICommand getCommand(IGlobalActionContext cntxt)

Specified by:
getCommand in interface IGlobalActionHandler
Overrides:
getCommand in class DiagramGlobalActionHandler

createPasteViewRequest

protected org.eclipse.gmf.runtime.diagram.ui.requests.PasteViewRequest createPasteViewRequest()

Overrides:
createPasteViewRequest in class DiagramGlobalActionHandler