private void popupInvoked(final Component comp, final int x, final int y) { Object userObject = null; final TreePath path = tree.getSelectionPath(); if(path != null) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if(node != null) { userObject = node.getUserObject(); } } ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); if( userObject instanceof SlingServerNodeDescriptor || userObject instanceof SlingServerModuleNodeDescriptor ) { group.add(actionManager.getAction("AEM.Connection.Popup")); } else { group.add(actionManager.getAction("AEM.Root.Popup")); } final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.ANT_EXPLORER_POPUP, group); popupMenu.getComponent().show(comp, x, y); }
public static EditorPopupHandler createEditorPopupHandler(final String groupId) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(groupId); 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 boolean checkShowPopupMenu(final MouseEvent e) { int cell = getCellAt(e.getPoint()); if(cell >= 0 && e.isPopupTrigger()) { if(!mySelectionModel.isSelectedIndex(cell)) { mySelectionModel.setSelectionInterval(cell, cell); } ActionGroup group = mySelectedContainer.getGridLayoutManager().getCaptionActions(); if(group != null) { final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); popupMenu.getComponent().show(GridCaptionPanel.this, e.getX(), e.getY()); return true; } } return false; }
@Nonnull public static MouseListener installPopupHandler(@Nonnull JComponent component, @Nonnull ActionGroup group, String place, @Nonnull ActionManager actionManager, @Nullable PopupMenuListener menuListener) { if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler popupHandler = new PopupHandler() { public void invokePopup(Component comp, int x, int y) { ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group); popupMenu.setTargetComponent(component); JPopupMenu menu = popupMenu.getComponent(); if (menuListener != null) menu.addPopupMenuListener(menuListener); menu.show(comp, x, y); } }; component.addMouseListener(popupHandler); return popupHandler; }
@Nonnull private static MouseListener installConditionalPopup(@Nonnull JComponent component, @Nonnull ActionGroup group, String place, @Nonnull ActionManager actionManager, @Nonnull ShowPopupPredicate condition) { if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler handler = new PopupHandler() { public void invokePopup(Component comp, int x, int y) { if (condition.shouldShowPopup(comp, x, y)) { ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group); popupMenu.getComponent().show(comp, x, y); } } }; component.addMouseListener(handler); return handler; }
public InspectDebuggerTree(Project project) { super(project); final PopupHandler popupHandler = new PopupHandler() { public void invokePopup(Component comp, int x, int y) { ActionPopupMenu popupMenu = createPopupMenu(); if (popupMenu != null) { myTipManager.registerPopup(popupMenu.getComponent()).show(comp, x, y); } } }; addMouseListener(popupHandler); new ValueNodeDnD(this, project); }
protected void invokeContextMenu(final MouseEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { final ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(myPlace, myPopupGroup); menu.getComponent().show(e.getComponent(), e.getPoint().x, e.getPoint().y); } }); }
public static MouseListener installPopupHandler(JComponent component, @NotNull final ActionGroup group, final String place, final ActionManager actionManager) { if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler popupHandler = new PopupHandler() { public void invokePopup(Component comp, int x, int y) { final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group); popupMenu.getComponent().show(comp, x, y); } }; component.addMouseListener(popupHandler); return popupHandler; }
public static MouseListener installFollowingSelectionTreePopup(final JTree tree, @NotNull final ActionGroup group, final String place, final ActionManager actionManager){ if (ApplicationManager.getApplication() == null) return new MouseAdapter(){}; PopupHandler handler = new PopupHandler() { public void invokePopup(Component comp, int x, int y) { if (tree.getPathForLocation(x, y) != null && Arrays.binarySearch(tree.getSelectionRows(), tree.getRowForLocation(x, y)) > -1) { //do not show popup menu on rows other than selection final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group); popupMenu.getComponent().show(comp, x, y); } } }; tree.addMouseListener(handler); return handler; }
private static void showEditorPopup(final EditorMouseEvent event, @NotNull final ActionGroup group) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { 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(); } }
public static ActionPopupMenu createShortPopupForRepositoryDialog(RepositoryBrowserComponent browserComponent) { DefaultActionGroup group = new DefaultActionGroup(); DefaultActionGroup newGroup = new DefaultActionGroup("_New", true); newGroup.add(new AddLocationAction(browserComponent)); newGroup.add(new MkDirAction(browserComponent)); group.add(newGroup); group.addSeparator(); group.add(new RefreshAction(browserComponent)); group.add(new DiscardLocationAction(browserComponent)); group.add(new DeleteAction(browserComponent)); return ActionManager.getInstance().createActionPopupMenu("", group); }
private void createUI() { myMainPanel = new JPanel(new BorderLayout()); myBrowser = new RepositoryBrowserComponent(SvnVcs.getInstance(myProject)); final DefaultActionGroup group = new DefaultActionGroup(); group.add(new RepositoryBrowserDialog.MkDirAction(myBrowser) { @Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setText("New Remote Folder..."); } }); group.add(new RepositoryBrowserDialog.DeleteAction(myBrowser)); group.add(new RepositoryBrowserDialog.RefreshAction(myBrowser)); final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu("", group); final JPopupMenu component = popupMenu.getComponent(); myBrowser.getRepositoryTree().addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { component.show(comp, x, y); } }); final Splitter splitter = new Splitter(true); splitter.setProportion(0.7f); final JPanel wrapper = createBrowserPartWrapper(); splitter.setFirstComponent(wrapper); final JPanel commitMessageWrapper = createCommitMessageWrapper(); splitter.setSecondComponent(commitMessageWrapper); myMainPanel.add(splitter, BorderLayout.CENTER); final JPanel recentMessagesWrapper = new JPanel(new BorderLayout()); recentMessagesWrapper.add(new JLabel("Recent Messages:"), BorderLayout.NORTH); myMessagesBox = new JComboBox(); recentMessagesWrapper.add(myMessagesBox, BorderLayout.SOUTH); recentMessagesWrapper.setBorder(BorderFactory.createEmptyBorder(4,0,0,0)); myMainPanel.add(recentMessagesWrapper, BorderLayout.SOUTH); }
protected JPopupMenu createPopup(boolean toolWindow) { DefaultActionGroup group = new DefaultActionGroup(); DefaultActionGroup newGroup = new DefaultActionGroup("_New", true); final RepositoryBrowserComponent browser = getRepositoryBrowser(); newGroup.add(new AddLocationAction(browser)); newGroup.add(new MkDirAction(browser)); group.add(newGroup); group.addSeparator(); group.add(new RefreshAction(browser)); group.add(new DiscardLocationAction(browser)); ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu("", group); return menu.getComponent(); }
@Override protected void handlePopup() { ActionManager actionManager = ActionManager.getInstance(); ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(myArea.getPopupPlace(), myArea.getPopupActions()); MouseEvent event = (MouseEvent)myInputEvent; popupMenu.getComponent().show(myArea.getNativeComponent(), event.getX(), event.getY()); }
@Override public void actionPerformed(AnActionEvent event) { final ActionGroup group = createGearActionGroup(); final ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); final Component component = event.getInputEvent().getComponent(); menu.getComponent().show(component, component.getX(), component.getY()); }
private void popupInvoked(Component component, int x, int y) { final TreePath path = myTree.getLeadSelectionPath(); if (path == null) return; if (!(path.getLastPathComponent()instanceof MessageNode)) return; if (getData(PlatformDataKeys.NAVIGATABLE_ARRAY) == null) return; DefaultActionGroup group = new DefaultActionGroup(); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE)); ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.ANT_MESSAGES_POPUP, group); menu.getComponent().show(component, x, y); }
private static void showEditorPopup(final EditorMouseEvent event, @Nonnull final ActionGroup group) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { 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(); } }
public static ActionPopupMenu createPopupMenu() { ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(DebuggerActions.INSPECT_PANEL_POPUP); return ActionManager.getInstance().createActionPopupMenu(DebuggerActions.INSPECT_PANEL_POPUP, group); }
protected ActionPopupMenu createPopupMenu() { return InspectDebuggerTree.createPopupMenu(); }
@Override protected ActionPopupMenu createPopupMenu() { DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction(DebuggerActions.THREADS_PANEL_POPUP); return ActionManager.getInstance().createActionPopupMenu(DebuggerActions.THREADS_PANEL_POPUP, group); }
private void showPopup(final Component component, final int x, final int y) { final ActionGroup group = myDecorator.createPopupGroup(); final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); popupMenu.getComponent().show(component, x, y); }
@Override public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", "")); return new RefreshableOnComponent() { @Override public JComponent getComponent() { JPanel panel = new JPanel(new BorderLayout(4, 0)); panel.add(checkBox, BorderLayout.WEST); setFilterText(myConfiguration.myTodoPanelSettings.todoFilterName); if (myConfiguration.myTodoPanelSettings.todoFilterName != null) { myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.todoFilterName); } final Consumer<TodoFilter> consumer = new Consumer<TodoFilter>() { @Override public void consume(TodoFilter todoFilter) { myTodoFilter = todoFilter; final String name = todoFilter == null ? null : todoFilter.getName(); myConfiguration.myTodoPanelSettings.todoFilterName = name; setFilterText(name); } }; final LinkLabel linkLabel = new LinkLabel("Configure", null); linkLabel.setListener(new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { DefaultActionGroup group = SetTodoFilterAction.createPopupActionGroup(myProject, myConfiguration.myTodoPanelSettings, consumer); ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.TODO_VIEW_TOOLBAR, group); popupMenu.getComponent().show(linkLabel, 0, linkLabel.getHeight()); } }, null); panel.add(linkLabel, BorderLayout.CENTER); CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "TODO check is impossible until indices are up-to-date"); return panel; } private void setFilterText(final String filterName) { if (filterName == null) { checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all"))); } else { checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName)); } } @Override public void refresh() { } @Override public void saveState() { myConfiguration.CHECK_NEW_TODO = checkBox.isSelected(); } @Override public void restoreState() { checkBox.setSelected(myConfiguration.CHECK_NEW_TODO); } }; }
protected JPopupMenu createPopup(boolean toolWindow) { ActionPopupMenu menu = createShortPopupForRepositoryDialog(getRepositoryBrowser()); return menu.getComponent(); }
protected ActionPopupMenu createPopupMenu() { return null; }
protected ActionPopupMenu createPopupMenu() { DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction(DebuggerActions.THREADS_PANEL_POPUP); return ActionManager.getInstance().createActionPopupMenu(DebuggerActions.THREADS_PANEL_POPUP, group); }
@Override public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", "")); return new RefreshableOnComponent() { @Override public JComponent getComponent() { JPanel panel = new JPanel(new BorderLayout(4, 0)); panel.add(checkBox, BorderLayout.WEST); setFilterText(myConfiguration.myTodoPanelSettings.getTodoFilterName()); if (myConfiguration.myTodoPanelSettings.getTodoFilterName() != null) { myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.getTodoFilterName()); } final Consumer<TodoFilter> consumer = new Consumer<TodoFilter>() { @Override public void consume(TodoFilter todoFilter) { myTodoFilter = todoFilter; final String name = todoFilter == null ? null : todoFilter.getName(); myConfiguration.myTodoPanelSettings.setTodoFilterName(name); setFilterText(name); } }; final LinkLabel linkLabel = new LinkLabel("Configure", null); linkLabel.setListener(new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { DefaultActionGroup group = SetTodoFilterAction.createPopupActionGroup(myProject, myConfiguration.myTodoPanelSettings, consumer); ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.TODO_VIEW_TOOLBAR, group); popupMenu.getComponent().show(linkLabel, 0, linkLabel.getHeight()); } }, null); panel.add(linkLabel, BorderLayout.CENTER); refreshEnable(checkBox); return panel; } private void setFilterText(final String filterName) { if (filterName == null) { checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all"))); } else { checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName)); } } @Override public void refresh() { } @Override public void saveState() { myConfiguration.CHECK_NEW_TODO = checkBox.isSelected(); } @Override public void restoreState() { checkBox.setSelected(myConfiguration.CHECK_NEW_TODO); } }; }