diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
index 1db0ed60774e..4714ca49bd06 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
@@ -322,10 +322,15 @@ public class DebugProcessEvents extends DebugProcessImpl {
myDebugProcessDispatcher.getMulticaster().processAttached(this);
// breakpoints should be initialized after all processAttached listeners work
- XDebugSession session = getSession().getXDebugSession();
- if (session != null) {
- session.initBreakpoints();
- }
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ XDebugSession session = getSession().getXDebugSession();
+ if (session != null) {
+ session.initBreakpoints();
+ }
+ }
+ });
final String addressDisplayName = DebuggerBundle.getAddressDisplayName(getConnection());
final String transportName = DebuggerBundle.getTransportName(getConnection());
@@ -459,13 +464,18 @@ public class DebugProcessEvents extends DebugProcessImpl {
if (requestHit && requestor instanceof Breakpoint) {
// if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy
- XDebugSession session = getSession().getXDebugSession();
- if (session != null) {
- XBreakpoint breakpoint = ((Breakpoint)requestor).getXBreakpoint();
- if (breakpoint != null) {
- ((XDebugSessionImpl)session).processDependencies(breakpoint);
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ XDebugSession session = getSession().getXDebugSession();
+ if (session != null) {
+ XBreakpoint breakpoint = ((Breakpoint)requestor).getXBreakpoint();
+ if (breakpoint != null) {
+ ((XDebugSessionImpl)session).processDependencies(breakpoint);
+ }
+ }
}
- }
+ });
}
if(!requestHit || resumePreferred) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java
index ad2c881d1336..75897417bd2e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaBreakpointHandler.java
@@ -49,13 +49,17 @@ public class JavaBreakpointHandler extends XBreakpointHandler {
if (javaBreakpoint != null) {
final Breakpoint bpt = javaBreakpoint;
BreakpointManager.addBreakpoint(bpt);
- // must use invoke to stay in the current request,
- // otherwise dependent breakpoints do not get enabled on not-suspending parents hit
- myProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
+ // use schedule not to block initBreakpoints
+ myProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
bpt.createRequest(myProcess);
}
+
+ @Override
+ public Priority getPriority() {
+ return Priority.HIGH;
+ }
});
}
}
@@ -64,12 +68,17 @@ public class JavaBreakpointHandler extends XBreakpointHandler {
public void unregisterBreakpoint(@NotNull final XBreakpoint breakpoint, boolean temporary) {
final Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
if (javaBreakpoint != null) {
- // must use invoke to stay in the current request, see comment in registerBreakpoint
- myProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
+ // use schedule not to block initBreakpoints
+ myProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
javaBreakpoint.delete();
}
+
+ @Override
+ public Priority getPriority() {
+ return Priority.HIGH;
+ }
});
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
index 576f781dc368..c1f1f87db1a9 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
@@ -15,6 +15,7 @@
*/
package com.intellij.debugger.engine;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.InternalException;
@@ -296,7 +297,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
}
- private void processVote(SuspendContextImpl suspendContext) {
+ private void processVote(final SuspendContextImpl suspendContext) {
LOG.assertTrue(suspendContext.myVotesToVote > 0);
suspendContext.myVotesToVote--;
@@ -305,7 +306,18 @@ public class SuspendManagerImpl implements SuspendManager {
}
if(suspendContext.myVotesToVote == 0) {
if(suspendContext.myIsVotedForResume) {
- resume(suspendContext);
+ // resume in a separate request to allow other requests be processed (e.g. dependent bpts enable)
+ myDebugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
+ @Override
+ protected void action() throws Exception {
+ resume(suspendContext);
+ }
+
+ @Override
+ public Priority getPriority() {
+ return Priority.HIGH;
+ }
+ });
}
else {
if (LOG.isDebugEnabled()) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
index 6b1c52c1085a..328dc5f2cd77 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
@@ -33,6 +33,7 @@ import com.intellij.debugger.requests.ClassPrepareRequestor;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
@@ -98,12 +99,17 @@ public abstract class Breakpoint
implements
*/
public abstract void createRequest(DebugProcessImpl debugProcess);
- protected boolean shouldCreateRequest(DebugProcessImpl debugProcess) {
- JavaDebugProcess process = debugProcess.getXdebugProcess();
- return process != null
- && debugProcess.isAttached()
- && ((XDebugSessionImpl)process.getSession()).isBreakpointActive(myXBreakpoint)
- && debugProcess.getRequestsManager().findRequests(this).isEmpty();
+ protected boolean shouldCreateRequest(final DebugProcessImpl debugProcess) {
+ return ApplicationManager.getApplication().runReadAction(new Computable() {
+ @Override
+ public Boolean compute() {
+ JavaDebugProcess process = debugProcess.getXdebugProcess();
+ return process != null
+ && debugProcess.isAttached()
+ && ((XDebugSessionImpl)process.getSession()).isBreakpointActive(myXBreakpoint)
+ && debugProcess.getRequestsManager().findRequests(Breakpoint.this).isEmpty();
+ }
+ });
}
/**
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
index 08d7012eeeea..39d1668c8d3e 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
@@ -91,7 +91,7 @@ public class XDebugSessionImpl implements XDebugSession {
private XDebugProcess myDebugProcess;
private final Map, CustomizedBreakpointPresentation> myRegisteredBreakpoints =
new THashMap, CustomizedBreakpointPresentation>();
- private final Set> myInactiveSlaveBreakpoints = Collections.synchronizedSet(new SmartHashSet>());
+ private final Set> myInactiveSlaveBreakpoints = new SmartHashSet>();
private boolean myBreakpointsDisabled;
private final XDebuggerManagerImpl myDebuggerManager;
private MyBreakpointListener myBreakpointListener;
@@ -289,21 +289,19 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public void initBreakpoints() {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
LOG.assertTrue(!breakpointsInitialized);
breakpointsInitialized = true;
XBreakpointManagerImpl breakpointManager = myDebuggerManager.getBreakpointManager();
XDependentBreakpointManager dependentBreakpointManager = breakpointManager.getDependentBreakpointManager();
disableSlaveBreakpoints(dependentBreakpointManager);
+ processAllBreakpoints(true, false);
- // listeners have to be applied before processing all existing breakpoints,
- // otherwise we may not process breakpoints added during the processing
myBreakpointListener = new MyBreakpointListener();
breakpointManager.addBreakpointListener(myBreakpointListener);
myDependentBreakpointListener = new MyDependentBreakpointListener();
dependentBreakpointManager.addListener(myDependentBreakpointListener);
-
- processAllBreakpoints(true, false);
}
@Override
@@ -371,12 +369,7 @@ public class XDebugSessionImpl implements XDebugSession {
private > void processBreakpoints(final XBreakpointHandler handler,
boolean register,
final boolean temporary) {
- Collection extends B> breakpoints = ApplicationManager.getApplication().runReadAction(new Computable>() {
- @Override
- public Collection extends B> compute() {
- return myDebuggerManager.getBreakpointManager().getBreakpoints(handler.getBreakpointTypeClass());
- }
- });
+ Collection extends B> breakpoints = myDebuggerManager.getBreakpointManager().getBreakpoints(handler.getBreakpointTypeClass());
for (B b : breakpoints) {
handleBreakpoint(handler, b, register, temporary);
}
@@ -426,6 +419,7 @@ public class XDebugSessionImpl implements XDebugSession {
}
public boolean isBreakpointActive(final XBreakpoint> b) {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
return !areBreakpointsMuted() && b.isEnabled() && !myInactiveSlaveBreakpoints.contains(b);
}
@@ -451,6 +445,7 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public void setBreakpointMuted(boolean muted) {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
if (areBreakpointsMuted() == muted) return;
mySessionData.setBreakpointsMuted(muted);
processAllBreakpoints(!muted, muted);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java
index ebcd027c2643..be227cec1698 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java
@@ -240,15 +240,14 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
@NotNull
public > Collection extends B> getBreakpoints(@NotNull final XBreakpointType type) {
ApplicationManager.getApplication().assertReadAccessAllowed();
+ Collection extends XBreakpointBase,?,?>> breakpoints = myBreakpoints.get(type);
+ Collection extends B> regular = breakpoints != null ? Collections.unmodifiableCollection((Collection extends B>)breakpoints) : Collections.emptyList();
+
+ final XBreakpointBase, ?, ?> defaultBreakpoint = myDefaultBreakpoints.get(type);
+ if (defaultBreakpoint == null) return regular;
List result = new ArrayList();
- B defaultBreakpoint = getDefaultBreakpoint(type);
- if (defaultBreakpoint != null) {
- result.add(defaultBreakpoint);
- }
- Collection> breakpoints = myBreakpoints.get(type);
- if (breakpoints != null) {
- result.addAll((Collection extends B>)breakpoints);
- }
+ result.add((B)defaultBreakpoint);
+ result.addAll(regular);
return result;
}
diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java
index 7e6b94dc4784..96ddb74494d1 100644
--- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java
+++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/ColorEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,33 +15,19 @@
*/
package com.intellij.uiDesigner.propertyInspector.editors;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.ui.ListSpeedSearch;
-import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.ui.components.JBList;
+import com.intellij.ui.ColorChooser;
+import com.intellij.ui.JBColor;
import com.intellij.uiDesigner.UIDesignerBundle;
import com.intellij.uiDesigner.lw.ColorDescriptor;
import com.intellij.uiDesigner.propertyInspector.InplaceContext;
import com.intellij.uiDesigner.propertyInspector.PropertyEditor;
-import com.intellij.uiDesigner.propertyInspector.renderers.ColorRenderer;
import com.intellij.uiDesigner.radComponents.RadComponent;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.colorchooser.AbstractColorChooserPanel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.plaf.ColorChooserUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.*;
-import java.util.List;
/**
* @author yole
@@ -50,7 +36,6 @@ public class ColorEditor extends PropertyEditor {
private final String myPropertyName;
private final TextFieldWithBrowseButton myTextField = new TextFieldWithBrowseButton();
private ColorDescriptor myValue;
- private Project myProject;
public ColorEditor(String propertyName) {
myPropertyName = propertyName;
@@ -58,11 +43,10 @@ public class ColorEditor extends PropertyEditor {
myTextField.getTextField().setEditable(false);
myTextField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- MyColorChooserDialog dialog = new MyColorChooserDialog(myProject);
- dialog.setSelectedValue(myValue);
- dialog.show();
- if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
- myValue = dialog.getSelectedValue();
+ String title = UIDesignerBundle.message("color.chooser.title", myPropertyName);
+ Color color = ColorChooser.chooseColor(myTextField, title , myValue.getColor());
+ if (color != null) {
+ myValue = new ColorDescriptor(color);
updateTextField();
}
}
@@ -74,8 +58,7 @@ public class ColorEditor extends PropertyEditor {
}
public JComponent getComponent(RadComponent component, ColorDescriptor value, InplaceContext inplaceContext) {
- myValue = value != null ? value : new ColorDescriptor(new Color(0));
- myProject = component.getProject();
+ myValue = value != null ? value : new ColorDescriptor(JBColor.BLACK);
updateTextField();
return myTextField;
}
@@ -87,174 +70,4 @@ public class ColorEditor extends PropertyEditor {
public void updateUI() {
SwingUtilities.updateComponentTreeUI(myTextField);
}
-
- private static class ColorDescriptorWrapper extends Color {
- private final ColorDescriptor myDescriptor;
-
- public ColorDescriptorWrapper(ColorDescriptor descriptor) {
- super(descriptor.getResolvedColor() == null ? 0 : descriptor.getResolvedColor().getRGB());
- myDescriptor = descriptor;
- }
-
- public ColorDescriptor getDescriptor() {
- return myDescriptor;
- }
- }
-
- private class MyColorChooserDialog extends DialogWrapper {
- private JColorChooser myColorChooser;
- private MyDescriptorChooserPanel mySwingChooserPanel;
- private MyDescriptorChooserPanel mySystemChooserPanel;
- private MyDescriptorChooserPanel myAWTChooserPanel;
-
- public MyColorChooserDialog(Project project) {
- super(project, false);
- setTitle(UIDesignerBundle.message("color.chooser.title", myPropertyName));
- init();
- }
-
- protected JComponent createCenterPanel() {
- myColorChooser = new JColorChooser();
- mySwingChooserPanel = new MyDescriptorChooserPanel(UIDesignerBundle.message("color.chooser.swing.palette"), collectSwingColorDescriptors());
- myColorChooser.addChooserPanel(mySwingChooserPanel);
- mySystemChooserPanel = new MyDescriptorChooserPanel(UIDesignerBundle.message("color.chooser.system.palette"),
- collectColorFields(SystemColor.class, true));
- myColorChooser.addChooserPanel(mySystemChooserPanel);
- myAWTChooserPanel = new MyDescriptorChooserPanel(UIDesignerBundle.message("color.chooser.awt.palette"),
- collectColorFields(Color.class, false));
- myColorChooser.addChooserPanel(myAWTChooserPanel);
- return myColorChooser;
- }
-
- private void selectTabForColor(@Nullable final ColorDescriptor value) {
- String tabName;
-
- if (value == null || value.getSwingColor() != null) {
- tabName = mySwingChooserPanel.getDisplayName();
- }
- else if (value.getSystemColor() != null) {
- tabName = mySystemChooserPanel.getDisplayName();
- }
- else if (value.getAWTColor() != null) {
- tabName = myAWTChooserPanel.getDisplayName();
- }
- else {
- return;
- }
-
- final ColorChooserUI ui = myColorChooser.getUI();
- try {
- final Field field = ui.getClass().getDeclaredField("tabbedPane");
- field.setAccessible(true);
- JTabbedPane tabbedPane = (JTabbedPane) field.get(ui);
- for(int i=0; i collectSwingColorDescriptors() {
- ArrayList result = new ArrayList();
- UIDefaults defaults = UIManager.getDefaults();
- Enumeration e = defaults.keys ();
- while(e.hasMoreElements()) {
- Object key = e.nextElement();
- Object value = defaults.get(key);
- if (key instanceof String && value instanceof Color) {
- result.add(ColorDescriptor.fromSwingColor((String) key));
- }
- }
- return result;
- }
-
- private List collectColorFields(final Class aClass, final boolean isSystem) {
- ArrayList result = new ArrayList();
- Field[] colorFields = aClass.getDeclaredFields();
- for(Field field: colorFields) {
- if ((field.getModifiers() & Modifier.STATIC) != 0 &&
- Color.class.isAssignableFrom(field.getType()) &&
- Character.isLowerCase(field.getName().charAt(0))) {
- final ColorDescriptor color = isSystem
- ? ColorDescriptor.fromSystemColor(field.getName())
- : ColorDescriptor.fromAWTColor(field.getName());
- result.add(color);
- }
- }
- return result;
- }
-
- public void setSelectedValue(@NotNull final ColorDescriptor value) {
- myColorChooser.setColor(new ColorDescriptorWrapper(value));
- selectTabForColor(value);
- }
-
- public ColorDescriptor getSelectedValue() {
- final Color color = myColorChooser.getColor();
- if (color instanceof ColorDescriptorWrapper) {
- return ((ColorDescriptorWrapper) color).getDescriptor();
- }
- return new ColorDescriptor(color);
- }
- }
-
- private static class MyDescriptorChooserPanel extends AbstractColorChooserPanel {
- private final String myDisplayName;
- private final ColorDescriptor[] myColorDescriptors;
- private JList myDescriptorList;
-
- public MyDescriptorChooserPanel(final String displayName, List colorDescriptorList) {
- myDisplayName = displayName;
-
- Collections.sort(colorDescriptorList, new Comparator() {
- public int compare(final ColorDescriptor o1, final ColorDescriptor o2) {
- return o1.toString().compareTo(o2.toString());
- }
- });
-
- myColorDescriptors = colorDescriptorList.toArray(new ColorDescriptor[colorDescriptorList.size()]);
- }
-
- public void updateChooser() {
- myDescriptorList.setSelectedValue(getColorFromModel(), true);
- }
-
- protected void buildChooser() {
- setLayout(new BorderLayout());
- myDescriptorList = new JBList(myColorDescriptors);
- myDescriptorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- myDescriptorList.setVisibleRowCount(15);
- myDescriptorList.setCellRenderer(new ColorRenderer());
- myDescriptorList.addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- ColorDescriptor descriptor = (ColorDescriptor)myDescriptorList.getSelectedValue();
- getColorSelectionModel().setSelectedColor(new ColorDescriptorWrapper(descriptor));
- }
- });
- new ListSpeedSearch(myDescriptorList);
- add(ScrollPaneFactory.createScrollPane(myDescriptorList), BorderLayout.CENTER);
- }
-
- public String getDisplayName() {
- return myDisplayName;
- }
-
- @Nullable
- public Icon getSmallDisplayIcon() {
- return null;
- }
-
- @Nullable
- public Icon getLargeDisplayIcon() {
- return null;
- }
- }
}