コード例 #1
0
  public void selectAction(String actionId) {
    final JTree tree = myTree;

    String path = myMainGroup.getActionQualifiedPath(actionId);
    if (path == null) {
      return;
    }
    final DefaultMutableTreeNode node = getNodeForPath(path);
    if (node == null) {
      return;
    }

    TreeUtil.selectInTree(node, true, tree);
  }
コード例 #2
0
  @Nullable
  private String getPath(DefaultMutableTreeNode node) {
    final Object userObject = node.getUserObject();
    if (userObject instanceof String) {
      String actionId = (String) userObject;

      final TreeNode parent = node.getParent();
      if (parent instanceof DefaultMutableTreeNode) {
        final Object object = ((DefaultMutableTreeNode) parent).getUserObject();
        if (object instanceof Group) {
          return ((Group) object).getActionQualifiedPath(actionId);
        }
      }

      return myMainGroup.getActionQualifiedPath(actionId);
    }
    if (userObject instanceof Group) {
      return ((Group) userObject).getQualifiedPath();
    }
    if (userObject instanceof QuickList) {
      return ((QuickList) userObject).getDisplayName();
    }
    return null;
  }
コード例 #3
0
  /** Updates all UI controls */
  private void updatePreviewAndConflicts() {
    if (myButton == -1 || myModifiers == -1) {
      return;
    }

    myTarConflicts.setText(null);

    // Set text into preview area

    // empty string should have same height
    myLblPreview.setText(
        KeymapUtil.getMouseShortcutText(myButton, myModifiers, myRbSingleClick.isSelected() ? 1 : 2)
            + " ");

    // Detect conflicts

    final MouseShortcut mouseShortcut;
    if (myRbSingleClick.isSelected()) {
      mouseShortcut = new MouseShortcut(myButton, myModifiers, 1);
    } else {
      mouseShortcut = new MouseShortcut(myButton, myModifiers, 2);
    }

    StringBuilder buffer = new StringBuilder();
    String[] actionIds = myKeymap.getActionIds(mouseShortcut);
    for (String actionId : actionIds) {
      if (actionId.equals(myActionId)) {
        continue;
      }

      String actionPath = myMainGroup.getActionQualifiedPath(actionId);
      // actionPath == null for editor actions having corresponding $-actions
      if (actionPath == null) {
        continue;
      }

      Shortcut[] shortcuts = myKeymap.getShortcuts(actionId);
      for (Shortcut shortcut1 : shortcuts) {
        if (!(shortcut1 instanceof MouseShortcut)) {
          continue;
        }

        MouseShortcut shortcut = (MouseShortcut) shortcut1;

        if (shortcut.getButton() != mouseShortcut.getButton()
            || shortcut.getModifiers() != mouseShortcut.getModifiers()) {
          continue;
        }

        if (buffer.length() > 1) {
          buffer.append('\n');
        }
        buffer.append('[');
        buffer.append(actionPath);
        buffer.append(']');
        break;
      }
    }

    if (buffer.length() == 0) {
      myTarConflicts.setForeground(UIUtil.getTextAreaForeground());
      myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.no.conflicts.area"));
    } else {
      myTarConflicts.setForeground(Color.red);
      myTarConflicts.setText(
          KeyMapBundle.message("mouse.shortcut.dialog.assigned.to.area", buffer.toString()));
    }
  }