src/share/classes/sun/tools/jconsole/inspector/XOpenTypeViewer.java
Print this page
rev 5340 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: duke
*** 26,75 ****
package sun.tools.jconsole.inspector;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
- import javax.swing.tree.*;
- import javax.swing.border.*;
import java.awt.BorderLayout;
- import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.Component;
- import java.awt.EventQueue;
import java.awt.Color;
import java.awt.Font;
- import java.awt.Rectangle;
import java.awt.event.*;
- import java.awt.Insets;
import java.awt.Dimension;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
import java.util.*;
- import java.io.*;
import java.lang.reflect.Array;
- import javax.management.*;
import javax.management.openmbean.*;
- import sun.tools.jconsole.BorderedComponent;
import sun.tools.jconsole.JConsole;
- import sun.tools.jconsole.LabeledComponent;
import sun.tools.jconsole.Resources;
! import sun.tools.jconsole.VariableGridLayout;
@SuppressWarnings("serial")
public class XOpenTypeViewer extends JPanel implements ActionListener {
JButton prev, incr, decr, tabularPrev, tabularNext;
JLabel compositeLabel, tabularLabel;
JScrollPane container;
XOpenTypeData current;
XOpenTypeDataListener listener = new XOpenTypeDataListener();
private static final String compositeNavigationSingle =
! Resources.getText("MBeansTab.compositeNavigationSingle");
private static final String tabularNavigationSingle =
! Resources.getText("MBeansTab.tabularNavigationSingle");
private static TableCellEditor editor =
new Utils.ReadOnlyTableCellEditor(new JTextField());
class XOpenTypeDataListener extends MouseAdapter {
--- 26,63 ----
package sun.tools.jconsole.inspector;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Component;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.*;
import java.awt.Dimension;
import java.util.*;
import java.lang.reflect.Array;
import javax.management.openmbean.*;
import sun.tools.jconsole.JConsole;
import sun.tools.jconsole.Resources;
! import sun.tools.jconsole.resources.Messages;
@SuppressWarnings("serial")
public class XOpenTypeViewer extends JPanel implements ActionListener {
JButton prev, incr, decr, tabularPrev, tabularNext;
JLabel compositeLabel, tabularLabel;
JScrollPane container;
XOpenTypeData current;
XOpenTypeDataListener listener = new XOpenTypeDataListener();
private static final String compositeNavigationSingle =
! Messages.MBEANS_TAB_COMPOSITE_NAVIGATION_SINGLE;
private static final String tabularNavigationSingle =
! Messages.MBEANS_TAB_TABULAR_NAVIGATION_SINGLE;
private static TableCellEditor editor =
new Utils.ReadOnlyTableCellEditor(new JTextField());
class XOpenTypeDataListener extends MouseAdapter {
*** 119,129 ****
static interface XViewedArrayData extends Navigatable {
}
static abstract class XOpenTypeData extends JTable {
XOpenTypeData parent;
- private Color defaultColor;
protected int col1Width = -1;
protected int col2Width = -1;
private boolean init;
private Font normalFont, boldFont;
protected XOpenTypeData(XOpenTypeData parent) {
--- 107,116 ----
*** 137,147 ****
public String getToolTip(int row, int col) {
if(col == 1) {
Object value = getModel().getValueAt(row, col);
if (value != null) {
if(isClickableElement(value))
! return Resources.getText("Double click to visualize")
+ ". " + value.toString();
else
return value.toString();
}
}
--- 124,134 ----
public String getToolTip(int row, int col) {
if(col == 1) {
Object value = getModel().getValueAt(row, col);
if (value != null) {
if(isClickableElement(value))
! return Messages.DOUBLE_CLICK_TO_VISUALIZE
+ ". " + value.toString();
else
return value.toString();
}
}
*** 263,273 ****
public int compare(CompositeData o1, CompositeData o2) {
for (String key : indexNames) {
Object c1 = o1.get(key);
Object c2 = o2.get(key);
if (c1 instanceof Comparable && c2 instanceof Comparable) {
! int result = ((Comparable) c1).compareTo(c2);
if (result != 0)
return result;
}
}
return 0;
--- 250,260 ----
public int compare(CompositeData o1, CompositeData o2) {
for (String key : indexNames) {
Object c1 = o1.get(key);
Object c2 = o2.get(key);
if (c1 instanceof Comparable && c2 instanceof Comparable) {
! int result = ((Comparable<Object>) c1).compareTo(c2);
if (result != 0)
return result;
}
}
return 0;
*** 356,366 ****
}
}
static class XCompositeData extends XOpenTypeData {
protected final String[] columnNames = {
! Resources.getText("Name"), Resources.getText("Value")
};
CompositeData composite;
public XCompositeData() {
super(null);
--- 343,353 ----
}
}
static class XCompositeData extends XOpenTypeData {
protected final String[] columnNames = {
! Messages.NAME, Messages.VALUE
};
CompositeData composite;
public XCompositeData() {
super(null);
*** 396,422 ****
return key;
}
private void load(CompositeData data) {
CompositeType type = data.getCompositeType();
! Set keys = type.keySet();
! Iterator it = keys.iterator();
Object[] rowData = new Object[2];
while (it.hasNext()) {
String key = (String) it.next();
Object val = data.get(key);
rowData[0] = formatKey(key);
if (val == null) {
rowData[1] = "";
} else {
! OpenType openType = type.getType(key);
if (openType instanceof CompositeType) {
rowData[1] =
new XCompositeData(this, (CompositeData) val);
} else if (openType instanceof ArrayType) {
rowData[1] =
! new XArrayData(this, (ArrayType) openType, val);
} else if (openType instanceof SimpleType) {
rowData[1] = val;
} else if (openType instanceof TabularType) {
rowData[1] = new XTabularData(this, (TabularData) val);
}
--- 383,409 ----
return key;
}
private void load(CompositeData data) {
CompositeType type = data.getCompositeType();
! Set<String> keys = type.keySet();
! Iterator<String> it = keys.iterator();
Object[] rowData = new Object[2];
while (it.hasNext()) {
String key = (String) it.next();
Object val = data.get(key);
rowData[0] = formatKey(key);
if (val == null) {
rowData[1] = "";
} else {
! OpenType<?> openType = type.getType(key);
if (openType instanceof CompositeType) {
rowData[1] =
new XCompositeData(this, (CompositeData) val);
} else if (openType instanceof ArrayType) {
rowData[1] =
! new XArrayData(this, (ArrayType<?>) openType, val);
} else if (openType instanceof SimpleType) {
rowData[1] = val;
} else if (openType instanceof TabularType) {
rowData[1] = new XTabularData(this, (TabularData) val);
}
*** 451,475 ****
static class XArrayData extends XCompositeData
implements XViewedArrayData {
private int dimension;
private int size;
! private OpenType elemType;
private Object val;
private boolean isCompositeType;
private boolean isTabularType;
private int currentIndex;
private CompositeData[] elements;
! private final String[] arrayColumns = {Resources.getText("Value")};
private Font normalFont, boldFont;
! XArrayData(XOpenTypeData parent, ArrayType type, Object val) {
this(parent, type.getDimension(), type.getElementOpenType(), val);
}
XArrayData(XOpenTypeData parent, int dimension,
! OpenType elemType, Object val) {
super(parent);
this.dimension = dimension;
this.elemType = elemType;
this.val = val;
String[] columns = null;
--- 438,462 ----
static class XArrayData extends XCompositeData
implements XViewedArrayData {
private int dimension;
private int size;
! private OpenType<?> elemType;
private Object val;
private boolean isCompositeType;
private boolean isTabularType;
private int currentIndex;
private CompositeData[] elements;
! private final String[] arrayColumns = {Messages.VALUE};
private Font normalFont, boldFont;
! XArrayData(XOpenTypeData parent, ArrayType<?> type, Object val) {
this(parent, type.getDimension(), type.getElementOpenType(), val);
}
XArrayData(XOpenTypeData parent, int dimension,
! OpenType<?> elemType, Object val) {
super(parent);
this.dimension = dimension;
this.elemType = elemType;
this.val = val;
String[] columns = null;
*** 484,497 ****
loadArray();
}
public void viewed(XOpenTypeViewer viewer) throws Exception {
if (size == 0)
! throw new Exception(Resources.getText("Empty array"));
if (dimension > 1)
! throw new Exception(Resources.getText("Dimension is not " +
! "supported:") +
dimension);
super.viewed(viewer);
}
public int getElementCount() {
--- 471,483 ----
loadArray();
}
public void viewed(XOpenTypeViewer viewer) throws Exception {
if (size == 0)
! throw new Exception(Messages.EMPTY_ARRAY);
if (dimension > 1)
! throw new Exception(Messages.DIMENSION_IS_NOT_SUPPORTED_COLON +
dimension);
super.viewed(viewer);
}
public int getElementCount() {
*** 563,573 ****
}
}
public String toString() {
if (dimension > 1) {
! return Resources.getText("Dimension is not supported:") +
dimension;
} else {
return elemType.getTypeName() + "[" + size + "]";
}
}
--- 549,559 ----
}
}
public String toString() {
if (dimension > 1) {
! return Messages.DIMENSION_IS_NOT_SUPPORTED_COLON +
dimension;
} else {
return elemType.getTypeName() + "[" + size + "]";
}
}
*** 692,702 ****
tabularPrev.setEnabled(tabular.canDecrement());
boolean hasMoreThanOneElement =
tabular.canIncrement() || tabular.canDecrement();
if (hasMoreThanOneElement) {
tabularLabel.setText(
! Resources.getText("MBeansTab.tabularNavigationMultiple",
String.format("%d", tabular.getSelectedElementIndex() + 1),
String.format("%d", tabular.getElementCount())));
} else {
tabularLabel.setText(tabularNavigationSingle);
}
--- 678,688 ----
tabularPrev.setEnabled(tabular.canDecrement());
boolean hasMoreThanOneElement =
tabular.canIncrement() || tabular.canDecrement();
if (hasMoreThanOneElement) {
tabularLabel.setText(
! Resources.format(Messages.MBEANS_TAB_TABULAR_NAVIGATION_MULTIPLE,
String.format("%d", tabular.getSelectedElementIndex() + 1),
String.format("%d", tabular.getElementCount())));
} else {
tabularLabel.setText(tabularNavigationSingle);
}
*** 715,725 ****
decr.setEnabled(array.canDecrement());
boolean hasMoreThanOneElement =
array.canIncrement() || array.canDecrement();
if (hasMoreThanOneElement) {
compositeLabel.setText(
! Resources.getText("MBeansTab.compositeNavigationMultiple",
String.format("%d", array.getSelectedElementIndex() + 1),
String.format("%d", array.getElementCount())));
} else {
compositeLabel.setText(compositeNavigationSingle);
}
--- 701,711 ----
decr.setEnabled(array.canDecrement());
boolean hasMoreThanOneElement =
array.canIncrement() || array.canDecrement();
if (hasMoreThanOneElement) {
compositeLabel.setText(
! Resources.format(Messages.MBEANS_TAB_COMPOSITE_NAVIGATION_MULTIPLE,
String.format("%d", array.getSelectedElementIndex() + 1),
String.format("%d", array.getElementCount())));
} else {
compositeLabel.setText(compositeNavigationSingle);
}
*** 779,807 ****
new JScrollPane(data,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT));
! tabularPrev = new JButton(Resources.getText("<"));
! tabularNext = new JButton(Resources.getText(">"));
JPanel tabularButtons = new JPanel(new FlowLayout(FlowLayout.LEFT));
tabularButtons.add(tabularPrev);
tabularPrev.addActionListener(this);
tabularLabel = new JLabel(tabularNavigationSingle);
tabularLabel.setEnabled(false);
tabularButtons.add(tabularLabel);
tabularButtons.add(tabularNext);
tabularNext.addActionListener(this);
tabularButtons.setBackground(Color.white);
! prev = new JButton(Resources.getText("<<"));
prev.addActionListener(this);
buttons.add(prev);
! incr = new JButton(Resources.getText(">"));
incr.addActionListener(this);
! decr = new JButton(Resources.getText("<"));
decr.addActionListener(this);
JPanel array = new JPanel();
array.setBackground(Color.white);
array.add(decr);
--- 765,793 ----
new JScrollPane(data,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT));
! tabularPrev = new JButton(Messages.LESS_THAN);
! tabularNext = new JButton(Messages.GREATER_THAN);
JPanel tabularButtons = new JPanel(new FlowLayout(FlowLayout.LEFT));
tabularButtons.add(tabularPrev);
tabularPrev.addActionListener(this);
tabularLabel = new JLabel(tabularNavigationSingle);
tabularLabel.setEnabled(false);
tabularButtons.add(tabularLabel);
tabularButtons.add(tabularNext);
tabularNext.addActionListener(this);
tabularButtons.setBackground(Color.white);
! prev = new JButton(Messages.A_LOT_LESS_THAN);
prev.addActionListener(this);
buttons.add(prev);
! incr = new JButton(Messages.GREATER_THAN);
incr.addActionListener(this);
! decr = new JButton(Messages.LESS_THAN);
decr.addActionListener(this);
JPanel array = new JPanel();
array.setBackground(Color.white);
array.add(decr);