Java Code Examples for com.intellij.ui.PopupHandler#installPopupHandler()

The following examples show how to use com.intellij.ui.PopupHandler#installPopupHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeHierarchyBrowserBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void createTreeAndSetupCommonActions(@Nonnull Map<String, JTree> trees, ActionGroup group) {
  final BaseOnThisTypeAction baseOnThisTypeAction = createBaseOnThisAction();
  final JTree tree1 = createTree(true);
  PopupHandler.installPopupHandler(tree1, group, ActionPlaces.TYPE_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
  baseOnThisTypeAction
          .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_TYPE_HIERARCHY).getShortcutSet(), tree1);
  trees.put(TYPE_HIERARCHY_TYPE, tree1);

  final JTree tree2 = createTree(true);
  PopupHandler.installPopupHandler(tree2, group, ActionPlaces.TYPE_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
  baseOnThisTypeAction
          .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_TYPE_HIERARCHY).getShortcutSet(), tree2);
  trees.put(SUPERTYPES_HIERARCHY_TYPE, tree2);

  final JTree tree3 = createTree(true);
  PopupHandler.installPopupHandler(tree3, group, ActionPlaces.TYPE_HIERARCHY_VIEW_POPUP, ActionManager.getInstance());
  baseOnThisTypeAction
          .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_TYPE_HIERARCHY).getShortcutSet(), tree3);
  trees.put(SUBTYPES_HIERARCHY_TYPE, tree3);
}
 
Example 2
Source File: TfsTreeForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public TfsTreeForm() {
    DataManager.registerDataProvider(tree, this);
    new TreeSpeedSearch(tree);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            selectedItem = doGetSelectedItem();
            pathField.setText(selectedItem != null ? selectedItem.path : null);
            eventDispatcher.getMulticaster().selectionChanged();
        }
    });
    PopupHandler.installPopupHandler(tree, POPUP_ACTION_GROUP, ActionPlaces.REMOTE_HOST_DIALOG_POPUP);
    setMessage(null, false);
}
 
Example 3
Source File: MongoResultPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
void buildPopupMenu() {
    DefaultActionGroup actionPopupGroup = new DefaultActionGroup("MongoResultPopupGroup", true);
    if (ApplicationManager.getApplication() != null) {
        actionPopupGroup.add(new EditMongoDocumentAction(this));
        actionPopupGroup.add(new CopyResultAction(this));
    }

    PopupHandler.installPopupHandler(resultTableView, actionPopupGroup, "POPUP", ActionManager.getInstance());
}
 
Example 4
Source File: MongoEditionPanel.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
void buildPopupMenu() {
    DefaultActionGroup actionPopupGroup = new DefaultActionGroup("MongoEditorPopupGroup", true);
    if (ApplicationManager.getApplication() != null) {
        actionPopupGroup.add(new AddKeyAction(this));
        actionPopupGroup.add(new AddValueAction(this));
        actionPopupGroup.add(new DeleteKeyAction(this));
    }

    PopupHandler.installPopupHandler(editTableView, actionPopupGroup, "POPUP", ActionManager.getInstance());
}
 
Example 5
Source File: StatisticsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) {
  myProject = project;
  myTableModel = new StatisticsTableModel();
  myStatisticsTableView.setModelAndUpdateColumns(myTableModel);
  myFrameworkRunningModel = model;

  final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      gotoSuiteOrParentAction.run();
      return true;
    }
  }.installOn(myStatisticsTableView);

  // Fire selection changed and move focus on SHIFT+ENTER
  final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
  SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view",
                          new Runnable() {
                            public void run() {
                              showSelectedProxyInTestsTree();
                            }
                          },
                          myStatisticsTableView);

  // Expand selected or go to parent on ENTER
  final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
  SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent",
                          gotoSuiteOrParentAction,
                          myStatisticsTableView);
  // Contex menu in Table
  PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
  // set this statistic tab as dataprovider for test's table view
  DataManager.registerDataProvider(myStatisticsTableView, this);
}
 
Example 6
Source File: SourceItemsTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SourceItemsTree(ArtifactEditorContext editorContext, ArtifactEditorImpl artifactsEditor) {
  myArtifactsEditor = artifactsEditor;
  myBuilder = new SimpleTreeBuilder(this, this.getBuilderModel(), new SourceItemsTreeStructure(editorContext, artifactsEditor), new WeightBasedComparator(true));
  setRootVisible(false);
  setShowsRootHandles(true);
  Disposer.register(this, myBuilder);
  PopupHandler.installPopupHandler(this, createPopupGroup(), ActionPlaces.UNKNOWN, ActionManager.getInstance());
  installDnD();
}
 
Example 7
Source File: ScopeViewPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent createComponent() {
  myViewPanel = new ScopeTreeViewPanel(myProject);
  Disposer.register(this, myViewPanel);
  myViewPanel.initListeners();
  myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId()));
  myTree = myViewPanel.getTree();
  PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP);
  enableDnD();

  return myViewPanel.getPanel();
}
 
Example 8
Source File: NoSqlExplorerPanel.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
public void installActions() {

        final TreeExpander treeExpander = new TreeExpander() {
            @Override
            public void expandAll() {
                NoSqlExplorerPanel.this.expandAll();
            }

            @Override
            public boolean canExpand() {
                return true;
            }

            @Override
            public void collapseAll() {
                NoSqlExplorerPanel.this.collapseAll();
            }

            @Override
            public boolean canCollapse() {
                return true;
            }
        };

        CommonActionsManager actionsManager = CommonActionsManager.getInstance();

        final AnAction expandAllAction = actionsManager.createExpandAllAction(treeExpander, rootPanel);
        final AnAction collapseAllAction = actionsManager.createCollapseAllAction(treeExpander, rootPanel);

        Disposer.register(this, new Disposable() {
            @Override
            public void dispose() {
                collapseAllAction.unregisterCustomShortcutSet(rootPanel);
                expandAllAction.unregisterCustomShortcutSet(rootPanel);
            }
        });


        DefaultActionGroup actionGroup = new DefaultActionGroup("NoSqlExplorerGroup", false);
        ViewCollectionValuesAction viewCollectionValuesAction = new ViewCollectionValuesAction(this);
        RefreshServerAction refreshServerAction = new RefreshServerAction(this);
        if (ApplicationManager.getApplication() != null) {
            actionGroup.add(refreshServerAction);
            actionGroup.add(new NoSqlDatabaseConsoleAction(this));
            actionGroup.add(viewCollectionValuesAction);
            actionGroup.add(expandAllAction);
            actionGroup.add(collapseAllAction);
            actionGroup.addSeparator();
            actionGroup.add(new OpenPluginSettingsAction());
        }

        GuiUtils.installActionGroupInToolBar(actionGroup, toolBarPanel, ActionManager.getInstance(), "NoSqlExplorerActions", true);

        DefaultActionGroup actionPopupGroup = new DefaultActionGroup("NoSqlExplorerPopupGroup", true);
        if (ApplicationManager.getApplication() != null) {
            actionPopupGroup.add(refreshServerAction);
            actionPopupGroup.add(viewCollectionValuesAction);
            actionPopupGroup.add(new DropCollectionAction(this));
            actionPopupGroup.add(new DropDatabaseAction(this));
        }

        PopupHandler.installPopupHandler(databaseTree, actionPopupGroup, "POPUP", ActionManager.getInstance());

        databaseTree.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent mouseEvent) {
                if (!(mouseEvent.getSource() instanceof JTree)) {
                    return;
                }

                DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) databaseTree.getLastSelectedPathComponent();
                if (treeNode == null) {
                    return;
                }

                if (mouseEvent.getClickCount() == 2) {
                    if (treeNode.getUserObject() instanceof DatabaseServer && treeNode.getChildCount() == 0) {
                        reloadServerConfiguration(getSelectedServerNode(), true);
                    }
                    if (treeNode.getUserObject() instanceof MongoCollection) {
                        loadRecords();
                    }
                    if (treeNode.getUserObject() instanceof RedisDatabase) {
                        loadRecords();
                    }

                    if (treeNode.getUserObject() instanceof CouchbaseDatabase) {
                        loadRecords();
                    }
                }
            }
        });
    }
 
Example 9
Source File: ChangesListView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setMenuActions(final ActionGroup menuGroup) {
  PopupHandler.installPopupHandler(this, menuGroup, ActionPlaces.CHANGES_VIEW_POPUP, ActionManager.getInstance());
  editSourceRegistration();
}