List of usage examples for com.intellij.openapi.actionSystem DefaultActionGroup addSeparator
public final void addSeparator()
From source file:altn8.ui.AbstractDataPanel.java
License:Apache License
/** * Init our Components// w w w . jav a 2s. c om */ 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: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 ww w. j a v a 2 s. c o m DefaultActionGroup group = new DefaultActionGroup(children); group.addSeparator(); group.add(action); return group; }
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(); }//from ww w .java2 s . c om } 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.idea.configurations.ActivityMenuAction.java
License:Apache License
@Override @NotNull// w w w . j a v a 2s . com 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//from w w w .jav 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 w w. j av a 2 s .co 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); } }); }
From source file:com.android.tools.idea.configurations.ConfigurationToolBar.java
License:Apache License
public static DefaultActionGroup createActions(RenderContext configurationHolder) { DefaultActionGroup group = new DefaultActionGroup(); ConfigurationMenuAction configAction = new ConfigurationMenuAction(configurationHolder); group.add(configAction);//w w w.j a va2 s . c o m group.addSeparator(); DeviceMenuAction deviceAction = new DeviceMenuAction(configurationHolder); group.add(deviceAction); group.addSeparator(); OrientationMenuAction orientationAction = new OrientationMenuAction(configurationHolder); group.add(orientationAction); group.addSeparator(); ThemeMenuAction themeAction = new ThemeMenuAction(configurationHolder); group.add(themeAction); group.addSeparator(); ActivityMenuAction activityAction = new ActivityMenuAction(configurationHolder); group.add(activityAction); group.addSeparator(); LocaleMenuAction localeAction = new LocaleMenuAction(configurationHolder); group.add(localeAction); group.addSeparator(); TargetMenuAction targetMenuAction = new TargetMenuAction(configurationHolder); group.add(targetMenuAction); return group; }
From source file:com.android.tools.idea.configurations.DeviceMenuAction.java
License:Apache License
@Override @NotNull//from w w w . j av a 2 s .c o m protected DefaultActionGroup createPopupActionGroup(JComponent button) { DefaultActionGroup group = new DefaultActionGroup(null, true); Configuration configuration = myRenderContext.getConfiguration(); if (configuration == null) { return group; } Device current = configuration.getDevice(); ConfigurationManager configurationManager = configuration.getConfigurationManager(); List<Device> deviceList = configurationManager.getDevices(); AndroidFacet facet = AndroidFacet.getInstance(configurationManager.getModule()); assert facet != null; final AvdManager avdManager = facet.getAvdManagerSilently(); if (avdManager != null) { boolean separatorNeeded = false; for (AvdInfo avd : avdManager.getValidAvds()) { Device device = configurationManager.createDeviceForAvd(avd); if (device != null) { String avdName = avd.getName(); boolean selected = current != null && current.getName().equals(avdName); group.add(new SetDeviceAction(myRenderContext, avdName, device, selected)); separatorNeeded = true; } } if (separatorNeeded) { group.addSeparator(); } } // Group the devices by manufacturer, then put them in the menu. // If we don't have anything but Nexus devices, group them together rather than // make many manufacturer submenus. boolean haveNexus = false; if (!deviceList.isEmpty()) { Map<String, List<Device>> manufacturers = new TreeMap<String, List<Device>>(); for (Device device : deviceList) { List<Device> devices; if (isNexus(device)) { haveNexus = true; } if (manufacturers.containsKey(device.getManufacturer())) { devices = manufacturers.get(device.getManufacturer()); } else { devices = new ArrayList<Device>(); manufacturers.put(device.getManufacturer(), devices); } devices.add(device); } List<Device> nexus = new ArrayList<Device>(); List<Device> generic = new ArrayList<Device>(); if (haveNexus) { // Nexus for (List<Device> devices : manufacturers.values()) { for (Device device : devices) { if (isNexus(device)) { if (device.getManufacturer().equals(MANUFACTURER_GENERIC)) { generic.add(device); } else { nexus.add(device); } } else { generic.add(device); } } } } if (!nexus.isEmpty()) { sortNexusList(nexus); for (final Device device : nexus) { group.add( new SetDeviceAction(myRenderContext, getNexusLabel(device), device, current == device)); } group.addSeparator(); } // Generate the generic menu. Collections.reverse(generic); for (final Device device : generic) { group.add(new SetDeviceAction(myRenderContext, getGenericLabel(device), device, current == device)); } } group.addSeparator(); group.add(new RunAndroidAvdManagerAction("Add Device Definition...")); group.addSeparator(); if (RenderPreviewMode.getCurrent() != RenderPreviewMode.SCREENS) { ConfigurationMenuAction.addScreenSizeAction(myRenderContext, group); } else { ConfigurationMenuAction.addRemovePreviewsAction(myRenderContext, group); } return group; }
From source file:com.android.tools.idea.configurations.LocaleMenuAction.java
License:Apache License
@Override @NotNull/*from w w w. jav a 2 s . c o m*/ protected DefaultActionGroup createPopupActionGroup(JComponent button) { DefaultActionGroup group = new DefaultActionGroup(null, true); // TODO: Offer submenus, lazily populated, which offer languages either by code or by name. // However, this doesn't currently work for the JBPopup dialog we're using as part // of the combo action (and using the JBPopup dialog rather than a Swing menu has some // other advantages: fitting in with the overall IDE look and feel (e.g. dark colors), // allowing typing to filter, etc. List<Locale> locales = getRelevantLocales(); if (locales.size() > 0) { group.add(new SetLocaleAction(myRenderContext, getLocaleLabel(Locale.ANY, false), Locale.ANY)); group.addSeparator(); Collections.sort(locales, Locale.LANGUAGE_CODE_COMPARATOR); for (Locale locale : locales) { String title = getLocaleLabel(locale, false); group.add(new SetLocaleAction(myRenderContext, title, locale)); } group.addSeparator(); } group.add(new AddTranslationAction()); if (locales.size() > 1) { group.addSeparator(); if (RenderPreviewMode.getCurrent() != RenderPreviewMode.LOCALES) { ConfigurationMenuAction.addLocalePreviewAction(myRenderContext, group, true); } else { ConfigurationMenuAction.addRemovePreviewsAction(myRenderContext, group); } } return group; }
From source file:com.android.tools.idea.configurations.OrientationMenuAction.java
License:Apache License
@Override @NotNull// ww w. j av a2 s . c o m protected DefaultActionGroup createPopupActionGroup(JComponent button) { DefaultActionGroup group = new DefaultActionGroup(null, true); Configuration configuration = myRenderContext.getConfiguration(); if (configuration != null) { Device device = configuration.getDevice(); State current = configuration.getDeviceState(); if (device != null) { List<State> states = device.getAllStates(); if (states.size() > 1 && current != null) { State flip = configuration.getNextDeviceState(current); String flipName = flip != null ? flip.getName() : current.getName(); String title = String.format("Switch to %1$s", flipName); group.add(new SetDeviceStateAction(myRenderContext, title, flip == null ? current : flip, false, true)); group.addSeparator(); } for (State config : states) { group.add(new SetDeviceStateAction(myRenderContext, config.getName(), config, config == current, false)); } group.addSeparator(); } group.addSeparator(); DefaultActionGroup uiModeGroup = new DefaultActionGroup("_UI Mode", true); UiMode currentUiMode = configuration.getUiMode(); for (UiMode uiMode : UiMode.values()) { String title = uiMode.getShortDisplayValue(); boolean checked = uiMode == currentUiMode; uiModeGroup.add(new SetUiModeAction(myRenderContext, title, uiMode, checked)); } group.add(uiModeGroup); group.addSeparator(); DefaultActionGroup nightModeGroup = new DefaultActionGroup("_Night Mode", true); NightMode currentNightMode = configuration.getNightMode(); for (NightMode nightMode : NightMode.values()) { String title = nightMode.getShortDisplayValue(); boolean checked = nightMode == currentNightMode; nightModeGroup.add(new SetNightModeAction(myRenderContext, title, nightMode, checked)); } group.add(nightModeGroup); } return group; }