From: Bob J. <jac...@us...> - 2010-03-12 14:54:36
|
Update of /cvsroot/jmri/jmri/jmrit/roster/swing In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv32460/src/jmri/jmrit/roster/swing Modified Files: RosterTableModel.java Log Message: more columns, Integer type for address Index: RosterTableModel.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/roster/swing/RosterTableModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RosterTableModel.java 30 Nov 2009 22:25:32 -0000 1.3 --- RosterTableModel.java 12 Mar 2010 14:54:28 -0000 1.4 *************** *** 14,18 **** * and only shows some of the fields. But it's a start.... * ! * @author Bob Jacobsen Copyright (C) 2009 * @version $Revision$ * @since 2.7.5 --- 14,18 ---- * and only shows some of the fields. But it's a start.... * ! * @author Bob Jacobsen Copyright (C) 2009, 2010 * @version $Revision$ * @since 2.7.5 *************** *** 21,29 **** static final int IDCOL = 0; ! static final int ROADNUMBERCOL = 1; ! static final int ROADNAMECOL = 2; ! static final int MFGCOL = 3; ! static final int NUMCOL = MFGCOL+1; public int getRowCount() { --- 21,33 ---- static final int IDCOL = 0; ! static final int ADDRESSCOL = 1; ! static final int DECODERCOL = 2; ! static final int ROADNAMECOL = 3; ! static final int ROADNUMBERCOL = 4; ! static final int MFGCOL = 5; ! static final int OWNERCOL = 6; ! static final int DATEUPDATECOL = 7; ! static final int NUMCOL = 7+1; public int getRowCount() { *************** *** 36,42 **** switch (col) { case IDCOL: return "ID"; ! case ROADNUMBERCOL: return "Road Number"; case ROADNAMECOL: return "Road Name"; case MFGCOL: return "Manufacturer"; default: return "<UNKNOWN>"; } --- 40,50 ---- switch (col) { case IDCOL: return "ID"; ! case ADDRESSCOL: return "DCC Address"; ! case DECODERCOL: return "Decoder"; case ROADNAMECOL: return "Road Name"; + case ROADNUMBERCOL: return "Road Number"; case MFGCOL: return "Manufacturer"; + case OWNERCOL: return "Owner"; + case DATEUPDATECOL: return "Last Updated"; default: return "<UNKNOWN>"; } *************** *** 44,47 **** --- 52,56 ---- public Class<?> getColumnClass(int col) { + if (col == ADDRESSCOL) return Integer.class; return String.class; } *************** *** 66,72 **** switch (col) { case IDCOL: return re.getId(); ! case ROADNUMBERCOL: return re.getRoadNumber(); case ROADNAMECOL: return re.getRoadName(); case MFGCOL: return re.getMfg(); default: return "<UNKNOWN>"; } --- 75,85 ---- switch (col) { case IDCOL: return re.getId(); ! case ADDRESSCOL: return new Integer(re.getDccLocoAddress().getNumber()); ! case DECODERCOL: return re.getDecoderModel(); case ROADNAMECOL: return re.getRoadName(); + case ROADNUMBERCOL: return re.getRoadNumber(); case MFGCOL: return re.getMfg(); + case OWNERCOL: return re.getOwner(); + case DATEUPDATECOL: return re.getDateUpdated(); default: return "<UNKNOWN>"; } *************** *** 76,79 **** --- 89,105 ---- } + public int getPreferredWidth(int column) { + int retval = 20; // always take some width + retval = Math.max(retval, new javax.swing.JLabel(getColumnName(column)).getPreferredSize().width+15); // leave room for sorter arrow + for (int row = 0 ; row < getRowCount(); row++) + retval = Math.max(retval, new javax.swing.JLabel(getValueAt(row, column).toString()).getPreferredSize().width); + + return retval+5; + } + + // drop listeners + public void dispose() { + } + static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(RosterTableModel.class.getName()); } |