void initSelection(Collection<BreakpointItem> breakpoints) {
    boolean found = false;
    for (BreakpointItem breakpoint : breakpoints) {
      if (breakpoint.getBreakpoint() == myInitialBreakpoint) {
        myTreeController.selectBreakpointItem(breakpoint, null);
        found = true;
        break;
      }
    }

    if (!found && !breakpoints.isEmpty()) {
      myTreeController.selectFirstBreakpointItem();
    }
  }
 @Override
 public ItemWrapper[] getSelectedItems() {
   final List<BreakpointItem> res = myTreeController.getSelectedBreakpoints();
   return res.toArray(new ItemWrapper[res.size()]);
 }
 @Nullable
 @Override
 public JComponent getPreferredFocusedComponent() {
   return myTreeController.getTreeView();
 }
 private void navigate() {
   List<BreakpointItem> breakpoints = myTreeController.getSelectedBreakpoints();
   if (!breakpoints.isEmpty()) {
     breakpoints.get(0).navigate(true);
   }
 }
  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;
  }