@Override protected ActionPopupMenu createPopupMenu() { ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP); return ActionManager.getInstance() .createActionPopupMenu(DebuggerActions.FRAME_PANEL_POPUP, group); }
protected ActionPopupMenu createPopupMenu() { ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction(DebuggerActions.WATCH_PANEL_POPUP); ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(DebuggerActions.WATCH_PANEL_POPUP, group); return popupMenu; }
private JComponent createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); group.add(ActionManager.getInstance().getAction(SERVERS_TOOL_WINDOW_TOOLBAR)); group.add(new Separator()); group.add(new ContextHelpAction(HELP_ID)); ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar(PLACE_TOOLBAR, group, false); myTree.putClientProperty( DataManager.CLIENT_PROPERTY_DATA_PROVIDER, new DataProvider() { @Override public Object getData(@NonNls String dataId) { if (KEY.getName().equals(dataId)) { return ServersToolWindowContent.this; } for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensions()) { Object data = contributor.getData(dataId, ServersToolWindowContent.this); if (data != null) { return data; } } return null; } }); actionToolBar.setTargetComponent(myTree); return actionToolBar.getComponent(); }
private JPanel createToolbarPanel() { RunAction runAction = new RunAction(this); runAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this); DefaultActionGroup leftActionGroup = new DefaultActionGroup(); leftActionGroup.add(runAction); leftActionGroup.add(new PauseOutputAction(this)); leftActionGroup.add(new StopAction(this)); leftActionGroup.add(new CloseAction()); leftActionGroup.add(new PreviousOccurenceToolbarAction(this)); leftActionGroup.add(new NextOccurenceToolbarAction(this)); leftActionGroup.add(new ContextHelpAction(HelpID.ANT)); DefaultActionGroup rightActionGroup = new DefaultActionGroup(); rightActionGroup.add(new ChangeViewAction(this)); rightActionGroup.add(new VerboseAction(this)); rightActionGroup.add( CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this)); rightActionGroup.add( CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this)); rightActionGroup.add(myTreeView.createToggleAutoscrollAction()); myLeftToolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, leftActionGroup, false); JPanel toolbarPanel = new JPanel(new GridLayout(1, 2, 2, 0)); toolbarPanel.add(myLeftToolbar.getComponent()); myRightToolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, rightActionGroup, false); toolbarPanel.add(myRightToolbar.getComponent()); return toolbarPanel; }
protected void addActionsTo(DefaultActionGroup group) { group.add(new MyGroupByPackagesAction()); group.add(new GroupByChangeListAction()); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_ALL)); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COLLAPSE_ALL)); group.add(ActionManager.getInstance().getAction("Diff.UpdatedFiles")); }
private void registerFileChooserShortcut( @NonNls final String baseActionId, @NonNls final String fileChooserActionId) { final JTree tree = myFileSystemTree.getTree(); final AnAction syncAction = ActionManager.getInstance().getAction(fileChooserActionId); AnAction original = ActionManager.getInstance().getAction(baseActionId); syncAction.registerCustomShortcutSet(original.getShortcutSet(), tree, myDisposable); }
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(DataConstants.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); }
public static void invokeNamedAction(final String actionId) { final AnAction action = ActionManager.getInstance().getAction(actionId); assertNotNull(action); final Presentation presentation = new Presentation(); @SuppressWarnings("deprecation") final DataContext context = DataManager.getInstance().getDataContext(); final AnActionEvent event = new AnActionEvent(null, context, "", presentation, ActionManager.getInstance(), 0); action.update(event); Assert.assertTrue(presentation.isEnabled()); action.actionPerformed(event); }
private void executeAction(final String watch) { AnAction action = ActionManager.getInstance().getAction(watch); Presentation presentation = action.getTemplatePresentation().clone(); DataContext context = DataManager.getInstance().getDataContext(myTreePanel.getTree()); AnActionEvent actionEvent = new AnActionEvent( null, context, ActionPlaces.DEBUGGER_TOOLBAR, presentation, ActionManager.getInstance(), 0); action.actionPerformed(actionEvent); }
@Override protected JComponent createTreePanel(final WatchDebuggerTree tree) { final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree); decorator.setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { executeAction(DebuggerActions.NEW_WATCH, tree); } }); // TODO[den]: add "Add to watches action" on Mac if (!SystemInfo.isMac) { decorator.addExtraAction( AnActionButton.fromAction( ActionManager.getInstance().getAction(XDebuggerActions.ADD_TO_WATCH))); } decorator.setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { executeAction(DebuggerActions.REMOVE_WATCH, tree); } }); CustomLineBorder border = new CustomLineBorder( CaptionPanel.CNT_ACTIVE_BORDER_COLOR, SystemInfo.isMac ? 1 : 0, 0, SystemInfo.isMac ? 0 : 1, 0); decorator.setToolbarBorder(border); final JPanel panel = decorator.createPanel(); panel.setBorder(null); return panel; }
private void mousePressedInIconsArea(MouseEvent e) { EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e); if (iconRenderer != null) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu popupMenu = iconRenderer.getPopupMenu(); if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) { e.consume(); Component component = e.getComponent(); popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY()); } return; } AnAction action = iconRenderer.getClickAction(); if (e.getButton() == MouseEvent.BUTTON1 && action != null) { if (e.getID() == MouseEvent.MOUSE_CLICKED) { AnActionEvent actionEvent = new AnActionEvent( e, new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()), ICON_AREA, action.getTemplatePresentation(), ActionManager.getInstance(), e.getModifiers()); action.update(actionEvent); action.actionPerformed(actionEvent); } e.consume(); } } }
@Override protected void processMouseEvent(MouseEvent e) { switch (e.getID()) { case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: case MouseEvent.MOUSE_CLICKED: if (isInFoldingArea(e)) { mousePressedInFoldingArea(e); } else if (isInTextArea(e)) { mousePressedInTextArea(e); } else { mousePressedInIconsArea(e); } if (!e.isConsumed() && e.getButton() == MouseEvent.BUTTON3 && e.getID() == MouseEvent.MOUSE_PRESSED) { DefaultActionGroup actionGroup = ActionUtils.getDefaultGroup(MPSActions.EDITOR_LEFTPANEL_GROUP); if (actionGroup != null) { ActionPopupMenu popupMenu = ActionManager.getInstance() .createActionPopupMenu(ActionPlaces.EDITOR_POPUP, actionGroup); popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY()); e.consume(); } } } // suppressing future event processig in case event was consumed by one of LeftHighlighter // elements if (!e.isConsumed()) { super.processMouseEvent(e); } }
public ActionMenuItem( final AnAction action, final Presentation presentation, @NotNull final String place, @NotNull DataContext context, final boolean enableMnemonics, final boolean prepareNow, final boolean insideCheckedGroup) { myAction = ActionRef.fromAction(action); myPresentation = presentation; myPlace = place; myContext = context; myEnableMnemonics = enableMnemonics; myToggleable = action instanceof Toggleable; myInsideCheckedGroup = insideCheckedGroup; myEvent = new AnActionEvent(null, context, place, myPresentation, ActionManager.getInstance(), 0); addActionListener(new ActionTransmitter()); setBorderPainted(false); updateUI(); if (prepareNow) { init(); } else { setText("loading..."); } }
public static ActionToolbar createAddRemoveToolbar(ListTable table) { final AnAction addAction = new AddAction(table); final AnAction removeAction = new RemoveAction(table); final ActionGroup group = new DefaultActionGroup(addAction, removeAction); final ActionManager actionManager = ActionManager.getInstance(); return actionManager.createActionToolbar(ActionPlaces.UNKNOWN, group, true); }
private void registerShortcuts() { ActionManager actionManager = ActionManager.getInstance(); actionManager .getAction(XDebuggerActions.SET_VALUE) .registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), this); actionManager .getAction(XDebuggerActions.COPY_VALUE) .registerCustomShortcutSet(CommonShortcuts.getCopy(), this); actionManager .getAction(XDebuggerActions.JUMP_TO_SOURCE) .registerCustomShortcutSet(CommonShortcuts.getEditSource(), this); Shortcut[] editTypeShortcuts = KeymapManager.getInstance() .getActiveKeymap() .getShortcuts(XDebuggerActions.EDIT_TYPE_SOURCE); actionManager .getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE) .registerCustomShortcutSet(new CustomShortcutSet(editTypeShortcuts), this); actionManager .getAction(XDebuggerActions.MARK_OBJECT) .registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark")), this); }
private ActionToolbar createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); BackAction back = new BackAction(); back.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)), this); group.add(back); ForwardAction forward = new ForwardAction(); forward.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)), this); group.add(forward); EditSourceActionBase edit = new EditSourceAction(); edit.registerCustomShortcutSet( new CompositeShortcutSet(CommonShortcuts.getEditSource(), CommonShortcuts.ENTER), this); group.add(edit); edit = new ShowSourceAction(); edit.registerCustomShortcutSet( new CompositeShortcutSet(CommonShortcuts.getViewSource(), CommonShortcuts.CTRL_ENTER), this); group.add(edit); return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); }
private JComponent toUsageViewToolbar(final DefaultActionGroup group) { ActionToolbar actionToolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, group, false); actionToolbar.setTargetComponent(myRootPanel); return actionToolbar.getComponent(); }
private void registerShortcut( @NotNull String actionId, @NotNull ShortcutSet shortcut, @NotNull JComponent component) { final AnAction action = ActionManager.getInstance().getAction(actionId); if (action != null) { action.registerCustomShortcutSet(shortcut, component, this); } }
private JComponent createTreeToolbar() { final DefaultActionGroup group = new DefaultActionGroup(); final Runnable update = new Runnable() { public void run() { rebuild(true); } }; if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) { group.add(new FlattenPackagesAction(update)); } final PatternDialectProvider[] dialectProviders = Extensions.getExtensions(PatternDialectProvider.EP_NAME); for (PatternDialectProvider provider : dialectProviders) { for (AnAction action : provider.createActions(myProject, update)) { group.add(action); } } group.add(new ShowFilesAction(update)); final Module[] modules = ModuleManager.getInstance(myProject).getModules(); if (modules.length > 1) { group.add(new ShowModulesAction(update)); group.add(new ShowModuleGroupsAction(update)); } group.add(new FilterLegalsAction(update)); if (dialectProviders.length > 1) { group.add(new ChooseScopeTypeAction(update)); } ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); return toolbar.getComponent(); }
static void subscribeTo(NavBarPanel panel) { if (panel.getClientProperty(LISTENER) != null) { unsubscribeFrom(panel); } final NavBarListener listener = new NavBarListener(panel); final Project project = panel.getProject(); panel.putClientProperty(LISTENER, listener); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener); FileStatusManager.getInstance(project).addFileStatusListener(listener); PsiManager.getInstance(project).addPsiTreeChangeListener(listener); WolfTheProblemSolver.getInstance(project).addProblemListener(listener); ActionManager.getInstance().addAnActionListener(listener); final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener); connection.subscribe(NavBarModelListener.NAV_BAR, listener); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener); panel.putClientProperty(BUS, connection); panel.addKeyListener(listener); if (panel.isInFloatingMode()) { final Window window = SwingUtilities.windowForComponent(panel); if (window != null) { window.addWindowFocusListener(listener); } } }
private JComponent createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new CloseAction()); group.add(new RerunAction(this)); group.add(new FlattenPackagesAction()); group.add(new ShowFilesAction()); if (ModuleManager.getInstance(myProject).getModules().length > 1) { group.add(new ShowModulesAction()); group.add(new ShowModuleGroupsAction()); } group.add(new GroupByScopeTypeAction()); // group.add(new GroupByFilesAction()); group.add(new FilterLegalsAction()); group.add(new MarkAsIllegalAction()); group.add(new ChooseScopeTypeAction()); group.add(new EditDependencyRulesAction()); group.add( CommonActionsManager.getInstance() .createExportToTextFileAction(new DependenciesExporterToTextFile())); group.add(new ContextHelpAction("dependency.viewer.tool.window")); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); return toolbar.getComponent(); }
public void showGroupPopupMenu(final Component comp, final int x, final int y) { ActionGroup group = myGroup.getPopupActionGroup(); if (group != null) { ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); popupMenu.getComponent().show(comp, x, y); } }
@Override protected void buildToolBar(final DefaultActionGroup toolBarGroup) { super.buildToolBar(toolBarGroup); EmptyAction.registerWithShortcutSet( IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), myViewer); toolBarGroup.add(ActionManager.getInstance().getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST)); }
private AnAction[] createActions() { final TreeExpander treeExpander = new TreeExpander() { @Override public void expandAll() { UsageViewImpl.this.expandAll(); } @Override public boolean canExpand() { return true; } @Override public void collapseAll() { UsageViewImpl.this.collapseAll(); } @Override public boolean canCollapse() { return true; } }; CommonActionsManager actionsManager = CommonActionsManager.getInstance(); myTextFileExporter = new ExporterToTextFile(this); final JComponent component = getComponent(); final AnAction expandAllAction = actionsManager.createExpandAllAction(treeExpander, component); final AnAction collapseAllAction = actionsManager.createCollapseAllAction(treeExpander, component); scheduleDisposeOnClose( new Disposable() { @Override public void dispose() { collapseAllAction.unregisterCustomShortcutSet(component); expandAllAction.unregisterCustomShortcutSet(component); } }); return new AnAction[] { canPerformReRun() ? new ReRunAction() : null, new CloseAction(), ActionManager.getInstance().getAction("PinToolwindowTab"), createRecentFindUsagesAction(), expandAllAction, collapseAllAction, actionsManager.createPrevOccurenceAction(myRootPanel), actionsManager.createNextOccurenceAction(myRootPanel), actionsManager.installAutoscrollToSourceHandler( myProject, myTree, new MyAutoScrollToSourceOptionProvider()), actionsManager.createExportToTextFileAction(myTextFileExporter), actionsManager.createHelpAction(HELP_ID) }; }
public void onContentChangedIn(EditorSource source) { myDiffUpdater.contentRemoved(source); final EditorEx editor = source.getEditor(); if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) { editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT); } DiffSideView viewSide = getSideView(source.getSide()); viewSide.setEditorSource(getProject(), source); Disposer.dispose(myScrollSupport); if (editor == null) { if (!myDisposed) { rediff(); } return; } final MouseListener mouseListener = PopupHandler.installUnknownPopupHandler( editor.getContentComponent(), new MergeActionGroup(this, source.getSide()), ActionManager.getInstance()); myDiffUpdater.contentAdded(source); editor.getSettings().setLineNumbersShown(true); editor.getSettings().setFoldingOutlineShown(false); editor.getFoldingModel().setFoldingEnabled(false); ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true); Editor editor1 = getEditor(FragmentSide.SIDE1); Editor editor2 = getEditor(FragmentSide.SIDE2); if (editor1 != null && editor2 != null && myIsSyncScroll) { myScrollSupport.install(new EditingSides[] {this}); } final VisibleAreaListener visibleAreaListener = mySplitter.getVisibleAreaListener(); final ScrollingModel scrollingModel = editor.getScrollingModel(); if (visibleAreaListener != null) { scrollingModel.addVisibleAreaListener(visibleAreaListener); scrollingModel.addVisibleAreaListener(myVisibleAreaListener); } myFontSizeSynchronizer.synchronize(editor); source.addDisposable( new Disposable() { public void dispose() { myFontSizeSynchronizer.stopSynchronize(editor); } }); source.addDisposable( new Disposable() { public void dispose() { if (visibleAreaListener != null) { scrollingModel.removeVisibleAreaListener(visibleAreaListener); scrollingModel.removeVisibleAreaListener(myVisibleAreaListener); } editor.getContentComponent().removeMouseListener(mouseListener); } }); }
public boolean processAction(final InputEvent e, ActionProcessor processor) { ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); final Project project = PlatformDataKeys.PROJECT.getData(myContext.getDataContext()); final boolean dumb = project != null && DumbService.getInstance(project).isDumb(); List<AnActionEvent> nonDumbAwareAction = new ArrayList<AnActionEvent>(); for (final AnAction action : myContext.getActions()) { final Presentation presentation = myPresentationFactory.getPresentation(action); // Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard final AnActionEvent actionEvent = processor.createEvent( e, myContext.getDataContext(), ActionPlaces.MAIN_MENU, presentation, ActionManager.getInstance()); ActionUtil.performDumbAwareUpdate(action, actionEvent, true); if (dumb && !action.isDumbAware()) { if (Boolean.FALSE.equals( presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) { continue; } nonDumbAwareAction.add(actionEvent); continue; } if (!presentation.isEnabled()) { continue; } processor.onUpdatePassed(e, action, actionEvent); ((DataManagerImpl.MyDataContext) myContext.getDataContext()) .setEventCount(IdeEventQueue.getInstance().getEventCount(), this); actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent); Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext()); if (component != null && !component.isShowing()) { return true; } processor.performAction(e, action, actionEvent); actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent); return true; } if (!nonDumbAwareAction.isEmpty()) { showDumbModeWarningLaterIfNobodyConsumesEvent( e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()])); } return false; }
@NotNull private AnActionEvent createActionEvent(@NotNull AnAction actionGroup) { return new AnActionEvent( null, myDataContext, myActionPlace, getPresentation(actionGroup), ActionManager.getInstance(), 0); }
public ExternalDocAction() { super( CodeInsightBundle.message("javadoc.action.view.external"), null, AllIcons.Actions.Browser_externalJavaDoc); registerCustomShortcutSet( ActionManager.getInstance() .getAction(IdeActions.ACTION_EXTERNAL_JAVADOC) .getShortcutSet(), null); }
private JPanel createToolbarPanel(Collection<AnAction> actions) { final DefaultActionGroup group = new DefaultActionGroup(); for (AnAction action : actions) { group.add(action); } final ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false); final JPanel panel = new JPanel(new BorderLayout()); panel.add(actionToolBar.getComponent(), BorderLayout.CENTER); return panel; }
protected void initTree() { ((DefaultTreeModel) myTree.getModel()).setRoot(myRoot); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); myTree.setCellRenderer( new ColoredTreeCellRenderer() { public void customizeCellRenderer( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof MyNode) { final MyNode node = ((MyNode) value); setIcon(node.getIcon(expanded)); final Font font = UIUtil.getTreeFont(); if (node.isDisplayInBold()) { setFont(font.deriveFont(Font.BOLD)); } else { setFont(font.deriveFont(Font.PLAIN)); } append( node.getDisplayName(), node.isDisplayInBold() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); } } }); initToolbar(); ArrayList<AnAction> actions = createActions(true); if (actions != null) { final DefaultActionGroup group = new DefaultActionGroup(); for (AnAction action : actions) { group.add(action); } actions = getAdditionalActions(); if (actions != null) { group.addSeparator(); for (AnAction action : actions) { group.add(action); } } PopupHandler.installPopupHandler( myTree, group, ActionPlaces.UNKNOWN, ActionManager.getInstance()); // popup should follow the selection } }