Class MoveAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

    public class MoveAction
    extends FigureAction
    An action to move an object up or down in its list. This can be used, for example, to move icon elements towards the foreground or to control the order in which attributes or ports appear.
    Since:
    Ptolemy II 4.1
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ptolemy.vergil.toolbox.MoveAction.MoveType DOWN
      Indicator for move down.
      static ptolemy.vergil.toolbox.MoveAction.MoveType TO_FIRST
      Indicator for move to first.
      static ptolemy.vergil.toolbox.MoveAction.MoveType TO_LAST
      Indicator for move to last.
      static ptolemy.vergil.toolbox.MoveAction.MoveType UP
      Indicator for move up.
      • 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

      Constructors 
      Constructor Description
      MoveAction​(java.lang.String description, ptolemy.vergil.toolbox.MoveAction.MoveType type)
      Construct a new action.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)
      Perform the move action and register the undo action.
      static void move​(java.util.List targets, ptolemy.vergil.toolbox.MoveAction.MoveType type, NamedObj context)
      Move the objects in the specified list up or down in the list of similar objects in their container, as specified by the move type.
      • 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 javax.swing.Action

        accept
    • Field Detail

      • DOWN

        public static final ptolemy.vergil.toolbox.MoveAction.MoveType DOWN
        Indicator for move down.
      • TO_FIRST

        public static final ptolemy.vergil.toolbox.MoveAction.MoveType TO_FIRST
        Indicator for move to first.
      • TO_LAST

        public static final ptolemy.vergil.toolbox.MoveAction.MoveType TO_LAST
        Indicator for move to last.
      • UP

        public static final ptolemy.vergil.toolbox.MoveAction.MoveType UP
        Indicator for move up.
    • Constructor Detail

      • MoveAction

        public MoveAction​(java.lang.String description,
                          ptolemy.vergil.toolbox.MoveAction.MoveType type)
        Construct a new action. The type of move is specified by the public fields DOWN, TO_FIRST, TO_LAST, and UP.
        Parameters:
        description - A description.
        type - Indicator of the type of move.
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Perform the move action and register the undo action.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class FigureAction
        Parameters:
        event - The event.
      • move

        public static void move​(java.util.List targets,
                                ptolemy.vergil.toolbox.MoveAction.MoveType type,
                                NamedObj context)
        Move the objects in the specified list up or down in the list of similar objects in their container, as specified by the move type. If the type is TO_FIRST or UP, then the objects in the specified list are processed in reverse order, under the assumption that they will already be sorted into the order in which they appear in the list of similar objects in their container. This is factored out as a separate static method so that it can be called in the redo action and so that it can be used elsewhere. The context is what is used to register an undo action. It should be a common container, or if there is only one target, then the target itself.
        Parameters:
        targets - The list of objects to move.
        type - One of DOWN, TO_FIRST, TO_LAST, and UP.
        context - The context.