Class MenuActionFactory

  • All Implemented Interfaces:
    MenuItemFactory
    Direct Known Subclasses:
    RadioMenuActionFactory

    public class MenuActionFactory
    extends java.lang.Object
    implements MenuItemFactory
    A factory that adds a given action or set of actions to a context menu. If an array of actions is given to the constructor, then the actions will be put in a submenu with the specified label.
    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Steve Neuendorffer
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Red (eal)
    • Constructor Summary

      Constructors 
      Constructor Description
      MenuActionFactory​(javax.swing.Action action)
      Construct a factory that adds a given action to a given context menu.
      MenuActionFactory​(javax.swing.Action[] actions, java.lang.String label)
      Construct a factory that adds a given group of actions to a given context menu in a submenu with the specified label.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected javax.swing.JMenuItem _add​(JContextMenu menu, javax.swing.Action action, java.lang.String tooltip)
      Add an action to the context menu.
      protected javax.swing.JMenuItem _add​(javax.swing.JMenu submenu, javax.swing.Action action)
      Add an action to the submenu.
      void addAction​(javax.swing.Action action)
      Add an action to the pre-existing group of actions.
      void addAction​(javax.swing.Action action, java.lang.String label)
      Add an action to the pre-existing group of actions.
      void addActions​(javax.swing.Action[] actions, java.lang.String label)
      Add a set of action to the pre-existing group of actions.
      void addMenuItemListener​(MenuItemListener listener)
      Add a menu item listener to the list of menu item listeners.
      javax.swing.JMenuItem create​(JContextMenu menu, NamedObj object)
      Add an item to the given context menu that will configure the parameters on the given target.
      boolean substitute​(javax.swing.Action oldAction, javax.swing.Action newAction)
      Substitute the old action with the new action, if the old action is added to this factory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MenuActionFactory

        public MenuActionFactory​(javax.swing.Action action)
        Construct a factory that adds a given action to a given context menu.
        Parameters:
        action - The action to be associated with the context menu.
      • MenuActionFactory

        public MenuActionFactory​(javax.swing.Action[] actions,
                                 java.lang.String label)
        Construct a factory that adds a given group of actions to a given context menu in a submenu with the specified label.
        Parameters:
        actions - The actions to be in the submenu.
        label - The label for the submenu.
    • Method Detail

      • addAction

        public void addAction​(javax.swing.Action action)
        Add an action to the pre-existing group of actions.
        Parameters:
        action - The action to add.
      • addAction

        public void addAction​(javax.swing.Action action,
                              java.lang.String label)
        Add an action to the pre-existing group of actions. If this was constructed with the single argument, then this converts the menu action into a submenu with the specified label.
        Parameters:
        action - The action to add.
        label - The label to give to the menu group.
      • addActions

        public void addActions​(javax.swing.Action[] actions,
                               java.lang.String label)
        Add a set of action to the pre-existing group of actions. If this was constructed with the single argument, then this converts the menu action into a submenu with the specified label.
        Parameters:
        actions - The actions to add.
        label - The label to give to the menu group if it previously not a menu group.
      • addMenuItemListener

        public void addMenuItemListener​(MenuItemListener listener)
        Add a menu item listener to the list of menu item listeners.
        Parameters:
        listener - The menu item listener.
      • create

        public javax.swing.JMenuItem create​(JContextMenu menu,
                                            NamedObj object)
        Add an item to the given context menu that will configure the parameters on the given target.
        Specified by:
        create in interface MenuItemFactory
        Parameters:
        menu - The context menu to add to.
        object - The object that the menu item command will operate on.
        Returns:
        A menu item, or null to decline to provide a menu item.
      • substitute

        public boolean substitute​(javax.swing.Action oldAction,
                                  javax.swing.Action newAction)
        Substitute the old action with the new action, if the old action is added to this factory.
        Parameters:
        oldAction - The old action.
        newAction - The new action.
        Returns:
        true if the old action is found and is substituted; false if the old action is not added to this factory.
      • _add

        protected javax.swing.JMenuItem _add​(JContextMenu menu,
                                             javax.swing.Action action,
                                             java.lang.String tooltip)
        Add an action to the context menu.
        Parameters:
        menu - The context menu.
        action - The action to be added to the context menu.
        tooltip - The tooltip for the action.
        Returns:
        The added menu item.
      • _add

        protected javax.swing.JMenuItem _add​(javax.swing.JMenu submenu,
                                             javax.swing.Action action)
        Add an action to the submenu.
        Parameters:
        submenu - The submenu.
        action - The action to be added to the submenu.
        Returns:
        The added menu item.