mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
breakpoints-ui. breakpoints tree nodes sorting.
This commit is contained in:
@@ -19,6 +19,7 @@ import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointTypeGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -56,4 +57,25 @@ public class XBreakpointCategoryGroup extends XBreakpointGroup {
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(XBreakpointGroup o) {
|
||||
if (o instanceof XBreakpointTypeGroup) {
|
||||
return -1;
|
||||
}
|
||||
if (o instanceof XBreakpointCategoryGroup) {
|
||||
return getFactoryIndex() - ((XBreakpointCategoryGroup)o).getFactoryIndex();
|
||||
}
|
||||
return super.compareTo(o);
|
||||
}
|
||||
|
||||
private int getFactoryIndex() {
|
||||
BreakpointFactory[] breakpointFactories = BreakpointFactory.getBreakpointFactories();
|
||||
for (int i = 0; i < breakpointFactories.length; ++i) {
|
||||
if (breakpointFactories[i].getBreakpointCategory().equals(myCategory)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -389,6 +389,11 @@ public abstract class BreakpointPropertiesPanel {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBreakpoint() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
renderer.clear();
|
||||
@@ -434,6 +439,11 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public void removed(Project project) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BreakpointItem breakpointItem) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -133,4 +133,14 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
public void setEnabled(boolean state) {
|
||||
myBreakpoint.ENABLED = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBreakpoint() {
|
||||
return myBreakpoint.getCategory().equals(AnyExceptionBreakpoint.CATEGORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BreakpointItem breakpointItem) {
|
||||
return getDisplayText().compareTo(breakpointItem.getDisplayText());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -41,8 +41,7 @@ import javax.swing.*;
|
||||
* Time: 4:48 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public abstract class BreakpointItem extends ItemWrapper {
|
||||
protected static final Key<Object> BREAKPOINT_ITEM = Key.create("BreakpointItem");
|
||||
public abstract class BreakpointItem extends ItemWrapper implements Comparable<BreakpointItem> {
|
||||
public static final Key<Object> EDITOR_ONLY = Key.create("EditorOnly");
|
||||
|
||||
public abstract Object getBreakpoint();
|
||||
@@ -51,6 +50,8 @@ public abstract class BreakpointItem extends ItemWrapper {
|
||||
|
||||
public abstract void setEnabled(boolean state);
|
||||
|
||||
public abstract boolean isDefaultBreakpoint();
|
||||
|
||||
protected boolean showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
TextAttributes attributes =
|
||||
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
|
||||
|
||||
+5
-7
@@ -20,13 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: zajac
|
||||
* Date: 23.05.12
|
||||
* Time: 15:55
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class XBreakpointTypeGroup extends XBreakpointGroup {
|
||||
|
||||
private XBreakpointType myBreakpointType;
|
||||
@@ -49,4 +42,9 @@ public class XBreakpointTypeGroup extends XBreakpointGroup {
|
||||
public Icon getIcon(boolean isOpen) {
|
||||
return myBreakpointType.getEnabledIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(XBreakpointGroup o) {
|
||||
return -o.compareTo(this);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ package com.intellij.xdebugger.impl.actions;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -30,7 +31,7 @@ import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsConfigurationDialogFactory;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
|
||||
|
||||
public class ViewBreakpointsAction extends AnAction implements AnAction.TransparentUpdate {
|
||||
public class ViewBreakpointsAction extends AnAction implements AnAction.TransparentUpdate, DumbAware {
|
||||
private Object myInitialBreakpoint;
|
||||
|
||||
public ViewBreakpointsAction(){
|
||||
|
||||
+6
-1
@@ -57,7 +57,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XBreakpointBase<Self extends XBreakpoint<P>, P extends XBreakpointProperties, S extends BreakpointState> extends UserDataHolderBase implements XBreakpoint<P> {
|
||||
public class XBreakpointBase<Self extends XBreakpoint<P>, P extends XBreakpointProperties, S extends BreakpointState> extends UserDataHolderBase implements XBreakpoint<P>, Comparable<Self> {
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
@NonNls private static final String BR_NBSP = "<br> ";
|
||||
private final XBreakpointType<Self, P> myType;
|
||||
@@ -347,6 +347,11 @@ public class XBreakpointBase<Self extends XBreakpoint<P>, P extends XBreakpointP
|
||||
myIcon = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Self self) {
|
||||
return myType.getBreakpointComparator().compare((Self)this, self);
|
||||
}
|
||||
|
||||
protected class BreakpointGutterIconRenderer extends GutterIconRenderer {
|
||||
@NotNull
|
||||
public Icon getIcon() {
|
||||
|
||||
+15
@@ -147,4 +147,19 @@ class XBreakpointItem extends BreakpointItem {
|
||||
public void setEnabled(boolean state) {
|
||||
myBreakpoint.setEnabled(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBreakpoint() {
|
||||
return getManager().isDefaultBreakpoint(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BreakpointItem breakpointItem) {
|
||||
if (breakpointItem.getBreakpoint() instanceof XBreakpointBase) {
|
||||
return ((XBreakpointBase)myBreakpoint).compareTo((XBreakpoint)breakpointItem.getBreakpoint());
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -38,7 +38,6 @@ public class BreakpointsMasterDetailPopupFactory {
|
||||
|
||||
public BreakpointsMasterDetailPopupFactory(Project project) {
|
||||
myProject = project;
|
||||
collectPanelProviders();
|
||||
}
|
||||
|
||||
public static List<BreakpointPanelProvider> collectPanelProviders() {
|
||||
@@ -84,7 +83,9 @@ public class BreakpointsMasterDetailPopupFactory {
|
||||
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
for (BreakpointPanelProvider provider : collectPanelProviders()) {
|
||||
provider.onDialogClosed(myProject);
|
||||
}
|
||||
}
|
||||
});
|
||||
return popup;
|
||||
|
||||
+8
-17
@@ -38,7 +38,7 @@ import java.util.*;
|
||||
* @author nik, zajac
|
||||
*/
|
||||
public class BreakpointItemsTreeController implements BreakpointsCheckboxTree.Delegate {
|
||||
//private final TreeNodeComparator myComparator;
|
||||
private final TreeNodeComparator myComparator = new TreeNodeComparator();
|
||||
private final CheckedTreeNode myRoot;
|
||||
private final Map<BreakpointItem, BreakpointItemNode> myNodes = new HashMap<BreakpointItem, BreakpointItemNode>();
|
||||
private List<XBreakpointGroupingRule> myGroupingRules;
|
||||
@@ -52,7 +52,6 @@ public class BreakpointItemsTreeController implements BreakpointsCheckboxTree.De
|
||||
|
||||
public BreakpointItemsTreeController(Collection<XBreakpointGroupingRule> groupingRules) {
|
||||
myRoot = new CheckedTreeNode("root");
|
||||
//myComparator = new TreeNodeComparator<B>(type, breakpointManager);
|
||||
setGroupingRulesInternal(groupingRules);
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ public class BreakpointItemsTreeController implements BreakpointsCheckboxTree.De
|
||||
parent.add(node);
|
||||
myNodes.put(breakpoint, node);
|
||||
}
|
||||
//TreeUtil.sort(myRoot, myComparator);
|
||||
TreeUtil.sort(myRoot, myComparator);
|
||||
((DefaultTreeModel)(myTreeView.getModel())).nodeStructureChanged(myRoot);
|
||||
state.applyTo(myTreeView, myRoot);
|
||||
TreeUtil.expandAll(myTreeView);
|
||||
@@ -204,26 +203,18 @@ public class BreakpointItemsTreeController implements BreakpointsCheckboxTree.De
|
||||
return myRoot;
|
||||
}
|
||||
|
||||
private static class TreeNodeComparator<B extends XBreakpoint<?>> implements Comparator<TreeNode> {
|
||||
private final Comparator<B> myBreakpointComparator;
|
||||
private final XBreakpointManager myBreakpointManager;
|
||||
|
||||
public TreeNodeComparator(final XBreakpointType<B, ?> type, XBreakpointManager breakpointManager) {
|
||||
myBreakpointManager = breakpointManager;
|
||||
myBreakpointComparator = type.getBreakpointComparator();
|
||||
}
|
||||
|
||||
private static class TreeNodeComparator implements Comparator<TreeNode> {
|
||||
public int compare(final TreeNode o1, final TreeNode o2) {
|
||||
if (o1 instanceof BreakpointItemNode && o2 instanceof BreakpointItemNode) {
|
||||
//noinspection unchecked
|
||||
B b1 = (B)((BreakpointItemNode)o1).getBreakpointItem();
|
||||
BreakpointItem b1 = ((BreakpointItemNode)o1).getBreakpointItem();
|
||||
//noinspection unchecked
|
||||
B b2 = (B)((BreakpointItemNode)o2).getBreakpointItem();
|
||||
boolean default1 = myBreakpointManager.isDefaultBreakpoint(b1);
|
||||
boolean default2 = myBreakpointManager.isDefaultBreakpoint(b2);
|
||||
BreakpointItem b2 = ((BreakpointItemNode)o2).getBreakpointItem();
|
||||
boolean default1 = b1.isDefaultBreakpoint();
|
||||
boolean default2 = b2.isDefaultBreakpoint();
|
||||
if (default1 && !default2) return -1;
|
||||
if (!default1 && default2) return 1;
|
||||
return myBreakpointComparator.compare(b1, b2);
|
||||
return b1.compareTo(b2);
|
||||
}
|
||||
if (o1 instanceof BreakpointsGroupNode && o2 instanceof BreakpointsGroupNode) {
|
||||
final BreakpointsGroupNode group1 = (BreakpointsGroupNode)o1;
|
||||
|
||||
Reference in New Issue
Block a user