@Override protected ActionPopupMenu createPopupMenu() { ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP); return ActionManager.getInstance() .createActionPopupMenu(DebuggerActions.FRAME_PANEL_POPUP, group); }
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(); }
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; }
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")); }
protected ActionPopupMenu createPopupMenu() { ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction(DebuggerActions.EVALUATION_DIALOG_POPUP); return ActionManager.getInstance() .createActionPopupMenu(DebuggerActions.EVALUATION_DIALOG_POPUP, group); }
private static String getSearchAgainMessage(PsiElement element, final FileSearchScope direction) { String message = getNoUsagesFoundMessage(element); if (direction == FileSearchScope.AFTER_CARET) { AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT); String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action); if (shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.top.action.message", message); } else { message = FindBundle.message("find.search.again.from.top.hotkey.message", message, shortcutsText); } } else { String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText( ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_PREVIOUS)); if (shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.bottom.action.message", message); } else { message = FindBundle.message( "find.search.again.from.bottom.hotkey.message", message, shortcutsText); } } return message; }
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; }
public NextOccurrenceAction( EditorSearchComponent editorSearchComponent, Getter<JTextComponent> editorTextField) { super(editorSearchComponent); myTextField = editorTextField; copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_NEXT_OCCURENCE)); ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>(); ContainerUtil.addAll( shortcuts, ActionManager.getInstance() .getAction(IdeActions.ACTION_FIND_NEXT) .getShortcutSet() .getShortcuts()); if (!editorSearchComponent.getFindModel().isMultiline()) { ContainerUtil.addAll( shortcuts, ActionManager.getInstance() .getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) .getShortcutSet() .getShortcuts()); shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), null)); } registerShortcutsForComponent(shortcuts, editorTextField.get()); }
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); }
public JComponent createActionsToolbar(ConsoleView console) { DefaultActionGroup group = new DefaultActionGroup(console.createConsoleActions()); ActionManager manager = ActionManager.getInstance(); ActionToolbar toolbar = manager.createActionToolbar(ActionPlaces.UNKNOWN, group, false); toolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY); return toolbar.getComponent(); }
public void initComponent() { log.info("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // System.out.println("Initializing WakaTime plugin v" + VERSION + " (https://wakatime.com/)"); // Set runtime constants IDE_NAME = PlatformUtils.getPlatformPrefix(); IDE_VERSION = ApplicationInfo.getInstance().getFullVersion(); if (!Dependencies.isCLIInstalled()) { log.info("Downloading and installing wakatime-cli ..."); Dependencies.installCLI(); } else if (Dependencies.isCLIOld()) { log.info("Upgrading wakatime-cli ..."); Dependencies.upgradeCLI(); } if (Dependencies.isPythonInstalled()) { WakaTime.DEBUG = WakaTime.isDebugEnabled(); if (WakaTime.DEBUG) { log.setLevel(Level.DEBUG); log.debug("Logging level set to DEBUG"); } log.debug("Python location: " + Dependencies.getPythonLocation()); log.debug("CLI location: " + Dependencies.getCLILocation()); // prompt for apiKey if it does not already exist if (ApiKey.getApiKey().equals("")) { Project project = ProjectManager.getInstance().getDefaultProject(); ApiKey apiKey = new ApiKey(project); apiKey.promptForApiKey(); } log.debug("Api Key: " + ApiKey.getApiKey()); // add WakaTime item to File menu ActionManager am = ActionManager.getInstance(); PluginMenu action = new PluginMenu(); am.registerAction("WakaTimeApiKey", action); DefaultActionGroup fileMenu = (DefaultActionGroup) am.getAction("FileMenu"); fileMenu.addSeparator(); fileMenu.add(action); // Setup message listeners MessageBus bus = ApplicationManager.getApplication().getMessageBus(); connection = bus.connect(); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new CustomSaveListener()); EditorFactory.getInstance() .getEventMulticaster() .addDocumentListener(new CustomDocumentListener()); log.debug("Finished initializing WakaTime plugin"); } else { Messages.showErrorDialog( "WakaTime requires Python to be installed.\nYou can install it from https://www.python.org/downloads/\nAfter installing Python, restart your IDE.", "Error"); } }
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); }
public static void clearActions(Project project) { ActionManager manager = ActionManager.getInstance(); if (manager != null) { for (String each : manager.getActionIds(getActionPrefix(project, null))) { manager.unregisterAction(each); } } }
public static ExternalSystemAction getOrRegisterAction( Project project, RunnerAndConfigurationSettings configurationSettings) { ActionManager manager = ActionManager.getInstance(); ExternalSystemRunConfigurationAction runConfigurationAction = new ExternalSystemRunConfigurationAction(project, configurationSettings); String id = runConfigurationAction.getId(); manager.unregisterAction(id); manager.registerAction(id, runConfigurationAction); return runConfigurationAction; }
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); Icon icon = null; if (userObject instanceof Group) { Group group = (Group) userObject; String name = group.getName(); setText(name != null ? name : group.getId()); icon = group.getIcon(); if (icon == null) { icon = getClosedIcon(); } } else if (userObject instanceof String) { String actionId = (String) userObject; AnAction action = ActionManager.getInstance().getAction(actionId); String name = action != null ? action.getTemplatePresentation().getText() : null; setText(!StringUtil.isEmptyOrSpaces(name) ? name : actionId); if (action != null) { Icon actionIcon = action.getTemplatePresentation().getIcon(); if (actionIcon != null) { icon = actionIcon; } } } else if (userObject instanceof Pair) { String actionId = (String) ((Pair) userObject).first; AnAction action = ActionManager.getInstance().getAction(actionId); setText(action != null ? action.getTemplatePresentation().getText() : actionId); icon = (Icon) ((Pair) userObject).second; } else if (userObject instanceof Separator) { setText("-------------"); } else if (userObject instanceof QuickList) { setText(((QuickList) userObject).getDisplayName()); icon = AllIcons.Actions.QuickList; } else { throw new IllegalArgumentException("unknown userObject: " + userObject); } setIcon(ActionsTree.getEvenIcon(icon)); if (sel) { setForeground(UIUtil.getTreeSelectionForeground()); } else { setForeground(UIUtil.getTreeForeground()); } } return this; }
private static void unregisterAction(String actionId, String groupId) { ActionManager actionManager = ActionManager.getInstance(); AnAction action = actionManager.getAction(actionId); if (action != null) { AnAction actionGroup = actionManager.getAction(groupId); if (actionGroup != null && actionGroup instanceof DefaultActionGroup) { ((DefaultActionGroup) actionGroup).remove(action); actionManager.unregisterAction(actionId); } } }
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); }
static { // enables rerun failed tests action in RubyMine final String rerunFailedTestsActionId = "RerunFailedTests"; ActionManager actionManager = ActionManager.getInstance(); AnAction rerunFailedTestsAction = actionManager.getAction(rerunFailedTestsActionId); if (rerunFailedTestsAction == null) { AbstractRerunFailedTestsAction action = new AbstractRerunFailedTestsAction(); actionManager.registerAction( rerunFailedTestsActionId, action, PluginId.getId("org.jetbrains.erlang")); action.getTemplatePresentation().setIcon(AllIcons.RunConfigurations.RerunFailedTests); } }
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); }
public static ExternalSystemAction getOrRegisterAction( Project project, String group, TaskData taskData) { ExternalSystemTaskAction action = new ExternalSystemTaskAction(project, group, taskData); ActionManager manager = ActionManager.getInstance(); AnAction anAction = manager.getAction(action.getId()); if (anAction instanceof ExternalSystemTaskAction && action.equals(anAction)) { return (ExternalSystemAction) anAction; } manager.unregisterAction(action.getId()); manager.registerAction(action.getId(), action); return action; }
@Override public void invokePopup(Component comp, int x, int y) { // Single right click ActionManager actionManager = ActionManager.getInstance(); ActionGroup actionGroup = (ActionGroup) actionManager.getAction(ImageEditorActions.GROUP_POPUP); ActionPopupMenu menu = actionManager.createActionPopupMenu(ImageEditorActions.ACTION_PLACE, actionGroup); JPopupMenu popupMenu = menu.getComponent(); popupMenu.pack(); popupMenu.show(comp, x, y); }
public void playBack(DataContext context) { AnAction action = ActionManager.getInstance().getAction(getActionId()); if (action == null) return; Presentation presentation = (Presentation) action.getTemplatePresentation().clone(); AnActionEvent event = new AnActionEvent( null, context, "MACRO_PLAYBACK", presentation, ActionManager.getInstance(), 0); action.beforeActionPerformedUpdate(event); if (!presentation.isEnabled()) { return; } action.actionPerformed(event); }
public static ActionToolbar createAddRemoveTreeAnnotationChooserToolbar( ListTable table, String chooserTitle) { final ClassFilter filter = new ClassFilter() { public boolean isAccepted(PsiClass psiClass) { return psiClass.isAnnotationType(); } }; final AnAction addAction = new TreeClassChooserAction(table, chooserTitle, filter); 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); }
public static ActionToolbar createAddRemoveTreeClassChooserToolbar( ListTable table, String chooserTitle, @NonNls String... ancestorClasses) { final ClassFilter filter; if (ancestorClasses.length == 0) { filter = ClassFilter.ALL; } else { filter = new SubclassFilter(ancestorClasses); } final AnAction addAction = new TreeClassChooserAction(table, chooserTitle, filter); 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); }
public static List<ActivateToolWindowAction> getToolWindowActions(@NotNull Project project) { ActionManager actionManager = ActionManager.getInstance(); ToolWindowManager manager = ToolWindowManager.getInstance(project); List<ActivateToolWindowAction> result = ContainerUtil.newArrayList(); for (String id : manager.getToolWindowIds()) { if (!manager.getToolWindow(id).isShowStripeButton()) continue; String actionId = ActivateToolWindowAction.getActionIdForToolWindow(id); AnAction action = actionManager.getAction(actionId); if (action instanceof ActivateToolWindowAction) { result.add((ActivateToolWindowAction) action); } } Collections.sort(result, COMPARATOR); return result; }
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); }
public static void performReferenceCopy(DataContext dataContext) { ActionManager actionManager = ActionManager.getInstance(); AnAction action = actionManager.getAction(IdeActions.ACTION_COPY_REFERENCE); AnActionEvent event = new AnActionEvent( null, dataContext, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.update(event); Assert.assertTrue(event.getPresentation().isEnabled()); action.actionPerformed(event); }
public static void clearActions(Project project, Collection<DataNode<TaskData>> taskData) { ActionManager actionManager = ActionManager.getInstance(); if (actionManager != null) { for (DataNode<TaskData> each : taskData) { for (String eachAction : actionManager.getActionIds( getActionPrefix(project, each.getData().getLinkedExternalProjectPath()))) { AnAction action = actionManager.getAction(eachAction); if (!(action instanceof ExternalSystemRunConfigurationAction)) { actionManager.unregisterAction(eachAction); } } } } }
private void handle(MouseEvent e) { if (UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED)) { if (!myPopup.isShowing()) { openProcessPopup(true); } else { hideProcessPopup(); } } else if (e.isPopupTrigger()) { ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("BackgroundTasks"); ActionManager.getInstance() .createActionPopupMenu(ActionPlaces.UNKNOWN, group) .getComponent() .show(e.getComponent(), e.getX(), e.getY()); } }
public String[] getNames(boolean checkBoxState) { final ArrayList<String> result = new ArrayList<String>(); collectActionIds( result, (ActionGroup) myActionManager.getActionOrStub(IdeActions.GROUP_MAIN_MENU)); if (checkBoxState) { final Set<String> ids = ((ActionManagerImpl) myActionManager).getActionIds(); for (String id : ids) { final AnAction anAction = myActionManager.getAction(id); if (!(anAction instanceof ActionGroup)) { result.add(id); } } } return ArrayUtil.toStringArray(result); }