mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java-xbreakpoints: rewrote breakpoints defaults
This commit is contained in:
@@ -216,7 +216,7 @@ public class BreakpointManager {
|
||||
}
|
||||
if (typeCls != null) {
|
||||
XBreakpointType<XBreakpoint<?>, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
|
||||
BreakpointState.setDefaultSuspendPolicy(type.getId(), Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
|
||||
((XBreakpointManagerImpl)getXBreakpointManager()).getBreakpointDefaults(type).setSuspendPolicy(Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
|
||||
}
|
||||
//myBreakpointDefaults.put(category, defaults);
|
||||
}
|
||||
|
||||
+2
-13
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints;
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
@@ -49,7 +48,6 @@ public class BreakpointState<B extends XBreakpoint<P>, P extends XBreakpointProp
|
||||
myEnabled = enabled;
|
||||
myTypeId = typeId;
|
||||
myTimeStamp = timeStamp;
|
||||
mySuspendPolicy = getDefaultSuspendPolicy(myTypeId); // apply default
|
||||
}
|
||||
|
||||
@Attribute("enabled")
|
||||
@@ -145,16 +143,7 @@ public class BreakpointState<B extends XBreakpoint<P>, P extends XBreakpointProp
|
||||
myTimeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public static SuspendPolicy getDefaultSuspendPolicy(String typeId) {
|
||||
String defaultPolicy = PropertiesComponent.getInstance().getValue(getDefaultSuspendPolicyKey(typeId));
|
||||
return defaultPolicy != null ? SuspendPolicy.valueOf(defaultPolicy) : SuspendPolicy.ALL;
|
||||
}
|
||||
|
||||
public static void setDefaultSuspendPolicy(String typeId, SuspendPolicy suspendPolicy) {
|
||||
PropertiesComponent.getInstance().setValue(getDefaultSuspendPolicyKey(typeId), suspendPolicy.name());
|
||||
}
|
||||
|
||||
private static String getDefaultSuspendPolicyKey(String typeId) {
|
||||
return "debugger.suspend.policy-" + typeId;
|
||||
void applyDefaults(BreakpointState state) {
|
||||
state.mySuspendPolicy = mySuspendPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
+53
-4
@@ -50,6 +50,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
public static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTER = new SkipDefaultValuesSerializationFilters();
|
||||
private final MultiValuesMap<XBreakpointType, XBreakpointBase<?,?,?>> myBreakpoints = new MultiValuesMap<XBreakpointType, XBreakpointBase<?,?,?>>(true);
|
||||
private final Map<XBreakpointType, XBreakpointBase<?,?,?>> myDefaultBreakpoints = new LinkedHashMap<XBreakpointType, XBreakpointBase<?, ?, ?>>();
|
||||
private final Map<XBreakpointType, BreakpointState<?,?,?>> myBreakpointsDefaults = new LinkedHashMap<XBreakpointType, BreakpointState<?, ?, ?>>();
|
||||
private final Set<XBreakpointBase<?,?,?>> myAllBreakpoints = new HashSet<XBreakpointBase<?, ?, ?>>();
|
||||
private final Map<XBreakpointType, EventDispatcher<XBreakpointListener>> myDispatchers = new HashMap<XBreakpointType, EventDispatcher<XBreakpointListener>>();
|
||||
private XBreakpointsDialogState myBreakpointsDialogSettings;
|
||||
@@ -127,6 +128,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
BreakpointState<?,T,?> state = new BreakpointState<XBreakpoint<T>,T,XBreakpointType<XBreakpoint<T>,T>>(enabled,
|
||||
type.getId(),
|
||||
defaultBreakpoint ? 0 : myTime++);
|
||||
getBreakpointDefaults(type).applyDefaults(state);
|
||||
return new XBreakpointBase<XBreakpoint<T>,T, BreakpointState<?,T,?>>(type, this, properties, state);
|
||||
}
|
||||
|
||||
@@ -213,8 +215,11 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
@Nullable final T properties,
|
||||
boolean temporary) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
LineBreakpointState<T> state = new LineBreakpointState<T>(true, type.getId(), fileUrl, line, temporary,
|
||||
myTime++);
|
||||
getBreakpointDefaults(type).applyDefaults(state);
|
||||
XLineBreakpointImpl<T> breakpoint = new XLineBreakpointImpl<T>(type, this, properties,
|
||||
new LineBreakpointState<T>(true, type.getId(), fileUrl, line, temporary, myTime++));
|
||||
state);
|
||||
addBreakpoint(breakpoint, false, true);
|
||||
return breakpoint;
|
||||
}
|
||||
@@ -353,6 +358,12 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
state.getBreakpoints().add(breakpoint.getState());
|
||||
}
|
||||
|
||||
for (Map.Entry<XBreakpointType, BreakpointState<?,?,?>> entry : myBreakpointsDefaults.entrySet()) {
|
||||
if (statesAreDifferent(entry.getValue(), createBreakpointDefaults(entry.getKey()))) {
|
||||
state.getBreakpointsDefaults().add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
state.setBreakpointsDialogProperties(myBreakpointsDialogSettings);
|
||||
state.setTime(myTime);
|
||||
return state;
|
||||
@@ -366,9 +377,13 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
}
|
||||
|
||||
BreakpointState defaultState = ((XBreakpointBase)defaultBreakpoint).getState();
|
||||
Element defaultElement = XmlSerializer.serialize(defaultState, SERIALIZATION_FILTER);
|
||||
Element currentElement = XmlSerializer.serialize(state, SERIALIZATION_FILTER);
|
||||
return !JDOMUtil.areElementsEqual(defaultElement, currentElement);
|
||||
return statesAreDifferent(state, defaultState);
|
||||
}
|
||||
|
||||
private static boolean statesAreDifferent(BreakpointState state1, BreakpointState state2) {
|
||||
Element elem1 = XmlSerializer.serialize(state1, SERIALIZATION_FILTER);
|
||||
Element elem2 = XmlSerializer.serialize(state2, SERIALIZATION_FILTER);
|
||||
return !JDOMUtil.areElementsEqual(elem1, elem2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -377,6 +392,8 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
|
||||
myAllBreakpoints.clear();
|
||||
myDefaultBreakpoints.clear();
|
||||
myBreakpointsDefaults.clear();
|
||||
|
||||
for (BreakpointState breakpointState : state.getDefaultBreakpoints()) {
|
||||
loadBreakpoint(breakpointState, true);
|
||||
}
|
||||
@@ -392,6 +409,12 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
for (BreakpointState breakpointState : state.getBreakpoints()) {
|
||||
loadBreakpoint(breakpointState, false);
|
||||
}
|
||||
|
||||
for (BreakpointState defaults : state.getBreakpointsDefaults()) {
|
||||
XBreakpointType<?,?> type = XBreakpointUtil.findType(defaults.getTypeId());
|
||||
myBreakpointsDefaults.put(type, defaults);
|
||||
}
|
||||
|
||||
myDependentBreakpointManager.loadState();
|
||||
myLineBreakpointManager.updateBreakpointsUI();
|
||||
myTime = state.getTime();
|
||||
@@ -439,11 +462,26 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
return breakpointState.createBreakpoint(type, this);
|
||||
}
|
||||
|
||||
public BreakpointState getBreakpointDefaults(XBreakpointType type) {
|
||||
BreakpointState defaultState = myBreakpointsDefaults.get(type);
|
||||
if (defaultState == null) {
|
||||
defaultState = createBreakpointDefaults(type);
|
||||
myBreakpointsDefaults.put(type, defaultState);
|
||||
}
|
||||
return defaultState;
|
||||
}
|
||||
|
||||
private static BreakpointState createBreakpointDefaults(XBreakpointType type) {
|
||||
BreakpointState state = new BreakpointState();
|
||||
state.setTypeId(type.getId());
|
||||
return state;
|
||||
}
|
||||
|
||||
@Tag("breakpoint-manager")
|
||||
public static class BreakpointManagerState {
|
||||
private List<BreakpointState> myDefaultBreakpoints = new ArrayList<BreakpointState>();
|
||||
private List<BreakpointState> myBreakpoints = new ArrayList<BreakpointState>();
|
||||
private List<BreakpointState> myBreakpointsDefaults = new ArrayList<BreakpointState>();
|
||||
private XBreakpointsDialogState myBreakpointsDialogProperties;
|
||||
|
||||
private long myTime;
|
||||
@@ -461,6 +499,13 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
return myBreakpoints;
|
||||
}
|
||||
|
||||
@Tag("breakpoints-defaults")
|
||||
@AbstractCollection(surroundWithTag = false,
|
||||
elementTypes = {BreakpointState.class, LineBreakpointState.class})
|
||||
public List<BreakpointState> getBreakpointsDefaults() {
|
||||
return myBreakpointsDefaults;
|
||||
}
|
||||
|
||||
@Tag("breakpoints-dialog")
|
||||
public XBreakpointsDialogState getBreakpointsDialogProperties() {
|
||||
return myBreakpointsDialogProperties;
|
||||
@@ -475,6 +520,10 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
myDefaultBreakpoints = defaultBreakpoints;
|
||||
}
|
||||
|
||||
public void setBreakpointsDefaults(List<BreakpointState> breakpointsDefaults) {
|
||||
myBreakpointsDefaults = breakpointsDefaults;
|
||||
}
|
||||
|
||||
public void setBreakpointsDialogProperties(XBreakpointsDialogState breakpointsDialogProperties) {
|
||||
myBreakpointsDialogProperties = breakpointsDialogProperties;
|
||||
}
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointManager;
|
||||
import com.intellij.xdebugger.impl.breakpoints.BreakpointState;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -89,7 +89,7 @@ public class XSuspendPolicyPanel<B extends XBreakpoint<?>> extends XBreakpointPr
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SuspendPolicy suspendPolicy = getSelectedSuspendPolicy();
|
||||
BreakpointState.setDefaultSuspendPolicy(myBreakpointType.getId(), suspendPolicy);
|
||||
((XBreakpointManagerImpl)myBreakpointManager).getBreakpointDefaults(myBreakpointType).setSuspendPolicy(suspendPolicy);
|
||||
updateSuspendPolicyFont();
|
||||
if (SuspendPolicy.THREAD == suspendPolicy) {
|
||||
mySuspendThread.requestFocus();
|
||||
@@ -103,11 +103,11 @@ public class XSuspendPolicyPanel<B extends XBreakpoint<?>> extends XBreakpointPr
|
||||
}
|
||||
|
||||
private void updateMakeDefaultEnableState() {
|
||||
myMakeDefaultButton.setEnabled(!getSelectedSuspendPolicy().equals(BreakpointState.getDefaultSuspendPolicy(myBreakpointType.getId())));
|
||||
myMakeDefaultButton.setEnabled(!getSelectedSuspendPolicy().equals(((XBreakpointManagerImpl)myBreakpointManager).getBreakpointDefaults(myBreakpointType).getSuspendPolicy()));
|
||||
}
|
||||
|
||||
private void updateSuspendPolicyFont() {
|
||||
SuspendPolicy defaultPolicy = BreakpointState.getDefaultSuspendPolicy(myBreakpointType.getId());
|
||||
SuspendPolicy defaultPolicy = ((XBreakpointManagerImpl)myBreakpointManager).getBreakpointDefaults(myBreakpointType).getSuspendPolicy();
|
||||
Font font = mySuspendAll.getFont().deriveFont(Font.PLAIN);
|
||||
Font boldFont = font.deriveFont(Font.BOLD);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user