src/share/classes/sun/tools/jconsole/inspector/XMBeanAttributes.java

Print this page
rev 5340 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: duke

*** 64,77 **** import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; - import sun.tools.jconsole.Resources; import sun.tools.jconsole.MBeansTab; import sun.tools.jconsole.JConsole; import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection; /*IMPORTANT : There is a deadlock issue there if we don't synchronize well loadAttributes, refresh attributes and empty table methods since a UI thread can call loadAttributes and at the same time a JMX notification can raise an --- 64,77 ---- import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; import sun.tools.jconsole.MBeansTab; import sun.tools.jconsole.JConsole; import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection; + import sun.tools.jconsole.resources.Messages; /*IMPORTANT : There is a deadlock issue there if we don't synchronize well loadAttributes, refresh attributes and empty table methods since a UI thread can call loadAttributes and at the same time a JMX notification can raise an
*** 82,93 **** final Logger LOGGER = Logger.getLogger(XMBeanAttributes.class.getPackage().getName()); private final static String[] columnNames = ! {Resources.getText("Name"), ! Resources.getText("Value")}; private XMBean mbean; private MBeanInfo mbeanInfo; private MBeanAttributeInfo[] attributesInfo; private HashMap<String, Object> attributes; --- 82,93 ---- final Logger LOGGER = Logger.getLogger(XMBeanAttributes.class.getPackage().getName()); private final static String[] columnNames = ! {Messages.NAME, ! Messages.VALUE}; private XMBean mbean; private MBeanInfo mbeanInfo; private MBeanAttributeInfo[] attributesInfo; private HashMap<String, Object> attributes;
*** 265,275 **** public void setTableValue(Object value, int row) { } public boolean isColumnEditable(int column) { if (column < getColumnCount()) { ! return getColumnName(column).equals(Resources.getText("Value")); } else { return false; } } --- 265,275 ---- public void setTableValue(Object value, int row) { } public boolean isColumnEditable(int column) { if (column < getColumnCount()) { ! return getColumnName(column).equals(Messages.VALUE); } else { return false; } }
*** 311,321 **** Object value = getValue(row); String tip = null; if (value != null) { tip = value.toString(); if(isAttributeViewable(row, VALUE_COLUMN)) ! tip = Resources.getText("Double click to expand/collapse")+ ". " + tip; } return tip; } --- 311,321 ---- Object value = getValue(row); String tip = null; if (value != null) { tip = value.toString(); if(isAttributeViewable(row, VALUE_COLUMN)) ! tip = Messages.DOUBLE_CLICK_TO_EXPAND_FORWARD_SLASH_COLLAPSE+ ". " + tip; } return tip; }
*** 587,597 **** cell.init(super.getCellRenderer(row, col), comp, rowMinHeight); ! mbeansTab.getDataViewer().registerForMouseEvent( comp, mouseListener); } else return cell; } --- 587,597 ---- cell.init(super.getCellRenderer(row, col), comp, rowMinHeight); ! XDataViewer.registerForMouseEvent( comp, mouseListener); } else return cell; }
*** 722,743 **** // Other viewers need to be updated manually. Component comp = mbeansTab.getDataViewer().createAttributeViewer( value, mbean, attribute, XMBeanAttributes.this); cell.init(cell.getMinRenderer(), comp, cell.getMinHeight()); ! mbeansTab.getDataViewer().registerForMouseEvent(comp, mouseListener); } } else { cell = new ZoomedCell(value); viewers.put(attribute, cell); } viewersCache.put(mbean, viewers); return cell; } } ! //will be called in a synchronzed block protected void addTableData(DefaultTableModel tableModel, XMBean mbean, MBeanAttributeInfo[] attributesInfo, HashMap<String, Object> attributes, HashMap<String, Object> unavailableAttributes, --- 722,743 ---- // Other viewers need to be updated manually. Component comp = mbeansTab.getDataViewer().createAttributeViewer( value, mbean, attribute, XMBeanAttributes.this); cell.init(cell.getMinRenderer(), comp, cell.getMinHeight()); ! XDataViewer.registerForMouseEvent(comp, mouseListener); } } else { cell = new ZoomedCell(value); viewers.put(attribute, cell); } viewersCache.put(mbean, viewers); return cell; } } ! //will be called in a synchronized block protected void addTableData(DefaultTableModel tableModel, XMBean mbean, MBeanAttributeInfo[] attributesInfo, HashMap<String, Object> attributes, HashMap<String, Object> unavailableAttributes,
*** 747,757 **** int col1Width = 0; int col2Width = 0; for (int i = 0; i < attributesInfo.length; i++) { rowData[0] = (attributesInfo[i].getName()); if (unavailableAttributes.containsKey(rowData[0])) { ! rowData[1] = Resources.getText("Unavailable"); } else if (viewableAttributes.containsKey(rowData[0])) { rowData[1] = viewableAttributes.get(rowData[0]); if (!attributesInfo[i].isWritable() || !Utils.isEditableType(attributesInfo[i].getType())) { rowData[1] = getZoomedCell(mbean, (String) rowData[0], rowData[1]); --- 747,757 ---- int col1Width = 0; int col2Width = 0; for (int i = 0; i < attributesInfo.length; i++) { rowData[0] = (attributesInfo[i].getName()); if (unavailableAttributes.containsKey(rowData[0])) { ! rowData[1] = Messages.UNAVAILABLE; } else if (viewableAttributes.containsKey(rowData[0])) { rowData[1] = viewableAttributes.get(rowData[0]); if (!attributesInfo[i].isWritable() || !Utils.isEditableType(attributesInfo[i].getType())) { rowData[1] = getZoomedCell(mbean, (String) rowData[0], rowData[1]);
*** 809,819 **** } } } } - @SuppressWarnings("serial") class ValueCellEditor extends XTextFieldEditor { // implements javax.swing.table.TableCellEditor @Override public Component getTableCellEditorComponent(JTable table, Object value, --- 809,818 ----
*** 864,874 **** } return super.stopCellEditing(); } } - @SuppressWarnings("serial") class MaximizedCellRenderer extends DefaultTableCellRenderer { Component comp; MaximizedCellRenderer(Component comp) { this.comp = comp; Dimension d = comp.getPreferredSize(); --- 863,872 ----
*** 1016,1026 **** tableValue = Utils.createObjectFromString(getClassName(e.getFirstRow()), // type (String)tableValue);// value } catch (Throwable ex) { popupAndLog(ex,"tableChanged", ! "Problem setting attribute"); } } final String attributeName = getValueName(e.getFirstRow()); final Attribute attribute = new Attribute(attributeName,tableValue); --- 1014,1024 ---- tableValue = Utils.createObjectFromString(getClassName(e.getFirstRow()), // type (String)tableValue);// value } catch (Throwable ex) { popupAndLog(ex,"tableChanged", ! Messages.PROBLEM_SETTING_ATTRIBUTE); } } final String attributeName = getValueName(e.getFirstRow()); final Attribute attribute = new Attribute(attributeName,tableValue);
*** 1040,1050 **** attribute.getName()+ "="+attribute.getValue()+")"); } mbean.setAttribute(attribute); } catch (Throwable ex) { ! popupAndLog(ex,method,"Problem setting attribute"); } return null; } @Override protected void done() { --- 1038,1048 ---- attribute.getName()+ "="+attribute.getValue()+")"); } mbean.setAttribute(attribute); } catch (Throwable ex) { ! popupAndLog(ex,method,Messages.PROBLEM_SETTING_ATTRIBUTE); } return null; } @Override protected void done() {
*** 1060,1077 **** }; mbeansTab.workerAdd(setAttribute); } // Call this outside EDT ! private void popupAndLog(Throwable ex, String method, String key) { ex = Utils.getActualException(ex); if (JConsole.isDebug()) ex.printStackTrace(); String message = (ex.getMessage() != null) ? ex.getMessage() : ex.toString(); EventQueue.invokeLater( new ThreadDialog(component, message+"\n", ! Resources.getText(key), JOptionPane.ERROR_MESSAGE)); } } } --- 1058,1075 ---- }; mbeansTab.workerAdd(setAttribute); } // Call this outside EDT ! private void popupAndLog(Throwable ex, String method, String title) { ex = Utils.getActualException(ex); if (JConsole.isDebug()) ex.printStackTrace(); String message = (ex.getMessage() != null) ? ex.getMessage() : ex.toString(); EventQueue.invokeLater( new ThreadDialog(component, message+"\n", ! title, JOptionPane.ERROR_MESSAGE)); } } }