mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-57742: Delete key should delete breakpoint selected in the breakpoint list
This commit is contained in:
+10
@@ -35,4 +35,14 @@ public abstract class XBreakpointGroup implements Comparable<XBreakpointGroup> {
|
||||
public int compareTo(final XBreakpointGroup o) {
|
||||
return getName().compareTo(o.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof XBreakpointGroup && compareTo((XBreakpointGroup)obj) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ public class AddBreakpointAction<B extends XBreakpoint<?>> extends XBreakpointPa
|
||||
return true;
|
||||
}
|
||||
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints, final JComponent parentComponent) {
|
||||
B b = myBreakpointsPanel.getType().addBreakpoint(myBreakpointsPanel.getProject(), parentComponent);
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints) {
|
||||
B b = myBreakpointsPanel.getType().addBreakpoint(myBreakpointsPanel.getProject(), myBreakpointsPanel.getTree());
|
||||
if (b != null) {
|
||||
myBreakpointsPanel.resetBreakpoints();
|
||||
myBreakpointsPanel.selectBreakpoint(b);
|
||||
|
||||
+10
-3
@@ -18,13 +18,15 @@ package com.intellij.xdebugger.impl.breakpoints.ui;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class XBreakpointPanelAction<B extends XBreakpoint<?>> {
|
||||
public abstract class XBreakpointPanelAction<B extends XBreakpoint<?>> implements ActionListener {
|
||||
protected final XBreakpointsPanel<B> myBreakpointsPanel;
|
||||
private final String myName;
|
||||
|
||||
@@ -39,6 +41,11 @@ public abstract class XBreakpointPanelAction<B extends XBreakpoint<?>> {
|
||||
|
||||
public abstract boolean isEnabled(@NotNull Collection<? extends B> breakpoints);
|
||||
|
||||
public abstract void perform(@NotNull Collection<? extends B> breakpoints, final JComponent parentComponent);
|
||||
public abstract void perform(@NotNull Collection<? extends B> breakpoints);
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<B> list = myBreakpointsPanel.getTree().getSelectedBreakpoints();
|
||||
perform(list);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -178,12 +178,7 @@ public class XBreakpointsPanel<B extends XBreakpoint<?>> extends AbstractBreakpo
|
||||
|
||||
private JButton createButton(final XBreakpointPanelAction<B> action) {
|
||||
final JButton button = new JButton(action.getName());
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
List<B> list = myTree.getSelectedBreakpoints();
|
||||
action.perform(list, button);
|
||||
}
|
||||
});
|
||||
button.addActionListener(action);
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -241,6 +236,10 @@ public class XBreakpointsPanel<B extends XBreakpoint<?>> extends AbstractBreakpo
|
||||
return myType;
|
||||
}
|
||||
|
||||
public XBreakpointsTree<B> getTree() {
|
||||
return myTree;
|
||||
}
|
||||
|
||||
public boolean canSelectBreakpoint(final XBreakpoint breakpoint) {
|
||||
return breakpoint.getType().equals(myType);
|
||||
}
|
||||
|
||||
+6
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints.ui;
|
||||
|
||||
import com.intellij.ide.util.treeView.TreeState;
|
||||
import com.intellij.openapi.util.MultiValuesMap;
|
||||
import com.intellij.ui.CheckboxTree;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
@@ -59,10 +60,11 @@ public class XBreakpointsTree<B extends XBreakpoint<?>> extends CheckboxTree {
|
||||
}
|
||||
|
||||
public static <B extends XBreakpoint<?>> XBreakpointsTree<B> createTree(final XBreakpointType<B, ?> type, final Collection<XBreakpointGroupingRule<B, ?>> groupingRules) {
|
||||
return new XBreakpointsTree<B>(type, new CheckedTreeNode(null), groupingRules);
|
||||
return new XBreakpointsTree<B>(type, new CheckedTreeNode("root"), groupingRules);
|
||||
}
|
||||
|
||||
public void buildTree(@NotNull Collection<? extends B> breakpoints) {
|
||||
final TreeState state = TreeState.createOn(this, myRoot);
|
||||
myRoot.removeAllChildren();
|
||||
myNodes.clear();
|
||||
myGroupNodes.clear();
|
||||
@@ -76,6 +78,7 @@ public class XBreakpointsTree<B extends XBreakpoint<?>> extends CheckboxTree {
|
||||
TreeUtil.sort(myRoot, myComparator);
|
||||
((DefaultTreeModel)getModel()).nodeStructureChanged(myRoot);
|
||||
expandPath(new TreePath(myRoot));
|
||||
state.applyTo(this, myRoot);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +188,7 @@ public class XBreakpointsTree<B extends XBreakpoint<?>> extends CheckboxTree {
|
||||
private final int myLevel;
|
||||
|
||||
private BreakpointsGroupNode(G group, int level) {
|
||||
super(null);
|
||||
super(group);
|
||||
myLevel = level;
|
||||
setChecked(false);
|
||||
myGroup = group;
|
||||
@@ -204,7 +207,7 @@ public class XBreakpointsTree<B extends XBreakpoint<?>> extends CheckboxTree {
|
||||
private final B myBreakpoint;
|
||||
|
||||
private BreakpointNode(final B breakpoint) {
|
||||
super(null);
|
||||
super(breakpoint);
|
||||
myBreakpoint = breakpoint;
|
||||
setChecked(breakpoint.isEnabled());
|
||||
}
|
||||
|
||||
+2
-3
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints.ui.actions;
|
||||
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.XBreakpointPanelAction;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.XBreakpointsPanel;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -45,7 +44,7 @@ public class GoToBreakpointAction<B extends XBreakpoint<?>> extends XBreakpointP
|
||||
return navigatable != null && navigatable.canNavigateToSource();
|
||||
}
|
||||
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints, final JComponent parentComponent) {
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints) {
|
||||
B b = breakpoints.iterator().next();
|
||||
Navigatable navigatable = b.getNavigatable();
|
||||
if (navigatable != null) {
|
||||
|
||||
+3
-1
@@ -25,6 +25,7 @@ import com.intellij.openapi.application.Result;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@@ -33,13 +34,14 @@ import java.util.Collection;
|
||||
public class RemoveBreakpointAction<B extends XBreakpoint<?>> extends XBreakpointPanelAction<B> {
|
||||
public RemoveBreakpointAction(final XBreakpointsPanel<B> panel) {
|
||||
super(panel, XDebuggerBundle.message("xbreakpoints.dialog.button.remove"));
|
||||
panel.getTree().registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
}
|
||||
|
||||
public boolean isEnabled(@NotNull final Collection<? extends B> breakpoints) {
|
||||
return !breakpoints.isEmpty();
|
||||
}
|
||||
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints, final JComponent parentComponent) {
|
||||
public void perform(@NotNull final Collection<? extends B> breakpoints) {
|
||||
final XBreakpointManager breakpointManager = myBreakpointsPanel.getBreakpointManager();
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
|
||||
Reference in New Issue
Block a user