IDEA-27445 Breakpoint groups - added support for default group

This commit is contained in:
Egor.Ushakov
2014-04-09 14:46:57 +04:00
parent e56d173523
commit c208dce910
6 changed files with 66 additions and 6 deletions
@@ -60,7 +60,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
private final XDebuggerManagerImpl myDebuggerManager;
private final XDependentBreakpointManager myDependentBreakpointManager;
private long myTime;
private String myDefaultGroup;
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
myProject = project;
@@ -131,6 +131,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
type.getId(),
defaultBreakpoint ? 0 : myTime++);
getBreakpointDefaults(type).applyDefaults(state);
state.setGroup(myDefaultGroup);
return new XBreakpointBase<XBreakpoint<T>,T, BreakpointState<?,T,?>>(type, this, properties, state);
}
@@ -220,6 +221,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
LineBreakpointState<T> state = new LineBreakpointState<T>(true, type.getId(), fileUrl, line, temporary,
myTime++);
getBreakpointDefaults(type).applyDefaults(state);
state.setGroup(myDefaultGroup);
XLineBreakpointImpl<T> breakpoint = new XLineBreakpointImpl<T>(type, this, properties,
state);
addBreakpoint(breakpoint, false, true);
@@ -368,6 +370,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
state.setBreakpointsDialogProperties(myBreakpointsDialogSettings);
state.setTime(myTime);
state.setDefaultGroup(myDefaultGroup);
return state;
}
@@ -420,6 +423,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
myDependentBreakpointManager.loadState();
myLineBreakpointManager.updateBreakpointsUI();
myTime = state.getTime();
myDefaultGroup = state.getDefaultGroup();
}
private <P extends XBreakpointProperties> void addDefaultBreakpoint(XBreakpointType<?, P> type) {
@@ -467,6 +471,14 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
return res;
}
public String getDefaultGroup() {
return myDefaultGroup;
}
public void setDefaultGroup(String defaultGroup) {
myDefaultGroup = defaultGroup;
}
@Nullable
private XBreakpointBase<?,?,?> createBreakpoint(final BreakpointState breakpointState) {
XBreakpointType<?,?> type = XBreakpointUtil.findType(breakpointState.getTypeId());
@@ -498,6 +510,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
private XBreakpointsDialogState myBreakpointsDialogProperties;
private long myTime;
private String myDefaultGroup;
@Tag("default-breakpoints")
@AbstractCollection(surroundWithTag = false)
@@ -548,5 +561,13 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
public void setTime(long time) {
myTime = time;
}
public String getDefaultGroup() {
return myDefaultGroup;
}
public void setDefaultGroup(String defaultGroup) {
myDefaultGroup = defaultGroup;
}
}
}
@@ -41,9 +41,11 @@ import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointsDialogState;
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointCustomGroup;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointItemNode;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointItemsTreeController;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointsCheckboxTree;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointsGroupNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -240,7 +242,13 @@ public class BreakpointsDialog extends DialogWrapper {
return res;
}
};
return new AnAction[]{group};
List<AnAction> res = new ArrayList<AnAction>();
res.add(group);
Object component = tree.getLastSelectedPathComponent();
if (component instanceof BreakpointsGroupNode && ((BreakpointsGroupNode)component).getGroup() instanceof XBreakpointCustomGroup) {
res.add(new SetAsDefaultGroupAction((XBreakpointCustomGroup)((BreakpointsGroupNode)component).getGroup()));
}
return res.toArray(new AnAction[res.size()]);
}
}, ActionPlaces.UNKNOWN, ActionManager.getInstance());
@@ -473,7 +481,21 @@ public class BreakpointsDialog extends DialogWrapper {
}
}
myTreeController.rebuildTree(myBreakpointItems);
}
}
private class SetAsDefaultGroupAction extends AnAction {
private final String myName;
private SetAsDefaultGroupAction(XBreakpointCustomGroup group) {
super(group.isDefault() ? "Unset as default" : "Set as default");
myName = group.isDefault() ? null : group.getName();
}
@Override
public void actionPerformed(AnActionEvent e) {
getBreakpointManager().setDefaultGroup(myName);
myTreeController.rebuildTree(myBreakpointItems);
}
}
}
@@ -16,7 +16,10 @@
package com.intellij.xdebugger.impl.breakpoints.ui.grouping;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,9 +30,11 @@ import javax.swing.*;
*/
public class XBreakpointCustomGroup extends XBreakpointGroup {
private final String myName;
private final boolean myIsDefault;
public XBreakpointCustomGroup(@NotNull String name) {
public XBreakpointCustomGroup(@NotNull String name, Project project) {
myName = name;
myIsDefault = name.equals(((XBreakpointManagerImpl)XDebuggerManager.getInstance(project).getBreakpointManager()).getDefaultGroup());
}
@Nullable
@@ -41,4 +46,8 @@ public class XBreakpointCustomGroup extends XBreakpointGroup {
public String getName() {
return myName;
}
public boolean isDefault() {
return myIsDefault;
}
}
@@ -51,7 +51,7 @@ public class XBreakpointCustomGroupingRule<B> extends XBreakpointGroupingRule<B,
if (StringUtil.isEmpty(name)) {
return null;
}
return new XBreakpointCustomGroup(name);
return new XBreakpointCustomGroup(name, ((XBreakpointBase)breakpoint).getProject());
}
@Nullable
@@ -18,7 +18,7 @@ package com.intellij.xdebugger.impl.breakpoints.ui.tree;
import com.intellij.ui.CheckedTreeNode;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
class BreakpointsGroupNode<G extends XBreakpointGroup> extends CheckedTreeNode {
public class BreakpointsGroupNode<G extends XBreakpointGroup> extends CheckedTreeNode {
private final G myGroup;
private final int myLevel;
@@ -21,10 +21,13 @@ import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointCustomGroup;
import javax.swing.*;
class BreakpointsTreeCellRenderer {
private static SimpleTextAttributes SIMPLE_CELL_ATTRIBUTES_BOLD = SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES.derive(SimpleTextAttributes.STYLE_BOLD, null, null, null);
private static void customizeRenderer(Project project,
Object value,
boolean selected,
@@ -38,7 +41,12 @@ class BreakpointsTreeCellRenderer {
else if (value instanceof BreakpointsGroupNode) {
XBreakpointGroup group = ((BreakpointsGroupNode)value).getGroup();
renderer.setIcon(group.getIcon(expanded));
renderer.append(group.getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
if (group instanceof XBreakpointCustomGroup && ((XBreakpointCustomGroup)group).isDefault()) {
renderer.append(group.getName(), SIMPLE_CELL_ATTRIBUTES_BOLD);
}
else {
renderer.append(group.getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
}
}
}