com.intellij.openapi.actionSystem.ActionGroup Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.ActionGroup.
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: SmartPopupActionGroup.java From consulo with Apache License 2.0 | 6 votes |
private static int getChildrenCountRecursive(ActionGroup group) { AnAction[] children; if (group instanceof DefaultActionGroup) { children = ((DefaultActionGroup) group).getChildActionsOrStubs(); } else { children = group.getChildren(null); } int count = 0; for (AnAction child : children) { if (child instanceof ActionGroup) { count += getChildrenCountRecursive((ActionGroup) child); } else { count++; } } return count; }
Example #2
Source File: ContextMenuPopupHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean handlePopup(@Nonnull EditorMouseEvent event) { ActionGroup group = getActionGroup(event); if (group != null) { ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group); MouseEvent e = event.getMouseEvent(); final Component c = e.getComponent(); if (c != null && c.isShowing()) { JPopupMenu popupComponent = popupMenu.getComponent(); EditorMouseHoverPopupControl.disablePopupsWhileShowing(event.getEditor(), popupComponent); popupComponent.show(c, e.getX(), e.getY()); event.consume(); } } return true; }
Example #3
Source File: CustomActionsSchema.java From consulo with Apache License 2.0 | 6 votes |
public boolean isCorrectActionGroup(ActionGroup group, String defaultGroupName) { if (myActions.isEmpty()) { return false; } final String text = group.getTemplatePresentation().getText(); if (!StringUtil.isEmpty(text)) { for (ActionUrl url : myActions) { if (url.getGroupPath().contains(text) || url.getGroupPath().contains(defaultGroupName)) { return true; } if (url.getComponent() instanceof Group) { final Group urlGroup = (Group)url.getComponent(); String id = urlGroup.getName() != null ? urlGroup.getName() : urlGroup.getId(); if (id == null || id.equals(text) || id.equals(defaultGroupName)) { return true; } } } return false; } return true; }
Example #4
Source File: ActiveConnectionPanel.java From p4ic4idea with Apache License 2.0 | 6 votes |
private void setup() { root = new JPanel(new BorderLayout()); JScrollPane scroll = new JBScrollPane(); root.add(scroll, BorderLayout.CENTER); connectionTree = new Tree(); scroll.setViewportView(connectionTree); connectionTree.getEmptyText().setText(P4Bundle.getString("connection.tree.initial")); connectionTree.setEditable(false); connectionTreeModel = new DefaultTreeModel(treeNode); connectionTree.setModel(connectionTreeModel); connectionTree.setCellRenderer(new ConnectionTreeCellRenderer()); connectionTree.setRootVisible(false); DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel(); selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); connectionTree.setSelectionModel(selectionModel); ActionGroup actionButtons = createActionGroup(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("p4.active-connection", actionButtons, false); root.add(toolbar.getComponent(), BorderLayout.WEST); // TODO add context menu support for each selected node type. // TODO add support for navigating to a file if a FilePath is selected. }
Example #5
Source File: ActionUrl.java From consulo with Apache License 2.0 | 6 votes |
public void readExternal(Element element) throws InvalidDataException { myGroupPath = new ArrayList<String>(); for (Object o : element.getChildren(PATH)) { myGroupPath.add(((Element)o).getAttributeValue(VALUE)); } final String attributeValue = element.getAttributeValue(VALUE); if (element.getAttributeValue(IS_ACTION) != null) { myComponent = attributeValue; } else if (element.getAttributeValue(SEPARATOR) != null) { myComponent = AnSeparator.getInstance(); } else if (element.getAttributeValue(IS_GROUP) != null) { final AnAction action = ActionManager.getInstance().getAction(attributeValue); myComponent = action instanceof ActionGroup ? ActionsTreeUtil.createGroup((ActionGroup)action, true, null) : new Group(attributeValue, attributeValue, null); } myActionType = Integer.parseInt(element.getAttributeValue(ACTION_TYPE)); myAbsolutePosition = Integer.parseInt(element.getAttributeValue(POSITION)); DefaultJDOMExternalizer.readExternal(this, element); }
Example #6
Source File: CustomActionsSchema.java From consulo with Apache License 2.0 | 6 votes |
public AnAction getCorrectedAction(String id) { if (!myIdToNameList.contains(new Pair(id, ""))) { return ActionManager.getInstance().getAction(id); } if (myIdToActionGroup.get(id) == null) { for (Pair pair : myIdToNameList) { if (pair.first.equals(id)) { final ActionGroup actionGroup = (ActionGroup)ActionManager.getInstance().getAction(id); if (actionGroup != null) { //J2EE/Commander plugin was disabled myIdToActionGroup.put(id, CustomizationUtil.correctActionGroup(actionGroup, this, pair.second)); } } } } return myIdToActionGroup.get(id); }
Example #7
Source File: DvcsBranchPopup.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private ActionGroup createActions() { LightActionGroup popupGroup = new LightActionGroup(); AbstractRepositoryManager<Repo> repositoryManager = myRepositoryManager; if (repositoryManager.moreThanOneRoot()) { if (userWantsSyncControl()) { fillWithCommonRepositoryActions(popupGroup, repositoryManager); } else { fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions()); } } else { fillPopupWithCurrentRepositoryActions(popupGroup, null); } popupGroup.addSeparator(); return popupGroup; }
Example #8
Source File: SelectedTestRunLineMarkerContributorTest.java From buck with Apache License 2.0 | 6 votes |
private AnAction findActionAtCaretWithText(Predicate<String> textMatcher) { List<GutterMark> gutterMarks = myFixture.findGuttersAtCaret(); for (GutterMark gutterMark : gutterMarks) { if (!(gutterMark instanceof GutterIconRenderer)) { continue; } GutterIconRenderer renderer = (GutterIconRenderer) gutterMark; ActionGroup group = renderer.getPopupMenuActions(); for (AnAction action : group.getChildren(new TestActionEvent())) { TestActionEvent actionEvent = new TestActionEvent(); action.update(actionEvent); String actualText = actionEvent.getPresentation().getText(); if (actualText == null) { actualText = action.getTemplatePresentation().getText(); if (actualText == null) { continue; } } if (textMatcher.test(actualText)) { return action; } } } return null; }
Example #9
Source File: LightToolWindowManager.java From consulo with Apache License 2.0 | 5 votes |
public final ActionGroup createGearActions() { DefaultActionGroup group = new DefaultActionGroup("In Editor Mode", true); if (myLeftEditorModeAction == null) { myLeftEditorModeAction = createToggleAction(ToolWindowAnchor.LEFT); } group.add(myLeftEditorModeAction); if (myRightEditorModeAction == null) { myRightEditorModeAction = createToggleAction(ToolWindowAnchor.RIGHT); } group.add(myRightEditorModeAction); return group; }
Example #10
Source File: TabInfo.java From consulo with Apache License 2.0 | 5 votes |
public TabInfo setTabLabelActions(final ActionGroup tabActions, String place) { ActionGroup old = myTabLabelActions; myTabLabelActions = tabActions; myTabActionPlace = place; myChangeSupport.firePropertyChange(TAB_ACTION_GROUP, old, myTabLabelActions); return this; }
Example #11
Source File: TabInfo.java From consulo with Apache License 2.0 | 5 votes |
public TabInfo setActions(ActionGroup group, String place) { ActionGroup old = myGroup; myGroup = group; myPlace = place; myChangeSupport.firePropertyChange(ACTION_GROUP, old, myGroup); return this; }
Example #12
Source File: FlatWelcomeScreen.java From consulo with Apache License 2.0 | 5 votes |
public static void collectAllActions(List<AnAction> group, ActionGroup actionGroup) { for (AnAction action : actionGroup.getChildren(null)) { if (action instanceof ActionGroup && !((ActionGroup)action).isPopup()) { collectAllActions(group, (ActionGroup)action); } else { group.add(action); } } }
Example #13
Source File: RootAction.java From consulo with Apache License 2.0 | 5 votes |
/** * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. * @param actionsGroup * @param branchText */ public RootAction(@Nonnull T repository, @javax.annotation.Nullable T currentRepository, @Nonnull ActionGroup actionsGroup, @Nonnull String branchText) { super("", true); myRepository = repository; myGroup = actionsGroup; myBranchText = branchText; if (repository.equals(currentRepository)) { getTemplatePresentation().setIcon(AllIcons.Actions.Checked); } getTemplatePresentation().setText(DvcsUtil.getShortRepositoryName(repository), false); }
Example #14
Source File: GridCellImpl.java From consulo with Apache License 2.0 | 5 votes |
private TabInfo createTabInfoFor(Content content) { final TabInfo tabInfo = updatePresentation(new TabInfo(new ProviderWrapper(content, myContext)), content).setObject(content).setPreferredFocusableComponent(content.getPreferredFocusableComponent()) .setActionsContextComponent(content.getActionsContextComponent()); myContents.remove(content); myContents.put(content, tabInfo); ActionGroup group = (ActionGroup)myContext.getActionManager().getAction(RunnerContentUi.VIEW_TOOLBAR); tabInfo.setTabLabelActions(group, ViewContext.CELL_TOOLBAR_PLACE); tabInfo.setDragOutDelegate(((RunnerContentUi)myContext).myDragOutDelegate); return tabInfo; }
Example #15
Source File: JBPopupFactory.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public abstract ListPopup createActionGroupPopup(@Nls(capitalization = Nls.Capitalization.Title) String title, @Nonnull ActionGroup actionGroup, @Nonnull DataContext dataContext, ActionSelectionAid aid, boolean showDisabledActions, @Nullable Runnable disposeCallback, int maxRowCount, @Nullable Condition<? super AnAction> preselectActionCondition, @Nullable String actionPlace);
Example #16
Source File: JBPopupFactory.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public abstract ListPopupStep createActionsStep(@Nonnull ActionGroup actionGroup, @Nonnull DataContext dataContext, @Nullable String actionPlace, boolean showNumbers, boolean showDisabledActions, String title, Component component, boolean honorActionMnemonics, int defaultOptionIndex, boolean autoSelectionEnabled);
Example #17
Source File: FlatSpeedSearchPopup.java From consulo with Apache License 2.0 | 5 votes |
protected static <T> T getSpecificAction(Object value, @Nonnull Class<T> clazz) { if (value instanceof PopupFactoryImpl.ActionItem) { AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); if (clazz.isInstance(action)) { return clazz.cast(action); } else if (action instanceof EmptyAction.MyDelegatingActionGroup) { ActionGroup group = ((EmptyAction.MyDelegatingActionGroup)action).getDelegate(); return clazz.isInstance(group) ? clazz.cast(group) : null; } } return null; }
Example #18
Source File: BuckToolWindowFactory.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 5 votes |
@NotNull public ActionGroup getLeftToolbarActions(final Project project) { ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); group.add(actionManager.getAction("buck.ChooseTarget")); group.addSeparator(); group.add(actionManager.getAction("buck.Install")); group.add(actionManager.getAction("buck.Build")); group.add(actionManager.getAction("buck.Kill")); group.add(actionManager.getAction("buck.Uninstall")); group.add(actionManager.getAction("buck.Project")); return group; }
Example #19
Source File: CsvTableEditorMouseListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
protected JPopupMenu getColumnPopupMenu() { if (columnPopupMenu == null) { ActionManager actionManager = ActionManager.getInstance(); ActionGroup columnContextMenu = (ActionGroup) actionManager.getAction(COLUMN_CONTEXT_MENU_ID); ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(COLUMN_CONTEXT_MENU_ID, columnContextMenu); // popupMenu.setTargetComponent(csvTableEditor.getComponent()); columnPopupMenu = popupMenu.getComponent(); } return columnPopupMenu; }
Example #20
Source File: PopupHandler.java From consulo with Apache License 2.0 | 5 votes |
public static MouseListener installFollowingSelectionTreePopup(final JTree tree, @Nonnull 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; }
Example #21
Source File: VcsLogClassicFilterUi.java From consulo with Apache License 2.0 | 5 votes |
/** * Returns filter components which will be added to the Log toolbar. */ @Nonnull public ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new FilterActionComponent(() -> new BranchFilterPopupComponent(myUi, myUiProperties, myBranchFilterModel).initUi())); actionGroup.add(new FilterActionComponent(() -> new UserFilterPopupComponent(myUiProperties, myLogData, myUserFilterModel).initUi())); actionGroup.add(new FilterActionComponent(() -> new DateFilterPopupComponent(myDateFilterModel).initUi())); actionGroup.add(new FilterActionComponent( () -> new StructureFilterPopupComponent(myStructureFilterModel, myUi.getColorManager()).initUi())); return actionGroup; }
Example #22
Source File: BranchFilterPopupComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override protected ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(createAllAction()); actionGroup.add(createSelectMultipleValuesAction()); actionGroup.add( new MyBranchPopupBuilder(myFilterModel.getDataPack(), myBranchFilterModel.getVisibleRoots(), getRecentValuesFromSettings()).build()); return actionGroup; }
Example #23
Source File: CsvTableEditorMouseListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
protected JPopupMenu getRowPopupMenu() { if (rowPopupMenu == null) { ActionManager actionManager = ActionManager.getInstance(); ActionGroup rowContextMenu = (ActionGroup) actionManager.getAction(ROW_CONTEXT_MENU_ID); ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(ROW_CONTEXT_MENU_ID, rowContextMenu); // popupMenu.setTargetComponent(csvTableEditor.getComponent()); rowPopupMenu = popupMenu.getComponent(); } return rowPopupMenu; }
Example #24
Source File: UnifiedContentImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setActions(final ActionGroup actions, String place, @Nullable JComponent contextComponent) { final ActionGroup oldActions = myActions; myActions = actions; myPlace = place; myActionsContextComponent = contextComponent; myChangeSupport.firePropertyChange(PROP_ACTIONS, oldActions, myActions); }
Example #25
Source File: TitleWithToolbar.java From consulo with Apache License 2.0 | 5 votes |
public TitleWithToolbar(@Nonnull String title, @Nonnull String actionGroupId, @Nonnull String place, @Nonnull JComponent targetComponent) { super(new GridBagLayout()); ActionManager actionManager = ActionManager.getInstance(); ActionGroup group = (ActionGroup)actionManager.getAction(actionGroupId); ActionToolbar actionToolbar = actionManager.createActionToolbar(place, group, true); actionToolbar.setTargetComponent(targetComponent); actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY); add(new MyTitleComponent(title), new GridBag().weightx(1).anchor(GridBagConstraints.WEST).fillCellHorizontally()); add(actionToolbar.getComponent(), new GridBag().anchor(GridBagConstraints.CENTER)); }
Example #26
Source File: CustomisedActionGroup.java From consulo with Apache License 2.0 | 5 votes |
public CustomisedActionGroup(String shortName, boolean popup, final ActionGroup group, CustomActionsSchema schema, String defaultGroupName) { super(shortName, popup); myGroup = group; mySchema = schema; myDefaultGroupName = defaultGroupName; myForceUpdate = true; }
Example #27
Source File: LineSeparatorPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override protected ListPopup createPopup(DataContext context) { AnAction group = ActionManager.getInstance().getAction("ChangeLineSeparators"); if (!(group instanceof ActionGroup)) { return null; } return JBPopupFactory.getInstance().createActionGroupPopup("Line Separator", (ActionGroup)group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); }
Example #28
Source File: EditorActionUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated Use {@link EditorEx#setContextMenuGroupId(String)} or * {@link EditorEx#installPopupHandler(com.intellij.openapi.editor.ex.EditorPopupHandler)} instead. To be removed in version 2020.2. */ @Deprecated //@ApiStatus.ScheduledForRemoval(inVersion = "2020.2") public static EditorPopupHandler createEditorPopupHandler(@Nonnull final ActionGroup group) { return new EditorPopupHandler () { @Override public void invokePopup(final EditorMouseEvent event) { showEditorPopup(event, group); } }; }
Example #29
Source File: EditorActionUtil.java From consulo with Apache License 2.0 | 5 votes |
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(); } }
Example #30
Source File: ActionUrl.java From consulo with Apache License 2.0 | 5 votes |
public boolean isGroupContainsInPath(ActionGroup group){ for (String s : myGroupPath) { if (s.equals(group.getTemplatePresentation().getText())) { return true; } } return false; }