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);
   }
 }
Beispiel #2
0
 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();
     }
   }
 }
  private AnAction createInterruptAction() {
    AnAction anAction =
        new AnAction() {
          @Override
          public void actionPerformed(final AnActionEvent e) {
            if (myPydevConsoleCommunication.isExecuting()) {
              getConsoleView().print("^C", ProcessOutputTypes.SYSTEM);
            }
            myPydevConsoleCommunication.interrupt();
          }

          @Override
          public void update(final AnActionEvent e) {
            EditorEx consoleEditor = getConsoleView().getConsole().getConsoleEditor();
            boolean enabled =
                IJSwingUtilities.hasFocus(consoleEditor.getComponent())
                    && !consoleEditor.getSelectionModel().hasSelection();
            e.getPresentation().setEnabled(enabled);
          }
        };
    anAction.registerCustomShortcutSet(
        KeyEvent.VK_C,
        InputEvent.CTRL_MASK,
        getConsoleView().getConsole().getConsoleEditor().getComponent());
    anAction.getTemplatePresentation().setVisible(false);
    return anAction;
  }
    private void calcMaxIconSize(final ActionGroup actionGroup) {
      AnAction[] actions = actionGroup.getChildren(createActionEvent(actionGroup));
      for (AnAction action : actions) {
        if (action == null) continue;
        if (action instanceof ActionGroup) {
          final ActionGroup group = (ActionGroup) action;
          if (!group.isPopup()) {
            calcMaxIconSize(group);
            continue;
          }
        }

        Icon icon = action.getTemplatePresentation().getIcon();
        if (icon == null && action instanceof Toggleable) icon = PlatformIcons.CHECK_ICON;
        if (icon != null) {
          final int width = icon.getIconWidth();
          final int height = icon.getIconHeight();
          if (myMaxIconWidth < width) {
            myMaxIconWidth = width;
          }
          if (myMaxIconHeight < height) {
            myMaxIconHeight = height;
          }
        }
      }
    }
  private AnAction createBackspaceHandlingAction() {
    final AnAction upAction =
        new AnAction() {
          @Override
          public void actionPerformed(final AnActionEvent e) {
            new WriteCommandAction(
                getLanguageConsole().getProject(), getLanguageConsole().getFile()) {
              @Override
              protected void run(@NotNull final Result result) throws Throwable {
                String text = getLanguageConsole().getEditorDocument().getText();
                String newText =
                    text.substring(
                        0, text.length() - myConsoleExecuteActionHandler.getPythonIndent());
                getLanguageConsole().getEditorDocument().setText(newText);
                getLanguageConsole()
                    .getConsoleEditor()
                    .getCaretModel()
                    .moveToOffset(newText.length());
              }
            }.execute();
          }

          @Override
          public void update(final AnActionEvent e) {
            e.getPresentation()
                .setEnabled(
                    myConsoleExecuteActionHandler.getCurrentIndentSize()
                            >= myConsoleExecuteActionHandler.getPythonIndent()
                        && isIndentSubstring(getLanguageConsole().getEditorDocument().getText()));
          }
        };
    upAction.registerCustomShortcutSet(KeyEvent.VK_BACK_SPACE, 0, null);
    upAction.getTemplatePresentation().setVisible(false);
    return upAction;
  }
  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 registerActionShortcuts(
     final List<AnAction> actions, final JComponent component) {
   for (AnAction action : actions) {
     if (action.getShortcutSet() != null) {
       action.registerCustomShortcutSet(action.getShortcutSet(), component);
     }
   }
 }
  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;
  }
 private void registerCustomShortcuts(DirDiffToolbarActions actions, JComponent component) {
   for (AnAction action : actions.getChildren(null)) {
     if (action instanceof ShortcutProvider) {
       final ShortcutSet shortcut = ((ShortcutProvider) action).getShortcut();
       if (shortcut != null) {
         action.registerCustomShortcutSet(shortcut, component);
       }
     }
   }
 }
 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);
 }
Beispiel #11
0
 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 boolean matches(@NotNull final String name, @NotNull final String pattern) {
   final AnAction anAction = myActionManager.getAction(name);
   if (!(anAction instanceof ActionGroup)) {
     final Presentation presentation = anAction.getTemplatePresentation();
     final String text = presentation.getText();
     final String description = presentation.getDescription();
     final Pattern compiledPattern = getPattern(pattern);
     if ((text != null && myMatcher.matches(text, compiledPattern))
         || (description != null && myMatcher.matches(description, compiledPattern))) {
       return true;
     }
   }
   return false;
 }
 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);
 }
  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);
  }
    private JComponent createActionPanel() {
      JPanel actions = new NonOpaquePanel();
      actions.setBorder(JBUI.Borders.emptyLeft(10));
      actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
      ActionManager actionManager = ActionManager.getInstance();
      ActionGroup quickStart =
          (ActionGroup) actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
      DefaultActionGroup group = new DefaultActionGroup();
      collectAllActions(group, quickStart);

      for (AnAction action : group.getChildren(null)) {
        JPanel button = new JPanel(new BorderLayout());
        button.setOpaque(false);
        button.setBorder(JBUI.Borders.empty(8, 20));
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                action,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        action.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isVisible()) {
          String text = presentation.getText();
          if (text != null && text.endsWith("...")) {
            text = text.substring(0, text.length() - 3);
          }
          Icon icon = presentation.getIcon();
          if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) {
            icon = JBUI.emptyIcon(16);
          }
          action = wrapGroups(action);
          ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action));
          link.setPaintUnderline(false);
          link.setNormalColor(getLinkNormalColor());
          button.add(link);
          if (action instanceof WelcomePopupAction) {
            button.add(createArrow(link), BorderLayout.EAST);
          }
          installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true);
          actions.add(button);
        }
      }

      WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel();
      panel.actions.add(actions);
      return panel.root;
    }
      private AnAction patch(final AnAction child) {
        if (child instanceof ActionGroup) {
          return new IconsFreeActionGroup((ActionGroup) child);
        }

        Presentation presentation = child.getTemplatePresentation();
        return new AnAction(presentation.getText(), presentation.getDescription(), null) {
          @Override
          public void actionPerformed(@NotNull AnActionEvent e) {
            child.actionPerformed(e);
            UsageTrigger.trigger("welcome.screen." + e.getActionManager().getId(child));
          }

          @Override
          public void update(@NotNull AnActionEvent e) {
            child.update(e);
            e.getPresentation().setIcon(null);
          }

          @Override
          public boolean isDumbAware() {
            return child.isDumbAware();
          }
        };
      }
Beispiel #17
0
  public void update(AnActionEvent e) {
    super.update(e);

    final Project project = e.getData(DataKeys.PROJECT);
    final VirtualFile file = e.getData(DataKeys.VIRTUAL_FILE);

    boolean visible =
        project != null
            && file != null
            && !file.isDirectory()
            && file.getFileType() == CppSupportLoader.CPP_FILETYPE
            && !Communicator.isHeaderFile(file);
    boolean enabled = visible;

    if (!visible) {
      visible = ActionPlaces.MAIN_MENU.equals(e.getPlace());
    }

    e.getPresentation().setEnabled(enabled);
    e.getPresentation().setVisible(visible);

    if (visible) {
      final String s =
          "Do c&ompile for " + (file != null ? file.getName() : "selected c/c++ fileToCompile");
      e.getPresentation().setText(s);
      e.getPresentation().setDescription(s);
    }
  }
Beispiel #18
0
  public final void update(final AnActionEvent e) {
    super.update(e);

    ActionPlace place = e.getData(MPSDataKeys.PLACE);

    if (e.getInputEvent() instanceof KeyEvent) {
      if (!getPlaces().contains(null)) {
        if (!getPlaces().contains(place)) {
          disable(e.getPresentation());
          return;
        }
      }
    }

    // TODO rewrite! do not start read action in EDT directly (to avoid UI freeze)
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                if (myDisableOnNoProject && e.getData(PlatformDataKeys.PROJECT) == null) {
                  disable(e.getPresentation());
                  return;
                }
                THashMap<String, Object> params = new THashMap<String, Object>();
                if (!collectActionData(e, params)) {
                  disable(e.getPresentation());
                  return;
                }
                doUpdate(e, params);
              }
            });
  }
 public static void executeAction(
     @NotNull Editor editor, @NotNull String actionId, boolean assertActionIsEnabled) {
   ActionManager actionManager = ActionManager.getInstance();
   AnAction action = actionManager.getAction(actionId);
   assertNotNull(action);
   DataContext dataContext = createEditorContext(editor);
   AnActionEvent event =
       new AnActionEvent(
           null, dataContext, "", action.getTemplatePresentation(), actionManager, 0);
   action.beforeActionPerformedUpdate(event);
   if (!event.getPresentation().isEnabled()) {
     assertFalse("Action " + actionId + " is disabled", assertActionIsEnabled);
     return;
   }
   action.actionPerformed(event);
 }
 private Presentation getPresentation(@NotNull AnAction action) {
   Presentation presentation = myAction2presentation.get(action);
   if (presentation == null) {
     presentation = action.getTemplatePresentation().clone();
     myAction2presentation.put(action, presentation);
   }
   return presentation;
 }
 @Override
 public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
   Project project = e.getProject();
   if (project != null) {
     getEditor(e.getDataContext(), project, false); // ensure documents are committed
   }
   super.beforeActionPerformedUpdate(e);
 }
 private ArrayList<Pair<AnAction, KeyStroke>> getSecondKeystrokeActions() {
   ArrayList<Pair<AnAction, KeyStroke>> secondKeyStrokes =
       new ArrayList<Pair<AnAction, KeyStroke>>();
   for (AnAction action : myContext.getActions()) {
     Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
     for (Shortcut shortcut : shortcuts) {
       if (shortcut instanceof KeyboardShortcut) {
         KeyboardShortcut keyShortcut = (KeyboardShortcut) shortcut;
         if (keyShortcut.getFirstKeyStroke().equals(myFirstKeyStroke)) {
           secondKeyStrokes.add(
               new Pair<AnAction, KeyStroke>(action, keyShortcut.getSecondKeyStroke()));
         }
       }
     }
   }
   return secondKeyStrokes;
 }
 private void performEditAction() {
   final AnAction action = getEditAction();
   if (action != null) {
     final int row = myInjectionsTable.getSelectedRow();
     action.actionPerformed(
         new AnActionEvent(
             null,
             DataManager.getInstance().getDataContext(myInjectionsTable),
             ActionPlaces.UNKNOWN,
             new Presentation(""),
             ActionManager.getInstance(),
             0));
     myInjectionsTable.getListTableModel().fireTableDataChanged();
     myInjectionsTable.getSelectionModel().setSelectionInterval(row, row);
     updateCountLabel();
   }
 }
Beispiel #24
0
 public MyEvaluationPanel(final Project project) {
   super(project, (DebuggerManagerEx.getInstanceEx(project)).getContextManager());
   final WatchDebuggerTree watchTree = getWatchTree();
   final AnAction setValueAction =
       ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
   setValueAction.registerCustomShortcutSet(
       new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), watchTree);
   registerDisposable(
       new Disposable() {
         public void dispose() {
           setValueAction.unregisterCustomShortcutSet(watchTree);
         }
       });
   setUpdateEnabled(true);
   getTree().getEmptyText().setText(XDebuggerBundle.message("debugger.no.results"));
   new ValueNodeDnD(myTree, project);
 }
    private AnAction wrapGroups(AnAction action) {
      if (action instanceof ActionGroup && ((ActionGroup) action).isPopup()) {
        final Pair<JPanel, JBList> panel =
            createActionGroupPanel(
                (ActionGroup) action,
                mySlidingPanel,
                new Runnable() {
                  @Override
                  public void run() {
                    goBack();
                  }
                });
        final Runnable onDone =
            new Runnable() {
              @Override
              public void run() {
                final JBList list = panel.second;
                ScrollingUtil.ensureSelectionExists(list);
                final ListSelectionListener[] listeners =
                    ((DefaultListSelectionModel) list.getSelectionModel())
                        .getListeners(ListSelectionListener.class);

                // avoid component cashing. This helps in case of LaF change
                for (ListSelectionListener listener : listeners) {
                  listener.valueChanged(
                      new ListSelectionEvent(
                          list, list.getSelectedIndex(), list.getSelectedIndex(), true));
                }
                list.requestFocus();
              }
            };
        final String name = action.getClass().getName();
        mySlidingPanel.add(name, panel.first);
        final Presentation p = action.getTemplatePresentation();
        return new DumbAwareAction(p.getText(), p.getDescription(), p.getIcon()) {
          @Override
          public void actionPerformed(@NotNull AnActionEvent e) {
            mySlidingPanel
                .getLayout()
                .swipe(mySlidingPanel, name, JBCardLayout.SwipeDirection.FORWARD, onDone);
          }
        };
      }
      return action;
    }
  private AnAction createConsoleStoppingAction(final AnAction generalStopAction) {
    final AnAction stopAction =
        new DumbAwareAction() {
          @Override
          public void update(AnActionEvent e) {
            generalStopAction.update(e);
          }

          @Override
          public void actionPerformed(AnActionEvent e) {
            e = stopConsole(e);

            generalStopAction.actionPerformed(e);
          }
        };
    stopAction.copyFrom(generalStopAction);
    return stopAction;
  }
 @NotNull
 @Override
 protected DefaultActionGroup createToolbarActions() {
   DefaultActionGroup defaultGroup = super.createToolbarActions();
   if (myDeletableFiles) {
     AnAction deleteAction =
         new DeleteUnversionedFilesAction() {
           @Override
           public void actionPerformed(AnActionEvent e) {
             super.actionPerformed(e);
             myFileList.refresh();
           }
         };
     defaultGroup.add(deleteAction);
     deleteAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), this.getFileList());
   }
   return defaultGroup;
 }
    private JComponent createSettingsAndDocs() {
      JPanel panel = new NonOpaquePanel(new BorderLayout());
      NonOpaquePanel toolbar = new NonOpaquePanel();
      AnAction register = ActionManager.getInstance().getAction("Register");
      boolean registeredVisible = false;
      if (register != null) {
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                register,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        register.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isEnabled()) {
          ActionLink registerLink = new ActionLink("Register", register);
          registerLink.setNormalColor(getLinkNormalColor());
          NonOpaquePanel button = new NonOpaquePanel(new BorderLayout());
          button.setBorder(JBUI.Borders.empty(4, 10));
          button.add(registerLink);
          installFocusable(button, register, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, true);
          NonOpaquePanel wrap = new NonOpaquePanel();
          wrap.setBorder(JBUI.Borders.emptyLeft(10));
          wrap.add(button);
          panel.add(wrap, BorderLayout.WEST);
          registeredVisible = true;
        }
      }

      toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
      toolbar.add(
          createActionLink(
              "Configure",
              IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE,
              AllIcons.General.GearPlain,
              !registeredVisible));
      toolbar.add(createActionLink("Get Help", IdeActions.GROUP_WELCOME_SCREEN_DOC, null, false));

      panel.add(toolbar, BorderLayout.EAST);

      panel.setBorder(JBUI.Borders.empty(0, 0, 8, 11));
      return panel;
    }
  private void fillActionsList(
      Component component, MouseShortcut mouseShortcut, boolean isModalContext) {
    myActions.clear();

    // here we try to find "local" shortcuts
    if (component instanceof JComponent) {
      for (AnAction action : ActionUtil.getActions((JComponent) component)) {
        for (Shortcut shortcut : action.getShortcutSet().getShortcuts()) {
          if (mouseShortcut.equals(shortcut) && !myActions.contains(action)) {
            myActions.add(action);
          }
        }
      }
      // once we've found a proper local shortcut(s), we exit
      if (!myActions.isEmpty()) {
        return;
      }
    }

    // search in main keymap
    if (KeymapManagerImpl.ourKeymapManagerInitialized) {
      final KeymapManager keymapManager = KeymapManager.getInstance();
      if (keymapManager != null) {
        final Keymap keymap = keymapManager.getActiveKeymap();
        final String[] actionIds = keymap.getActionIds(mouseShortcut);

        ActionManager actionManager = ActionManager.getInstance();
        for (String actionId : actionIds) {
          AnAction action = actionManager.getAction(actionId);

          if (action == null) continue;

          if (isModalContext && !action.isEnabledInModalContext()) continue;

          if (!myActions.contains(action)) {
            myActions.add(action);
          }
        }
      }
    }
  }
  private ActionPopupMenu createNewResourcePopupMenu() {
    ActionManager actionManager = ActionManager.getInstance();
    DefaultActionGroup actionGroup = new DefaultActionGroup();

    ResourceGroup resourceGroup =
        getSelectedElement(myProjectPanel.myTreeBuilder, ResourceGroup.class);
    if (resourceGroup == null) {
      resourceGroup =
          getSelectedElement(myProjectPanel.myTreeBuilder, ResourceItem.class).getGroup();
    }

    if (AndroidResourceUtil.XML_FILE_RESOURCE_TYPES.contains(resourceGroup.getType())) {
      myNewResourceFileAction
          .getTemplatePresentation()
          .setText("New " + resourceGroup + " File...");
      myNewResourceFileAction
          .getTemplatePresentation()
          .putClientProperty(TYPE_KEY, resourceGroup.getType());
      actionGroup.add(myNewResourceFileAction);
    }
    if (AndroidResourceUtil.VALUE_RESOURCE_TYPES.contains(resourceGroup.getType())) {
      String title = "New " + resourceGroup + " Value...";
      if (resourceGroup.getType() == ResourceType.LAYOUT) {
        title = "New Layout Alias";
      }
      myNewResourceValueAction.getTemplatePresentation().setText(title);
      myNewResourceValueAction
          .getTemplatePresentation()
          .putClientProperty(TYPE_KEY, resourceGroup.getType());
      actionGroup.add(myNewResourceValueAction);
    }
    if (myTag != null && ResourceType.STYLE.equals(resourceGroup.getType())) {
      final boolean enabled =
          AndroidBaseLayoutRefactoringAction.getLayoutViewElement(myTag) != null
              && AndroidExtractStyleAction.doIsEnabled(myTag);
      myExtractStyleAction.getTemplatePresentation().setEnabled(enabled);
      actionGroup.add(myExtractStyleAction);
    }

    return actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, actionGroup);
  }