[Mc4j-cvs] mc4j/src/org/mc4j/console/dashboard/components NumericAttributeGraph.java,1.15,1.16 Attri
Brought to you by:
ghinkl
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6745/src/org/mc4j/console/dashboard/components Modified Files: NumericAttributeGraph.java AttributeTableComponent.java AttributeTablePopupComponent.java RefreshControlComponent.java Log Message: Dashboard and component tweaks Index: AttributeTableComponent.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/components/AttributeTableComponent.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AttributeTableComponent.java 12 Apr 2006 19:13:59 -0000 1.13 --- AttributeTableComponent.java 17 Apr 2006 03:07:25 -0000 1.14 *************** *** 29,32 **** --- 29,33 ---- import javax.swing.*; import javax.swing.table.DefaultTableModel; + import javax.swing.table.AbstractTableModel; import java.awt.*; import java.util.*; *************** *** 34,43 **** /** * @author Greg Hinkle (gh...@us...), January 2004 * @version $Revision$($Author$ / $Date$) */ ! public class AttributeTableComponent extends JPanel implements BeanListComponent, Runnable { ! protected List attributeNames = new ArrayList(); protected List<EmsBean> beanList; --- 35,47 ---- /** + * This is meant to be a table where the rows are a list of beans that come from a match + * and the columns are attributes that are common to those beans. + * * @author Greg Hinkle (gh...@us...), January 2004 * @version $Revision$($Author$ / $Date$) */ ! public class AttributeTableComponent extends JPanel implements BeanListComponent { ! protected List<String> attributeNames = new ArrayList<String>(); protected List<EmsBean> beanList; *************** *** 48,52 **** protected AttributeTableModel tableModel; ! protected boolean sorted = false; public void setAttributeName(String name) { --- 52,59 ---- protected AttributeTableModel tableModel; ! protected Map context; ! protected boolean scrollPane = true; ! ! public void setAttributeName(String name) { *************** *** 66,71 **** this.removeAll(); ! this.setMinimumSize(null); ! this.setPreferredSize(null); //this.setBorder(new TitledBorder(this.label)); --- 73,78 ---- this.removeAll(); ! // this.setMinimumSize(null); ! // this.setPreferredSize(null); //this.setBorder(new TitledBorder(this.label)); *************** *** 74,81 **** ! Object[] columnNames = attributeNames.toArray(new String[attributeNames.size()]); ! ! ! this.tableModel = new AttributeTableModel(columnNames, this.attributeNames.size()); this.table = new JXTable(tableModel); --- 81,85 ---- ! this.tableModel = new AttributeTableModel(beanList, attributeNames); this.table = new JXTable(tableModel); *************** *** 88,96 **** ! add(new JScrollPane(this.table), BorderLayout.CENTER); // The first refresh sets column classes properly refresh(); this.doLayout(); --- 92,101 ---- ! add(scrollPane ? new JScrollPane(this.table) : this.table, BorderLayout.CENTER); // The first refresh sets column classes properly refresh(); + this.table.packAll(); this.doLayout(); *************** *** 118,123 **** public void refresh() { ! if (this.tableModel instanceof AttributeTableModel) ! ((AttributeTableModel) this.tableModel).resetChangeList(); // TODO GH: FIX! Here we are going to try and re-execute the original dashboard --- 123,128 ---- public void refresh() { ! // if (this.tableModel instanceof AttributeTableModel) ! // ((AttributeTableModel) this.tableModel).resetChangeList(); // TODO GH: FIX! Here we are going to try and re-execute the original dashboard *************** *** 149,152 **** --- 154,158 ---- */ + /* int row = 0; for (EmsBean bean : beanList) { *************** *** 168,179 **** EmsOperation operation = bean.getOperation(attributeName); ! try { ! value = operation.invoke(); ! } catch (Exception e) { ! e.printStackTrace(); } ! ! } else if (value == null) value = "unknown"; --- 174,187 ---- EmsOperation operation = bean.getOperation(attributeName); ! if (operation != null) { ! try { ! value = operation.invoke(); ! } catch (Exception e) { ! e.printStackTrace(); ! } } + } ! if (value == null) value = "unknown"; *************** *** 182,187 **** this.tableModel.setColumnClass(col, (value != null) ? value.getClass() : Object.class); } ! if ((value != null) && !value.equals(this.tableModel.getValueAt(row, col))) this.tableModel.setValueAt(value, row, col); col++; --- 190,200 ---- this.tableModel.setColumnClass(col, (value != null) ? value.getClass() : Object.class); } ! if ((value == null) || (this.tableModel.getRowCount() > row && value.equals(this.tableModel.getValueAt(row, col)))) { ! // no need to reset it ! } else { ! while(this.tableModel.getRowCount() <= row) ! this.tableModel.addRow((Vector) null); this.tableModel.setValueAt(value, row, col); + } col++; *************** *** 197,227 **** } } this.tableModel.fireTableDataChanged(); } ! public void run() { ! // Its a hack, but sleep until the component is likely to be showing ! try { ! Thread.sleep(2000); ! } catch (Exception e) { } ! while (this.isShowing()) { ! refresh(); ! try { ! Thread.sleep(1000); ! } catch (Exception e) { } } } ! public class AttributeTableModel extends DefaultTableModel { Class[] columnClass = new Class[20]; boolean[][] changes; ! public AttributeTableModel(Object[] columnNames, int rowCount) { super(columnNames, rowCount); reallocateIndexes(); --- 210,269 ---- } } + */ this.tableModel.fireTableDataChanged(); } ! public static class AttributeTableModel extends AbstractTableModel { ! List<EmsBean> beans; ! List<String> names; ! ! ! public AttributeTableModel(List<EmsBean> beans, List<String> names) { ! this.beans = beans; ! this.names = names; } ! public int getRowCount() { ! return beans.size(); ! } ! ! public int getColumnCount() { ! return names.size(); ! } ! ! public String getColumnName(int column) { ! return names.get(column); ! } ! ! public Object getValueAt(int rowIndex, int columnIndex) { ! EmsBean bean = beans.get(rowIndex); ! ! String name = names.get(columnIndex); ! EmsAttribute attribute = bean.getAttribute(name); ! if (attribute != null) { ! return attribute.getValue(); ! } ! ! // see if its an operation ! EmsOperation operation = bean.getOperation(name); ! if (operation != null) { ! return operation.invoke(); } + + // See if its an object name key property + String val = bean.getBeanName().getKeyProperty(name); + + return val != null ? val :"?" + name + "?"; } } ! public class OldAttributeTableModel extends DefaultTableModel { Class[] columnClass = new Class[20]; boolean[][] changes; ! public OldAttributeTableModel(Object[] columnNames, int rowCount) { super(columnNames, rowCount); reallocateIndexes(); *************** *** 317,320 **** --- 359,363 ---- public void setContext(Map context) { + this.context = context; if (this.beanList == null) { throw new IllegalStateException("AttributeTableComponent: You must specify an appropriate [beanList] attribute."); *************** *** 341,343 **** --- 384,394 ---- this.label = label; } + + public boolean isScrollPane() { + return scrollPane; + } + + public void setScrollPane(boolean scrollPane) { + this.scrollPane = scrollPane; + } } Index: AttributeTablePopupComponent.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/components/AttributeTablePopupComponent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AttributeTablePopupComponent.java 12 Apr 2006 19:13:59 -0000 1.5 --- AttributeTablePopupComponent.java 17 Apr 2006 03:07:25 -0000 1.6 *************** *** 19,22 **** --- 19,23 ---- import org.mc4j.console.bean.MBeanNode; import org.mc4j.console.bean.OperationListAction; + import org.mc4j.console.dashboard.Dashboard; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; *************** *** 81,85 **** selectedRow = AttributeTablePopupComponent.this.table.convertRowIndexToModel(selectedRow); ! MBeanNode mbeanNode = (MBeanNode) AttributeTablePopupComponent.this.beanList.get(selectedRow); JPopupMenu popupMenu = new JPopupMenu(); --- 82,91 ---- selectedRow = AttributeTablePopupComponent.this.table.convertRowIndexToModel(selectedRow); ! ! String beanName = AttributeTablePopupComponent.this.beanList.get(selectedRow).getBeanName().getCanonicalName(); ! ! MBeanNode mbeanNode = ! Dashboard.getDashboard(context).getConnectionNode().getMBeanNode(beanName); ! JPopupMenu popupMenu = new JPopupMenu(); Index: RefreshControlComponent.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/components/RefreshControlComponent.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RefreshControlComponent.java 12 Apr 2006 19:13:59 -0000 1.6 --- RefreshControlComponent.java 17 Apr 2006 03:07:25 -0000 1.7 *************** *** 22,25 **** --- 22,26 ---- import org.mc4j.console.dashboard.match.BeanMatch; import org.mc4j.ems.connection.bean.EmsBean; + import org.openide.ErrorManager; import javax.swing.*; *************** *** 191,195 **** // with large numbers of attributes that aren't all being displayed long start = System.currentTimeMillis(); ! bean.refreshAttributes(); //System.out.println((System.currentTimeMillis() - start) + "ms to refresh " + bean.getBeanName().toString()); } --- 192,200 ---- // with large numbers of attributes that aren't all being displayed long start = System.currentTimeMillis(); ! try { ! bean.refreshAttributes(); ! } catch(Exception e) { ! ErrorManager.getDefault().notify(e); ! } //System.out.println((System.currentTimeMillis() - start) + "ms to refresh " + bean.getBeanName().toString()); } Index: NumericAttributeGraph.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/components/NumericAttributeGraph.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** NumericAttributeGraph.java 12 Apr 2006 22:27:52 -0000 1.15 --- NumericAttributeGraph.java 17 Apr 2006 03:07:25 -0000 1.16 *************** *** 50,54 **** } ! public Set<EmsAttribute> getAttributes() { return (Set<EmsAttribute>) getTimeSeriesKeys(); } --- 50,54 ---- } ! public Set<EmsAttribute> getAttributes() { return (Set<EmsAttribute>) getTimeSeriesKeys(); } *************** *** 64,67 **** --- 64,75 ---- public void setContext(Map context) { + if (getChartTitle() == null || getChartTitle().length() == 0) { + Set<EmsAttribute> attrs = getAttributes(); + if (attrs.size() == 1) { + setChartTitle(attrs.iterator().next().getName()); + } else { + setChartTitle("Multi-value chart"); + } + } //setChartTitle("??"); |