templates.diagram.actions
Class AbstractDiagramAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by templates.diagram.actions.AbstractDiagramAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
DiagramActions.AddLinkAction, DiagramActions.AssignFSAAction, DiagramActions.AssignNewFSAAction, DiagramActions.CreateAndMatchConnectorAction, DiagramActions.CreateConnectorAction, DiagramActions.CreateEntityAction, DiagramActions.CreateTemplateInstanceAction, DiagramActions.DefaultIconAction, DiagramActions.DeleteElementsAction, DiagramActions.LabelEntityAction, DiagramActions.MatchEventsAction, DiagramActions.MovedSelectionAction, DiagramActions.RemoveLinksAction, DiagramActions.SetIconColorAction, DiagramActions.SetTypeAction

public abstract class AbstractDiagramAction
extends javax.swing.AbstractAction

Provides functionality common to all undoable actions working on TemplateDiagrams.

Author:
Lenko Grigorov
See Also:
Serialized Form

Field Summary
protected  javax.swing.undo.CompoundEdit parentEdit
          If this action is not independent, the UndoableEdit the action is part of.
protected  boolean usePluralDescription
          Specifies if the user-readable description of the UndoableEdit for this action should use the plural form.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractDiagramAction()
          Calls super.
AbstractDiagramAction(java.lang.String arg0)
          Calls super with the given arguments.
AbstractDiagramAction(java.lang.String arg0, javax.swing.Icon arg1)
          Calls super with the given arguments.
 
Method Summary
protected  javax.swing.undo.UndoableEdit addBoundsAdjust(TemplateDiagram diagram, javax.swing.undo.UndoableEdit edit)
          Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates) and add the information necessary to undo the translation to the given UndoableEdit.
 void execute()
          Perform the action.
protected  void postEdit(ides.api.plugin.model.DESModel model, javax.swing.undo.UndoableEdit edit)
          Posts the given UndoableEdit to the undo stack of the given DESModel (if this action is independent), or adds the given UndoableEdit to the UndoableEdit this action is part of.
protected  void postEdit(javax.swing.undo.UndoableEdit edit)
          Posts the given UndoableEdit to the undo stack of the active DESModel in the workspace (if this action is independent), or adds the given UndoableEdit to the UndoableEdit this action is part of.
protected  void postEditAdjustCanvas(ides.api.plugin.model.DESModel model, TemplateDiagram diagram, javax.swing.undo.UndoableEdit edit)
          Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates), add the information necessary to undo the translation to the given UndoableEdit, and post the given UndoableEdit to the undo stack of the given DESModel (if this action is independent) or add the given UndoableEdit to the UndoableEdit this action is part of (if this action is not independent).
protected  void postEditAdjustCanvas(TemplateDiagram diagram, javax.swing.undo.UndoableEdit edit)
          Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates), add the information necessary to undo the translation to the given UndoableEdit, and post the given UndoableEdit to the undo stack of the active DESModel in the workspace (if this action is independent) or add the given UndoableEdit to the UndoableEdit this action is part of (if this action is not independent).
 void setLastOfMultiple(boolean b)
          Specify if the action is the last one of a multiple similar action, in effect specifying if the the plural form of the user-readable description should be used.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

parentEdit

protected javax.swing.undo.CompoundEdit parentEdit
If this action is not independent, the UndoableEdit the action is part of. null if this action is independent.


usePluralDescription

protected boolean usePluralDescription
Specifies if the user-readable description of the UndoableEdit for this action should use the plural form.

Constructor Detail

AbstractDiagramAction

public AbstractDiagramAction()
Calls super.


AbstractDiagramAction

public AbstractDiagramAction(java.lang.String arg0,
                             javax.swing.Icon arg1)
Calls super with the given arguments.

Parameters:
arg0 -
arg1 -

AbstractDiagramAction

public AbstractDiagramAction(java.lang.String arg0)
Calls super with the given arguments.

Parameters:
arg0 -
Method Detail

postEdit

protected void postEdit(javax.swing.undo.UndoableEdit edit)
Posts the given UndoableEdit to the undo stack of the active DESModel in the workspace (if this action is independent), or adds the given UndoableEdit to the UndoableEdit this action is part of. The setting for the use of a plural user-readable description is respected.

This method is called internally by the action to post the information required to undo the modifications made by the action.

Parameters:
edit - the UndoableEdit to be posted

postEdit

protected void postEdit(ides.api.plugin.model.DESModel model,
                        javax.swing.undo.UndoableEdit edit)
Posts the given UndoableEdit to the undo stack of the given DESModel (if this action is independent), or adds the given UndoableEdit to the UndoableEdit this action is part of. The setting for the use of a plural user-readable description is respected.

Parameters:
model - the DESModel to whose undo stack the UndoableEdit should be added
edit - the UndoableEdit to be posted

postEditAdjustCanvas

protected void postEditAdjustCanvas(TemplateDiagram diagram,
                                    javax.swing.undo.UndoableEdit edit)
Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates), add the information necessary to undo the translation to the given UndoableEdit, and post the given UndoableEdit to the undo stack of the active DESModel in the workspace (if this action is independent) or add the given UndoableEdit to the UndoableEdit this action is part of (if this action is not independent). The setting for the use of a plural user-readable description is respected.

This method is called internally by the action to shift the TemplateDiagram into view after executing the action and to post the information required to undo the modifications made by the action.

Parameters:
diagram - the TemplateDiagram to be shifted into view
edit - the UndoableEdit to be posted

postEditAdjustCanvas

protected void postEditAdjustCanvas(ides.api.plugin.model.DESModel model,
                                    TemplateDiagram diagram,
                                    javax.swing.undo.UndoableEdit edit)
Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates), add the information necessary to undo the translation to the given UndoableEdit, and post the given UndoableEdit to the undo stack of the given DESModel (if this action is independent) or add the given UndoableEdit to the UndoableEdit this action is part of (if this action is not independent). The setting for the use of a plural user-readable description is respected.

This method is called internally by the action to shift the TemplateDiagram into view after executing the action and to post the information required to undo the modifications made by the action.

Parameters:
model - the DESModel to whose undo stack the UndoableEdit should be added
diagram - the TemplateDiagram to be shifted into view
edit - the UndoableEdit to be posted

addBoundsAdjust

protected javax.swing.undo.UndoableEdit addBoundsAdjust(TemplateDiagram diagram,
                                                        javax.swing.undo.UndoableEdit edit)
Translate the given TemplateDiagram so that all of its elements are completely in view (have positive co-ordinates) and add the information necessary to undo the translation to the given UndoableEdit.

Parameters:
diagram - the TemplateDiagram to be shifted into view
edit - the UndoableEdit where the addition undo information has to be included
Returns:
the new UndoableEdit which includes both the original undo information from the given UndoableEdit and the new undo information from the TemplateDiagram translation

setLastOfMultiple

public void setLastOfMultiple(boolean b)
Specify if the action is the last one of a multiple similar action, in effect specifying if the the plural form of the user-readable description should be used.

Parameters:
b - true if this is the last action of a multiple and the plural form of the user-readable description has to be used; otherwise false

execute

public void execute()
Perform the action.