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;
 }
  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;
  }
示例#3
0
 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);
 }
 @Override
 protected ActionPopupMenu createPopupMenu() {
   ActionGroup group =
       (ActionGroup) ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP);
   return ActionManager.getInstance()
       .createActionPopupMenu(DebuggerActions.FRAME_PANEL_POPUP, group);
 }
示例#5
0
  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 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"));
 }
  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);
  }
示例#8
0
文件: TreeView.java 项目: jexp/idea2
 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);
 }
 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);
 }
 @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);
 }
示例#11
0
 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);
 }
示例#12
0
 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);
 }
  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);
  }
示例#14
0
 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);
 }
    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 ActionToolbar createToolbar() {
    DefaultActionGroup group = new DefaultActionGroup();

    BackAction back = new BackAction();
    back.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)), this);
    group.add(back);

    ForwardAction forward = new ForwardAction();
    forward.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)), this);
    group.add(forward);

    EditSourceActionBase edit = new EditSourceAction();
    edit.registerCustomShortcutSet(
        new CompositeShortcutSet(CommonShortcuts.getEditSource(), CommonShortcuts.ENTER), this);
    group.add(edit);

    edit = new ShowSourceAction();
    edit.registerCustomShortcutSet(
        new CompositeShortcutSet(CommonShortcuts.getViewSource(), CommonShortcuts.CTRL_ENTER),
        this);
    group.add(edit);

    return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
  }
 private JComponent toUsageViewToolbar(final DefaultActionGroup group) {
   ActionToolbar actionToolbar =
       ActionManager.getInstance()
           .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, group, false);
   actionToolbar.setTargetComponent(myRootPanel);
   return actionToolbar.getComponent();
 }
  public ActionMenuItem(
      final AnAction action,
      final Presentation presentation,
      @NotNull final String place,
      @NotNull DataContext context,
      final boolean enableMnemonics,
      final boolean prepareNow,
      final boolean insideCheckedGroup) {
    myAction = ActionRef.fromAction(action);
    myPresentation = presentation;
    myPlace = place;
    myContext = context;
    myEnableMnemonics = enableMnemonics;
    myToggleable = action instanceof Toggleable;
    myInsideCheckedGroup = insideCheckedGroup;

    myEvent =
        new AnActionEvent(null, context, place, myPresentation, ActionManager.getInstance(), 0);
    addActionListener(new ActionTransmitter());
    setBorderPainted(false);

    updateUI();

    if (prepareNow) {
      init();
    } else {
      setText("loading...");
    }
  }
  private JComponent createTreeToolbar() {
    final DefaultActionGroup group = new DefaultActionGroup();
    final Runnable update =
        new Runnable() {
          public void run() {
            rebuild(true);
          }
        };
    if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
      group.add(new FlattenPackagesAction(update));
    }
    final PatternDialectProvider[] dialectProviders =
        Extensions.getExtensions(PatternDialectProvider.EP_NAME);
    for (PatternDialectProvider provider : dialectProviders) {
      for (AnAction action : provider.createActions(myProject, update)) {
        group.add(action);
      }
    }
    group.add(new ShowFilesAction(update));
    final Module[] modules = ModuleManager.getInstance(myProject).getModules();
    if (modules.length > 1) {
      group.add(new ShowModulesAction(update));
      group.add(new ShowModuleGroupsAction(update));
    }
    group.add(new FilterLegalsAction(update));

    if (dialectProviders.length > 1) {
      group.add(new ChooseScopeTypeAction(update));
    }

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    return toolbar.getComponent();
  }
 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);
   }
 }
  static void subscribeTo(NavBarPanel panel) {
    if (panel.getClientProperty(LISTENER) != null) {
      unsubscribeFrom(panel);
    }

    final NavBarListener listener = new NavBarListener(panel);
    final Project project = panel.getProject();
    panel.putClientProperty(LISTENER, listener);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener);
    FileStatusManager.getInstance(project).addFileStatusListener(listener);
    PsiManager.getInstance(project).addPsiTreeChangeListener(listener);
    WolfTheProblemSolver.getInstance(project).addProblemListener(listener);
    ActionManager.getInstance().addAnActionListener(listener);

    final MessageBusConnection connection = project.getMessageBus().connect();
    connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
    connection.subscribe(NavBarModelListener.NAV_BAR, listener);
    connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
    panel.putClientProperty(BUS, connection);
    panel.addKeyListener(listener);

    if (panel.isInFloatingMode()) {
      final Window window = SwingUtilities.windowForComponent(panel);
      if (window != null) {
        window.addWindowFocusListener(listener);
      }
    }
  }
示例#22
0
  @Override
  protected void processMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_CLICKED:
        if (isInFoldingArea(e)) {
          mousePressedInFoldingArea(e);
        } else if (isInTextArea(e)) {
          mousePressedInTextArea(e);
        } else {
          mousePressedInIconsArea(e);
        }
        if (!e.isConsumed()
            && e.getButton() == MouseEvent.BUTTON3
            && e.getID() == MouseEvent.MOUSE_PRESSED) {
          DefaultActionGroup actionGroup =
              ActionUtils.getDefaultGroup(MPSActions.EDITOR_LEFTPANEL_GROUP);
          if (actionGroup != null) {
            ActionPopupMenu popupMenu =
                ActionManager.getInstance()
                    .createActionPopupMenu(ActionPlaces.EDITOR_POPUP, actionGroup);
            popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY());
            e.consume();
          }
        }
    }

    // suppressing future event processig in case event was consumed by one of LeftHighlighter
    // elements
    if (!e.isConsumed()) {
      super.processMouseEvent(e);
    }
  }
  private JComponent createToolbar() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new CloseAction());
    group.add(new RerunAction(this));
    group.add(new FlattenPackagesAction());
    group.add(new ShowFilesAction());
    if (ModuleManager.getInstance(myProject).getModules().length > 1) {
      group.add(new ShowModulesAction());
      group.add(new ShowModuleGroupsAction());
    }
    group.add(new GroupByScopeTypeAction());
    // group.add(new GroupByFilesAction());
    group.add(new FilterLegalsAction());
    group.add(new MarkAsIllegalAction());
    group.add(new ChooseScopeTypeAction());
    group.add(new EditDependencyRulesAction());
    group.add(
        CommonActionsManager.getInstance()
            .createExportToTextFileAction(new DependenciesExporterToTextFile()));
    group.add(new ContextHelpAction("dependency.viewer.tool.window"));

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    return toolbar.getComponent();
  }
示例#24
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();
     }
   }
 }
 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);
 }
 @Override
 protected JComponent createTreePanel(final WatchDebuggerTree tree) {
   final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree);
   decorator.setAddAction(
       new AnActionButtonRunnable() {
         @Override
         public void run(AnActionButton button) {
           executeAction(DebuggerActions.NEW_WATCH, tree);
         }
       });
   // TODO[den]: add "Add to watches action" on Mac
   if (!SystemInfo.isMac) {
     decorator.addExtraAction(
         AnActionButton.fromAction(
             ActionManager.getInstance().getAction(XDebuggerActions.ADD_TO_WATCH)));
   }
   decorator.setRemoveAction(
       new AnActionButtonRunnable() {
         @Override
         public void run(AnActionButton button) {
           executeAction(DebuggerActions.REMOVE_WATCH, tree);
         }
       });
   CustomLineBorder border =
       new CustomLineBorder(
           CaptionPanel.CNT_ACTIVE_BORDER_COLOR,
           SystemInfo.isMac ? 1 : 0,
           0,
           SystemInfo.isMac ? 0 : 1,
           0);
   decorator.setToolbarBorder(border);
   final JPanel panel = decorator.createPanel();
   panel.setBorder(null);
   return panel;
 }
  // todo terrible constructor
  public MultipleChangeListBrowser(
      Project project,
      List<? extends ChangeList> changeLists,
      List<Change> changes,
      Disposable parentDisposable,
      ChangeList initialListSelection,
      boolean capableOfExcludingChanges,
      boolean highlightProblems,
      Runnable rebuildListListener,
      @Nullable Runnable inclusionListener,
      AnAction... additionalActions) {
    super(
        project,
        changeLists,
        changes,
        initialListSelection,
        capableOfExcludingChanges,
        highlightProblems,
        inclusionListener,
        MyUseCase.LOCAL_CHANGES,
        null);
    myParentDisposable = parentDisposable;
    myRebuildListListener = rebuildListListener;

    myChangeListChooser = new ChangeListChooser(changeLists);
    myHeaderPanel.add(myChangeListChooser, BorderLayout.EAST);
    myShowingAllChangeLists =
        Comparing.haveEqualElements(
            changeLists, ChangeListManager.getInstance(project).getChangeLists());
    ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener);

    myExtender = new Extender(project, this, additionalActions);

    ActionManager actionManager = ActionManager.getInstance();
    final AnAction moveAction = actionManager.getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST);
    actionManager.addAnActionListener(
        new AnActionListener.Adapter() {
          @Override
          public void afterActionPerformed(
              AnAction action, DataContext dataContext, AnActionEvent event) {
            if (moveAction.equals(action)) {
              rebuildList();
            }
          }
        },
        myParentDisposable);
  }
示例#28
0
 public void showGroupPopupMenu(final Component comp, final int x, final int y) {
   ActionGroup group = myGroup.getPopupActionGroup();
   if (group != null) {
     ActionPopupMenu popupMenu =
         ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
     popupMenu.getComponent().show(comp, x, y);
   }
 }
  private Component createActionsToolbar(ActionManager actionManager) {
    DefaultActionGroup actionGroup = createActionGroup();

    if (actionManager != null)
      return actionManager.createActionToolbar("TOOLBAR", actionGroup, true).getComponent();

    return new JLabel();
  }
  @Override
  protected void buildToolBar(final DefaultActionGroup toolBarGroup) {
    super.buildToolBar(toolBarGroup);

    EmptyAction.registerWithShortcutSet(
        IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), myViewer);
    toolBarGroup.add(ActionManager.getInstance().getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST));
  }