コード例 #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;
        }
      }
    }
  }
コード例 #2
0
 private void updateMenus() {
   Controller controller = Controller.getCurrentController();
   final ModeController modeController = controller.getModeController();
   final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder();
   menuBuilder.removeChildElements(MENU_CATEGORY);
   int i = 0;
   int maxEntries = getMaxMenuEntries();
   for (final String key : lastOpenedList) {
     if (i == 0
         && (!modeController.getModeName().equals(MModeController.MODENAME)
             || controller.getMap() == null
             || controller.getMap().getURL() == null)) {
       i++;
       maxEntries++;
     }
     if (i == maxEntries) {
       break;
     }
     final AFreeplaneAction lastOpenedActionListener = new OpenLastOpenedAction(i++, this);
     final IFreeplaneAction decoratedAction = menuBuilder.decorateAction(lastOpenedActionListener);
     final JMenuItem item = new JFreeplaneMenuItem(decoratedAction);
     item.setActionCommand(key);
     String text = createOpenMapItemName(key);
     item.setText(text);
     item.setMnemonic(0);
     menuBuilder.addMenuItem(
         MENU_CATEGORY,
         item,
         MENU_CATEGORY + '/' + lastOpenedActionListener.getKey(),
         UIBuilder.AS_CHILD);
   }
 }
コード例 #3
0
  /**
   * ********************************************************************************* CONSTRUCTORS
   * ********************************************************************************
   */
  public FreeplaneActionMultiCaster(AFreeplaneAction a, AFreeplaneAction b) {
    super(b.getKey());

    if (a != null) {
      assert (b.getKey().equals(a.getKey()));
    }
    this.a = a;
    this.b = b;
  }
コード例 #4
0
  public static String getActionTitle(final AFreeplaneAction action) {
    String title = (String) action.getValue(Action.NAME);

    if (title == null || title.isEmpty()) {
      title = TextUtils.getText(action.getTextKey());
    }
    if (title == null || title.isEmpty()) {
      title = action.getTextKey();
    }
    return TextUtils.removeTranslateComment(title);
  }
コード例 #5
0
 public static ResizableIcon getActionIcon(final AFreeplaneAction action) {
   ResizableIcon icon = null;
   ImageIcon ico = (ImageIcon) action.getValue(Action.SMALL_ICON);
   if (ico != null) {
     icon =
         ImageWrapperResizableIcon.getIcon(
             ico.getImage(), new Dimension(ico.getIconWidth(), ico.getIconHeight()));
   } else {
     String resource =
         ResourceController.getResourceController().getProperty(action.getIconKey(), null);
     if (resource != null) {
       URL location = ResourceController.getResourceController().getResource(resource);
       icon = ImageWrapperResizableIcon.getIcon(location, new Dimension(16, 16));
     }
   }
   if (icon == null) {
     icon = RibbonActionContributorFactory.BLANK_ACTION_ICON;
   }
   return icon;
 }
コード例 #6
0
 /**
  * ********************************************************************************* REQUIRED
  * METHODS FOR INTERFACES
  * ********************************************************************************
  */
 public void actionPerformed(ActionEvent e) {
   if (b != null) b.actionPerformed(e);
   if (a != null) a.actionPerformed(e);
 }
コード例 #7
0
 /**
  * ********************************************************************************* METHODS
  * ********************************************************************************
  */
 public boolean isEnabled() {
   return b.isEnabled();
 }