Enum Class NodeEditCommand

java.lang.Object
java.lang.Enum<NodeEditCommand>
sc.fiji.snt.gui.NodeEditCommand
All Implemented Interfaces:
Serializable, Comparable<NodeEditCommand>, java.lang.constant.Constable

public enum NodeEditCommand extends Enum<NodeEditCommand>
Node-editing commands of 'Edit Mode': single source of truth for their labels, default shortcuts and enabled-state logic, so that every front-end (classic canvas, Bdv, Bvv) exposes the same menu and key bindings. The operations themselves live in PathNodeEditor; hosts only map a command to a call and supply the cursor position (see BigViewerEditor).
Author:
Tiago Ferreira
  • Enum Constant Details

  • Field Details

    • UNDO_LABEL

      public static final String UNDO_LABEL
      Label of UNDO as a compile-time constant (e.g., for switch dispatch)
      See Also:
  • Method Details

    • values

      public static NodeEditCommand[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NodeEditCommand valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • label

      public String label(boolean nodeLocked)
      Parameters:
      nodeLocked - whether the active node is locked
      Returns:
      the menu label, which for LOCK depends on the state of the active node
    • tooltip

      public String tooltip()
      Returns:
      the tooltip, or null
    • fromActionId

      public static NodeEditCommand fromActionId(String id)
      Parameters:
      id - an id as returned by actionId()
      Returns:
      the matching command, or null
    • createMenuItem

      public JMenuItem createMenuItem(ActionListener listener)
      Creates a menu item for this command (label, shortcut and tooltip). Its action command is actionId()
      Parameters:
      listener - the listener to be notified when the item is chosen
      Returns:
      the menu item
    • label

      public String label()
      Returns:
      the menu label
    • keyCode

      public int keyCode()
      Returns:
      the default (unmodified) key code, or 0 if the command has no shortcut
    • actionId

      public String actionId()
      Returns:
      the id used to register the command in an InputMap/ActionMap
    • editToggleLabel

      public static String editToggleLabel(String pathName)
      Parameters:
      pathName - the (abbreviated) name of the path to be edited, or null
      Returns:
      the label of the Edit Mode toggle in context menus
    • shortName

      public static String shortName(Path p)
      Parameters:
      p - the path
      Returns:
      the (abbreviated) name of the path, for use in menu labels
    • addMenuItems

      public static void addMenuItems(JPopupMenu menu, NodeEditCommand.MenuState state, Consumer<NodeEditCommand> handler)
      Appends the node-editing commands to a menu, grouped by separators. Commands that are not applicable in the given state are disabled, not omitted
      Parameters:
      menu - the menu to be populated
      state - the editor state
      handler - the callback executed when an item is chosen
    • inputMap

      public static InputMap inputMap()
      Returns:
      a new map with the default shortcut of every command that has one
    • actionMap

      public static ActionMap actionMap(Consumer<NodeEditCommand> handler)
      Parameters:
      handler - the callback executed when a command is triggered
      Returns:
      a new map associating every command id of inputMap() with an action calling handler