Class KeyBindingData

java.lang.Object
docking.action.KeyBindingData

public class KeyBindingData extends Object
A class for storing an action's key stroke, mouse binding or both.

Note: this class creates key strokes that work on key pressed. This effectively normalizes all client key bindings to work on the same type of key stroke (pressed, typed or released).

  • Constructor Details

    • KeyBindingData

      public KeyBindingData(KeyStroke keyStroke)
    • KeyBindingData

      public KeyBindingData(char c, int modifiers)
    • KeyBindingData

      public KeyBindingData(int keyCode, int modifiers)
    • KeyBindingData

      public KeyBindingData(MouseBinding mouseBinding)
      Constructs an instance of this class that uses a mouse binding instead of a key stroke.
      Parameters:
      mouseBinding - the mouse binding.
    • KeyBindingData

      public KeyBindingData(String keyStrokeString)
      Creates a key stroke from the given text. See KeyBindingUtils.parseKeyStroke(KeyStroke). The key stroke created for this class will always be a key pressed key stroke.
      Parameters:
      keyStrokeString - the key stroke string to parse
    • KeyBindingData

      public KeyBindingData(ActionTrigger actionTrigger)
      Creates a key binding data with the given action trigger.
      Parameters:
      actionTrigger - the trigger; may not be null
    • KeyBindingData

      public KeyBindingData(KeyStroke keyStroke, KeyBindingPrecedence precedence)
  • Method Details

    • update

      public static KeyBindingData update(KeyBindingData kbData, ActionTrigger newTrigger)
      Returns a key binding data object that matches the given trigger. If the existing key binding object already matches the new trigger, then the existing key binding data is returned. If the new trigger is null, the null will be returned.
      Parameters:
      kbData - the existing key binding data; my be null
      newTrigger - the new action trigger; may be null
      Returns:
      a key binding data based on the new action trigger; may be null
    • getKeyBinding

      public KeyStroke getKeyBinding()
      Returns an accelerator keystroke to be associated with this action.
      Returns:
      the binding
    • getKeyBindingPrecedence

      public KeyBindingPrecedence getKeyBindingPrecedence()
      Returns the keyBindingPrecedence for this action
      Returns:
      the precedence
    • getMouseBinding

      public MouseBinding getMouseBinding()
      Returns the mouse binding assigned to this key binding data.
      Returns:
      the mouse binding; may be null
    • getActionTrigger

      public ActionTrigger getActionTrigger()
      Creates a new action trigger with the values of this class
      Returns:
      the action trigger
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object