List of usage examples for com.intellij.openapi.actionSystem DefaultActionGroup add
public final void add(@NotNull AnAction action)
From source file:altn8.ui.AbstractDataPanel.java
License:Apache License
/** * Init our Components/*from ww w . j a v a 2s . co m*/ */ private void initUIComponents() { DefaultActionGroup actionGroup = new DefaultActionGroup(); // buttonAdd actionGroup.add(new AnAction("Add", "Add new item...", AllIcons.General.Add) { @Override public void actionPerformed(AnActionEvent e) { doAdd(); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(enabled); } }); // buttonRemove actionGroup.add(new AnAction("Remove", "Remove item...", AllIcons.General.Remove) { @Override public void actionPerformed(AnActionEvent e) { doRemove(); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(enabled && table.getSelectedRow() >= 0); } }); // buttonEdit actionGroup.add(new AnAction("Edit", "Edit item...", AllIcons.Actions.Edit) { @Override public void actionPerformed(AnActionEvent e) { doEdit(); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(enabled && table.getSelectedRow() >= 0); } }); // buttonCopy actionGroup.add(new AnAction("Copy", "Copy item...", AllIcons.Actions.Copy) { @Override public void actionPerformed(AnActionEvent e) { doCopy(); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(enabled && table.getSelectedRow() >= 0); } }); actionGroup.addSeparator(); // buttonMoveUp actionGroup.add(new AnAction("Move Up", "Move item up...", AllIcons.Actions.MoveUp) { @Override public void actionPerformed(AnActionEvent e) { doMove(true); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(enabled && table.getSelectedRow() > 0); } }); // buttonMoveDown actionGroup.add(new AnAction("Move Down", "Move item down...", AllIcons.Actions.MoveDown) { @Override public void actionPerformed(AnActionEvent e) { doMove(false); } @Override public void update(AnActionEvent e) { int selectedRow = table.getSelectedRow(); e.getPresentation().setEnabled( enabled && selectedRow >= 0 && selectedRow < (table.getModel().getRowCount() - 1)); } }); toolbar.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true) .getComponent()); }
From source file:be.mavicon.intellij.ppimport.PPImportPlugin.java
License:Apache License
@Override public void initComponent() { ActionManager am = ActionManager.getInstance(); DefaultActionGroup group = (DefaultActionGroup) am.getAction("PPImportGroup"); group.removeAll();// w ww. j a va2s .c om List<AnAction> actions = new ArrayList<AnAction>(); if (state == null) { state = new PPConfiguration(); state.init(); } List<String> includeExtentions = getIncludeExtentions(state.getFileExtensions()); for (Target target : state.getTargets()) { AnAction action = new PPImportAction(target, includeExtentions, state.packMultipleFilesInJar); actions.add(action); am.unregisterAction(target.getProfile()); am.registerAction(target.getProfile(), action); group.add(action); } }
From source file:be.wimsymons.intellij.polopolyimport.PPImportPlugin.java
License:Apache License
private void registerActions() { ActionManager am = ActionManager.getInstance(); DefaultActionGroup group = (DefaultActionGroup) am.getAction(PLUGIN_GROUP_NAME); group.removeAll();//from w ww . j a va2 s .c o m for (Target target : state.getTargets()) { AnAction action = new PPImportAction(target, getIncludeExtensions(state.getFileExtensions()), state.getReplacements(), state.isPackMultipleFilesInJar()); am.unregisterAction(target.getProfile()); am.registerAction(target.getProfile(), action); group.add(action); } }
From source file:cn.fishy.plugin.idea.ponytail.Console.java
License:Apache License
private DefaultActionGroup createPopupActions(ActionManager actionManager, ClearLogAction action) { AnAction[] children = ((ActionGroup) actionManager.getAction(IdeActions.GROUP_CONSOLE_EDITOR_POPUP)) .getChildren(null);/*from w w w.ja v a2s. com*/ DefaultActionGroup group = new DefaultActionGroup(children); group.addSeparator(); group.add(action); return group; }
From source file:com.abelsky.idea.geekandpoke.ui.impl.ComicsPanelImpl.java
License:Apache License
@NotNull private JComponent createToolbar() { final ActionManager actionManager = ActionManager.getInstance(); @NotNull final DefaultActionGroup actionGroup = new DefaultActionGroup(); actionGroup.add(new RefreshAction()); actionGroup.add(new MoreAction()); final ActionToolbar actionToolbar = actionManager.createActionToolbar("ComicsPanelToolbar", actionGroup, true);/*from w w w .j a v a 2 s . c o m*/ final JComponent actionToolbarComponent = actionToolbar.getComponent(); @NotNull final JPanel actionsPanel = new JPanel(); actionToolbar.setReservePlaceAutoPopupIcon(false); actionsPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); actionsPanel.add(actionToolbarComponent); return actionsPanel; }
From source file:com.android.tools.adtui.workbench.AttachedToolWindow.java
License:Apache License
private void addGearPopupActions(@NotNull DefaultActionGroup group) { if (myContent != null) { List<AnAction> myExtraGearActions = myContent.getGearActions(); if (!myExtraGearActions.isEmpty()) { group.addAll(myExtraGearActions); group.addSeparator();/*w ww . j a v a2 s . co m*/ } } DefaultActionGroup attachedSide = new DefaultActionGroup("Attached Side", true); attachedSide.add(new TogglePropertyTypeAction(PropertyType.LEFT, "Left")); attachedSide.add(new ToggleOppositePropertyTypeAction(PropertyType.LEFT, "Right")); attachedSide.add(new SwapAction()); group.add(attachedSide); ActionManager manager = ActionManager.getInstance(); group.add(new ToggleOppositePropertyTypeAction(PropertyType.AUTO_HIDE, manager.getAction(InternalDecorator.TOGGLE_DOCK_MODE_ACTION_ID))); group.add(new TogglePropertyTypeAction(PropertyType.FLOATING, manager.getAction(InternalDecorator.TOGGLE_FLOATING_MODE_ACTION_ID))); group.add(new TogglePropertyTypeAction(PropertyType.SPLIT, manager.getAction(InternalDecorator.TOGGLE_SIDE_MODE_ACTION_ID))); }
From source file:com.android.tools.adtui.workbench.FloatingToolWindow.java
License:Apache License
private void setAdditionalGearPopupActions(@NotNull ToolWindowEx toolWindow) { DefaultActionGroup attachedSide = new DefaultActionGroup("Attached Side", true); attachedSide.add(new AttachToSideAction(Side.LEFT)); attachedSide.add(new AttachToSideAction(Side.RIGHT)); toolWindow.setAdditionalGearActions(new DefaultActionGroup(attachedSide)); }
From source file:com.android.tools.idea.configurations.ActivityMenuAction.java
License:Apache License
@Override @NotNull//from w w w. j a va 2 s . co m protected DefaultActionGroup createPopupActionGroup(JComponent button) { DefaultActionGroup group = new DefaultActionGroup("Activity", true); Configuration configuration = myRenderContext.getConfiguration(); if (configuration != null) { String activity = configuration.getActivity(); String currentFqcn = null; if (activity != null && !activity.isEmpty()) { int dotIndex = activity.indexOf('.'); if (dotIndex <= 0) { String pkg = ManifestInfo.get(myRenderContext.getModule()).getPackage(); activity = pkg + (dotIndex == -1 ? "." : "") + activity; currentFqcn = activity; } else { currentFqcn = activity; } String title = String.format("Open %1$s", activity.substring(activity.lastIndexOf('.') + 1)); group.add(new ShowActivityAction(myRenderContext, title, activity)); group.addSeparator(); } // List activities that reference the R.layout.<self> field here boolean haveSpecificActivities = false; VirtualFile file = configuration.getFile(); if (file != null) { String layoutName = ResourceHelper.getResourceName(file); Module module = myRenderContext.getModule(); Project project = module.getProject(); String pkg = ManifestInfo.get(module).getPackage(); String rLayoutFqcn = pkg + '.' + R_CLASS + '.' + ResourceType.LAYOUT.getName(); PsiClass layoutClass = JavaPsiFacade.getInstance(project).findClass(rLayoutFqcn, GlobalSearchScope.projectScope(project)); if (layoutClass != null) { PsiClass activityBase = JavaPsiFacade.getInstance(project).findClass(CLASS_ACTIVITY, GlobalSearchScope.allScope(project)); PsiField field = layoutClass.findFieldByName(layoutName, false); if (field != null && activityBase != null) { Iterable<PsiReference> allReferences = SearchUtils.findAllReferences(field, GlobalSearchScope.projectScope(project)); Iterator<PsiReference> iterator = allReferences.iterator(); if (iterator.hasNext()) { PsiReference reference = iterator.next(); PsiElement element = reference.getElement(); if (element != null) { PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof PsiJavaFile) { PsiJavaFile javaFile = (PsiJavaFile) containingFile; for (PsiClass cls : javaFile.getClasses()) { if (cls.isInheritor(activityBase, false)) { String fqcn = cls.getQualifiedName(); if (fqcn != null && !fqcn.equals(currentFqcn)) { String className = cls.getName(); String title = String.format("Associate with %1$s", className); group.add(new ChooseActivityAction(myRenderContext, title, fqcn)); haveSpecificActivities = true; } } } } } } } } } if (haveSpecificActivities) { group.addSeparator(); } group.add(new ChooseActivityAction(myRenderContext, "Associate with other Activity...", null)); } return group; }
From source file:com.android.tools.idea.configurations.ConfigurationMenuAction.java
License:Apache License
@Override @NotNull/*ww w . j a v a 2 s. c o m*/ protected DefaultActionGroup createPopupActionGroup(JComponent button) { DefaultActionGroup group = new DefaultActionGroup("Configuration", true); VirtualFile virtualFile = myRenderContext.getVirtualFile(); if (virtualFile != null) { Module module = myRenderContext.getModule(); if (module == null) { return group; } Project project = module.getProject(); List<VirtualFile> variations = ResourceHelper.getResourceVariations(virtualFile, true); if (variations.size() > 1) { for (VirtualFile file : variations) { String title = String.format("Switch to %1$s", file.getParent().getName()); group.add(new SwitchToVariationAction(title, project, file, virtualFile == file)); } group.addSeparator(); } boolean haveLandscape = false; boolean haveLarge = false; for (VirtualFile file : variations) { String name = file.getParent().getName(); if (name.startsWith(FD_RES_LAYOUT)) { FolderConfiguration config = FolderConfiguration.getConfigForFolder(name); if (config != null) { ScreenOrientationQualifier orientation = config.getScreenOrientationQualifier(); if (orientation != null && orientation.getValue() == ScreenOrientation.LANDSCAPE) { haveLandscape = true; if (haveLarge) { break; } } ScreenSizeQualifier size = config.getScreenSizeQualifier(); if (size != null && size.getValue() == ScreenSize.XLARGE) { haveLarge = true; if (haveLandscape) { break; } } } } } // Create actions for creating "common" versions of a layout (that don't exist), // e.g. Create Landscape Version, Create RTL Version, Create XLarge version // Do statistics on what is needed! if (!haveLandscape) { group.add(new CreateVariationAction(myRenderContext, "Create Landscape Variation", "layout-land")); } if (!haveLarge) { group.add(new CreateVariationAction(myRenderContext, "Create layout-xlarge Variation", "layout-xlarge")); //group.add(new CreateVariationAction(myRenderContext, "Create layout-sw600dp Variation...", "layout-sw600dp")); } group.add(new CreateVariationAction(myRenderContext, "Create Other...", null)); if (myRenderContext.supportsPreviews()) { addMultiConfigActions(group); } } return group; }
From source file:com.android.tools.idea.configurations.ConfigurationMenuAction.java
License:Apache License
private void addMultiConfigActions(DefaultActionGroup group) { VirtualFile file = myRenderContext.getVirtualFile(); if (file == null) { return;/*from w ww. j a v a 2 s.c o m*/ } Configuration configuration = myRenderContext.getConfiguration(); if (configuration == null) { return; } ConfigurationManager configurationManager = configuration.getConfigurationManager(); group.addSeparator(); // Configuration Previews if (SUPPORTS_MANUAL_PREVIEWS) { group.add(new PreviewAction(myRenderContext, "Add As Thumbnail...", ACTION_ADD, null, true)); RenderPreviewMode mode = RenderPreviewMode.getCurrent(); if (mode == RenderPreviewMode.CUSTOM) { RenderPreviewManager previewManager = myRenderContext.getPreviewManager(false); boolean hasPreviews = previewManager != null && previewManager.hasManualPreviews(); group.add(new PreviewAction(myRenderContext, "Delete All Thumbnails", ACTION_DELETE_ALL, null, hasPreviews)); } group.addSeparator(); } group.add(new PreviewAction(myRenderContext, "Preview Representative Sample", ACTION_PREVIEW_MODE, RenderPreviewMode.DEFAULT, true)); addScreenSizeAction(myRenderContext, group); boolean haveMultipleLocales = configurationManager.getLocales().size() > 1; addLocalePreviewAction(myRenderContext, group, haveMultipleLocales); boolean canPreviewIncluded = false; // TODO: Support included layouts //canPreviewIncluded = includedBy != null && !includedBy.isEmpty(); //if (!graphicalEditor.renderingSupports(Capability.EMBEDDED_LAYOUT)) { // canPreviewIncluded = false; //} group.add(new PreviewAction(myRenderContext, "Preview Included", ACTION_PREVIEW_MODE, RenderPreviewMode.INCLUDES, canPreviewIncluded)); List<VirtualFile> variations = ResourceHelper.getResourceVariations(file, true); group.add(new PreviewAction(myRenderContext, "Preview Layout Versions", ACTION_PREVIEW_MODE, RenderPreviewMode.VARIATIONS, variations.size() > 1)); if (SUPPORTS_MANUAL_PREVIEWS) { group.add(new PreviewAction(myRenderContext, "Manual Previews", ACTION_PREVIEW_MODE, RenderPreviewMode.CUSTOM, true)); } group.add(new PreviewAction(myRenderContext, "None", ACTION_PREVIEW_MODE, RenderPreviewMode.NONE, true)); // Debugging only group.addSeparator(); group.add(new AnAction("Toggle Layout Mode") { @Override public void actionPerformed(AnActionEvent e) { RenderPreviewManager.toggleLayoutMode(myRenderContext); } }); }