org.argouml.uml.ui
Class ActionRemoveFromModel

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended byorg.argouml.uml.ui.UMLAction
          extended byorg.argouml.uml.ui.ActionRemoveFromModel
All Implemented Interfaces:
Action, ActionListener, Cloneable, EventListener, Serializable

public class ActionRemoveFromModel
extends UMLAction

Action for removing (moving to trash) objects from the model. Objects can be: - Modelelements (NSUML) - Diagrams (argodiagram and it's children) The root model and the last diagram in the project can not be removed. The reason for this is to prevent problems updating the detailspane and the navpane. Besides that, it is not possible to make a new root model.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.AbstractAction
 
Field Summary
 
Fields inherited from class org.argouml.uml.ui.UMLAction
HAS_ICON, NO_ICON
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
ActionRemoveFromModel()
          Constructor.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Moves the selected target to the trash bin.
private  Object getNewTarget(Object target)
          Gets the object that should be target after the given target is deleted from the model.
protected  Object[] getTargets()
           
 boolean shouldBeEnabled()
          Only disabled when nothing is selected.
static boolean sureRemove(Object target)
          A utility method that asks the user if he is sure to remove the selected target.
static boolean sureRemoveModelElement(Object me)
          An utility method that asks the user if he is sure to remove a selected modelement.
 
Methods inherited from class org.argouml.uml.ui.UMLAction
getMnemonic, getValue, isEnabled, putValue, updateEnabled, updateEnabled
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionRemoveFromModel

public ActionRemoveFromModel()
Constructor.

Method Detail

shouldBeEnabled

public boolean shouldBeEnabled()
Only disabled when nothing is selected. Necessary to use since this option works via the menu too. A user cannot delete the last diagram. A user cannot delete the root model.

Overrides:
shouldBeEnabled in class UMLAction
Returns:
true if the action should be available.
See Also:
UMLAction.shouldBeEnabled()

actionPerformed

public void actionPerformed(ActionEvent ae)
Moves the selected target to the trash bin. Moves the selected target after the remove to the parent of the selected target (that is: the next level up in the navpane). In case of a diagram the selected target will be the next diagram in the list with diagrams.

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class UMLAction
See Also:
ActionListener.actionPerformed(ActionEvent)

getNewTarget

private Object getNewTarget(Object target)
Gets the object that should be target after the given target is deleted from the model.

Parameters:
target - the target to delete
Returns:
The object.

sureRemove

public static boolean sureRemove(Object target)
A utility method that asks the user if he is sure to remove the selected target.

Parameters:
target - the object that will be removed
Returns:
boolean

sureRemoveModelElement

public static boolean sureRemoveModelElement(Object me)
An utility method that asks the user if he is sure to remove a selected modelement.

Parameters:
me - the modelelement that may be removed
Returns:
boolean
See Also:
sureRemove(Object)

getTargets

protected Object[] getTargets()
Returns:
the complete array of targets


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook