예제 #1
0
  public void keyPressed(KeyEvent e) {
    KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);

    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      TreePath path = ((JTree) e.getSource()).getSelectionPath();
      if (path == null) {
        return;
      }
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();

      if (node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node)
            .handleAction(
                new WorkspaceActionEvent(
                    node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
        e.consume();
      }
    } else {
      for (HotKeyIdentifier id : actionKeyMap.keySet()) {
        if (currentStroke.equals(id.getKeyStroke())) {
          if (id.accept(e)) {
            AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
            if (action != null) {
              action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
            } else {
              LogUtils.info("No action set for: " + id.getKeyStroke());
            }
          }
          e.consume();
          break;
        }
      }
    }
  }
 /**
  * ********************************************************************************* REQUIRED
  * METHODS FOR INTERFACES
  * ********************************************************************************
  */
 public void actionPerformed(ActionEvent e) {
   if (b != null) b.actionPerformed(e);
   if (a != null) a.actionPerformed(e);
 }