(no message)

This commit is contained in:
Eugene Zhuravlev
2005-02-28 14:48:26 +03:00
parent 8511419891
commit 766c0c819f
13 changed files with 375 additions and 140 deletions
@@ -9,6 +9,7 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
import com.intellij.debugger.settings.ArrayRendererConfigurable;
import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.project.Project;
@@ -112,5 +113,10 @@ public class AdjustArrayRangeAction extends DebuggerAction {
public String getHelpTopic() {
return null;
}
public void apply() {
super.apply();
NodeRendererSettings.getInstance().fireRenderersChanged();
}
}
}
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import javax.swing.*;
@@ -26,10 +27,15 @@ public class CustomizeContextViewAction extends DebuggerAction{
protected List<Configurable> createConfigurables() {
ArrayList<Configurable> array = new ArrayList<Configurable>();
array.add(new BaseRenderersConfigurable(project));
array.add(new NodeRendererConfigurable(project));
array.add(new UserRenderersConfigurable(project));
return array;
}
public void apply() throws ConfigurationException {
super.apply();
NodeRendererSettings.getInstance().fireRenderersChanged();
}
public String getDisplayName() {
return "Customize view";
}
@@ -16,7 +16,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.debugger.settings.AutoRendererNode;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.debugger.settings.ViewsGeneralSettings;
@@ -121,8 +121,6 @@ public class BaseRenderersConfigurable implements Configurable {
}
public void apply() {
final boolean renderersWereModified = areDefaultRenderersModified();
final ViewsGeneralSettings generalSettings = ViewsGeneralSettings.getInstance();
final NodeRendererSettings rendererSettings = NodeRendererSettings.getInstance();
@@ -142,10 +140,6 @@ public class BaseRenderersConfigurable implements Configurable {
toStringRenderer.setClassFilters(myToStringFilterEditor.getFilters());
myArrayRendererConfigurable.apply();
if (renderersWereModified) {
rendererSettings.fireRenderersChanged();
}
}
public void reset() {
@@ -211,7 +205,7 @@ public class BaseRenderersConfigurable implements Configurable {
final boolean isToStringRendererModified =
(toStringRenderer.isEnabled() != myCbEnableToString.isSelected()) ||
(toStringRenderer.isUseClassFilters() != myRbFromList.isSelected()) ||
(DebuggerUtilsEx.filterEquals(toStringRenderer.getClassFilters(), myToStringFilterEditor.getFilters()));
(!DebuggerUtilsEx.filterEquals(toStringRenderer.getClassFilters(), myToStringFilterEditor.getFilters()));
if (isToStringRendererModified) {
return true;
}
@@ -6,12 +6,15 @@ package com.intellij.debugger.settings;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.ui.DebuggerExpressionTextField;
import com.intellij.debugger.ui.tree.render.*;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiClass;
import com.intellij.ui.TableUtil;
import com.intellij.util.ui.AbstractTableCellEditor;
@@ -20,9 +23,14 @@ import com.intellij.util.ui.Table;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Eugene Zhuravlev
@@ -52,8 +60,8 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
private JButton myRemoveButton;
private JButton myUpButton;
private JButton myDownButton;
private static final String NAME_TABLE_COLUMN = "Name";
private static final String EXPRESSION_TABLE_COLUMN = "Expression";
private static final int NAME_TABLE_COLUMN = 0;
private static final int EXPRESSION_TABLE_COLUMN = 1;
public CompoundRendererConfigurable(Project project) {
myProject = project;
@@ -118,25 +126,24 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
myRbExpressionLabel.addItemListener(updateListener);
myRbListChildrenRenderer.addItemListener(updateListener);
myRbExpressionChildrenRenderer.addItemListener(updateListener);
myRbListChildrenRenderer.addItemListener(updateListener);
panel.add(new JLabel("Apply renderer to objects of type (fully-qualified name):"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
panel.add(myClassNameField, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 6), 0, 0));
panel.add(new JLabel("Apply renderer to objects of type (fully-qualified name):"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
panel.add(myClassNameField, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
panel.add(new JLabel("When rendering the node"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
panel.add(myRbDefaultLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
panel.add(myRbExpressionLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
panel.add(myLabelEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 6), 0, 0));
panel.add(myLabelEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0));
panel.add(new JLabel("When expanding the node"), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
panel.add(myRbDefaultChildrenRenderer, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
panel.add(myRbExpressionChildrenRenderer, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
panel.add(myChildrenEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 6), 0, 0));
panel.add(myChildrenEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0));
myExpandedLabel = new JLabel("Test if the node can be expanded (optional):");
panel.add(myExpandedLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 30, 0, 0), 0, 0));
panel.add(myChildrenExpandedEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 6), 0, 0));
panel.add(myChildrenExpandedEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 30, 0, 0), 0, 0));
panel.add(myRbListChildrenRenderer, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
panel.add(myChildrenListEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(4, 30, 0, 6), 0, 0));
panel.add(myChildrenListEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(4, 30, 0, 0), 0, 0));
myMainPanel = new JPanel(new CardLayout());
myMainPanel.add(new JPanel(), EMPTY_PANEL_ID);
@@ -159,22 +166,16 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
myChildrenExpandedEditor.setEnabled(isChildrenExpression);
myExpandedLabel.setEnabled(isChildrenExpression);
myChildrenEditor.setEnabled(isChildrenExpression);
myChildrenListEditor.setEnabled(myRbListChildrenRenderer.isSelected());
}
private JComponent createChildrenListEditor() {
final JPanel panel = new JPanel(new GridBagLayout());
myTable = new Table(new DefaultTableModel());
getModel().addColumn(NAME_TABLE_COLUMN, (Object[])null);
getModel().addColumn(EXPRESSION_TABLE_COLUMN, (Object[])null);
final MyTableModel tableModel = new MyTableModel();
myTable = new Table(tableModel);
myListChildrenEditor = new DebuggerExpressionTextField(myProject, null, "NamedChildrenConfigurable");
myTable.setDragEnabled(false);
myTable.setIntercellSpacing(new Dimension(0, 0));
myTable.getColumn(EXPRESSION_TABLE_COLUMN).setCellEditor(new AbstractTableCellEditor() {
final TableColumn exprColumn = myTable.getColumnModel().getColumn(EXPRESSION_TABLE_COLUMN);
exprColumn.setCellEditor(new AbstractTableCellEditor() {
public Object getCellEditorValue() {
return myListChildrenEditor.getText();
}
@@ -184,6 +185,13 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
return myListChildrenEditor;
}
});
exprColumn.setCellRenderer(new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final TextWithImports textWithImports = (TextWithImports)value;
String text = (textWithImports != null)? textWithImports.toString() : "";
return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
}
});
myAddButton = new JButton("Add");
myAddButton.setMnemonic('A');
@@ -196,7 +204,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
myAddButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
getModel().addRow(new Object[] {"", DebuggerUtils.getInstance().createExpressionWithImports("") });
tableModel.addRow("", DebuggerUtils.getInstance().createExpressionWithImports(""));
}
});
@@ -204,7 +212,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
public void actionPerformed(ActionEvent e) {
int selectedRow = myTable.getSelectedRow();
if(selectedRow >= 0 && selectedRow < myTable.getRowCount()) {
getModel().removeRow(selectedRow);
getTableModel().removeRow(selectedRow);
}
}
});
@@ -223,16 +231,29 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
updateButtons();
int selectedRow = myTable.getSelectedRow();
myRemoveButton.setEnabled(selectedRow != -1);
myUpButton.setEnabled(selectedRow > 0);
myDownButton.setEnabled(selectedRow < myTable.getRowCount() - 1);
}
});
final JPanel panel = new JPanel(new GridBagLayout()) {
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
myTable.setEnabled(enabled);
myAddButton.setEnabled(enabled);
myRemoveButton.setEnabled(enabled);
myUpButton.setEnabled(enabled);
myDownButton.setEnabled(enabled);
}
};
final JScrollPane scrollPane = new JScrollPane(myTable);
panel.add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 4, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
panel.add(myAddButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 4, 0, 0), 0, 0));
panel.add(myRemoveButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 4, 0, 0), 0, 0));
panel.add(myUpButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 4, 0, 0), 0, 0));
panel.add(myDownButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 4, 0, 0), 0, 0));
panel.add(myAddButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 4, 0), 0, 0));
panel.add(myRemoveButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 4, 0), 0, 0));
panel.add(myUpButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 4, 0), 0, 0));
panel.add(myDownButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 4, 0), 0, 0));
return panel;
}
@@ -241,14 +262,40 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
if (myRenderer == null) {
return false;
}
return !myOriginalRenderer.equals(myRenderer);
final CompoundReferenceRenderer cloned = (CompoundReferenceRenderer)myRenderer.clone();
flushDataTo(cloned);
return !DebuggerUtilsEx.externalizableEqual(cloned, myOriginalRenderer);
}
public void apply() throws ConfigurationException {
if (myRenderer == null) {
return;
}
flushDataTo(myRenderer);
// update the renderer to compare with in order to find out whether we've been modified since last apply
myOriginalRenderer = (CompoundReferenceRenderer)myRenderer.clone();
}
private void flushDataTo(final CompoundReferenceRenderer renderer) { // label
LabelRenderer labelRenderer = null;
if (myRbExpressionLabel.isSelected()) {
labelRenderer = new LabelRenderer();
labelRenderer.setLabelExpression(myLabelEditor.getText());
}
renderer.setLabelRenderer(labelRenderer);
// children
ChildrenRenderer childrenRenderer = null;
if (myRbExpressionChildrenRenderer.isSelected()) {
childrenRenderer = new ExpressionChildrenRenderer();
((ExpressionChildrenRenderer)childrenRenderer).setChildrenExpression(myChildrenEditor.getText());
((ExpressionChildrenRenderer)childrenRenderer).setChildrenExpandable(myChildrenExpandedEditor.getText());
}
else if (myRbListChildrenRenderer.isSelected()) {
childrenRenderer = new EnumerationChildrenRenderer(getTableModel().getExpressions());
}
renderer.setChildrenRenderer(childrenRenderer);
// classname
renderer.setClassName(myClassNameField.getText());
}
public void reset() {
@@ -264,6 +311,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
if (rendererSettings.isBase(labelRenderer)) {
myRbDefaultLabel.setSelected(true);
myLabelEditor.setText(TextWithImportsImpl.EMPTY);
}
else {
myRbExpressionLabel.setSelected(true);
@@ -272,17 +320,27 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
if (rendererSettings.isBase(childrenRenderer)) {
myRbDefaultChildrenRenderer.setSelected(true);
myChildrenEditor.setText(TextWithImportsImpl.EMPTY);
myChildrenExpandedEditor.setText(TextWithImportsImpl.EMPTY);
getTableModel().clear();
}
else if (childrenRenderer instanceof ExpressionChildrenRenderer) {
myRbExpressionChildrenRenderer.setSelected(true);
final ExpressionChildrenRenderer exprRenderer = (ExpressionChildrenRenderer)childrenRenderer;
myChildrenEditor.setText(exprRenderer.getChildrenExpression());
myChildrenExpandedEditor.setText(exprRenderer.getChildrenExpandable());
getTableModel().clear();
}
else {
myRbListChildrenRenderer.setSelected(true);
// todo
//myChildrenListEditor.
myChildrenEditor.setText(TextWithImportsImpl.EMPTY);
myChildrenExpandedEditor.setText(TextWithImportsImpl.EMPTY);
if (childrenRenderer instanceof EnumerationChildrenRenderer) {
getTableModel().init(((EnumerationChildrenRenderer)childrenRenderer).getChildren());
}
else {
getTableModel().clear();
}
}
updateEnabledState();
@@ -292,15 +350,130 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
public void disposeUIResources() {
}
private DefaultTableModel getModel() {
return ((DefaultTableModel)myTable.getModel());
private MyTableModel getTableModel() {
return (MyTableModel)myTable.getModel();
}
private void updateButtons() {
int selectedRow = myTable.getSelectedRow();
myRemoveButton.setEnabled(selectedRow != -1);
myUpButton.setEnabled(selectedRow > 0);
myDownButton.setEnabled(selectedRow < myTable.getRowCount() - 1);
}
private final static class MyTableModel extends AbstractTableModel {
private final java.util.List<Row> myData = new ArrayList<Row>();
public MyTableModel(java.util.List<Pair<String, TextWithImports>> data) {
init(data);
}
public MyTableModel() {
}
public void init(java.util.List<Pair<String, TextWithImports>> data) {
myData.clear();
for (Iterator<Pair<String, TextWithImports>> it = data.iterator(); it.hasNext();) {
final Pair<String, TextWithImports> pair = it.next();
myData.add(new Row(pair.getFirst(), pair.getSecond()));
}
}
public int getColumnCount() {
return 2;
}
public int getRowCount() {
return myData.size();
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
public Class getColumnClass(int columnIndex) {
switch (columnIndex) {
case NAME_TABLE_COLUMN: return String.class;
case EXPRESSION_TABLE_COLUMN: return TextWithImports.class;
default: return super.getColumnClass(columnIndex);
}
}
public Object getValueAt(int rowIndex, int columnIndex) {
if (rowIndex >= getRowCount()) {
return null;
}
final Row row = myData.get(rowIndex);
switch (columnIndex) {
case NAME_TABLE_COLUMN: return row.name;
case EXPRESSION_TABLE_COLUMN: return row.value;
default: return null;
}
}
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (rowIndex >= getRowCount()) {
return;
}
final Row row = myData.get(rowIndex);
switch (columnIndex) {
case NAME_TABLE_COLUMN:
row.name = (String)aValue;
break;
case EXPRESSION_TABLE_COLUMN:
row.value = (TextWithImports)aValue;
break;
}
}
public String getColumnName(int columnIndex) {
switch (columnIndex) {
case NAME_TABLE_COLUMN: return "Name";
case EXPRESSION_TABLE_COLUMN: return "Expression";
default: return "";
}
}
public void addRow(final String name, final TextWithImports expressionWithImports) {
myData.add(new Row(name, expressionWithImports));
final int lastRow = myData.size() - 1;
fireTableRowsInserted(lastRow, lastRow);
}
public void removeRow(final int row) {
if (row >= 0 && row < myData.size()) {
myData.remove(row);
fireTableRowsDeleted(row, row);
}
}
public String getNameAt(int row) {
return (row >= 0 && row < myData.size())? myData.get(row).name : null;
}
public TextWithImports getExpressionAt(int row) {
return (row >= 0 && row < myData.size())? myData.get(row).value : null;
}
public void clear() {
myData.clear();
fireTableDataChanged();
}
public List<Pair<String, TextWithImports>> getExpressions() {
final ArrayList<Pair<String, TextWithImports>> pairs = new ArrayList<Pair<String, TextWithImports>>(myData.size());
for (Iterator<Row> it = myData.iterator(); it.hasNext();) {
final Row row = it.next();
pairs.add(new Pair<String, TextWithImports>(row.name, row.value));
}
return pairs;
}
private static final class Row {
public String name;
public TextWithImports value;
public Row(final String name, final TextWithImports value) {
this.name = name;
this.value = value;
}
public Row() {
this("", TextWithImportsImpl.EMPTY);
}
}
}
}
@@ -4,6 +4,7 @@ import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.BaseConfigurable;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
@@ -51,8 +52,12 @@ public class DebuggerConfigurable extends CompositeConfigurable implements Appli
project = ProjectManager.getInstance().getDefaultProject();
}
configurables.add(new DebuggerGeneralConfigurable(project));
configurables.add(new NodeRendererConfigurable(project));
//configurables.add(new UserRenderersConfigurable(project));
configurables.add(new UserRenderersConfigurable(project));
return configurables;
}
public void apply() throws ConfigurationException {
super.apply();
NodeRendererSettings.getInstance().fireRenderersChanged();
}
}
@@ -17,6 +17,7 @@ import org.jdom.Element;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
/**
* User: lex
@@ -30,7 +31,7 @@ public class NodeRendererSettings implements ApplicationComponent, NamedJDOMExte
private static final String RENDERER_ID = "ID";
private final EventDispatcher<NodeRendererSettingsListener> myDispatcher = EventDispatcher.create(NodeRendererSettingsListener.class);
private RendererConfiguration myRendererConfiguration = new RendererConfiguration(this);
private RendererConfiguration myCustomRenderers = new RendererConfiguration(this);
// base renderers
private final PrimitiveRenderer myPrimitiveRenderer = new PrimitiveRenderer();
@@ -58,6 +59,7 @@ public class NodeRendererSettings implements ApplicationComponent, NamedJDOMExte
};
private static final String HEX_VIEW_ENABLED = "HEX_VIEW_ENABLED";
private static final String ALTERNATIVE_COLLECTION_VIEW_ENABLED = "ALTERNATIVE_COLLECTION_VIEW_ENABLED";
private static final String CUSTOM_RENDERERS_TAG_NAME = "CustomRenderers";
public NodeRendererSettings() {
// default configuration
@@ -110,11 +112,16 @@ public class NodeRendererSettings implements ApplicationComponent, NamedJDOMExte
public void writeExternal(final Element element) throws WriteExternalException {
JDOMExternalizerUtil.writeField(element, HEX_VIEW_ENABLED, myHexRenderer.isEnabled()? "true" : "false");
JDOMExternalizerUtil.writeField(element, ALTERNATIVE_COLLECTION_VIEW_ENABLED, areAlternateCollectionViewsEnabled()? "true" : "false");
myRendererConfiguration.writeExternal(element);
element.addContent(writeRenderer(myArrayRenderer));
element.addContent(writeRenderer(myToStringRenderer));
if (myCustomRenderers.getRendererCount() > 0) {
final Element custom = new Element(CUSTOM_RENDERERS_TAG_NAME);
element.addContent(custom);
myCustomRenderers.writeExternal(custom);
}
}
public void readExternal(final Element root) {
public void readExternal(final Element root) throws InvalidDataException {
final String hexEnabled = JDOMExternalizerUtil.readField(root, HEX_VIEW_ENABLED);
if (hexEnabled != null) {
myHexRenderer.setEnabled("true".equalsIgnoreCase(hexEnabled));
@@ -125,20 +132,37 @@ public class NodeRendererSettings implements ApplicationComponent, NamedJDOMExte
setAlternateCollectionViewsEnabled("true".equalsIgnoreCase(alternativeEnabled));
}
myRendererConfiguration.readExternal(root);
final List rendererElements = root.getChildren(RENDERER_TAG);
for (Iterator it = rendererElements.iterator(); it.hasNext();) {
final Element elem = (Element)it.next();
final String id = elem.getAttributeValue(RENDERER_ID);
if (id == null) {
continue;
}
if (ArrayRenderer.UNIQUE_ID.equals(id)) {
myArrayRenderer.readExternal(elem);
}
else if (ToStringRenderer.UNIQUE_ID.equals(id)) {
myToStringRenderer.readExternal(elem);
}
}
final Element custom = root.getChild(CUSTOM_RENDERERS_TAG_NAME);
if (custom != null) {
myCustomRenderers.readExternal(custom);
}
myDispatcher.getMulticaster().renderersChanged();
}
public RendererConfiguration getRendererConfiguration() {
return myRendererConfiguration;
public RendererConfiguration getCustomRenderers() {
return myCustomRenderers;
}
public void setRendererConfiguration(final RendererConfiguration rendererConfiguration) {
LOG.assertTrue(rendererConfiguration != null);
RendererConfiguration oldConfig = myRendererConfiguration;
myRendererConfiguration = rendererConfiguration;
if (oldConfig == null || !oldConfig.equals(rendererConfiguration)) {
public void setCustomRenderers(final RendererConfiguration customRenderers) {
LOG.assertTrue(customRenderers != null);
RendererConfiguration oldConfig = myCustomRenderers;
myCustomRenderers = customRenderers;
if (oldConfig == null || !oldConfig.equals(customRenderers)) {
fireRenderersChanged();
}
}
@@ -176,9 +200,9 @@ public class NodeRendererSettings implements ApplicationComponent, NamedJDOMExte
final List<NodeRenderer> allRenderers = new ArrayList<NodeRenderer>();
allRenderers.add(myHexRenderer);
allRenderers.add(myPrimitiveRenderer);
myRendererConfiguration.iterateRenderers(new InternalIterator<AutoRendererNode>() {
public boolean visit(final AutoRendererNode element) {
allRenderers.add(element.getRenderer());
myCustomRenderers.iterateRenderers(new InternalIterator<NodeRenderer>() {
public boolean visit(final NodeRenderer renderer) {
allRenderers.add(renderer);
return true;
}
});
@@ -1,8 +1,7 @@
package com.intellij.debugger.settings;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.ui.tree.render.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.debugger.ui.tree.render.NodeRenderer;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
@@ -15,11 +14,10 @@ import java.util.List;
public class RendererConfiguration implements Cloneable, JDOMExternalizable {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.settings.NodeRendererSettings");
private static final String AUTO_NODE = "node";
private static final int VERSION = 6;
private static final int VERSION = 8;
private List<AutoRendererNode> myRepresentationNodes = new ArrayList<AutoRendererNode>();
private List<NodeRenderer> myRepresentationNodes = new ArrayList<NodeRenderer>();
private final NodeRendererSettings myRendererSettings;
protected RendererConfiguration(NodeRendererSettings rendererSettings) {
@@ -34,10 +32,9 @@ public class RendererConfiguration implements Cloneable, JDOMExternalizable {
catch (CloneNotSupportedException e) {
LOG.error(e);
}
result.myRepresentationNodes = new ArrayList<AutoRendererNode>();
for (Iterator<AutoRendererNode> iterator = myRepresentationNodes.iterator(); iterator.hasNext();) {
AutoRendererNode autoRendererNode = iterator.next();
result.addNode(autoRendererNode.clone());
result.myRepresentationNodes = new ArrayList<NodeRenderer>();
for (Iterator<NodeRenderer> iterator = myRepresentationNodes.iterator(); iterator.hasNext();) {
result.addRenderer((NodeRenderer)iterator.next().clone());
}
return result;
@@ -50,11 +47,9 @@ public class RendererConfiguration implements Cloneable, JDOMExternalizable {
}
public void writeExternal(final Element element) throws WriteExternalException {
for (Iterator<AutoRendererNode> iterator = myRepresentationNodes.iterator(); iterator.hasNext();) {
AutoRendererNode autoRendererNode = iterator.next();
Element nodeElement = new Element(AUTO_NODE);
autoRendererNode.writeExternal(nodeElement);
element.addContent(nodeElement);
for (Iterator<NodeRenderer> iterator = myRepresentationNodes.iterator(); iterator.hasNext();) {
NodeRenderer renderer = iterator.next();
element.addContent(myRendererSettings.writeRenderer(renderer));
}
element.setAttribute("VERSION", String.valueOf(VERSION));
}
@@ -74,51 +69,36 @@ public class RendererConfiguration implements Cloneable, JDOMExternalizable {
return;
}
List<Element> children = root.getChildren(AUTO_NODE);
List<Element> children = root.getChildren(NodeRendererSettings.RENDERER_TAG);
myRepresentationNodes.clear();
for (Iterator<Element> iterator = children.iterator(); iterator.hasNext();) {
Element nodeRepresentation = iterator.next();
Element nodeElement = iterator.next();
try {
addNode(AutoRendererNode.read(nodeRepresentation, myRendererSettings));
} catch (Exception e) {
addRenderer((NodeRenderer)myRendererSettings.readRenderer(nodeElement));
}
catch (Exception e) {
LOG.debug(e);
}
}
}
private void addNode(AutoRendererNode nodeRepresentation) {
LOG.assertTrue(nodeRepresentation != null);
myRepresentationNodes.add(nodeRepresentation);
}
public void addRenderer(NodeRenderer renderer) {
addNode(new AutoRendererNode(renderer));
myRepresentationNodes.add(renderer);
}
public void removeRenderer(NodeRenderer renderer) {
myRepresentationNodes.remove(renderer);
}
public List<AutoRendererNode> getAutoNodes() {
List<AutoRendererNode> result = new ArrayList<AutoRendererNode>();
for (Iterator<AutoRendererNode> iterator = myRepresentationNodes.iterator(); iterator.hasNext();) {
AutoRendererNode autoRendererNode = iterator.next();
result.add(autoRendererNode);
}
return result;
public void removeAllRenderers() {
myRepresentationNodes.clear();
}
public void setAutoNodes(List<AutoRendererNode> nodes) {
myRepresentationNodes = nodes;
}
public void iterateRenderers(InternalIterator<AutoRendererNode> iterator) {
for (Iterator<AutoRendererNode> it = myRepresentationNodes.iterator(); it.hasNext();) {
AutoRendererNode autoRendererNode = it.next();
final boolean shouldContinue = iterator.visit(autoRendererNode);
public void iterateRenderers(InternalIterator<NodeRenderer> iterator) {
for (Iterator<NodeRenderer> it = myRepresentationNodes.iterator(); it.hasNext();) {
final NodeRenderer renderer = it.next();
final boolean shouldContinue = iterator.visit(renderer);
if (!shouldContinue) {
break;
}
@@ -63,16 +63,16 @@ public class UserRenderersConfigurable implements Configurable{
final JComponent toolbar = createToolbar();
final JComponent rendererDataPanel = myRendererDataConfigurable.createComponent();
panel.add(toolbar, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 0, 4), 0, 0));
panel.add(renderersList, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(4, 0, 0, 0), 0, 0));
panel.add(toolbar, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
panel.add(renderersList, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 0, 0, 0), 0, 0));
myNameField = new JTextField();
final JPanel nameFieldPanel = new JPanel(new BorderLayout());
nameFieldPanel.add(new JLabel("Renderer name:"), BorderLayout.WEST);
nameFieldPanel.add(myNameField, BorderLayout.CENTER);
panel.add(nameFieldPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
panel.add(nameFieldPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 6), 0, 0));
panel.add(rendererDataPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
panel.add(rendererDataPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 6, 10, 6), 0, 0));
myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
@@ -147,36 +147,39 @@ public class UserRenderersConfigurable implements Configurable{
}
public void apply() throws ConfigurationException {
myRendererDataConfigurable.apply();
flushTo(NodeRendererSettings.getInstance().getCustomRenderers());
}
private void flushTo(final RendererConfiguration rendererConfiguration) {
rendererConfiguration.removeAllRenderers();
final int count = myRendererChooser.getElementCount();
for (int idx = 0; idx < count; idx++) {
rendererConfiguration.addRenderer(myRendererChooser.getElementAt(idx));
}
}
public boolean isModified() {
final RendererConfiguration rendererConfiguration = NodeRendererSettings.getInstance().getRendererConfiguration();
if (myRendererChooser.getElementCount() != rendererConfiguration.getRendererCount()) {
return true;
}
if (myRendererDataConfigurable.isModified()) {
return true;
}
final boolean[] modified = new boolean[] {false};
rendererConfiguration.iterateRenderers(new InternalIterator<AutoRendererNode>() {
int rendererIndex = 0;
public boolean visit(final AutoRendererNode autoNode) {
final NodeRenderer originalRenderer = autoNode.getRenderer();
final NodeRenderer editedRenderer = myRendererChooser.getElementAt(rendererIndex++);
modified[0] = !originalRenderer.equals(editedRenderer);
return !modified[0];
}
});
return modified[0];
final NodeRendererSettings settings = NodeRendererSettings.getInstance();
final RendererConfiguration rendererConfiguration = settings.getCustomRenderers();
if (myRendererChooser.getElementCount() != rendererConfiguration.getRendererCount()) {
return true;
}
final RendererConfiguration uiConfiguration = new RendererConfiguration(settings);
flushTo(uiConfiguration);
return !uiConfiguration.equals(rendererConfiguration);
}
public void reset() {
myRendererChooser.removeAllElements();
final RendererConfiguration rendererConfiguration = NodeRendererSettings.getInstance().getRendererConfiguration();
final RendererConfiguration rendererConfiguration = NodeRendererSettings.getInstance().getCustomRenderers();
final ArrayList<NodeRenderer> elementsToSelect = new ArrayList<NodeRenderer>(1);
rendererConfiguration.iterateRenderers(new InternalIterator<AutoRendererNode>() {
public boolean visit(final AutoRendererNode autoNode) {
final NodeRenderer clonedRenderer = (NodeRenderer)autoNode.getRenderer().clone();
rendererConfiguration.iterateRenderers(new InternalIterator<NodeRenderer>() {
public boolean visit(final NodeRenderer renderer) {
final NodeRenderer clonedRenderer = (NodeRenderer)renderer.clone();
myRendererChooser.addElement(clonedRenderer, clonedRenderer.isEnabled());
if (elementsToSelect.size() == 0) {
elementsToSelect.add(clonedRenderer);
@@ -201,7 +204,13 @@ public class UserRenderersConfigurable implements Configurable{
public void actionPerformed(AnActionEvent e) {
final NodeRenderer renderer = (NodeRenderer)NodeRendererSettings.getInstance().createRenderer(CompoundNodeRenderer.UNIQUE_ID);
myRendererChooser.addElement(renderer, true);
renderer.setEnabled(true);
myRendererChooser.addElement(renderer, renderer.isEnabled());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
myNameField.requestFocus();
}
});
}
}
@@ -42,7 +42,7 @@ public class DebuggerExpressionTextField extends DebuggerEditorImpl {
}
public TextWithImportsImpl createText(String text, String importsString) {
return new TextWithImportsImpl(TextWithImportsImpl.CODE_BLOCK_FACTORY, text, importsString);
return new TextWithImportsImpl(TextWithImportsImpl.EXPRESSION_FACTORY, text, importsString);
}
public void setEnabled(boolean enabled) {
@@ -4,6 +4,7 @@ import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.openapi.project.Project;
@@ -26,7 +27,7 @@ public abstract class CachedEvaluator {
protected PsiExpression myPsiChildrenExpression;
};
SoftReference<Cache> myCache = new SoftReference<Cache>(null);
private TextWithImports myReferenceExpression = DebuggerUtils.getInstance().createExpressionWithImports("");
private TextWithImports myReferenceExpression = TextWithImportsImpl.EMPTY;
protected abstract String getClassName();
@@ -14,6 +14,7 @@ import com.sun.jdi.Type;
import com.sun.jdi.Value;
import org.jdom.Element;
import java.util.Iterator;
import java.util.List;
/*
@@ -84,16 +85,35 @@ public class CompoundNodeRenderer extends NodeRendererImpl{
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
final List<Element> children = element.getChildren(NodeRendererSettings.RENDERER_TAG);
myLabelRenderer = (ValueLabelRenderer) myRendererSettings.readRenderer(children.get(0));
myChildrenRenderer = (ChildrenRenderer) myRendererSettings.readRenderer(children.get(1));
final List children = element.getChildren(NodeRendererSettings.RENDERER_TAG);
if (children != null) {
for (Iterator it = children.iterator(); it.hasNext();) {
final Element elem = (Element)it.next();
final String role = elem.getAttributeValue("role");
if (role == null) {
continue;
}
if ("label".equals(role)) {
myLabelRenderer = (ValueLabelRenderer)myRendererSettings.readRenderer(elem);
}
else if ("children".equals(role)) {
myChildrenRenderer = (ChildrenRenderer)myRendererSettings.readRenderer(elem);
}
}
}
}
public void writeExternal(Element element) throws WriteExternalException {
super.writeExternal(element);
final Element labelRendererElement = myRendererSettings.writeRenderer(myLabelRenderer);
element.addContent(labelRendererElement);
final Element childrenRendererElement = myRendererSettings.writeRenderer(myChildrenRenderer);
element.addContent(childrenRendererElement);
if (myLabelRenderer != null) {
final Element labelRendererElement = myRendererSettings.writeRenderer(myLabelRenderer);
labelRendererElement.setAttribute("role", "label");
element.addContent(labelRendererElement);
}
if (myChildrenRenderer != null) {
final Element childrenRendererElement = myRendererSettings.writeRenderer(myChildrenRenderer);
childrenRendererElement.setAttribute("role", "children");
element.addContent(childrenRendererElement);
}
}
}
@@ -19,11 +19,25 @@ public class CompoundReferenceRenderer extends CompoundNodeRenderer{
}
public void setLabelRenderer(ValueLabelRenderer labelRenderer) {
final ValueLabelRenderer prevRenderer = getLabelRenderer();
super.setLabelRenderer(myRendererSettings.isBase(labelRenderer) ? null : labelRenderer);
final ValueLabelRenderer currentRenderer = getLabelRenderer();
if (prevRenderer != currentRenderer) {
if (currentRenderer instanceof ReferenceRenderer) {
((ReferenceRenderer)currentRenderer).setClassName(getClassName());
}
}
}
public void setChildrenRenderer(ChildrenRenderer childrenRenderer) {
final ChildrenRenderer prevRenderer = getChildrenRenderer();
super.setChildrenRenderer(myRendererSettings.isBase(childrenRenderer) ? null : childrenRenderer);
final ChildrenRenderer currentRenderer = getChildrenRenderer();
if (prevRenderer != currentRenderer) {
if (currentRenderer instanceof ReferenceRenderer) {
((ReferenceRenderer)currentRenderer).setClassName(getClassName());
}
}
}
public ChildrenRenderer getChildrenRenderer() {
@@ -52,11 +66,15 @@ public class CompoundReferenceRenderer extends CompoundNodeRenderer{
LOG.assertTrue(name != null);
myProperties.setClassName(name);
if(getRawLabelRenderer() != null) {
((ReferenceRenderer)myLabelRenderer).setClassName(name);
if (myLabelRenderer instanceof ReferenceRenderer) {
((ReferenceRenderer)myLabelRenderer).setClassName(name);
}
}
if(getRawChildrenRenderer() != null) {
((ReferenceRenderer)myChildrenRenderer).setClassName(name);
if (myChildrenRenderer instanceof ReferenceRenderer) {
((ReferenceRenderer)myChildrenRenderer).setClassName(name);
}
}
}