@NotNull @Override protected List<AnAction> createToolbarActions() { List<AnAction> group = new ArrayList<AnAction>(); group.add(new MyIgnorePolicySettingAction()); //group.add(new MyHighlightPolicySettingAction()); // TODO group.add(new MyToggleExpandByDefaultAction()); group.add(new MyToggleAutoScrollAction()); group.add(new MyEditorReadOnlyLockAction()); group.add(myEditorSettingsAction); group.add(Separator.getInstance()); group.add(new ShowLeftBasePartialDiffAction()); group.add(new ShowBaseRightPartialDiffAction()); group.add(new ShowLeftRightPartialDiffAction()); group.add(Separator.getInstance()); group.addAll(super.createToolbarActions()); return group; }
@NotNull @Override protected List<AnAction> createPopupActions() { List<AnAction> group = new ArrayList<AnAction>(); group.add(Separator.getInstance()); group.add(new MyIgnorePolicySettingAction().getPopupGroup()); //group.add(Separator.getInstance()); //group.add(new MyHighlightPolicySettingAction().getPopupGroup()); group.add(Separator.getInstance()); group.add(new MyToggleAutoScrollAction()); group.add(new MyToggleExpandByDefaultAction()); group.add(Separator.getInstance()); group.addAll(super.createPopupActions()); return group; }
@Override public void update(AnActionEvent e) { removeAll(); final List<ProjectGroup> groups = new ArrayList<ProjectGroup>(RecentProjectsManager.getInstance().getGroups()); Collections.sort(groups, new Comparator<ProjectGroup>() { @Override public int compare(ProjectGroup o1, ProjectGroup o2) { return StringUtil.naturalCompare(o1.getName(), o2.getName()); } }); for (ProjectGroup group : groups) { add(new MoveProjectToGroupAction(group)); } if (groups.size() > 0) { add(Separator.getInstance()); add(new RemoveSelectedProjectsFromGroupsAction()); } }
@Nullable public AnAction getComponentAction(){ if (myComponent instanceof Separator){ return Separator.getInstance(); } if (myComponent instanceof String){ return ActionManager.getInstance().getAction((String)myComponent); } if (myComponent instanceof Group){ final String id = ((Group)myComponent).getId(); if (id == null || id.length() == 0){ return ((Group)myComponent).constructActionGroup(true); } return ActionManager.getInstance().getAction(id); } return null; }
@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); }
@Override public void writeExternal(Element element) throws WriteExternalException { for (String s : myGroupPath) { Element path = new Element(PATH); path.setAttribute(VALUE, s); element.addContent(path); } if (myComponent instanceof String) { element.setAttribute(VALUE, (String)myComponent); element.setAttribute(IS_ACTION, Boolean.TRUE.toString()); } else if (myComponent instanceof Separator) { element.setAttribute(SEPARATOR, Boolean.TRUE.toString()); } else if (myComponent instanceof Group) { final String groupId = ((Group)myComponent).getId() != null && ((Group)myComponent).getId().length() != 0 ? ((Group)myComponent).getId() : ((Group)myComponent).getName(); element.setAttribute(VALUE, groupId != null ? groupId : ""); element.setAttribute(IS_GROUP, Boolean.TRUE.toString()); } element.setAttribute(ACTION_TYPE, Integer.toString(myActionType)); element.setAttribute(POSITION, Integer.toString(myAbsolutePosition)); DefaultJDOMExternalizer.writeExternal(this, element); }
protected void enableSetIconButton(ActionManager actionManager) { final TreePath selectionPath = myTree.getSelectionPath(); Object userObject = null; if (selectionPath != null) { userObject = ((DefaultMutableTreeNode)selectionPath.getLastPathComponent()).getUserObject(); if (userObject instanceof String) { final AnAction action = actionManager.getAction((String)userObject); if (action != null && action.getTemplatePresentation().getIcon() != null) { mySetIconButton.setEnabled(true); return; } } } mySetIconButton.setEnabled(myTextField.getText().length() != 0 && selectionPath != null && new DefaultMutableTreeNode(selectionPath).isLeaf() && !(userObject instanceof Separator)); }
@Nullable public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) { if (activeVcs == null || !getVcsName().equals(activeVcs.getName())) { return null; } final ActionManager manager = ActionManager.getInstance(); final List<AnAction> actions = new ArrayList<AnAction>(); actions.add(new Separator(activeVcs.getDisplayName())); add("CheckinProject", manager, actions); add("CheckinFiles", manager, actions); add("ChangesView.Revert", manager, actions); addSeparator(actions); add("Vcs.ShowTabbedFileHistory", manager, actions); add("Annotate", manager, actions); add("Compare.SameVersion", manager, actions); addSeparator(actions); addVcsSpecificActions(manager, actions); return actions; }
@Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { if (e == null) return AnAction.EMPTY_ARRAY; final Project project = e.getProject(); if (project == null) { return AnAction.EMPTY_ARRAY; } final List<String> availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); availableFavoritesLists.remove(FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext())); if (availableFavoritesLists.isEmpty()) { return new AnAction[]{new AddToNewFavoritesListAction()}; } AnAction[] actions = new AnAction[availableFavoritesLists.size() + 2]; int idx = 0; for (String favoritesList : availableFavoritesLists) { actions[idx++] = new AddToFavoritesAction(favoritesList); } actions[idx++] = Separator.getInstance(); actions[idx] = new AddToNewFavoritesListAction(); return actions; }
@Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { if (e == null) return AnAction.EMPTY_ARRAY; final Project project = e.getProject(); if (project == null) { return AnAction.EMPTY_ARRAY; } final List<String> listNames = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); final List<String> availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames(); availableFavoritesLists.remove(FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(e.getDataContext())); if (availableFavoritesLists.isEmpty()) { return new AnAction[]{new AddAllOpenFilesToNewFavoritesListAction()}; } AnAction[] actions = new AnAction[listNames.size() + 2]; int idx = 0; for (String favoritesList : listNames) { actions[idx++] = new AddAllOpenFilesToFavorites(favoritesList); } actions[idx++] = Separator.getInstance(); actions[idx] = new AddAllOpenFilesToNewFavoritesListAction(); return actions; }
@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; }
@Override protected void addVcsSpecificActions(@NotNull ActionManager manager, @NotNull List<AnAction> actions) { add("Git.Branches", manager, actions); add("Vcs.Push", manager, actions); add("Git.Stash", manager, actions); add("Git.Unstash", manager, actions); add("ChangesView.AddUnversioned", manager, actions); add("Git.ResolveConflicts", manager, actions); // Github addSeparator(actions); final AnAction githubRebase = manager.getAction("Github.Rebase"); if (githubRebase != null) { actions.add(new Separator(GitBundle.message("vcs.popup.git.github.section"))); actions.add(githubRebase); } }
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 void writeExternal(Element element) throws WriteExternalException { for (String s : myGroupPath) { Element path = new Element(PATH); path.setAttribute(VALUE, s); element.addContent(path); } if (myComponent instanceof String) { element.setAttribute(VALUE, (String)myComponent); element.setAttribute(IS_ACTION, Boolean.TRUE.toString()); } else if (myComponent instanceof Separator) { element.setAttribute(SEPARATOR, Boolean.TRUE.toString()); } else if (myComponent instanceof Group) { final String groupId = ((Group)myComponent).getId() != null && ((Group)myComponent).getId().length() != 0 ? ((Group)myComponent).getId() : ((Group)myComponent).getName(); element.setAttribute(VALUE, groupId != null ? groupId : ""); element.setAttribute(IS_GROUP, Boolean.TRUE.toString()); } element.setAttribute(ACTION_TYPE, Integer.toString(myActionType)); element.setAttribute(POSITION, Integer.toString(myAbsolutePosition)); DefaultJDOMExternalizer.writeExternal(this, element); }
protected void enableSetIconButton(ActionManager actionManager) { final TreePath selectionPath = myTree.getSelectionPath(); Object userObject = null; if (selectionPath != null) { userObject = ((DefaultMutableTreeNode)selectionPath.getLastPathComponent()).getUserObject(); if (userObject instanceof String) { final AnAction action = actionManager.getAction((String)userObject); if (action != null && action.getTemplatePresentation() != null && action.getTemplatePresentation().getIcon() != null) { mySetIconButton.setEnabled(true); return; } } } mySetIconButton.setEnabled(myTextField.getText().length() != 0 && selectionPath != null && new DefaultMutableTreeNode(selectionPath).isLeaf() && !(userObject instanceof Separator)); }
AnnotationPresentation(@NotNull final HighlightAnnotationsActions highlighting, @Nullable final AnnotationSourceSwitcher switcher, final EditorGutterComponentEx gutter, final List<AnnotationFieldGutter> gutters, final AnAction... actions) { myHighlighting = highlighting; mySwitcher = switcher; myActions = new ArrayList<AnAction>(); myActions.add(Separator.getInstance()); if (actions != null) { final List<AnAction> actionsList = Arrays.asList(actions); if (!actionsList.isEmpty()) { myActions.addAll(actionsList); myActions.add(new Separator()); } } myActions.addAll(myHighlighting.getList()); if (mySwitcher != null) { mySwitchAction = new SwitchAnnotationSourceAction(mySwitcher, gutter); myActions.add(mySwitchAction); } }
public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) { if (activeVcs == null || !HgVcs.VCS_NAME.equals(activeVcs.getName())) { return null; } final ActionManager manager = ActionManager.getInstance(); final List<AnAction> actions = new ArrayList<AnAction>(); actions.add(new Separator(activeVcs.getDisplayName())); actions.add(new Separator()); add("hg4idea.branches", manager, actions); add("hg4idea.pull", manager, actions); add("hg4idea.push", manager, actions); add("hg4idea.updateTo", manager, actions); return actions; }
@NotNull @Override public AnAction[] getChildren(final @Nullable AnActionEvent event) { return new AnAction[]{ new IntegerGroupAction(), new DecimalGroupAction(), new StringGroupAction(), new WordGroupAction(), new Separator(), new ArraySettingsAction() }; }
public void initComponent() { ActionManager am = ActionManager.getInstance(); // for debugging // Notifications.Bus.notify(new Notification(notificationGroupId, "Loading " + InstantPatchRemotePluginRegistration.shortName, "Loading started...", NotificationType.INFORMATION, NotificationListener.URL_OPENING_LISTENER)); try { final RemoteOperationRootGroup rootAction = new RemoteOperationRootGroup(pluginSettings); // Passes an instance of your custom TextBoxes class to the registerAction method of the ActionManager class. am.registerAction(RemoteOperationRootGroup.class.getName(), rootAction); final AnAction ProjectViewPopupMenuAction = am.getAction("ProjectViewPopupMenu"); if (!(ProjectViewPopupMenuAction instanceof DefaultActionGroup)) { System.err.print("ProjectViewPopupMenu is not instanceof DefaultActionGroup, but " + ProjectViewPopupMenuAction.getClass()); } final DefaultActionGroup ProjectViewPopupMenuGroup = (DefaultActionGroup) ProjectViewPopupMenuAction; ProjectViewPopupMenuGroup.add(new Separator(), Constraints.FIRST); ProjectViewPopupMenuGroup.add(rootAction, Constraints.FIRST); // for debugging // Notifications.Bus.notify(new Notification(notificationGroupId, "Loading " + InstantPatchRemotePluginRegistration.shortName, "Loading finished...", NotificationType.INFORMATION, NotificationListener.URL_OPENING_LISTENER)); } catch (Exception e) { System.err.println("Exception happened while registering root action group: " + e); Notifications.Bus.notify(new Notification(InstantPatchRemotePluginRegistration.notificationGroupId, "Loading " + InstantPatchRemotePluginRegistration.shortName, "Loading error: " + e.toString(), NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER)); } }
@NotNull @Override protected List<AnAction> createToolbarActions() { List<AnAction> group = new ArrayList<AnAction>(); group.add(new MyIgnorePolicySettingAction()); group.add(new MyHighlightPolicySettingAction()); group.add(new MyReadOnlyLockAction()); group.add(myEditorSettingsAction); group.add(Separator.getInstance()); group.addAll(super.createToolbarActions()); return group; }
@NotNull @Override protected List<AnAction> createPopupActions() { List<AnAction> group = new ArrayList<AnAction>(); group.add(Separator.getInstance()); group.add(new MyIgnorePolicySettingAction().getPopupGroup()); group.add(Separator.getInstance()); group.add(new MyHighlightPolicySettingAction().getPopupGroup()); group.add(Separator.getInstance()); group.addAll(super.createPopupActions()); return group; }
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { if (e == null) return EMPTY_ARRAY; final Project project = e.getProject(); if (project == null) return EMPTY_ARRAY; final Collection<String> filePaths = TestHistoryConfiguration.getInstance(project).getFiles(); final File testHistoryRoot = TestStateStorage.getTestHistoryRoot(project); final List<File> fileNames = ContainerUtil.map(filePaths, new Function<String, File>() { @Override public File fun(String fileName) { return new File(testHistoryRoot, fileName); } }); Collections.sort(fileNames, new Comparator<File>() { @Override public int compare(File f1, File f2) { return f1.lastModified() > f2.lastModified() ? -1 : 1; } }); final int historySize = fileNames.size(); final AnAction[] actions = new AnAction[historySize + 2]; for (int i = 0; i < historySize; i++) { actions[i] = new ImportTestsFromHistoryAction(myProperties, project, fileNames.get(i).getName()); } actions[historySize] = Separator.getInstance(); actions[historySize + 1] = new ImportTestsFromFileAction(myProperties); return actions; }
public AnnotateActionGroup(List<AnnotationFieldGutter> gutters, EditorGutterComponentEx gutterComponent) { super("View", true); final List<AnAction> actions = new ArrayList<AnAction>(); for (AnnotationFieldGutter g : gutters) { if (g.getID() != null) { actions.add(new ShowHideAspectAction(g, gutterComponent)); } } actions.add(Separator.getInstance()); actions.add(new ShowAnnotationColorsAction(gutterComponent)); actions.add(new ShowShortenNames(gutterComponent)); myActions = actions.toArray(new AnAction[actions.size()]); }
private static void addActionsFromExtensions(@NotNull AnnotationPresentation presentation, @NotNull FileAnnotation fileAnnotation) { AnnotationGutterActionProvider[] extensions = AnnotationGutterActionProvider.EP_NAME.getExtensions(); if (extensions.length > 0) { presentation.addAction(new Separator()); } for (AnnotationGutterActionProvider provider : extensions) { presentation.addAction(provider.createAction(fileAnnotation)); } }
@Override public void addContainerSelectionActions(DesignerEditorPanel designer, DefaultActionGroup actionGroup, List<? extends RadViewComponent> selection) { // Add render mode action if (myContainer != null && (myContainer.isBackground() || myContainer.getParent() != null && myContainer.getParent().isBackground())) { actionGroup.add(new ToggleRenderModeAction(designer)); actionGroup.add(new Separator()); } super.addContainerSelectionActions(designer, actionGroup, selection); }
@Override public void appendAdditionalActions(DefaultActionGroup actionGroup, JComponent parent, TestConsoleProperties target) { super.appendAdditionalActions(actionGroup, parent, target); actionGroup.add(createIncludeNonStartedInRerun(target)); actionGroup.add(Separator.getInstance()); actionGroup.add(createHideSuccessfulConfig(target)); }
public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) { if (activeVcs == null || !GitVcs.NAME.equals(activeVcs.getName())) { return null; } final ActionManager manager = ActionManager.getInstance(); final List<AnAction> actions = new ArrayList<AnAction>(); actions.add(new Separator(activeVcs.getDisplayName())); add("CheckinProject", manager, actions); add("CheckinFiles", manager, actions); add("ChangesView.Revert", manager, actions); addSeparator(actions); add("Vcs.ShowTabbedFileHistory", manager, actions); add("Annotate", manager, actions); add("Compare.SameVersion", manager, actions); addSeparator(actions); add("Git.Branches", manager, actions); add("Git.Push", manager, actions); add("Git.Stash", manager, actions); add("Git.Unstash", manager, actions); add("ChangesView.AddUnversioned", manager, actions); add("Git.ResolveConflicts", manager, actions); // Github addSeparator(actions); final AnAction githubRebase = manager.getAction("Github.Rebase"); if (githubRebase != null) { actions.add(new Separator(GitBundle.message("vcs.popup.git.github.section"))); actions.add(githubRebase); } return actions; }
@Override public void addContainerSelectionActions(CordovaDesignerEditorPanel designer, DefaultActionGroup actionGroup, List<? extends RadViewComponent> selection) { // Add render mode action if (myContainer != null && (myContainer.isBackground() || myContainer.getParent() != null && myContainer.getParent().isBackground())) { actionGroup.add(new ToggleRenderModeAction(designer)); actionGroup.add(new Separator()); } super.addContainerSelectionActions(designer, actionGroup, selection); }
public ParametersActionGroup(GuardPopupController controller, PsiGuardTarget parent) { super(controller, parent); this.parameters = parent.getParameters().toList(); add(asPopup(new ElementActionGroup(controller, parent), true)); if ( !parameters.isEmpty() ) { add(new Separator("Parameters")); for( PsiGuardTarget parameter : parameters ) { add(asPopup(new ElementActionGroup(controller, parameter), true)); } } getTemplatePresentation().setText(((PsiNamedElement)parent.getElement()).getName()); getTemplatePresentation().setIcon(parent.getElement().getIcon(0)); }
private void addChildren(@NotNull ActionGroup anAction) { AnAction[] children = anAction.getChildren(null); for (AnAction child : children) { if (child instanceof ActionGroup) { addChildren(((ActionGroup)child)); } else if (child instanceof Separator) { } else { createActionLabel(child); } } }
protected static void addSeparator(@NotNull final List<AnAction> actions) { actions.add(new Separator()); }
@Nullable @Override public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { List<RunLineMarkerContributor> contributors = RunLineMarkerContributor.EXTENSION.allForLanguage(element.getLanguage()); final DefaultActionGroup actionGroup = new DefaultActionGroup(); Icon icon = null; for (RunLineMarkerContributor contributor : contributors) { RunLineMarkerContributor.Info info = contributor.getInfo(element); if (info == null) { continue; } if (icon == null) { icon = info.icon; } for (AnAction action : info.actions) { actionGroup.add(new LineMarkerActionWrapper(element, action)); } actionGroup.add(new Separator()); } if (icon == null) return null; return new LineMarkerInfo<PsiElement>(element, element.getTextOffset(), icon, Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.CENTER) { @Nullable @Override public GutterIconRenderer createGutterRenderer() { return new LineMarkerGutterIconRenderer<PsiElement>(this) { @Override public AnAction getClickAction() { return null; } @Override public boolean isNavigateAction() { return true; } @Nullable @Override public ActionGroup getPopupMenuActions() { return actionGroup; } }; } }; }
/** * @param addClearListItem - used for detecting whether the "Clear List" action should be added * to the end of the returned list of actions * @return */ public AnAction[] getRecentProjectsActions(boolean addClearListItem) { validateRecentProjects(); final Set<String> openedPaths = ContainerUtil.newHashSet(); for (Project openProject : ProjectManager.getInstance().getOpenProjects()) { ContainerUtil.addIfNotNull(openedPaths, getProjectPath(openProject)); } final LinkedHashSet<String> paths; synchronized (myStateLock) { paths = ContainerUtil.newLinkedHashSet(myState.recentPaths); } paths.remove(null); paths.removeAll(openedPaths); ArrayList<AnAction> actions = new ArrayList<AnAction>(); Set<String> duplicates = getDuplicateProjectNames(openedPaths, paths); for (final String path : paths) { final String projectName = getProjectName(path); String displayName; synchronized (myStateLock) { displayName = myState.names.get(path); } if (StringUtil.isEmptyOrSpaces(displayName)) { displayName = duplicates.contains(path) ? path : projectName; } // It's better don't to remove non-existent projects. Sometimes projects stored // on USB-sticks or flash-cards, and it will be nice to have them in the list // when USB device or SD-card is mounted if (new File(path).exists()) { actions.add(new ReopenProjectAction(path, projectName, displayName)); } } if (actions.isEmpty()) { return AnAction.EMPTY_ARRAY; } ArrayList<AnAction> list = new ArrayList<AnAction>(); for (AnAction action : actions) { list.add(action); } if (addClearListItem) { AnAction clearListAction = new AnAction(IdeBundle.message("action.clear.list")) { public void actionPerformed(AnActionEvent e) { final int rc = Messages.showOkCancelDialog(e.getData(PlatformDataKeys.PROJECT), "Would you like to clear the list of recent projects?", "Clear Recent Projects List", Messages.getQuestionIcon()); if (rc == 0) { synchronized (myStateLock) { myState.recentPaths.clear(); } WelcomeFrame.clearRecents(); } } }; list.add(Separator.getInstance()); list.add(clearListAction); } return list.toArray(new AnAction[list.size()]); }
private static void addSeparator(@NotNull final List<AnAction> actions) { actions.add(new Separator()); }