diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorGutterComponentEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorGutterComponentEx.java index e6124b8f3c55..f9f5aae23ed0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorGutterComponentEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorGutterComponentEx.java @@ -17,6 +17,8 @@ package com.intellij.openapi.editor.ex; import com.intellij.openapi.editor.EditorGutter; import com.intellij.openapi.editor.FoldRegion; +import com.intellij.openapi.editor.markup.GutterIconRenderer; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -47,4 +49,7 @@ public abstract class EditorGutterComponentEx extends JComponent implements Edit public abstract int getLineMarkerAreaOffset(); public abstract int getIconsAreaWidth(); + + @Nullable + public abstract Point getPoint(GutterIconRenderer renderer); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index b19acd7b05a0..90bedf032547 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -1273,6 +1273,20 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } } + @Nullable + public Point getPoint(GutterIconRenderer renderer) { + for (int line : myLineToGutterRenderers.keys()) { + for (GutterIconRenderer gutterIconRenderer : myLineToGutterRenderers.get(line)) { + if (gutterIconRenderer == renderer) { + int x = getLineMarkerAreaOffset() + 1; + final int y = myEditor.logicalPositionToXY(new LogicalPosition(line, 0)).y; + return new Point(x, y); + } + } + } + return null; + } + private void invokePopup(MouseEvent e) { final ActionManager actionManager = ActionManager.getInstance(); if (myEditor.getMouseEventArea(e) == EditorMouseEventArea.ANNOTATIONS_AREA) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java new file mode 100644 index 000000000000..08927c8ea9c8 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.ex.EditorGutterComponentEx; +import com.intellij.openapi.editor.markup.GutterIconRenderer; +import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; + +public class EditBreakpointAction extends AnAction { + private XBreakpointBase myBreakpoint; + private GutterIconRenderer myBreakpointGutterRenderer; + + public EditBreakpointAction(String text, + @NotNull XBreakpointBase breakpoint, + GutterIconRenderer breakpointGutterRenderer) { + super(text); + myBreakpoint = breakpoint; + myBreakpointGutterRenderer = breakpointGutterRenderer; + } + + @Override + public void actionPerformed(AnActionEvent e) { + DataContext dataContext = e.getDataContext(); + Project project = PlatformDataKeys.PROJECT.getData(dataContext); + if (project == null) return; + + Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); + if (editor != null) { + final EditorGutterComponentEx gutterComponent = ((EditorEx)editor).getGutterComponentEx(); + Point point = gutterComponent.getPoint(myBreakpointGutterRenderer); + final Icon icon = myBreakpointGutterRenderer.getIcon(); + DebuggerUIUtil.showBreakpointEditorBalloon(project, new Point(point.x + icon.getIconWidth()/2 + gutterComponent.getIconsAreaWidth(), point.y + icon.getIconHeight()/2), gutterComponent, false, myBreakpoint); + } + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java index 184151a5cf2c..78af79d989af 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java @@ -48,7 +48,7 @@ public class ViewBreakpointsAction extends AnAction implements AnAction.Transpar if (project == null) return; if (myInitialBreakpoint == null) { - Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); + Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); if (editor != null) { myInitialBreakpoint = findSelectedBreakpoint(project, editor); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java index fe4146603af9..b16495f1e779 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java @@ -32,13 +32,13 @@ import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.XSourcePosition; -import com.intellij.xdebugger.impl.XDebugSessionImpl; -import com.intellij.xdebugger.impl.XDebuggerUtilImpl; import com.intellij.xdebugger.breakpoints.SuspendPolicy; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; import com.intellij.xdebugger.breakpoints.XBreakpointType; -import com.intellij.xdebugger.impl.actions.ViewBreakpointsAction; +import com.intellij.xdebugger.impl.XDebugSessionImpl; +import com.intellij.xdebugger.impl.XDebuggerUtilImpl; +import com.intellij.xdebugger.impl.actions.EditBreakpointAction; import com.intellij.xdebugger.ui.DebuggerIcons; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -368,7 +368,8 @@ public class XBreakpointBase, P extends XBreakpointP group.add(action); } group.add(new Separator()); - group.add(new ViewBreakpointsAction(XDebuggerBundle.message("xdebugger.view.breakpoint.properties.action"), XBreakpointBase.this)); + + group.add(new EditBreakpointAction(XDebuggerBundle.message("xdebugger.view.breakpoint.properties.action"), XBreakpointBase.this, this)); return group; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.form new file mode 100644 index 000000000000..8760242fda48 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.form @@ -0,0 +1,58 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java new file mode 100644 index 000000000000..48059252b7ca --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.java @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.breakpoints.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; +import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; +import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by IntelliJ IDEA. + * User: zajac + * Date: 18.06.11 + * Time: 9:45 + * To change this template use File | Settings | File Templates. + */ +public class XBreakpointActionsPanel> extends XBreakpointPropertiesSubPanel { + private JCheckBox myLogMessageCheckBox; + private JCheckBox myLogExpressionCheckBox; + private JPanel myLogExpressionPanel; + private JPanel myContentPane; + private JPanel myMainPanel; + private XDebuggerExpressionComboBox myLogExpressionComboBox; + + public void init(Project project, XBreakpointManager breakpointManager, @NotNull B breakpoint, @Nullable XDebuggerEditorsProvider debuggerEditorsProvider) { + init(project, breakpointManager, breakpoint); + if (debuggerEditorsProvider != null) { + ActionListener listener = new ActionListener() { + public void actionPerformed(final ActionEvent e) { + onCheckboxChanged(); + } + }; + + myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, "breakpointLogExpression", myBreakpoint.getSourcePosition()); + JComponent logExpressionComponent = myLogExpressionComboBox.getComponent(); + myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER); + myLogExpressionComboBox.setEnabled(false); + myLogExpressionCheckBox.addActionListener(listener); + DebuggerUIUtil.focusEditorOnCheck(myLogExpressionCheckBox, logExpressionComponent); + } + else { + myLogExpressionCheckBox.setVisible(false); + } + } + + @Override + public boolean lightVariant(boolean showAllOptions) { + if (!showAllOptions && !myBreakpoint.isLogMessage() && myBreakpoint.getLogExpression() == null) { + myMainPanel.setVisible(false); + return true; + } else { + myMainPanel.setBorder(null); + return false; + } + } + + private void onCheckboxChanged() { + if (myLogExpressionComboBox != null) { + myLogExpressionComboBox.setEnabled(myLogExpressionCheckBox.isSelected()); + } + } + + @Override + void loadProperties() { + myLogMessageCheckBox.setSelected(myBreakpoint.isLogMessage()); + if (myLogExpressionComboBox != null) { + String logExpression = myBreakpoint.getLogExpression(); + myLogExpressionCheckBox.setSelected(logExpression != null); + myLogExpressionComboBox.setText(logExpression != null ? logExpression : ""); + } + onCheckboxChanged(); + } + + @Override + void saveProperties() { + myBreakpoint.setLogMessage(myLogMessageCheckBox.isSelected()); + + if (myLogExpressionComboBox != null) { + String logExpression = myLogExpressionCheckBox.isSelected() ? myLogExpressionComboBox.getText() : null; + myBreakpoint.setLogExpression(logExpression); + myLogExpressionComboBox.saveTextInHistory(); + } + //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.form index 52e21a4f26aa..124babc2b9fe 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.form +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.form @@ -3,7 +3,7 @@ - + @@ -16,124 +16,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -142,64 +29,21 @@ - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.java index 62c0cfb89d0a..a4e6010f37cd 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesPanel.java @@ -16,19 +16,15 @@ package com.intellij.xdebugger.impl.breakpoints.ui; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.ComboBox; -import com.intellij.xdebugger.XDebuggerBundle; -import com.intellij.xdebugger.breakpoints.*; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; +import com.intellij.xdebugger.breakpoints.XBreakpointType; import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; -import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; -import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager; import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox; -import com.intellij.ui.GuiUtils; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -36,65 +32,41 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * @author nik */ public class XBreakpointPropertiesPanel> { private JPanel myMainPanel; - private JCheckBox mySuspendCheckBox; - private JRadioButton mySuspendAllRadioButton; - private JRadioButton mySuspendThreadRadioButton; - private JRadioButton mySuspendNoneRadioButton; - private JCheckBox myLogMessageCheckBox; - private JCheckBox myLogExpressionCheckBox; - private JPanel myLogExpressionPanel; + + private XSuspendPolicyPanel mySuspendPolicyPanel; + private JCheckBox myConditionCheckBox; private JPanel myConditionExpressionPanel; private JPanel myCustomConditionsPanelWrapper; - private JPanel mySuspendPolicyPanel; private JPanel myCustomPropertiesPanelWrapper; - private JRadioButton myLeaveEnabledRadioButton; - private JPanel myMasterBreakpointComboBoxPanel; - private JPanel myAfterBreakpointHitPanel; private JPanel myConditionsPanel; - private final XBreakpointManager myBreakpointManager; - private final B myBreakpoint; - private final Map mySuspendRadioButtons; - private final List> myCustomPanels; - private XDebuggerExpressionComboBox myLogExpressionComboBox; + + private XMasterBreakpointPanel myMasterBreakpointPanel; + private XBreakpointActionsPanel myBreakpointActionsPanel; + private XDebuggerExpressionComboBox myConditionComboBox; - private final ComboBox myMasterBreakpointComboBox; - private final XDependentBreakpointManager myDependentBreakpointManager; + + private final List> myCustomPanels; + + private final B myBreakpoint; public XBreakpointPropertiesPanel(Project project, final XBreakpointManager breakpointManager, @NotNull B breakpoint) { - myBreakpointManager = breakpointManager; - myDependentBreakpointManager = ((XBreakpointManagerImpl)breakpointManager).getDependentBreakpointManager(); myBreakpoint = breakpoint; + XBreakpointType breakpointType = XBreakpointUtil.getType(breakpoint); - XBreakpointType type = XBreakpointUtil.getType(breakpoint); + mySuspendPolicyPanel.init(project, breakpointManager, breakpoint); - mySuspendRadioButtons = new HashMap(); - mySuspendRadioButtons.put(SuspendPolicy.ALL, mySuspendAllRadioButton); - mySuspendRadioButtons.put(SuspendPolicy.THREAD, mySuspendThreadRadioButton); - mySuspendRadioButtons.put(SuspendPolicy.NONE, mySuspendNoneRadioButton); - @NonNls String card = type.isSuspendThreadSupported() ? "radioButtons" : "checkbox"; - ((CardLayout)mySuspendPolicyPanel.getLayout()).show(mySuspendPolicyPanel, card); + XDebuggerEditorsProvider debuggerEditorsProvider = breakpointType.getEditorsProvider(); - myMasterBreakpointComboBox = new ComboBox(300); - myMasterBreakpointComboBoxPanel.add(myMasterBreakpointComboBox, BorderLayout.CENTER); - myMasterBreakpointComboBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - updateAfterBreakpointHitPanel(); - } - }); - myMasterBreakpointComboBox.setRenderer(new BreakpointsListCellRenderer()); - fillMasterBreakpointComboBox(); + myBreakpointActionsPanel.init(project, breakpointManager, breakpoint, debuggerEditorsProvider); - XDebuggerEditorsProvider debuggerEditorsProvider = type.getEditorsProvider(); if (debuggerEditorsProvider != null) { ActionListener listener = new ActionListener() { public void actionPerformed(final ActionEvent e) { @@ -102,13 +74,6 @@ public class XBreakpointPropertiesPanel> { } }; - myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, "breakpointLogExpression", myBreakpoint.getSourcePosition()); - JComponent logExpressionComponent = myLogExpressionComboBox.getComponent(); - myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER); - myLogExpressionComboBox.setEnabled(false); - myLogExpressionCheckBox.addActionListener(listener); - DebuggerUIUtil.focusEditorOnCheck(myLogExpressionCheckBox, logExpressionComponent); - myConditionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, "breakpointCondition", myBreakpoint.getSourcePosition()); JComponent conditionComponent = myConditionComboBox.getComponent(); myConditionExpressionPanel.add(conditionComponent, BorderLayout.CENTER); @@ -117,12 +82,13 @@ public class XBreakpointPropertiesPanel> { DebuggerUIUtil.focusEditorOnCheck(myConditionCheckBox, conditionComponent); } else { - myLogExpressionCheckBox.setVisible(false); myConditionCheckBox.setVisible(false); } + myMasterBreakpointPanel.init(project, breakpointManager, breakpoint); + myCustomPanels = new ArrayList>(); - XBreakpointCustomPropertiesPanel customConditionPanel = type.createCustomConditionsPanel(); + XBreakpointCustomPropertiesPanel customConditionPanel = breakpointType.createCustomConditionsPanel(); if (customConditionPanel != null) { myCustomConditionsPanelWrapper.add(customConditionPanel.getComponent(), BorderLayout.CENTER); myCustomPanels.add(customConditionPanel); @@ -132,7 +98,7 @@ public class XBreakpointPropertiesPanel> { myConditionsPanel.setVisible(false); } - XBreakpointCustomPropertiesPanel customPropertiesPanel = type.createCustomPropertiesPanel(); + XBreakpointCustomPropertiesPanel customPropertiesPanel = breakpointType.createCustomPropertiesPanel(); if (customPropertiesPanel != null) { myCustomPropertiesPanelWrapper.add(customPropertiesPanel.getComponent(), BorderLayout.CENTER); myCustomPanels.add(customPropertiesPanel); @@ -141,44 +107,25 @@ public class XBreakpointPropertiesPanel> { loadProperties(); } - private void updateAfterBreakpointHitPanel() { - boolean enable = myMasterBreakpointComboBox.getSelectedItem() != null; - GuiUtils.enableChildren(enable, myAfterBreakpointHitPanel); - } - private void onCheckboxChanged() { - if (myLogExpressionComboBox != null) { - myLogExpressionComboBox.setEnabled(myLogExpressionCheckBox.isSelected()); - } if (myConditionComboBox != null) { myConditionComboBox.setEnabled(myConditionCheckBox.isSelected()); } } private void loadProperties() { - SuspendPolicy suspendPolicy = myBreakpoint.getSuspendPolicy(); - mySuspendRadioButtons.get(suspendPolicy).setSelected(true); - mySuspendCheckBox.setSelected(suspendPolicy != SuspendPolicy.NONE); + mySuspendPolicyPanel.loadProperties(); + + myBreakpointActionsPanel.loadProperties(); + + myMasterBreakpointPanel.loadProperties(); - myLogMessageCheckBox.setSelected(myBreakpoint.isLogMessage()); - if (myLogExpressionComboBox != null) { - String logExpression = myBreakpoint.getLogExpression(); - myLogExpressionCheckBox.setSelected(logExpression != null); - myLogExpressionComboBox.setText(logExpression != null ? logExpression : ""); - } if (myConditionComboBox != null) { String condition = myBreakpoint.getCondition(); myConditionCheckBox.setSelected(condition != null); myConditionComboBox.setText(condition != null ? condition : ""); } - XBreakpoint masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(myBreakpoint); - if (masterBreakpoint != null) { - myMasterBreakpointComboBox.setSelectedItem(masterBreakpoint); - myLeaveEnabledRadioButton.setSelected(myDependentBreakpointManager.isLeaveEnabled(myBreakpoint)); - } - updateAfterBreakpointHitPanel(); - for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) { customPanel.loadFrom(myBreakpoint); } @@ -186,16 +133,6 @@ public class XBreakpointPropertiesPanel> { onCheckboxChanged(); } - private void fillMasterBreakpointComboBox() { - myMasterBreakpointComboBox.removeAllItems(); - myMasterBreakpointComboBox.addItem(null); - for (B breakpoint : myBreakpointManager.getBreakpoints(XBreakpointUtil.getType(myBreakpoint))) { - if (breakpoint != myBreakpoint) { - myMasterBreakpointComboBox.addItem(breakpoint); - } - } - } - public B getBreakpoint() { return myBreakpoint; } @@ -205,14 +142,11 @@ public class XBreakpointPropertiesPanel> { } public void saveProperties() { - myBreakpoint.setSuspendPolicy(getConfiguredSuspendPolicy()); - myBreakpoint.setLogMessage(myLogMessageCheckBox.isSelected()); + mySuspendPolicyPanel.saveProperties(); - if (myLogExpressionComboBox != null) { - String logExpression = myLogExpressionCheckBox.isSelected() ? myLogExpressionComboBox.getText() : null; - myBreakpoint.setLogExpression(logExpression); - myLogExpressionComboBox.saveTextInHistory(); - } + myBreakpointActionsPanel.saveProperties(); + + myMasterBreakpointPanel.saveProperties(); if (myConditionComboBox != null) { String condition = myConditionCheckBox.isSelected() ? myConditionComboBox.getText() : null; @@ -220,14 +154,6 @@ public class XBreakpointPropertiesPanel> { myConditionComboBox.saveTextInHistory(); } - XBreakpoint masterBreakpoint = (XBreakpoint)myMasterBreakpointComboBox.getSelectedItem(); - if (masterBreakpoint == null) { - myDependentBreakpointManager.clearMasterBreakpoint(myBreakpoint); - } - else { - myDependentBreakpointManager.setMasterBreakpoint(myBreakpoint, masterBreakpoint, myLeaveEnabledRadioButton.isSelected()); - } - for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) { customPanel.saveTo(myBreakpoint); } @@ -236,18 +162,6 @@ public class XBreakpointPropertiesPanel> { } } - private SuspendPolicy getConfiguredSuspendPolicy() { - if (!myBreakpoint.getType().isSuspendThreadSupported()) { - return mySuspendCheckBox.isSelected() ? SuspendPolicy.ALL : SuspendPolicy.NONE; - } - - for (SuspendPolicy policy : mySuspendRadioButtons.keySet()) { - if (mySuspendRadioButtons.get(policy).isSelected()) { - return policy; - } - } - return SuspendPolicy.ALL; - } public void dispose() { for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) { @@ -255,23 +169,4 @@ public class XBreakpointPropertiesPanel> { } } - private static class BreakpointsListCellRenderer> extends DefaultListCellRenderer { - public Component getListCellRendererComponent(final JList list, - final Object value, - final int index, - final boolean isSelected, - final boolean cellHasFocus) { - Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value != null) { - B breakpoint = (B)value; - setText(XBreakpointUtil.getDisplayText(breakpoint)); - setIcon(breakpoint.getType().getEnabledIcon()); - } - else { - setText(XDebuggerBundle.message("xbreakpoint.master.breakpoint.none")); - setIcon(null); - } - return component; - } - } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesSubPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesSubPanel.java new file mode 100644 index 000000000000..3ff9a419f4cd --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPropertiesSubPanel.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.breakpoints.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; +import com.intellij.xdebugger.breakpoints.XBreakpointProperties; +import com.intellij.xdebugger.breakpoints.XBreakpointType; +import org.jetbrains.annotations.NotNull; + +/** + * Created by IntelliJ IDEA. + * User: zajac + * Date: 16.06.11 + * Time: 19:21 + * To change this template use File | Settings | File Templates. + */ +public abstract class XBreakpointPropertiesSubPanel> { + + protected Project myProject; + protected XBreakpointManager myBreakpointManager; + protected B myBreakpoint; + protected XBreakpointType myBreakpointType; + + public void init(Project project, final XBreakpointManager breakpointManager, @NotNull B breakpoint) { + myProject = project; + myBreakpointManager = breakpointManager; + myBreakpoint = breakpoint; + myBreakpointType = breakpoint.getType(); + } + + abstract void loadProperties(); + + abstract void saveProperties(); + + public boolean lightVariant(boolean showAllOptions) { + return false; + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form new file mode 100644 index 000000000000..d25ce4fc7f1f --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form @@ -0,0 +1,73 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java new file mode 100644 index 000000000000..2520625f82fb --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java @@ -0,0 +1,166 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.breakpoints.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.components.labels.LinkLabel; +import com.intellij.ui.components.labels.LinkListener; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; +import com.intellij.xdebugger.breakpoints.XBreakpointType; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel; +import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil; +import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by IntelliJ IDEA. + * User: zajac + * Date: 16.06.11 + * Time: 15:46 + * To change this template use File | Settings | File Templates. + */ +public class XLightBreakpointPropertiesPanel> { + + private LinkLabel myShowMoreOptionsLink; + + private void createUIComponents() { + myShowMoreOptionsLink = new LinkLabel("More Options", null, new LinkListener() { + @Override + public void linkSelected(LinkLabel aSource, Object aLinkData) { + if (myDelegate != null) { + myDelegate.showMoreOptions(); + } + } + }); + } + + public interface Delegate { + void showMoreOptions(); + } + + private JPanel myConditionExpressionPanel; + private JPanel myConditionPanel; + private JPanel myMainPanel; + + public Delegate getDelegate() { + return myDelegate; + } + + public void setDelegate(Delegate delegate) { + myDelegate = delegate; + } + + private Delegate myDelegate; + + private XSuspendPolicyPanel mySuspendPolicyPanel; + private XBreakpointActionsPanel myActionsPanel; + private XMasterBreakpointPanel myMasterBreakpointPanel; + private JPanel myCustomPropertiesPanelWrapper; + private final List> myCustomPanels; + + private List> mySubPanels = new ArrayList>(); + + private XDebuggerExpressionComboBox myConditionComboBox; + + private B myBreakpoint; + + public XLightBreakpointPropertiesPanel(Project project, XBreakpointManager breakpointManager, B breakpoint, boolean showAllOptions) { + myBreakpoint = breakpoint; + XBreakpointType breakpointType = XBreakpointUtil.getType(breakpoint); + + mySuspendPolicyPanel.init(project, breakpointManager, breakpoint); + mySubPanels.add(mySuspendPolicyPanel); + myMasterBreakpointPanel.init(project, breakpointManager, breakpoint); + mySubPanels.add(myMasterBreakpointPanel); + XDebuggerEditorsProvider debuggerEditorsProvider = breakpointType.getEditorsProvider(); + + myActionsPanel.init(project, breakpointManager, breakpoint, debuggerEditorsProvider); + mySubPanels.add(myActionsPanel); + + if (debuggerEditorsProvider != null) { + myConditionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, "breakpointCondition", myBreakpoint.getSourcePosition()); + JComponent conditionComponent = myConditionComboBox.getComponent(); + myConditionExpressionPanel.add(conditionComponent, BorderLayout.CENTER); + } else { + myConditionPanel.setVisible(false); + } + + boolean showMoreOptions = false; + for (XBreakpointPropertiesSubPanel panel : mySubPanels) { + if (panel.lightVariant(showAllOptions)) { + showMoreOptions = true; + } + } + + myShowMoreOptionsLink.setVisible(showMoreOptions); + + myCustomPanels = new ArrayList>(); + XBreakpointCustomPropertiesPanel customPropertiesPanel = breakpointType.createCustomPropertiesPanel(); + if (customPropertiesPanel != null) { + myCustomPropertiesPanelWrapper.add(customPropertiesPanel.getComponent(), BorderLayout.CENTER); + myCustomPanels.add(customPropertiesPanel); + } + + loadProperties(); + } + + public void saveProperties() { + for (XBreakpointPropertiesSubPanel panel : mySubPanels) { + panel.saveProperties(); + } + + if (myConditionComboBox != null) { + final String text = myConditionComboBox.getText(); + final String condition = StringUtil.isEmptyOrSpaces(text) ? null : text; + myBreakpoint.setCondition(condition); + myConditionComboBox.saveTextInHistory(); + } + + for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) { + customPanel.saveTo(myBreakpoint); + } + if (!myCustomPanels.isEmpty()) { + ((XBreakpointBase)myBreakpoint).fireBreakpointChanged(); + } + } + + private void loadProperties() { + for (XBreakpointPropertiesSubPanel panel : mySubPanels) { + panel.loadProperties(); + } + + if (myConditionComboBox != null) { + String condition = myBreakpoint.getCondition(); + myConditionComboBox.setText(condition != null ? condition : ""); + } + + for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) { + customPanel.loadFrom(myBreakpoint); + } + } + + public JComponent getMainPanel() { + return myMainPanel; + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.form new file mode 100644 index 000000000000..b24713a26fe0 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.form @@ -0,0 +1,71 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java new file mode 100644 index 000000000000..0ab62bec4d86 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.java @@ -0,0 +1,133 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.breakpoints.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ComboBox; +import com.intellij.ui.GuiUtils; +import com.intellij.xdebugger.XDebuggerBundle; +import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XBreakpointManager; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; +import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil; +import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by IntelliJ IDEA. + * User: zajac + * Date: 16.06.11 + * Time: 21:26 + * To change this template use File | Settings | File Templates. + */ +public class XMasterBreakpointPanel> extends XBreakpointPropertiesSubPanel { + private JPanel myMasterBreakpointComboBoxPanel; + private JPanel myAfterBreakpointHitPanel; + private JRadioButton myLeaveEnabledRadioButton; + private JPanel myContentPane; + private JPanel myMainPanel; + + private ComboBox myMasterBreakpointComboBox; + private XDependentBreakpointManager myDependentBreakpointManager; + + private static class BreakpointsListCellRenderer> extends DefaultListCellRenderer { + public Component getListCellRendererComponent(final JList list, + final Object value, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value != null) { + B breakpoint = (B)value; + setText(XBreakpointUtil.getDisplayText(breakpoint)); + setIcon(breakpoint.getType().getEnabledIcon()); + } + else { + setText(XDebuggerBundle.message("xbreakpoint.master.breakpoint.none")); + setIcon(null); + } + return component; + } + } + + @Override + public void init(Project project, XBreakpointManager breakpointManager, @NotNull B breakpoint) { + super.init(project, breakpointManager, breakpoint); + myDependentBreakpointManager = ((XBreakpointManagerImpl)breakpointManager).getDependentBreakpointManager(); + myMasterBreakpointComboBox = new ComboBox(300); + myMasterBreakpointComboBoxPanel.add(myMasterBreakpointComboBox, BorderLayout.CENTER); + myMasterBreakpointComboBox.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent e) { + updateAfterBreakpointHitPanel(); + } + }); + myMasterBreakpointComboBox.setRenderer(new BreakpointsListCellRenderer()); + fillMasterBreakpointComboBox(); + } + + @Override + public boolean lightVariant(boolean showAllOptions) { + XBreakpoint masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(myBreakpoint); + if (!showAllOptions && masterBreakpoint == null) { + myMainPanel.setVisible(false); + return true; + } + return false; + } + + private void fillMasterBreakpointComboBox() { + myMasterBreakpointComboBox.removeAllItems(); + myMasterBreakpointComboBox.addItem(null); + for (B breakpoint : myBreakpointManager.getBreakpoints(XBreakpointUtil.getType(myBreakpoint))) { + if (breakpoint != myBreakpoint) { + myMasterBreakpointComboBox.addItem(breakpoint); + } + } + } + + + private void updateAfterBreakpointHitPanel() { + boolean enable = myMasterBreakpointComboBox.getSelectedItem() != null; + GuiUtils.enableChildren(enable, myAfterBreakpointHitPanel); + } + + @Override + void loadProperties() { + XBreakpoint masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(myBreakpoint); + if (masterBreakpoint != null) { + myMasterBreakpointComboBox.setSelectedItem(masterBreakpoint); + myLeaveEnabledRadioButton.setSelected(myDependentBreakpointManager.isLeaveEnabled(myBreakpoint)); + } + updateAfterBreakpointHitPanel(); + + } + + @Override + void saveProperties() { + XBreakpoint masterBreakpoint = (XBreakpoint)myMasterBreakpointComboBox.getSelectedItem(); + if (masterBreakpoint == null) { + myDependentBreakpointManager.clearMasterBreakpoint(myBreakpoint); + } + else { + myDependentBreakpointManager.setMasterBreakpoint(myBreakpoint, masterBreakpoint, myLeaveEnabledRadioButton.isSelected()); + } + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.form new file mode 100644 index 000000000000..6da05372d63f --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.form @@ -0,0 +1,81 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java new file mode 100644 index 000000000000..526dd3fb1901 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.java @@ -0,0 +1,88 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl.breakpoints.ui; + +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 org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by IntelliJ IDEA. + * User: zajac + * Date: 16.06.11 + * Time: 17:40 + * To change this template use File | Settings | File Templates. + */ +public class XSuspendPolicyPanel> extends XBreakpointPropertiesSubPanel { + + private JPanel mySuspendPolicyPanel; + private JCheckBox mySuspendCheckBox; + private JRadioButton mySuspendAllRadioButton; + private JRadioButton mySuspendThreadRadioButton; + private JRadioButton mySuspendNoneRadioButton; + private JPanel myContentPane; + private Map mySuspendRadioButtons; + + public void init(Project project, final XBreakpointManager breakpointManager, @NotNull B breakpoint) { + super.init(project, breakpointManager, breakpoint); + mySuspendRadioButtons = new HashMap(); + mySuspendRadioButtons.put(SuspendPolicy.ALL, mySuspendAllRadioButton); + mySuspendRadioButtons.put(SuspendPolicy.THREAD, mySuspendThreadRadioButton); + mySuspendRadioButtons.put(SuspendPolicy.NONE, mySuspendNoneRadioButton); + @NonNls String card = myBreakpointType.isSuspendThreadSupported() ? "radioButtons" : "checkbox"; + ((CardLayout)mySuspendPolicyPanel.getLayout()).show(mySuspendPolicyPanel, card); + } + + @Override + public boolean lightVariant(boolean showAllOptions) { + mySuspendPolicyPanel.setBorder(null); + return false; + } + + @Override + void loadProperties() { + SuspendPolicy suspendPolicy = myBreakpoint.getSuspendPolicy(); + mySuspendRadioButtons.get(suspendPolicy).setSelected(true); + mySuspendCheckBox.setSelected(suspendPolicy != SuspendPolicy.NONE); + } + + private SuspendPolicy getConfiguredSuspendPolicy() { + if (!myBreakpoint.getType().isSuspendThreadSupported()) { + return mySuspendCheckBox.isSelected() ? SuspendPolicy.ALL : SuspendPolicy.NONE; + } + + for (SuspendPolicy policy : mySuspendRadioButtons.keySet()) { + if (mySuspendRadioButtons.get(policy).isSelected()) { + return policy; + } + } + return SuspendPolicy.ALL; + } + + + @Override + void saveProperties() { + myBreakpoint.setSuspendPolicy(getConfiguredSuspendPolicy()); + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java index 202fef7348a9..0cdf85fb4ab8 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java @@ -20,14 +20,16 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.DimensionService; import com.intellij.openapi.wm.WindowManager; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.awt.RelativePoint; +import com.intellij.xdebugger.XDebuggerManager; +import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.frame.XFullValueEvaluator; +import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -133,6 +135,48 @@ public class DebuggerUIUtil { popup.show(point); } + public static void showBreakpointEditorBalloon(final Project project, + @Nullable final Point point, final JComponent gutterComponent, + final boolean showAllOptions, + final XBreakpoint breakpoint) { + final XLightBreakpointPropertiesPanel propertiesPanel = + new XLightBreakpointPropertiesPanel(project, XDebuggerManager.getInstance(project).getBreakpointManager(), + breakpoint, showAllOptions); + + final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(propertiesPanel.getMainPanel()). + setHideOnAction(false). + setHideOnClickOutside(false). + setHideOnKeyOutside(false). + setCloseButtonEnabled(true). + setDialogMode(true). + setFillColor(propertiesPanel.getMainPanel().getBackground()). + setTitle(breakpoint.getType().getDisplayText(breakpoint)). + setHideOnFrameResize(false).createBalloon(); + balloon.addListener(new JBPopupListener() { + @Override + public void beforeShown(LightweightWindowEvent event) { + } + + @Override + public void onClosed(LightweightWindowEvent event) { + propertiesPanel.saveProperties(); + } + }); + propertiesPanel.setDelegate(new XLightBreakpointPropertiesPanel.Delegate() { + @Override + public void showMoreOptions() { + balloon.hide(); + showBreakpointEditorBalloon(project, point, gutterComponent, true, breakpoint); + } + }); + + if (point == null) { + balloon.showInCenterOf(gutterComponent); + } else { + balloon.show(new RelativePoint(gutterComponent, point), Balloon.Position.atRight); + } + } + private static class FullValueEvaluationCallbackImpl implements XFullValueEvaluator.XFullValueEvaluationCallback { private final AtomicBoolean myObsolete = new AtomicBoolean(false); private final JTextArea myTextArea;