breakpoints-ui. master breakpoint preview for XBreakpoints

This commit is contained in:
andrey.zaytsev
2012-08-30 21:45:59 +04:00
parent 95bd1a942f
commit c63df32c68
14 changed files with 305 additions and 261 deletions
@@ -1,197 +0,0 @@
/*
* Copyright 2000-2012 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.debugger.ui.breakpoints;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.ui.CollectionComboBoxModel;
import com.intellij.ui.components.JBList;
import com.intellij.ui.popup.util.*;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
public class BreakpointChooser {
private DetailView myDetailView;
private Delegate myDelegate;
private final ComboBox myComboBox;
private DetailController myDetailController;
private JBList myList;
public void setDetailView(DetailView detailView) {
myDetailView = detailView;
myDetailController.setDetailView(new MyDetailView(myDetailView.getEditorState()));
}
public Object getSelectedBreakpoint() {
return ((BreakpointItem)myComboBox.getSelectedItem()).getBreakpoint();
}
private void pop(DetailView.PreviewEditorState pushed) {
if (pushed.getFile() != null) {
myDetailView
.navigateInPreviewEditor(
new DetailView.PreviewEditorState(pushed.getFile(), pushed.getNavigate(), pushed.getAttributes()));
}
else {
myDetailView.clearEditor();
}
}
public interface Delegate {
void breakpointChosen(Project project, BreakpointItem breakpointItem);
}
public BreakpointChooser(final Project project, Delegate delegate, Breakpoint baseBreakpoint, List<BreakpointItem> breakpointItems) {
myDelegate = delegate;
BreakpointItem breakpointItem = null;
for (BreakpointItem item : breakpointItems) {
if (item.getBreakpoint() == baseBreakpoint) {
breakpointItem = item;
break;
}
}
final Ref<Object> hackedSelection = Ref.create();
myDetailController = new DetailController(new MasterController() {
JLabel fake = new JLabel();
@Override
public ItemWrapper[] getSelectedItems() {
if (hackedSelection.get() == null) {
return new ItemWrapper[0];
}
return new ItemWrapper[]{((BreakpointItem) hackedSelection.get())};
}
@Override
public JLabel getPathLabel() {
return fake;
}
});
final ItemWrapperListRenderer listRenderer = new ItemWrapperListRenderer(project, null);
ComboBoxModel model = new CollectionComboBoxModel(breakpointItems, breakpointItem);
myComboBox = new ComboBox(model);
myComboBox.setRenderer(new ItemWrapperListRenderer(project, null) {
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
super.customizeCellRenderer(list, value, index, selected,
hasFocus);
if (selected) {
if (hackedSelection.get() != value) {
hackedSelection.set(value);
myDetailController.selectionChanged();
}
}
}
});
myComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
myDelegate.breakpointChosen(project, ((BreakpointItem)myComboBox.getSelectedItem()));
}
});
}
public JComponent getComponent() {
return myComboBox;
}
private class MyDetailView implements DetailView {
private final PreviewEditorState myPushed;
private ItemWrapper myCurrentItem;
public MyDetailView(PreviewEditorState pushed) {
myPushed = pushed;
putUserData(BreakpointItem.EDITOR_ONLY, Boolean.TRUE);
}
@Override
public Editor getEditor() {
return myDetailView.getEditor();
}
@Override
public void navigateInPreviewEditor(PreviewEditorState editorState) {
if (myDetailView != null) {
myDetailView.navigateInPreviewEditor(editorState);
}
}
@Override
public JPanel getDetailPanel() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void setDetailPanel(@Nullable JPanel panel) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void clearEditor() {
pop(myPushed);
}
@Override
public PreviewEditorState getEditorState() {
return myDetailView.getEditorState();
}
public void setCurrentItem(ItemWrapper currentItem) {
myCurrentItem = currentItem;
}
@Override
public ItemWrapper getCurrentItem() {
return myCurrentItem;
}
@Override
public boolean hasEditorOnly() {
return true;
}
UserDataHolderBase myDataHolderBase = new UserDataHolderBase();
@Override
public <T> T getUserData(@NotNull Key<T> key) {
return myDataHolderBase.getUserData(key);
}
@Override
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
myDataHolderBase.putUserData(key, value);
}
}
}
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.debugger.ui.breakpoints.BreakpointPropertiesPanel">
<grid id="6570" binding="myPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="6570" binding="myPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="23" y="37" width="547" height="347"/>
<xy x="23" y="37" width="751" height="404"/>
</constraints>
<properties/>
<border type="none"/>
@@ -95,7 +95,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="da86f" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="da86f" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
@@ -105,10 +105,10 @@
<properties/>
<border type="none"/>
<children>
<grid id="1d1c" binding="myActionsPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="1d1c" binding="myActionsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="5"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
@@ -124,12 +124,7 @@
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.log.message"/>
</properties>
</component>
<vspacer id="f635a">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="42168" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
<grid id="42168" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
@@ -173,74 +168,6 @@
</component>
</children>
</grid>
<grid id="d7b0a" binding="myDependsOnPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="bebec" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.depends.on"/>
</properties>
</component>
<grid id="4241e" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="13a5b">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="15" height="-1"/>
</grid>
</constraints>
</hspacer>
<grid id="9b21c" binding="myDependentBreakpointComboPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="15" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="7f1f0" class="javax.swing.JLabel" binding="myEnableOrDisableLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.dependency.type.lable"/>
</properties>
</component>
<component id="e3baf" class="javax.swing.JRadioButton" binding="myDisableAgainRadio" default-binding="true">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.depends.disable.again"/>
</properties>
</component>
<component id="10e41" class="javax.swing.JRadioButton" binding="myLeaveEnabledRadioButton" default-binding="true">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.depends.leave.enabled"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
<xy id="862d9" binding="mySpecialBoxPanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
@@ -254,6 +181,75 @@
<border type="none"/>
<children/>
</xy>
<grid id="d7b0a" binding="myDependsOnPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value=""/>
</clientProperties>
<border type="empty"/>
<children>
<grid id="4241e" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="5"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="9b21c" binding="myDependentBreakpointComboPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="15" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="7f1f0" class="javax.swing.JLabel" binding="myEnableOrDisableLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.dependency.type.lable"/>
</properties>
</component>
<component id="e3baf" class="javax.swing.JRadioButton" binding="myDisableAgainRadio" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.depends.disable.again"/>
</properties>
</component>
<component id="10e41" class="javax.swing.JRadioButton" binding="myLeaveEnabledRadioButton" default-binding="true">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.depends.leave.enabled"/>
</properties>
</component>
<component id="f3672" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/XDebuggerBundle" key="xbreakpoint.master.breakpoint.description"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<vspacer id="21184">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<grid id="d03f5" binding="myConditionsPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="7">
@@ -413,6 +409,11 @@
</grid>
</children>
</grid>
<vspacer id="62b02">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<buttonGroups>
@@ -20,7 +20,6 @@
*/
package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.InstanceFilter;
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
@@ -44,12 +43,13 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.ui.FieldPanel;
import com.intellij.ui.MultiLineTooltipUI;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.popup.util.DetailView;
import com.intellij.util.IJSwingUtilities;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointChooser;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointNoneItem;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -390,102 +390,19 @@ public abstract class BreakpointPropertiesPanel {
private List<BreakpointItem> getBreakpointItemsExceptMy() {
List<BreakpointItem> items = new ArrayList<BreakpointItem>();
findJavaDebuggerSupport().getBreakpointPanelProvider().provideBreakpointItems(myProject, items);
final DebuggerSupport support = DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class);
support.getBreakpointPanelProvider().provideBreakpointItems(myProject, items);
for (BreakpointItem item : items) {
if (item.getBreakpoint() == myBreakpoint) {
items.remove(item);
break;
}
}
items.add(new BreakpointItem() {
@Override
public Object getBreakpoint() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isEnabled() {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void setEnabled(boolean state) {
//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();
renderer.append(getDisplayText());
}
@Override
public Icon getIcon() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String getDisplayText() {
return DebuggerBundle.message("value.none");
}
@Override
public boolean navigate() {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String speedSearchText() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String footerText() {
return "";
}
@Override
protected void doUpdateDetailView(DetailView panel, boolean editorOnly) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean allowedToRemove() {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void removed(Project project) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public int compareTo(BreakpointItem breakpointItem) {
return 1;
}
});
items.add(new BreakpointNoneItem());
return items;
}
private DebuggerSupport findJavaDebuggerSupport() {
DebuggerSupport[] supports = DebuggerSupport.getDebuggerSupports();
DebuggerSupport support = null;
for (DebuggerSupport s : supports) {
if (s instanceof JavaDebuggerSupport) {
support = s;
}
}
return support;
}
private void saveMasterBreakpoint() {
Breakpoint masterBreakpoint = (Breakpoint)myMasterBreakpointChooser.getSelectedBreakpoint();
if (masterBreakpoint == null) {
getBreakpointManager(myProject).removeBreakpointRule(myBreakpoint);
@@ -84,10 +84,10 @@ class JavaBreakpointItem extends BreakpointItem {
breakpointPropertiesPanel.setDetailView(panel);
final JPanel mainPanel = breakpointPropertiesPanel.getPanel();
panel.setDetailPanel(mainPanel);
panel.setPropertiesPanel(mainPanel);
}
else {
panel.setDetailPanel(null);
panel.setPropertiesPanel(null);
}
}