コード例 #1
0
 void collectItems() {
   if (!myBreakpointsPanelProviders.isEmpty()) {
     myBreakpointItems.clear();
     for (BreakpointPanelProvider panelProvider : myBreakpointsPanelProviders) {
       panelProvider.provideBreakpointItems(myProject, myBreakpointItems);
     }
   }
 }
コード例 #2
0
  private void collectGroupingRules() {
    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
      provider.createBreakpointsGroupingRules(myRulesAvailable);
    }

    myRulesEnabled.clear();
    XBreakpointsDialogState settings = (getBreakpointManager()).getBreakpointsDialogSettings();

    for (XBreakpointGroupingRule rule : myRulesAvailable) {
      if (rule.isAlwaysEnabled()
          || (settings != null && settings.getSelectedGroupingRules().contains(rule.getId()))) {
        myRulesEnabled.add(rule);
      }
    }

    for (XBreakpointGroupingRule rule : myRulesAvailable) {
      if (!rule.isAlwaysEnabled()) {
        myToggleRuleActions.add(new ToggleBreakpointGroupingRuleEnabledAction(rule));
      }
    }
  }
コード例 #3
0
  private JComponent createMasterView() {
    myTreeController = new BreakpointItemsTreeController(myRulesEnabled);
    JTree tree = new BreakpointsCheckboxTree(myProject, myTreeController);

    new AnAction("BreakpointDialog.GoToSource") {
      @Override
      public void actionPerformed(AnActionEvent e) {
        navigate();
        close(OK_EXIT_CODE);
      }
    }.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), tree);

    new AnAction("BreakpointDialog.ShowSource") {
      @Override
      public void actionPerformed(AnActionEvent e) {
        navigate();
      }
    }.registerCustomShortcutSet(
        ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(),
        tree);

    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2
                && UIUtil.isActionClick(event, MouseEvent.MOUSE_CLICKED)
                && !UIUtil.isSelectionButtonDown(event)
                && !event.isConsumed()) {
              navigate();
              close(OK_EXIT_CODE);
            }
          }
        });

    final DefaultActionGroup breakpointTypes = new DefaultActionGroup();
    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
      breakpointTypes.addAll(provider.getAddBreakpointActions(myProject));
    }

    ToolbarDecorator decorator =
        ToolbarDecorator.createDecorator(tree)
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    JBPopupFactory.getInstance()
                        .createActionGroupPopup(
                            null,
                            breakpointTypes,
                            DataManager.getInstance().getDataContext(button.getContextComponent()),
                            JBPopupFactory.ActionSelectionAid.NUMBERING,
                            false)
                        .show(button.getPreferredPopupPoint());
                  }
                })
            .setRemoveAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    myTreeController.removeSelectedBreakpoints(myProject);
                  }
                })
            .setRemoveActionUpdater(
                new AnActionButtonUpdater() {
                  @Override
                  public boolean isEnabled(AnActionEvent e) {
                    boolean enabled = false;
                    final ItemWrapper[] items = myMasterController.getSelectedItems();
                    for (ItemWrapper item : items) {
                      if (item.allowedToRemove()) {
                        enabled = true;
                      }
                    }
                    return enabled;
                  }
                });

    for (ToggleActionButton action : myToggleRuleActions) {
      decorator.addExtraAction(action);
    }

    JPanel decoratedTree = decorator.createPanel();
    myTreeController.setTreeView(tree);

    myDetailController.setTree(tree);

    myTreeController.buildTree(myBreakpointItems);

    initSelection(myBreakpointItems);

    final BreakpointPanelProvider.BreakpointsListener listener =
        new BreakpointPanelProvider.BreakpointsListener() {
          @Override
          public void breakpointsChanged() {
            collectItems();
            myTreeController.rebuildTree(myBreakpointItems);
          }
        };

    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
      provider.addListener(listener, myProject, myListenerDisposable);
    }

    return decoratedTree;
  }