private static void patchMainMenu() {
    final CustomActionsSchema schema = new CustomActionsSchema();

    final JTree actionsTree = new Tree();
    Group rootGroup = new Group("root", null, null);
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootGroup);
    DefaultTreeModel model = new DefaultTreeModel(root);
    actionsTree.setModel(model);

    schema.fillActionGroups(root);
    for (int i = 0; i < root.getChildCount(); i++) {
      final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) root.getChildAt(i);
      if ("Main menu".equals(getItemId(treeNode))) {
        hideActionFromMainMenu(root, schema, treeNode);
      }
      hideActions(schema, root, treeNode, HIDDEN_ACTIONS);
    }
    CustomActionsSchema.getInstance().copyFrom(schema);
  }
Пример #2
0
  private JComponent createToolbar() {
    ActionGroup group =
        (ActionGroup)
            CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_MAIN_TOOLBAR);
    final ActionToolbar toolBar =
        myActionManager.createActionToolbar(ActionPlaces.MAIN_TOOLBAR, group, true);
    toolBar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);

    DefaultActionGroup menuGroup = new DefaultActionGroup();
    menuGroup.add(new ViewToolbarAction());
    menuGroup.add(new CustomizeUIAction());
    PopupHandler.installUnknownPopupHandler(toolBar.getComponent(), menuGroup, myActionManager);

    return toolBar.getComponent();
  }
 @Override
 public void invokePopup(final EditorMouseEvent event) {
   if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
     ActionGroup group =
         (ActionGroup)
             CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_POPUP);
     ActionPopupMenu popupMenu =
         ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
     MouseEvent e = event.getMouseEvent();
     final Component c = e.getComponent();
     if (c != null && c.isShowing()) {
       popupMenu.getComponent().show(c, e.getX(), e.getY());
     }
     e.consume();
   }
 }
 private static void hideActions(
     @NotNull CustomActionsSchema schema,
     @NotNull DefaultMutableTreeNode root,
     @NotNull final TreeNode actionGroup,
     Set<String> items) {
   for (int i = 0; i < actionGroup.getChildCount(); i++) {
     final DefaultMutableTreeNode child = (DefaultMutableTreeNode) actionGroup.getChildAt(i);
     final int childCount = child.getChildCount();
     final String childId = getItemId(child);
     if (childId != null && items.contains(childId)) {
       final TreePath treePath = TreeUtil.getPath(root, child);
       final ActionUrl url = CustomizationUtil.getActionUrl(treePath, ActionUrl.DELETED);
       schema.addAction(url);
     } else if (childCount > 0) {
       hideActions(schema, child, child, items);
     }
   }
 }