Esempio n. 1
2
  public MainPanel() {
    super(new BorderLayout());

    InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke stab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK);
    KeyStroke senter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
    im.put(tab, im.get(enter));
    im.put(stab, im.get(senter));

    final Color orgColor = table.getSelectionBackground();
    final Color tflColor = this.getBackground();
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            table.setSelectionForeground(Color.WHITE);
            table.setSelectionBackground(orgColor);
          }

          @Override
          public void focusLost(FocusEvent e) {
            table.setSelectionForeground(Color.BLACK);
            table.setSelectionBackground(tflColor);
          }
        });

    table.setComponentPopupMenu(new TablePopupMenu());
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }
Esempio n. 2
0
 // -------->
 // original code:
 // ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java
 // modified by terai
 //     private Hashtable<Object, ArrayList<KeyStroke>> buildReverseMap(InputMap im) {
 //         Hashtable<Object, ArrayList<KeyStroke>> h = new Hashtable<>();
 //         if (Objects.isNull(im.allKeys())) {
 //             return h;
 //         }
 //         for (KeyStroke ks: im.allKeys()) {
 //             Object name = im.get(ks);
 //             if (h.containsKey(name)) {
 //                 h.get(name).add(ks);
 //             } else {
 //                 ArrayList<KeyStroke> keylist = new ArrayList<>();
 //                 keylist.add(ks);
 //                 h.put(name, keylist);
 //             }
 //         }
 //         return h;
 //     }
 private void loadBindingMap(Integer focusType, InputMap im, ActionMap am) {
   if (Objects.isNull(im.allKeys())) {
     return;
   }
   ActionMap tmpAm = new ActionMap();
   for (Object actionMapKey : am.allKeys()) {
     tmpAm.put(actionMapKey, am.get(actionMapKey));
   }
   for (KeyStroke ks : im.allKeys()) {
     Object actionMapKey = im.get(ks);
     Action action = am.get(actionMapKey);
     if (Objects.isNull(action)) {
       model.addBinding(new Binding(focusType, "____" + actionMapKey.toString(), ks.toString()));
     } else {
       model.addBinding(new Binding(focusType, actionMapKey.toString(), ks.toString()));
     }
     tmpAm.remove(actionMapKey);
   }
   if (Objects.isNull(tmpAm.allKeys())) {
     return;
   }
   for (Object actionMapKey : tmpAm.allKeys()) {
     model.addBinding(new Binding(focusType, actionMapKey.toString(), ""));
   }
 }
  private void initWizard(final String title) {
    setTitle(title);
    myCurrentStep = 0;
    myPreviousButton = new JButton(IdeBundle.message("button.wizard.previous"));
    myNextButton = new JButton(IdeBundle.message("button.wizard.next"));
    myCancelButton = new JButton(CommonBundle.getCancelButtonText());
    myHelpButton = new JButton(CommonBundle.getHelpButtonText());
    myContentPanel = new JPanel(new CardLayout());

    myIcon = new TallImageComponent(null);

    JRootPane rootPane = getRootPane();
    if (rootPane != null) { // it will be null in headless mode, i.e. tests
      rootPane.registerKeyboardAction(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              helpAction();
            }
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);

      rootPane.registerKeyboardAction(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              helpAction();
            }
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);
    }
  }
Esempio n. 4
0
  public ImagePanel(Kdu_coords viewSize) throws KduException {
    int width = Math.min(viewSize.Get_x(), 1600);
    int height = Math.min(viewSize.Get_y(), 1200);

    setPreferredSize(new Dimension(width, height));

    getInputMap().put(KeyStroke.getKeyStroke("UP"), "pressedUpArrow");
    getActionMap()
        .put(
            "pressedUpArrow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent evt) {
                // placeholder
              }
            });
    getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "pressedDownArrow");
    getActionMap()
        .put(
            "pressedDownArrow",
            new AbstractAction() {
              public void actionPerformed(ActionEvent evt) {
                // placeholder
              }
            });
  }
Esempio n. 5
0
  public Input() {

    this.map = new boolean[256];

    for (int i = 0; i < map.length; i++) {

      final int KEY_CODE = i;

      this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
          .put(KeyStroke.getKeyStroke(i, 0, false), i * 2);
      this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
          .put(KeyStroke.getKeyStroke(i, 0, true), i * 2 + 1);

      this.getActionMap()
          .put(
              i * 2,
              new AbstractAction() {
                public void actionPerformed(ActionEvent actionEvent) {
                  Input.this.map[KEY_CODE] = true;
                }
              });

      this.getActionMap()
          .put(
              i * 2 + 1,
              new AbstractAction() {
                public void actionPerformed(ActionEvent actionEvent) {
                  Input.this.map[KEY_CODE] = false;
                }
              });
    }
  }
  public static InputEvent getInputEvent(String actionName) {
    final Shortcut[] shortcuts =
        KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionName);
    KeyStroke keyStroke = null;
    for (Shortcut each : shortcuts) {
      if (each instanceof KeyboardShortcut) {
        keyStroke = ((KeyboardShortcut) each).getFirstKeyStroke();
        if (keyStroke != null) break;
      }
    }

    if (keyStroke != null) {
      return new KeyEvent(
          JOptionPane.getRootFrame(),
          KeyEvent.KEY_PRESSED,
          System.currentTimeMillis(),
          keyStroke.getModifiers(),
          keyStroke.getKeyCode(),
          keyStroke.getKeyChar(),
          KeyEvent.KEY_LOCATION_STANDARD);
    } else {
      return new MouseEvent(
          JOptionPane.getRootFrame(),
          MouseEvent.MOUSE_PRESSED,
          0,
          0,
          0,
          0,
          1,
          false,
          MouseEvent.BUTTON1);
    }
  }
Esempio n. 7
0
  public ActionFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    buttonPanel = new JPanel();

    // define actions
    Action yellowAction = new ColorAction("Yellow", new ImagIcon("yellow-ball.gif"), Color.YELLOW);
    Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE);
    Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED);

    // add buttons for these actions
    buttonPanel.add(new JButton(yellowAction));
    buttonPanel.add(new JButton(blueAction));
    buttonPanel.add(new JButton(recAction));

    // add panel to frame
    add(buttonPanel);

    // associate the Y, B, and R keys with names
    InputMap imap = buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow");
    imap.put(KeyStroke.getKeyStroke("Ctrl B"), "panel.blue");
    imap.put(KeyStroke.getKeyStroke("ctrl R"), "panel.red");

    // associate the names with actions
    ActionMap amap = buttonPanel.getActionMap();
    amap.put("panel.yellow", yellowAction);
    amap.put("panel.blue", blueAction);
    amap.put("panel.red", redAction);
  }
Esempio n. 8
0
 private void initKeyMap() {
   InputMap map = this.getInputMap();
   int shift = InputEvent.SHIFT_MASK;
   int ctrl = InputEvent.CTRL_MASK;
   map.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, shift), SikuliEditorKit.deIndentAction);
   map.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, ctrl), SikuliEditorKit.deIndentAction);
 }
  private ActionToolbar createToolbar() {
    DefaultActionGroup group = new DefaultActionGroup();

    BackAction back = new BackAction();
    back.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)), this);
    group.add(back);

    ForwardAction forward = new ForwardAction();
    forward.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)), this);
    group.add(forward);

    EditSourceActionBase edit = new EditSourceAction();
    edit.registerCustomShortcutSet(
        new CompositeShortcutSet(CommonShortcuts.getEditSource(), CommonShortcuts.ENTER), this);
    group.add(edit);

    edit = new ShowSourceAction();
    edit.registerCustomShortcutSet(
        new CompositeShortcutSet(CommonShortcuts.getViewSource(), CommonShortcuts.CTRL_ENTER),
        this);
    group.add(edit);

    return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
  }
Esempio n. 10
0
  /** Installs the UI defaults. */
  @Override
  protected void installDefaults() {
    updateStyle(splitPane);

    setOrientation(splitPane.getOrientation());
    setContinuousLayout(splitPane.isContinuousLayout());

    resetLayoutManager();

    /* Install the nonContinuousLayoutDivider here to avoid having to
    add/remove everything later. */
    if (nonContinuousLayoutDivider == null) {
      setNonContinuousLayoutDivider(createDefaultNonContinuousLayoutDivider(), true);
    } else {
      setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true);
    }

    // focus forward traversal key
    if (managingFocusForwardTraversalKeys == null) {
      managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
      managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
    }
    splitPane.setFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
    // focus backward traversal key
    if (managingFocusBackwardTraversalKeys == null) {
      managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
      managingFocusBackwardTraversalKeys.add(
          KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
    }
    splitPane.setFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
  }
 /**
  * This is hack. AWT doesn't allow to create KeyStroke with specified key code and key char
  * simultaneously. Therefore we are using reflection.
  */
 private static KeyStroke getKeyStrokeWithoutMouseModifiers(KeyStroke originalKeyStroke) {
   int modifier =
       originalKeyStroke.getModifiers()
           & ~InputEvent.BUTTON1_DOWN_MASK
           & ~InputEvent.BUTTON1_MASK
           & ~InputEvent.BUTTON2_DOWN_MASK
           & ~InputEvent.BUTTON2_MASK
           & ~InputEvent.BUTTON3_DOWN_MASK
           & ~InputEvent.BUTTON3_MASK;
   try {
     Method[] methods = AWTKeyStroke.class.getDeclaredMethods();
     Method getCachedStrokeMethod = null;
     for (Method method : methods) {
       if (GET_CACHED_STROKE_METHOD_NAME.equals(method.getName())) {
         getCachedStrokeMethod = method;
         getCachedStrokeMethod.setAccessible(true);
         break;
       }
     }
     if (getCachedStrokeMethod == null) {
       throw new IllegalStateException("not found method with name getCachedStrokeMethod");
     }
     Object[] getCachedStrokeMethodArgs =
         new Object[] {
           originalKeyStroke.getKeyChar(),
           originalKeyStroke.getKeyCode(),
           modifier,
           originalKeyStroke.isOnKeyRelease()
         };
     return (KeyStroke) getCachedStrokeMethod.invoke(originalKeyStroke, getCachedStrokeMethodArgs);
   } catch (Exception exc) {
     throw new IllegalStateException(exc.getMessage());
   }
 }
Esempio n. 12
0
  private void AboutBoxKeyEventActionIntialization() {
    Action ESCactionListener =
        new AbstractAction() {
          public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
            dispose();
          }
        };
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
    JComponent comp = this.getRootPane();
    comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ESCAPE");
    ActionMap actionMap = comp.getActionMap();
    actionMap.put("ESCAPE", ESCactionListener);

    /* OK button Action Solves MAC , Linux and Window enter key issue*/
    Action OKactionListener =
        new AbstractAction() {
          public void actionPerformed(ActionEvent actionEvent) {
            btnOKActionPerformed(actionEvent);
          }
        };

    KeyStroke enter_ok = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
    btnOK.getInputMap(JButton.WHEN_FOCUSED).put(enter_ok, "OK");
    actionMap = btnOK.getActionMap();
    actionMap.put("OK", OKactionListener);
    btnOK.setActionMap(actionMap);
  }
Esempio n. 13
0
 /**
  * Converts a KeyStroke into a string representation for preference storage.
  *
  * @param prefsStroke the KeyStroke to convert
  * @return a string representation of the form &quot;modifiers keyCode&quot; or <code>null</code>
  *     if the prefsStroke is invalid or <code>null</code>
  */
 public static final String strokeToPrefs(KeyStroke prefsStroke) {
   if (prefsStroke == null) return null;
   else
     return String.valueOf(prefsStroke.getModifiers())
         + ' '
         + String.valueOf(prefsStroke.getKeyCode());
 }
 @Override
 public KeyStroke[] getClearBufferKeyStrokes() {
   return new KeyStroke[] {
     UIUtil.isMac
         ? KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.META_DOWN_MASK)
         : KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_DOWN_MASK)
   };
 }
 @Override
 public KeyStroke[] getCloseSessionKeyStrokes() {
   return new KeyStroke[] {
     UIUtil.isMac
         ? KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK)
         : KeyStroke.getKeyStroke(
             KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)
   };
 }
 private void init() {
   getActionMap().put("startEditing", new StartEditingAction()); // NOI18N
   getActionMap().put("cancel", new CancelEditingAction()); // NOI18N
   addMouseListener(new MouseListener());
   getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "startEditing"); // NOI18N
   getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
       .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N
   putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // NOI18N
 }
 @Override
 public KeyStroke[] getPasteKeyStrokes() {
   return new KeyStroke[] {
     UIUtil.isMac
         ? KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_DOWN_MASK)
         // CTRL + V is used for signal; use CTRL + SHIFT + V instead
         : KeyStroke.getKeyStroke(
             KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)
   };
 }
Esempio n. 18
0
 @Override
 protected JRootPane createRootPane() {
   JRootPane jrootPane = new JRootPane();
   int menuShortcutKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
   KeyStroke w = KeyStroke.getKeyStroke(KeyEvent.VK_W, menuShortcutKey);
   KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
   jrootPane.registerKeyboardAction(this, ACTION_CLOSE, w, JComponent.WHEN_IN_FOCUSED_WINDOW);
   jrootPane.registerKeyboardAction(this, ACTION_CLOSE, esc, JComponent.WHEN_IN_FOCUSED_WINDOW);
   return jrootPane;
 }
 private static void installActions(JTable table) {
   InputMap inputMap = table.getInputMap(WHEN_FOCUSED);
   inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "selectLastRow");
   inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "selectFirstRow");
   inputMap.put(
       KeyStroke.getKeyStroke(KeyEvent.VK_HOME, KeyEvent.SHIFT_DOWN_MASK),
       "selectFirstRowExtendSelection");
   inputMap.put(
       KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.SHIFT_DOWN_MASK),
       "selectLastRowExtendSelection");
 }
Esempio n. 20
0
  public static boolean isDigraphStart(@NotNull KeyStroke key) {
    if ((key.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
      if (key.getKeyCode() == KeyEvent.VK_K
          || key.getKeyCode() == KeyEvent.VK_V
          || key.getKeyCode() == KeyEvent.VK_Q) {
        return true;
      }
    }

    return false;
  }
Esempio n. 21
0
 /**
  * The Excel Adapter is constructed with a JTable on which it enables Copy-Paste and acts as a
  * Clipboard listener.
  */
 public ExcelAdapter(JTable myJTable) {
   jTable1 = myJTable;
   KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
   // Identifying the copy KeyStroke user can modify this
   // to copy on some other Key combination.
   KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
   // Identifying the Paste KeyStroke user can modify this
   // to copy on some other Key combination.
   jTable1.registerKeyboardAction(this, "Copy", copy, JComponent.WHEN_FOCUSED);
   jTable1.registerKeyboardAction(this, "Paste", paste, JComponent.WHEN_FOCUSED);
   system = Toolkit.getDefaultToolkit().getSystemClipboard();
 }
Esempio n. 22
0
 /** Get the text in the register. */
 @Nullable
 public String getText() {
   final StringBuilder builder = new StringBuilder();
   for (KeyStroke key : keys) {
     final char c = key.getKeyChar();
     if (c == KeyEvent.CHAR_UNDEFINED) {
       return null;
     }
     builder.append(c);
   }
   return builder.toString();
 }
Esempio n. 23
0
  private JMenuBar createMenuBar() {
    JMenu menu = new JMenu("Menu");

    disablingItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK));

    menu.add(disablingItem);
    menu.addSeparator();

    blurItem.setSelected(true);
    blurItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK));
    menu.add(blurItem);

    embossItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.ALT_MASK));
    menu.add(embossItem);

    busyPainterItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.ALT_MASK));
    menu.add(busyPainterItem);

    ButtonGroup group = new ButtonGroup();
    group.add(blurItem);
    group.add(embossItem);
    group.add(busyPainterItem);

    ItemListener menuListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (blurItem.isSelected()) {
              //                    layer.setUI(blurUI);
            } else if (embossItem.isSelected()) {
              //                    layer.setUI(embossUI);
            } else if (busyPainterItem.isSelected()) {
              layer.setUI(busyPainterUI);
            }
          }
        };

    blurItem.addItemListener(menuListener);
    embossItem.addItemListener(menuListener);
    busyPainterItem.addItemListener(menuListener);

    //        embossUI.getUnlockButton().addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                disablingItem.doClick();
    //            }
    //        });

    JMenuBar bar = new JMenuBar();
    bar.add(menu);

    bar.add(new LafMenu());
    return bar;
  }
Esempio n. 24
0
  private void initActions() {
    @NonNls InputMap inputMap = getInputMap(WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "moveFocusDown");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "moveFocusUp");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "collapse");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "expand");

    @NonNls ActionMap actionMap = getActionMap();
    actionMap.put("moveFocusDown", new MoveFocusAction(true));
    actionMap.put("moveFocusUp", new MoveFocusAction(false));
    actionMap.put("collapse", new ExpandAction(false));
    actionMap.put("expand", new ExpandAction(true));
  }
Esempio n. 25
0
 private void initKeyMaps() {
   // Down-arrow nudges this Spacer downward:
   registerKeyboardAction(
       new AbstractAction() {
         public void actionPerformed(ActionEvent event) {
           Point p = getLocation();
           moveTo(p.y + 1);
         }
       },
       KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
       WHEN_FOCUSED);
   // Up-arrow nudges this Spacer upward:
   registerKeyboardAction(
       new AbstractAction() {
         public void actionPerformed(ActionEvent event) {
           Point p = getLocation();
           moveTo(p.y - 1);
         }
       },
       KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
       WHEN_FOCUSED);
   // Space sticks this Spacer where it is:
   registerKeyboardAction(
       new AbstractAction() {
         public void actionPerformed(ActionEvent event) {
           Point p = getLocation();
           moveTo(p.y);
         }
       },
       KeyStroke.getKeyStroke(KeyEvent.VK_X, 0),
       WHEN_FOCUSED);
   // Delete unsticks this Spacer:
   registerKeyboardAction(
       new AbstractAction() {
         public void actionPerformed(ActionEvent event) {
           model.removePoint(index);
         }
       },
       KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
       WHEN_FOCUSED);
   // Backspace is same as Delete:
   registerKeyboardAction(
       new AbstractAction() {
         public void actionPerformed(ActionEvent event) {
           model.removePoint(index);
         }
       },
       KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
       WHEN_FOCUSED);
 }
Esempio n. 26
0
  private void registerKeyStrokes() {
    KeyStroke keyStroke;
    Action act;

    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK);
    act =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            onRightCtrl();
          }
        };
    _textPane.getKeymap().addActionForKeyStroke(keyStroke, act);

    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK | Event.SHIFT_MASK);
    act =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            onRightCtrlShift();
          }
        };
    _textPane.getKeymap().addActionForKeyStroke(keyStroke, act);

    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK);
    act =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            onLeftCtrl();
          }
        };
    _textPane.getKeymap().addActionForKeyStroke(keyStroke, act);

    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK | Event.SHIFT_MASK);
    act =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            onLeftCtrlShift();
          }
        };
    _textPane.getKeymap().addActionForKeyStroke(keyStroke, act);

    keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Event.CTRL_MASK);
    act =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            onCtrlBackSpace();
          }
        };
    _textPane.getKeymap().addActionForKeyStroke(keyStroke, act);
  }
Esempio n. 27
0
  public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) {
    JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent);
    final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS);

    final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit);
    searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
              }
            });

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG_WITH_ENTER",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                searchDialogPanel.selectEntity();
              }
            });

    dialog.setContentPane(searchDialogPanel);
    dialog.setResizable(true);
    dialog.pack();
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            searchDialogPanel.searchField.requestFocusInWindow();
          }
        });
    return dialog;
  }
 public Action4() {
   putValue(Action.NAME, "action4");
   putValue(Action.SHORT_DESCRIPTION, "Toggle Action 4");
   putValue(Action.ACTION_COMMAND_KEY, "action4");
   putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_4));
   putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F4"));
 }
Esempio n. 29
0
 private void registerShortcuts() {
   ActionManager actionManager = ActionManager.getInstance();
   actionManager
       .getAction(XDebuggerActions.SET_VALUE)
       .registerCustomShortcutSet(
           new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), this);
   actionManager
       .getAction(XDebuggerActions.COPY_VALUE)
       .registerCustomShortcutSet(CommonShortcuts.getCopy(), this);
   actionManager
       .getAction(XDebuggerActions.JUMP_TO_SOURCE)
       .registerCustomShortcutSet(CommonShortcuts.getEditSource(), this);
   Shortcut[] editTypeShortcuts =
       KeymapManager.getInstance()
           .getActiveKeymap()
           .getShortcuts(XDebuggerActions.EDIT_TYPE_SOURCE);
   actionManager
       .getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE)
       .registerCustomShortcutSet(new CustomShortcutSet(editTypeShortcuts), this);
   actionManager
       .getAction(XDebuggerActions.MARK_OBJECT)
       .registerCustomShortcutSet(
           new CustomShortcutSet(
               KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark")),
           this);
 }
 public AboutAction() {
   putValue(Action.NAME, "about");
   putValue(Action.SHORT_DESCRIPTION, "About the author");
   putValue(Action.ACTION_COMMAND_KEY, "about");
   putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_A));
   putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F9"));
 }