generic debugger settings: step 2 — stepping — transform Groovy, all Stepping configurable on one page

This commit is contained in:
Vladimir Krivosheev
2014-07-22 12:41:36 +02:00
parent e46729f070
commit 6608b52da6
19 changed files with 299 additions and 68 deletions
@@ -113,7 +113,7 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText
myTable.setTableHeader(null);
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
myTable.setColumnSelectionAllowed(false);
myTable.setPreferredScrollableViewportSize(new Dimension(200, 100));
myTable.setPreferredScrollableViewportSize(new Dimension(200, myTable.getRowHeight() * JBTable.PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS));
TableColumnModel columnModel = myTable.getColumnModel();
TableColumn column = columnModel.getColumn(FilterTableModel.CHECK_MARK);
@@ -38,6 +38,8 @@ import java.util.Comparator;
import java.util.EventObject;
public class JBTable extends JTable implements ComponentWithEmptyText, ComponentWithExpandableItems<TableCell> {
public static final int PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS = 7;
private final StatusText myEmptyText;
private final ExpandableItemsHandler<TableCell> myExpandableItemsHandler;
@@ -0,0 +1,52 @@
package com.intellij.openapi.options;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public abstract class ConfigurableBase<UI extends ConfigurableUi<S>, S> implements SearchableConfigurable, Configurable.NoScroll {
private UI ui;
@Nullable
@Override
public Runnable enableSearch(String option) {
return null;
}
protected abstract S getSettings();
@Override
public void reset() {
if (ui != null) {
ui.reset(getSettings());
}
}
@Nullable
@Override
public final JComponent createComponent() {
if (ui == null) {
ui = createUi();
}
return ui.getComponent();
}
protected abstract UI createUi();
@Override
public final boolean isModified() {
return ui != null && ui.isModified(getSettings());
}
@Override
public final void apply() {
if (ui != null) {
ui.apply(getSettings());
}
}
@Override
public void disposeUIResources() {
ui = null;
}
}
@@ -0,0 +1,16 @@
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public interface ConfigurableUi<S> {
void reset(@NotNull S settings);
boolean isModified(@NotNull S settings);
void apply(@NotNull S settings);
@NotNull
JComponent getComponent();
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.ui.table.TableView;
import com.intellij.util.Function;
import com.intellij.util.FunctionUtil;
@@ -42,6 +43,7 @@ import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import java.awt.*;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
@@ -71,6 +73,8 @@ public class TableModelEditor<T> implements ElementProducer<T> {
table = new TableView<T>(model);
table.setDefaultEditor(Enum.class, ComboBoxTableCellEditor.INSTANCE);
table.setStriped(true);
table.setEnableAntialiasing(true);
preferredScrollableViewportHeightInRows(JBTable.PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS);
new TableSpeedSearch(table);
if (columns[0].getColumnClass() == Boolean.class && columns[0].getName().isEmpty()) {
TableUtil.setupCheckboxColumn(table.getColumnModel().getColumn(0));
@@ -97,6 +101,11 @@ public class TableModelEditor<T> implements ElementProducer<T> {
}
}
public TableModelEditor<T> preferredScrollableViewportHeightInRows(int rows) {
table.setPreferredScrollableViewportSize(new Dimension(200, table.getRowHeight() * rows));
return this;
}
private void addDialogActions() {
toolbarDecorator.setEditAction(new AnActionButtonRunnable() {
@Override
@@ -35,20 +35,11 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class XDebuggerSettings<T> implements PersistentStateComponent<T> {
public enum Category {
DATA_VIEWS(true), STEPPING(true);
private final boolean separatePage;
Category(boolean separatePage) {
this.separatePage = separatePage;
}
public boolean isSeparatePage() {
return separatePage;
}
ROOT, DATA_VIEWS, STEPPING;
}
public static final ExtensionPointName<XDebuggerSettings> EXTENSION_POINT = ExtensionPointName.create("com.intellij.xdebugger.settings");
private final String myId;
protected XDebuggerSettings(final @NotNull @NonNls String id) {
@@ -0,0 +1,88 @@
package com.intellij.xdebugger.impl.settings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
abstract class MergedCompositeConfigurable implements SearchableConfigurable {
protected final Configurable[] children;
protected JComponent rootComponent;
protected MergedCompositeConfigurable(@NotNull Configurable[] children) {
this.children = children;
}
@Nullable
@Override
public Runnable enableSearch(String option) {
return null;
}
@Nullable
@Override
public String getHelpTopic() {
return children.length == 1 ? children[0].getHelpTopic() : null;
}
@Nullable
@Override
public JComponent createComponent() {
if (rootComponent == null) {
if (children.length == 1) {
rootComponent = children[0].createComponent();
}
else {
JPanel panel = new JPanel(new VerticalFlowLayout(0, 0));
for (Configurable child : children) {
JComponent component = child.createComponent();
assert component != null;
component.setBorder(IdeBorderFactory.createTitledBorder(child.getDisplayName(), false));
panel.add(component);
}
rootComponent = panel;
}
}
return rootComponent;
}
@Override
public boolean isModified() {
for (Configurable child : children) {
if (child.isModified()) {
return true;
}
}
return false;
}
@Override
public void apply() throws ConfigurationException {
for (Configurable child : children) {
if (child.isModified()) {
child.apply();
}
}
}
@Override
public void reset() {
for (Configurable child : children) {
child.reset();
}
}
@Override
public void disposeUIResources() {
rootComponent = null;
for (Configurable child : children) {
child.disposeUIResources();
}
}
}
@@ -17,16 +17,14 @@ package com.intellij.xdebugger.impl.settings;
import com.intellij.openapi.options.Configurable;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.settings.XDebuggerSettings;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.List;
class SteppingConfigurable extends SubCompositeConfigurable implements Configurable.NoScroll {
class SteppingConfigurable extends MergedCompositeConfigurable {
public SteppingConfigurable(@NotNull List<Configurable> configurables) {
assert !configurables.isEmpty();
children = configurables.toArray(new Configurable[configurables.size()]);
super(configurables.toArray(new Configurable[configurables.size()]));
}
@NotNull
@@ -40,15 +38,4 @@ class SteppingConfigurable extends SubCompositeConfigurable implements Configura
public String getDisplayName() {
return XDebuggerBundle.message("debugger.stepping.display.name");
}
@Override
protected DataViewsConfigurableUi createRootUi() {
return null;
}
@NotNull
@Override
protected XDebuggerSettings.Category getCategory() {
return XDebuggerSettings.Category.STEPPING;
}
}
@@ -35,7 +35,7 @@ abstract class SubCompositeConfigurable implements SearchableConfigurable.Parent
@Override
public boolean hasOwnContent() {
return getCategory() != XDebuggerSettings.Category.STEPPING;
return true;
}
@Override
@@ -80,7 +80,7 @@ abstract class SubCompositeConfigurable implements SearchableConfigurable.Parent
protected abstract XDebuggerSettings.Category getCategory();
private boolean isChildrenMerged() {
return children != null && (!getCategory().isSeparatePage() || children.length == 1);
return children != null && children.length == 1;
}
@Override
@@ -16,7 +16,6 @@
package com.intellij.xdebugger.impl.settings;
import com.intellij.openapi.components.*;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
import com.intellij.util.xmlb.XmlSerializer;
import com.intellij.util.xmlb.annotations.AbstractCollection;
@@ -102,9 +101,10 @@ public class XDebuggerSettingsManager extends com.intellij.xdebugger.settings.XD
private void initSettings() {
if (mySettingsById == null) {
mySettingsById = new HashMap<String, XDebuggerSettings<?>>();
mySettingsByClass = new HashMap<Class<? extends XDebuggerSettings>, XDebuggerSettings<?>>();
for (XDebuggerSettings settings : Extensions.getExtensions(XDebuggerSettings.EXTENSION_POINT)) {
XDebuggerSettings[] extensions = XDebuggerSettings.EXTENSION_POINT.getExtensions();
mySettingsById = new LinkedHashMap<String, XDebuggerSettings<?>>(extensions.length);
mySettingsByClass = new LinkedHashMap<Class<? extends XDebuggerSettings>, XDebuggerSettings<?>>(extensions.length);
for (XDebuggerSettings settings : extensions) {
mySettingsById.put(settings.getId(), settings);
mySettingsByClass.put(settings.getClass(), settings);
}
+2 -2
View File
@@ -445,13 +445,13 @@
<weigher key="proximity" implementationClass="org.jetbrains.plugins.groovy.lang.completion.weighers.GrReferenceListWeigher"
id="groovyReferenceListWeigher" order="before openedInEditor"/>
<debuggerClassFilterProvider implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerClassFilterProvider"/>
<debuggerClassFilterProvider implementation="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerClassFilterProvider"/>
<useScopeEnlarger implementation="org.jetbrains.plugins.groovy.lang.psi.impl.search.GrPrivateFieldScopeEnlarger"/>
<debuggerEditorTextProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.debugger.GroovyEditorTextProvider"/>
<xdebugger.settings implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings"/>
<xdebugger.settings implementation="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerSettings"/>
<langCodeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyLanguageCodeStyleSettingsProvider"/>
<codeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettingsProvider"/>
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.debugger.filters;
package org.jetbrains.plugins.groovy.debugger;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.ui.classFilter.DebuggerClassFilterProvider;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.debugger.filters;
package org.jetbrains.plugins.groovy.debugger;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.intellij.xdebugger.settings.XDebuggerSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author ilyas
@@ -35,7 +36,6 @@ import org.jetbrains.annotations.NotNull;
)}
)
public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSettings> {
public Boolean DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = true;
public boolean ENABLE_GROOVY_HOTSWAP = Registry.is("enable.groovy.hotswap");
@@ -49,6 +49,15 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett
return new GroovyDebuggerSettingsConfigurable(this);
}
@Nullable
@Override
public Configurable createConfigurable(@NotNull Category category) {
if (category == Category.STEPPING) {
return new GroovySteppingConfigurable();
}
return null;
}
@Override
public GroovyDebuggerSettings getState() {
return this;
@@ -62,5 +71,4 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett
public static GroovyDebuggerSettings getInstance() {
return getInstance(GroovyDebuggerSettings.class);
}
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettingsConfigurable">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerSettingsConfigurable">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" 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="20" y="20" width="661" height="400"/>
@@ -8,22 +8,14 @@
<properties/>
<border type="none"/>
<children>
<component id="84a2f" class="javax.swing.JCheckBox" binding="myIgnoreGroovyMethods">
<constraints>
<grid row="0" column="0" 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="org/jetbrains/plugins/groovy/GroovyBundle" key="groovy.debug.disable.specific.methods"/>
</properties>
</component>
<vspacer id="30909">
<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"/>
<grid row="2" 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>
<component id="908a2" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
@@ -33,7 +25,7 @@
<grid id="bd4f0" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="2" 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"/>
<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"/>
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.debugger.filters;
package org.jetbrains.plugins.groovy.debugger;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
@@ -29,7 +29,6 @@ import java.awt.event.ActionListener;
* @author ilyas
*/
public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurable {
private JCheckBox myIgnoreGroovyMethods;
private JPanel myPanel;
private JCheckBox myEnableHotSwap;
private boolean isModified = false;
@@ -37,19 +36,13 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl
public GroovyDebuggerSettingsConfigurable(final GroovyDebuggerSettings settings) {
mySettings = settings;
final Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS;
myIgnoreGroovyMethods.setSelected(flag == null || flag.booleanValue());
myIgnoreGroovyMethods.setSelected(mySettings.ENABLE_GROOVY_HOTSWAP);
ActionListener listener = new ActionListener() {
myEnableHotSwap.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
isModified = mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS.booleanValue() != myIgnoreGroovyMethods.isSelected() ||
mySettings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected();
isModified = mySettings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected();
}
};
myIgnoreGroovyMethods.addActionListener(listener);
myEnableHotSwap.addActionListener(listener);
});
}
@Override
@@ -59,6 +52,7 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl
}
@Override
@NotNull
public String getHelpTopic() {
return "reference.idesettings.debugger.groovy";
}
@@ -87,7 +81,6 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl
@Override
public void apply() throws ConfigurationException {
if (isModified) {
mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = myIgnoreGroovyMethods.isSelected();
mySettings.ENABLE_GROOVY_HOTSWAP = myEnableHotSwap.isSelected();
}
isModified = false;
@@ -95,8 +88,6 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl
@Override
public void reset() {
final Boolean flag = mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS;
myIgnoreGroovyMethods.setSelected(flag == null || flag.booleanValue());
myEnableHotSwap.setSelected(mySettings.ENABLE_GROOVY_HOTSWAP);
}
@@ -41,7 +41,6 @@ import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings;
import java.io.File;
import java.io.IOException;
@@ -0,0 +1,37 @@
package org.jetbrains.plugins.groovy.debugger;
import com.intellij.openapi.options.ConfigurableBase;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyBundle;
class GroovySteppingConfigurable extends ConfigurableBase<GroovySteppingConfigurableUi, GroovyDebuggerSettings> {
@Override
protected GroovyDebuggerSettings getSettings() {
return GroovyDebuggerSettings.getInstance();
}
@Override
protected GroovySteppingConfigurableUi createUi() {
return new GroovySteppingConfigurableUi();
}
@NotNull
@Override
public String getId() {
return "debugger.stepping.groovy";
}
@Nls
@Override
public String getDisplayName() {
return GroovyBundle.message("groovy.debug.caption");
}
@Nullable
@Override
public String getHelpTopic() {
return "reference.idesettings.debugger.groovy";
}
}
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovySteppingConfigurableUi">
<grid id="27dc6" binding="rootPanel" 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>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="821e8" class="javax.swing.JCheckBox" binding="ignoreGroovyMethods">
<constraints>
<grid row="0" column="0" 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="org/jetbrains/plugins/groovy/GroovyBundle" key="groovy.debug.disable.specific.methods"/>
</properties>
</component>
<vspacer id="209fe">
<constraints>
<grid row="1" 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>
</form>
@@ -0,0 +1,33 @@
package org.jetbrains.plugins.groovy.debugger;
import com.intellij.openapi.options.ConfigurableUi;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
class GroovySteppingConfigurableUi implements ConfigurableUi<GroovyDebuggerSettings> {
private JCheckBox ignoreGroovyMethods;
private JPanel rootPanel;
@Override
public void reset(@NotNull GroovyDebuggerSettings settings) {
Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS;
ignoreGroovyMethods.setSelected(flag == null || flag.booleanValue());
}
@Override
public boolean isModified(@NotNull GroovyDebuggerSettings settings) {
return settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS.booleanValue() != ignoreGroovyMethods.isSelected();
}
@Override
public void apply(@NotNull GroovyDebuggerSettings settings) {
settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = ignoreGroovyMethods.isSelected();
}
@NotNull
@Override
public JComponent getComponent() {
return rootPanel;
}
}