public void insertTab( final VirtualFile file, final Icon icon, final JComponent comp, final String tooltip, final int indexToInsert) { TabInfo tab = myTabs.findInfo(file); if (tab != null) return; tab = new TabInfo(comp) .setText(calcTabTitle(myProject, file)) .setIcon(icon) .setTooltipText(tooltip) .setObject(file) .setTabColor(calcTabColor(myProject, file)) .setDragOutDelegate(myDragOutDelegate); tab.setTestableUi(new MyQueryable(tab)); final DefaultActionGroup tabActions = new DefaultActionGroup(); tabActions.add(new CloseTab(comp, tab)); tab.setTabLabelActions(tabActions, ActionPlaces.EDITOR_TAB); myTabs.addTab(tab, indexToInsert); }
private void collectAllActions(DefaultActionGroup group, ActionGroup actionGroup) { for (AnAction action : actionGroup.getChildren(null)) { if (action instanceof ActionGroup && !((ActionGroup) action).isPopup()) { collectAllActions(group, (ActionGroup) action); } else { group.add(action); } } }
public void buildUi() { myTopPanel = new JPanel(new BorderLayout()); final JPanel wrapper = new JPanel(); // final BoxLayout boxLayout = new BoxLayout(wrapper, BoxLayout.X_AXIS); wrapper.setLayout(new BorderLayout()); myTitleLabel.setBorder(BorderFactory.createEmptyBorder(1, 2, 0, 0)); wrapper.add(myTitleLabel, BorderLayout.WEST); DefaultActionGroup dag = new DefaultActionGroup(); myPreviousDiff.copyShortcutFrom(ActionManager.getInstance().getAction("PreviousDiff")); myNextDiff.copyShortcutFrom(ActionManager.getInstance().getAction("NextDiff")); dag.add(new MyChangeContextAction()); dag.add(myPreviousDiff); dag.add(myNextDiff); myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myPanel); myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myPanel); dag.add(new PopupAction()); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, dag, true); wrapper.add(toolbar.getComponent(), BorderLayout.EAST); myTopPanel.add(wrapper, BorderLayout.CENTER); final JPanel wrapperDiffs = new JPanel(new GridBagLayout()); final JPanel oneMore = new JPanel(new BorderLayout()); oneMore.add(wrapperDiffs, BorderLayout.NORTH); myCurrentHorizontal = myConfiguration.SHORT_DIFF_HORISONTALLY; myHorizontal = createPanel(true); myVertical = createPanel(false); myPanel.add(myTopPanel, BorderLayout.NORTH); myPanel.add(getCurrentPanel().getComponent(), BorderLayout.CENTER); myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myParent); myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myParent); }
@Override public void actionPerformed(AnActionEvent e) { final DefaultActionGroup dag = new DefaultActionGroup(); dag.add(myUsual); dag.add(myNumbered); dag.add(mySoftWrapsAction); final ListPopup popup = JBPopupFactory.getInstance() .createActionGroupPopup( null, dag, e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); if (e.getInputEvent() instanceof MouseEvent) { popup.show(new RelativePoint((MouseEvent) e.getInputEvent())); } else { // todo correct /*final Dimension dimension = popup.getContent().getPreferredSize(); final Point at = new Point(-dimension.width / 2, 0); popup.show(new RelativePoint(myParent, at));*/ popup.showInBestPositionFor(e.getDataContext()); } }
protected ActionGroup createActionGroup() { DefaultActionGroup result = new DefaultActionGroup(); Sorter[] sorters = myTreeModel.getSorters(); for (final Sorter sorter : sorters) { if (sorter.isVisible()) { result.add(new TreeActionWrapper(sorter, this)); } } if (sorters.length > 0) { result.addSeparator(); } Grouper[] groupers = myTreeModel.getGroupers(); for (Grouper grouper : groupers) { result.add(new TreeActionWrapper(grouper, this)); } Filter[] filters = myTreeModel.getFilters(); for (Filter filter : filters) { result.add(new TreeActionWrapper(filter, this)); } if (myTreeModel instanceof ProvidingTreeModel) { final Collection<NodeProvider> providers = ((ProvidingTreeModel) myTreeModel).getNodeProviders(); for (NodeProvider provider : providers) { result.add(new TreeActionWrapper(provider, this)); } } result.add(new ExpandAllAction(getTree())); result.add(new CollapseAllAction(getTree())); if (showScrollToFromSourceActions()) { result.addSeparator(); result.add(myAutoScrollToSourceHandler.createToggleAction()); result.add(myAutoScrollFromSourceHandler.createToggleAction()); } return result; }