@Override protected void createTrees(@NotNull final Map<String, JTree> type2TreeMap) { ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP); final JTree tree1 = createTree(false); PopupHandler.installPopupHandler(tree1, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); final BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree1); type2TreeMap.put(CALLEE_TYPE, tree1); final JTree tree2 = createTree(false); PopupHandler.installPopupHandler(tree2, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree2); type2TreeMap.put(CALLER_TYPE, tree2); }
private void createConsole(@NotNull final NetService netService) { TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(netService.getProject()); netService.configureConsole(consoleBuilder); console = consoleBuilder.getConsole(); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { ActionGroup actionGroup = netService.getConsoleToolWindowActions(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false); SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true); toolWindowPanel.setContent(console.getComponent()); toolWindowPanel.setToolbar(toolbar.getComponent()); ToolWindow toolWindow = ToolWindowManager.getInstance(netService.getProject()) .registerToolWindow(netService.getConsoleToolWindowId(), false, ToolWindowAnchor.BOTTOM, netService.getProject(), true); toolWindow.setIcon(netService.getConsoleToolWindowIcon()); Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel, "", false); Disposer.register(content, console); toolWindow.getContentManager().addContent(content); } }, netService.getProject().getDisposed()); }
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; }
@Override 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 = Separator.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); }
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, pair.second)); } } } } return myIdToActionGroup.get(id); }
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; }
@NotNull private ActionGroup createActions() { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); AbstractRepositoryManager<Repo> repositoryManager = myRepositoryManager; if (repositoryManager.moreThanOneRoot()) { if (userWantsSyncControl()) { fillWithCommonRepositoryActions(popupGroup, repositoryManager); } else { fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions()); } } else { fillPopupWithCurrentRepositoryActions(popupGroup, null); } popupGroup.addSeparator(); return popupGroup; }
@Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { List<AnAction> result = new ArrayList<AnAction>(); for (AnAction action : myDelegate.getChildren(e)) { if (myExcludes.contains(action)) { continue; } if (action instanceof ActionGroup) { result.add(new ExcludingActionGroup((ActionGroup) action, myExcludes)); } else { result.add(action); } } return result.toArray(new AnAction[result.size()]); }
@NotNull public ActionGroup getToolbarActions(Project project, DeviceContext deviceContext) { DefaultActionGroup group = new DefaultActionGroup(); group.add(new ScreenshotAction(project, deviceContext)); group.add(new ScreenRecorderAction(project, deviceContext)); group.add(DumpSysActions.create(project, deviceContext)); //group.add(new MyFileExplorerAction()); group.add(new Separator()); group.add(new TerminateVMAction(deviceContext)); //group.add(new MyAllocationTrackerAction()); //group.add(new Separator()); return group; }
@NotNull private ActionGroup createActionToolbar(JComponent consolePanel, ConsoleView consoleView, @NotNull final RunnerLayoutUi myUi, RunContentDescriptor contentDescriptor, Executor runExecutorInstance) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new FilterAction()); actionGroup.add(new RerunAction(consolePanel, consoleView)); actionGroup.add(new StopAction()); actionGroup.add(new FormatAction()); actionGroup.add(new MyCloseAction(runExecutorInstance, contentDescriptor, myProject)); return actionGroup; }
private static JComponent createConsolePanel(ConsoleView view, ActionGroup actions) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(view.getComponent(), BorderLayout.CENTER); panel.add(createToolbar(actions), BorderLayout.WEST); return panel; }
/** * Create a list of idea actions that the user can choose, to change their pairs. * * @param pairController Pair logic controller for list of members. * @return list of actions. */ private static ActionGroup createActions(@NotNull PairController pairController, @NotNull TeamMemberAction.TeamMemberActionPerformer teamMemberActionPerformer) { DefaultActionGroup defaultActionGroup = new DefaultActionGroup(null, false); PairConfig pairConfig = pairController.getPairConfig(); for (TeamMember teamMember : pairConfig.getTeamMembers()) { defaultActionGroup.add(new TeamMemberAction(teamMember, teamMemberActionPerformer)); } return defaultActionGroup; }
private static ActionToolbar createToolbarFromGroupId(final String groupId) { final ActionManager actionManager = ActionManager.getInstance(); if (!actionManager.isGroup(groupId)) { throw new IllegalStateException(groupId + " should have been a group"); } final ActionGroup group = ((ActionGroup)actionManager.getAction(groupId)); final ActionToolbarImpl editorToolbar = ((ActionToolbarImpl)actionManager.createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, group, true)); editorToolbar.setOpaque(false); editorToolbar.setBorder(new JBEmptyBorder(0, 2, 0, 2)); return editorToolbar; }
@NotNull private ActionGroup createActionToolbar(JComponent consolePanel, ConsoleView consoleView, @NotNull final RunnerLayoutUi myUi, RunContentDescriptor contentDescriptor, Executor runExecutorInstance) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new RerunAction(consolePanel, consoleView)); actionGroup.add(new StopAction()); actionGroup.add(new FormatAction()); actionGroup.add(new MyCloseAction(runExecutorInstance, contentDescriptor, myProject)); return actionGroup; }
protected void createTrees(@NotNull Map<String, JTree> trees) { final JTree tree = createTree(false); ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP); PopupHandler.installPopupHandler(tree, group, ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); final BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_METHOD_HIERARCHY).getShortcutSet(), tree); trees.put(METHOD_TYPE, tree); }
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgNewBookmarkAction(Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgShowUnnamedHeadsForCurrentBranchAction(myRepository)); if (toInsert != null) { popupGroup.addAll(toInsert); } popupGroup.addSeparator("Bookmarks"); List<String> bookmarkNames = getSortedNamesWithoutHashes(myRepository.getBookmarks()); String currentBookmark = myRepository.getCurrentBookmark(); for (String bookmark : bookmarkNames) { AnAction bookmarkAction = new BookmarkActions(myProject, Collections.singletonList(myRepository), bookmark); if (bookmark.equals(currentBookmark)) { bookmarkAction.getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } popupGroup.add(bookmarkAction); } popupGroup.addSeparator("Branches"); List<String> branchNamesList = new ArrayList<String>(myRepository.getOpenedBranches());//only opened branches have to be shown Collections.sort(branchNamesList); for (String branch : branchNamesList) { if (!branch.equals(myRepository.getCurrentBranch())) { // don't show current branch in the list popupGroup.add(new HgCommonBranchActions(myProject, Collections.singletonList(myRepository), branch)); } } return popupGroup; }
public void initContent() { final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(TOOL_WINDOW_TOOLBAR_ID); ActionToolbar actionToolbar = actionManager.createActionToolbar(myPlace, actionGroup, true); JPanel toolbarControl = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; toolbarControl.add(actionToolbar.getComponent(), constraints); for (JComponent component : getToolbarControls()) { component.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP)); toolbarControl.add(component, constraints); } setToolbar(toolbarControl); final JComponent payloadControl = buildContent(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(payloadControl); JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); scrollBar.setUnitIncrement(scrollBar.getUnitIncrement() * 7); myContent.add(scrollPane, CONTENT_CARD_NAME); RichTextControlBuilder builder = new RichTextControlBuilder(); builder.setBackgroundColor(payloadControl.getBackground()); builder.setForegroundColor(UIUtil.getInactiveTextColor()); builder.setFont(payloadControl.getFont()); builder.setText(GradleBundle.message("gradle.toolwindow.text.no.linked.project")); final JComponent noLinkedProjectControl = builder.build(); myContent.add(noLinkedProjectControl, NON_LINKED_CARD_NAME); update(); }
@NotNull public abstract ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions, String title, Component component, boolean honorActionMnemonics);
@NotNull public abstract ListPopupStep createActionsStep(@NotNull ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions, String title, Component component, boolean honorActionMnemonics, int defaultOptionIndex, final boolean autoSelectionEnabled);
@NotNull public abstract ListPopup createActionGroupPopup(@Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions, boolean honorActionMnemonics, @Nullable Runnable disposeCallback, int maxRowCount, @Nullable Condition<AnAction> preselectActionCondition);
public ToolbarPanel(JComponent contentComponent, ActionGroup actions, final String toolbarPlace) { super(new GridBagLayout()); setBorder(BorderFactory.createEtchedBorder()); if (contentComponent.getBorder() != null) { contentComponent.setBorder(BorderFactory.createEmptyBorder()); } final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(toolbarPlace, actions, true); add(actionToolbar.getComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(contentComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
public TabInfo setActions(ActionGroup group, String place) { ActionGroup old = myGroup; myGroup = group; myPlace = place; myChangeSupport.firePropertyChange(ACTION_GROUP, old, myGroup); return this; }
public TabInfo setTabLabelActions(final ActionGroup tabActions, String place) { ActionGroup old = myTabLabelActions; myTabLabelActions = tabActions; myTabActionPlace = place; myChangeSupport.firePropertyChange(TAB_ACTION_GROUP, old, myTabLabelActions); return this; }
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; }
@Override protected ActionGroup createActionGroup() { DefaultActionGroup group = new DefaultActionGroup(); group.add(createAllAction()); group.add(createSelectMultipleValuesAction()); if (!myDataHolder.getCurrentUser().isEmpty()) { group.add(createPredefinedValueAction(Collections.singleton(VcsLogUserFilterImpl.ME))); } group.addAll(createRecentItemsActionGroup()); return group; }
/** * Returns filter components which will be added to the Log toolbar. */ @NotNull public ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new TextFilterComponent(myTextFilterModel)); actionGroup.add(new FilterActionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new BranchFilterPopupComponent(myUiProperties, myBranchFilterModel).initUi(); } })); actionGroup.add(new FilterActionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new UserFilterPopupComponent(myUiProperties, myLogDataHolder, myUserFilterModel).initUi(); } })); actionGroup.add(new FilterActionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new DateFilterPopupComponent(myDateFilterModel).initUi(); } })); actionGroup.add(new FilterActionComponent(new Computable<JComponent>() { @Override public JComponent compute() { return new StructureFilterPopupComponent(myStructureFilterModel, myUi.getColorManager()).initUi(); } })); return actionGroup; }
@Override protected ActionGroup createActionGroup() { DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(createAllAction()); actionGroup.add(createSelectMultipleValuesAction()); actionGroup.add(constructActionGroup(myFilterModel.getDataPack(), createRecentItemsActionGroup(), new Function<String, AnAction>() { @Override public AnAction fun(String name) { return createPredefinedValueAction(Collections.singleton(name)); } }, myBranchFilterModel.getVisibleRoots())); return actionGroup; }
@Override protected ActionGroup createActionGroup() { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR, -1); Date oneDayBefore = cal.getTime(); cal.add(Calendar.DAY_OF_YEAR, -6); Date oneWeekBefore = cal.getTime(); return new DefaultActionGroup(createAllAction(), new DateAction(oneDayBefore, "Last 24 hours"), new DateAction(oneWeekBefore, "Last 7 days"), new SelectAction()); }
public WelcomePane(ActionGroup actions, WelcomeScreen screen) { super(new GridBagLayout()); JPanel actionsPanel = new CardActionsPanel(actions) { @Override public Dimension getPreferredSize() { return new Dimension(500, super.getPreferredSize().height); } }; actionsPanel.setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR)); JPanel recentsPanel = new JPanel(new BorderLayout(30, 30)); recentsPanel.add(new RecentProjectPanel(screen)); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(15, 15, 15, 15); c.weightx = 0.33; c.weighty = 1; c.fill = GridBagConstraints.BOTH; add(recentsPanel, c); c.gridx = 1; c.gridy = 0; c.weightx = 0.66; c.weighty = 1; c.insets = new Insets(15, 0, 15, 15); c.anchor = GridBagConstraints.NORTH; c.fill = GridBagConstraints.BOTH; add(actionsPanel, c); }
public static EditorPopupHandler createEditorPopupHandler(@NotNull 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); showEditorPopup(event, group); } } }; }
public static EditorPopupHandler createEditorPopupHandler(@NotNull final ActionGroup group) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { showEditorPopup(event, group); } }; }
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(); } }
@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); }
@Override public ActionGroup getCaptionActions() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new InsertBeforeAction()); group.add(new InsertAfterAction()); group.add(new SplitAction()); group.add(new DeleteAction()); return group; }
public boolean isGroupContainsInPath(ActionGroup group){ for (String s : myGroupPath) { if (s.equals(group.getTemplatePresentation().getText())) { return true; } } return false; }
public void fillActionGroups(DefaultMutableTreeNode root){ final ActionManager actionManager = ActionManager.getInstance(); for (Pair pair : myIdToNameList) { final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(pair.first); if (actionGroup != null) { //J2EE/Commander plugin was disabled root.add(ActionsTreeUtil.createNode(ActionsTreeUtil.createGroup(actionGroup, pair.second, null, null, true, null, false))); } } }
/** * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. * @param actionsGroup * @param branchText */ public RootAction(@NotNull T repository, @Nullable T currentRepository, @NotNull ActionGroup actionsGroup, @NotNull String branchText) { super("", true); myRepository = repository; myGroup = actionsGroup; myBranchText = branchText; if (repository.equals(currentRepository)) { getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); } getTemplatePresentation().setText(DvcsUtil.getShortRepositoryName(repository), false); }
public JComponent initContent() { myBrowser = new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList()); myBrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.not.loaded.message")); ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("IncomingChangesToolbar"); final ActionToolbar toolbar = myBrowser.createGroupFilterToolbar(myProject, group, null, Collections.<AnAction>emptyList()); myBrowser.setToolBar(toolbar.getComponent()); myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList()); myConnection = myBus.connect(); myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new MyCommittedChangesListener()); loadChangesToBrowser(false, true); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(myBrowser, BorderLayout.CENTER); return contentPane; }
@Override public ActionGroup getCaptionActions() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new InsertBeforeAction()); group.add(new InsertAfterAction()); group.add(new SplitAction()); group.add(new DeleteAction()); group.add(new GroupRowsColumnsAction()); group.add(new UngroupRowsColumnsAction()); return group; }