Extension SDK 10.1.2

Package oracle.ide.keyboard

Contains classes used by addins for providing accelerators for the commands they define.

See:
          Description

Interface Summary
KeyStrokeContext A KeyStrokeContext describes the keystrokes/command mappings available for a component.
KeyStrokesConstraint Defines what key can be used as a shortcut.
 

Class Summary
DefaultKeyStrokeContext This class implements the most common behavior of a KeyStrokeContext.
GrabbableFocusManager This FocusManager allows to 'steal' keys on demand.
IdeInputMapUIResource  
KeyPresetConfigPanel A IDE Settings that controls the shortcut presets
KeyStroke2String This is a custom String converter class that meets the static interface requirements as defined by
KeyStrokeContextRegistry The KeyStrokeContextRegistry is a collection of KeyStrokeContext.
KeyStrokeField A kind of text field that captures key strokes (equivalent to the windows's hot key control).
KeyStrokeFilter This class controls the keyup/keydown events to determine what can be used as an accelerator.
KeyStrokeMap The KeyStrokeMap maps Keystrokes to action binding objects.
KeyStrokeMap does not extend a real Map but implements most of the Map methods.
KeyStrokeOptions This class stores the KeyStrokeMap for one global context and multiple local contexts.
KeyStrokePanel This panel edits shortcuts in one context.
KeyStrokes Stores a multi-KeyStroke.
KeyStrokesConfigUI This is the Navigable for configurable shortcuts.
KeyStrokesConstraintFactory KeyStrokesConstraintFactory is a factory of KeyStrokeConstraint.
Since I only expect two KeyStrokeConstraint, this factory builds them.
KeyUtil Some generic methods related to KeyEvents and KeyStrokes.
MultiInputMap An InputMap that can handle multiple keys like Ctrl+K, S
MultiMapAdapter This class contains some utilities for the keyboard mapping.
PresetsPanel  
XMLKeyStrokeContext This class should only be used if your addin is part of the product.
XMLKeystrokeContextDefs  
 

Package oracle.ide.keyboard Description

Contains classes used by addins for providing accelerators for the commands they define.

Defining your default accelerators

To define your custom accelerators for your addin, you must register a KeyStrokeContext.
This object will define what actions, presets and for each preset what key is mapped with what action.

If your addin is part of JDeveloper, you should use XMLKeyStrokeContext and add your default settings to the .KDF files that are distributed with the application.

The following example shows an implementation for 2 global actions. This example assumes you have already created the 2 actions.

        final KeyStrokeContextRegistry keyStrokeContextRegistry = Ide.getKeyStrokeContextRegistry();
        keyStrokeContextRegistry.addContext(new KeyStrokeContext()
        {
          public String getName()
          {
            return "TestKeyStrokeContext";
          }

          public Set getAllActions(boolean bGlobal)
          {
            final HashSet ret;

            if (bGlobal)
            { // We only have global keys.
              ret = new HashSet();
              ret.add(myAction_1); // myAction_1 and 2 refer to IdeAction you already have created
              ret.add(myAction_2);
            }else
            {
              ret = null;
            }
            return ret;
          }

          public KeyStrokeMap getPresetKeyStrokeMap(Object preset, boolean bGlobal)
          {
            // the preset parameter would be used only if we had declared to have different
            // accelerators in multiple presets. preset would be one of the values we
            // would have returned from getAllPresets()

            final KeyStrokeMap keyStrokeMap;
            if (bGlobal)
            {
              keyStrokeMap = new KeyStrokeMap();

              // Fill the KeyStrokeMap with our accelerator/action mappings
              final KeyStrokes key_1 = new KeyStrokes(KeyEvent.CTRL_MASK|KeyEvent.SHIFT_MASK, KeyEvent.VK_X);
              final Integer commandID_1 = new Integer(myAction_1.getCommandId());
              keyStrokeMap.put(key_1, commandID_1);

              final KeyStrokes key_2 = new KeyStrokes(KeyEvent.CTRL_MASK|KeyEvent.SHIFT_MASK, KeyEvent.VK_X);
              final Integer commandID_2 = new Integer(myAction_2.getCommandId());
              keyStrokeMap.put(key_2, commandID_2);

            } else
            {
              keyStrokeMap = null;
            }
            return keyStrokeMap;
          }

          public List getAllPresets()
          { // We only have one preset: Default.
            return null;
          }

          public KeyStrokesConstraint getKeyStrokeConstraint()
          { // Safe to ignore
            return null;
          }
        };

Related Documentation

See Extending JDeveloper Using the Addin API for detailed information.


Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.