use of com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointItemNode in project intellij-community by JetBrains.
the class BreakpointsDialog method createMasterView.
private JComponent createMasterView() {
myTreeController = new BreakpointItemsTreeController(myRulesEnabled) {
@Override
public void nodeStateWillChangeImpl(CheckedTreeNode node) {
if (node instanceof BreakpointItemNode) {
((BreakpointItemNode) node).getBreakpointItem().saveState();
}
super.nodeStateWillChangeImpl(node);
}
@Override
public void nodeStateDidChangeImpl(CheckedTreeNode node) {
super.nodeStateDidChangeImpl(node);
if (node instanceof BreakpointItemNode) {
myDetailController.doUpdateDetailView(true);
}
}
@Override
protected void selectionChangedImpl() {
super.selectionChangedImpl();
saveCurrentItem();
myDetailController.updateDetailView();
}
};
final JTree tree = new BreakpointsCheckboxTree(myProject, myTreeController) {
@Override
protected void onDoubleClick(CheckedTreeNode node) {
if (node instanceof BreakpointsGroupNode) {
TreePath path = TreeUtil.getPathFromRoot(node);
if (isExpanded(path)) {
collapsePath(path);
} else {
expandPath(path);
}
} else {
navigate(false);
}
}
};
PopupHandler.installPopupHandler(tree, new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
ActionGroup group = new ActionGroup("Move to group", true) {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
Set<String> groups = getBreakpointManager().getAllGroups();
AnAction[] res = new AnAction[groups.size() + 3];
int i = 0;
res[i++] = new MoveToGroupAction(null);
for (String group : groups) {
res[i++] = new MoveToGroupAction(group);
}
res[i++] = new Separator();
res[i] = new MoveToGroupAction();
return res;
}
};
List<AnAction> res = new ArrayList<>();
res.add(group);
Object component = tree.getLastSelectedPathComponent();
if (tree.getSelectionCount() == 1 && component instanceof BreakpointsGroupNode && ((BreakpointsGroupNode) component).getGroup() instanceof XBreakpointCustomGroup) {
res.add(new SetAsDefaultGroupAction((XBreakpointCustomGroup) ((BreakpointsGroupNode) component).getGroup()));
}
if (tree.getSelectionCount() == 1 && component instanceof BreakpointItemNode) {
res.add(new EditDescriptionAction((XBreakpointBase) ((BreakpointItemNode) component).getBreakpointItem().getBreakpoint()));
}
return res.toArray(new AnAction[res.size()]);
}
}, ActionPlaces.UNKNOWN, ActionManager.getInstance());
new AnAction("BreakpointDialog.GoToSource") {
@Override
public void actionPerformed(AnActionEvent e) {
navigate(true);
close(OK_EXIT_CODE);
}
}.registerCustomShortcutSet(CommonShortcuts.ENTER, tree, myDisposable);
new AnAction("BreakpointDialog.ShowSource") {
@Override
public void actionPerformed(AnActionEvent e) {
navigate(true);
close(OK_EXIT_CODE);
}
}.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(), tree, myDisposable);
DefaultActionGroup breakpointTypes = XBreakpointUtil.breakpointTypes().filter(XBreakpointType::isAddBreakpointButtonVisible).map(AddXBreakpointAction::new).toListAndThen(DefaultActionGroup::new);
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) {
for (BreakpointItem item : myTreeController.getSelectedBreakpoints(true)) {
if (item.allowedToRemove()) {
return true;
}
}
return false;
}
}).setToolbarPosition(ActionToolbarPosition.TOP).setToolbarBorder(IdeBorderFactory.createEmptyBorder());
for (ToggleActionButton action : myToggleRuleActions) {
decorator.addExtraAction(action);
}
JPanel decoratedTree = decorator.createPanel();
decoratedTree.setBorder(IdeBorderFactory.createEmptyBorder());
JScrollPane pane = UIUtil.getParentOfType(JScrollPane.class, tree);
if (pane != null)
pane.setBorder(IdeBorderFactory.createBorder());
myTreeController.setTreeView(tree);
myTreeController.buildTree(myBreakpointItems);
initSelection(myBreakpointItems);
final BreakpointPanelProvider.BreakpointsListener listener = new BreakpointPanelProvider.BreakpointsListener() {
@Override
public void breakpointsChanged() {
myRebuildAlarm.cancelAndRequest();
}
};
for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
provider.addListener(listener, myProject, myListenerDisposable);
}
return decoratedTree;
}
Aggregations