[opencoe-cvs] coekernel/src/COE/src/COE/java/org/opencoe/coe/kernel/apps COEInstaller.java,1.8,1.9
Status: Alpha
Brought to you by:
rbroberg
|
From: <rbr...@us...> - 2003-10-18 18:03:55
|
Update of /cvsroot/opencoe/coekernel/src/COE/src/COE/java/org/opencoe/coe/kernel/apps
In directory sc8-pr-cvs1:/tmp/cvs-serv18267/java/org/opencoe/coe/kernel/apps
Modified Files:
COEInstaller.java
Log Message:
20031018:rb:825985 - COEInstaller S/W row cells should not be editableZ
Index: COEInstaller.java
===================================================================
RCS file: /cvsroot/opencoe/coekernel/src/COE/src/COE/java/org/opencoe/coe/kernel/apps/COEInstaller.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** COEInstaller.java 18 Oct 2003 14:37:40 -0000 1.8
--- COEInstaller.java 18 Oct 2003 18:00:38 -0000 1.9
***************
*** 20,23 ****
--- 20,24 ----
*
* Created on January 29, 2001, 1:02 PM
+ * 20031018:rb:825985 - COEInstaller S/W row cells should not be editable
* 20031018:rb:825973 - COEInstaller Available Disks not used
*/
***************
*** 85,89 ****
cfgDiskTable = new javax.swing.JTable();
//cfgDiskTableLSM = cfgDiskTable.getSelectionModel();
! //cfgDiskTableModel = cfgDiskTable.getModel();
cfgDiskButtonPanel = new javax.swing.JPanel();
cfgDiskSpaceButton = new javax.swing.JButton();
--- 86,90 ----
cfgDiskTable = new javax.swing.JTable();
//cfgDiskTableLSM = cfgDiskTable.getSelectionModel();
! //cfgDisk = cfgDiskTable.getModel();
cfgDiskButtonPanel = new javax.swing.JPanel();
cfgDiskSpaceButton = new javax.swing.JButton();
***************
*** 492,511 ****
swInstalledPanel.setBorder(new javax.swing.border.TitledBorder("Software Installed"));
! swInstalledTableModel = new javax.swing.table.DefaultTableModel(
! new String[]{"Type", "Name", "Version", "Class", "Size", "Dir"},
! 0);
! swInstalledTable = new javax.swing.JTable(swInstalledTableModel);
!
! instArray = getINST();
! for (int i = 0; i < instArray.length; i++) {
! String[] newrow = new String[]{instArray[i][0],
! instArray[i][1],
! instArray[i][2],
! instArray[i][3],
! instArray[i][4],
! instArray[i][5],};
! swInstalledTableModel.addRow(newrow);
! }
!
swInstalledScrollPanel.setViewportView(swInstalledTable);
--- 493,502 ----
swInstalledPanel.setBorder(new javax.swing.border.TitledBorder("Software Installed"));
! //20031018:rb:825985 - COEInstaller S/W row cells should not be editable
! swInstalledTableModel = new COEInstallerTableModel();
! instArray = getInstalled();
! swInstalledTableModel.setData(instArray);
! swInstalledTable= new javax.swing.JTable(swInstalledTableModel);
! swInstalledTable.tableChanged(new javax.swing.event.TableModelEvent(swInstalledTableModel));
swInstalledScrollPanel.setViewportView(swInstalledTable);
***************
*** 536,546 ****
//# Set Available Software Panel
//# ------------------------------------------------------------------
swAvailablePanel.setLayout(new java.awt.BorderLayout());
swAvailablePanel.setBorder(new javax.swing.border.TitledBorder("Software Available"));
swAvailableTableModel = new javax.swing.table.DefaultTableModel(
! new String[]{"Type", "Name", "Version", "Class", "Size", "Dir"},
! 0);
!
swAvailableTable = new javax.swing.JTable(swAvailableTableModel);
--- 527,538 ----
//# Set Available Software Panel
//# ------------------------------------------------------------------
+ //swAvailable = swAvailableTable.getModel();
swAvailablePanel.setLayout(new java.awt.BorderLayout());
swAvailablePanel.setBorder(new javax.swing.border.TitledBorder("Software Available"));
+ //20031018:rb:825985 - COEInstaller S/W row cells should not be editable
swAvailableTableModel = new javax.swing.table.DefaultTableModel(
! new String[]{"Type", "Name", "Version", "Class", "Size", "Dir"}, 0)
! { public boolean isCellEditable(int row, int column) { return false;} };
swAvailableTable = new javax.swing.JTable(swAvailableTableModel);
***************
*** 569,573 ****
// tweak list and table models
swAvailableTableLSM = swAvailableTable.getSelectionModel();
- //swAvailableTableModel = swAvailableTable.getModel();
swAvailableTableLSM.addListSelectionListener(
--- 561,564 ----
***************
*** 704,707 ****
--- 695,699 ----
//# +----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
+
/**
* Description of the Method
***************
*** 879,883 ****
* refresh the installed table
*/
! readINST();
}
--- 871,875 ----
* refresh the installed table
*/
! readInstalled();
}
***************
*** 916,920 ****
* refresh the installed table
*/
! readINST();
}
--- 908,912 ----
* refresh the installed table
*/
! readInstalled();
}
***************
*** 937,945 ****
/**
! * Gets the iNST attribute of the COEInstaller object
*
! *@return The iNST value
*/
! private String[][] getINST() {
String cmdstr = "COE_HOME/bin/COEListSegs";
String flagstr = "--installer";
--- 929,937 ----
/**
! * Gets the Installed Segments attribute of the COEInstaller object
*
! *@return The Installed Segments value
*/
! private String[][] getInstalled() {
String cmdstr = "COE_HOME/bin/COEListSegs";
String flagstr = "--installer";
***************
*** 969,993 ****
* Description of the Method
*/
! private void readINST() {
!
! int rows = swInstalledTableModel.getRowCount();
! System.out.println("rows ==" + rows);
! for (int i = rows; i > 0; i--) {
! swInstalledTableModel.removeRow(i - 1);
! }
! /*
! * get the new stuff
! */
! instArray = getINST();
! for (int i = 0; i < instArray.length; i++) {
! String[] newrow = new String[]{instArray[i][0],
! instArray[i][1],
! instArray[i][2],
! instArray[i][3],
! instArray[i][4],
! instArray[i][5]};
! swInstalledTableModel.addRow(newrow);
! }
}
--- 961,970 ----
* Description of the Method
*/
! private void readInstalled() {
! // 20031018:rb:825985 - COEInstaller S/W row cells should not be editable
! instArray = getInstalled();
! swInstalledTableModel.setData(instArray);
! swInstalledTable.tableChanged(new javax.swing.event.TableModelEvent(swInstalledTableModel));
}
***************
*** 1024,1028 ****
*
*@param path Description of the Parameter
! *@return The tOC value
*/
private String[][] getTOC(String path) {
--- 1001,1005 ----
*
*@param path Description of the Parameter
! *@return The TOC value
*/
private String[][] getTOC(String path) {
***************
*** 1305,1309 ****
private javax.swing.JScrollPane cfgDiskTableScrollPane;
private javax.swing.JTable cfgDiskTable;
! private javax.swing.table.TableModel cfgDiskTableModel;
private javax.swing.ListSelectionModel cfgDiskTableLSM;
private javax.swing.JPanel cfgDiskButtonPanel;
--- 1282,1286 ----
private javax.swing.JScrollPane cfgDiskTableScrollPane;
private javax.swing.JTable cfgDiskTable;
! private javax.swing.table.TableModel cfgDiskTableModel;
private javax.swing.ListSelectionModel cfgDiskTableLSM;
private javax.swing.JPanel cfgDiskButtonPanel;
***************
*** 1315,1319 ****
private javax.swing.JScrollPane swInstalledScrollPanel;
private javax.swing.JTable swInstalledTable;
! private javax.swing.table.DefaultTableModel swInstalledTableModel;
private javax.swing.JPanel swInstalledButtonPanel;
private javax.swing.JButton swInstalledRelnotesButton;
--- 1292,1297 ----
private javax.swing.JScrollPane swInstalledScrollPanel;
private javax.swing.JTable swInstalledTable;
! //private javax.swing.table.Default swInstalled;
! private COEInstallerTableModel swInstalledTableModel;
private javax.swing.JPanel swInstalledButtonPanel;
private javax.swing.JButton swInstalledRelnotesButton;
***************
*** 1335,1339 ****
--- 1313,1428 ----
//20031006:rb - Use Coe Env Variables to set install path
private org.opencoe.coe.kernel.util._OpenCOEEnv coeEnv;
+
+ // 20031018:rb:825985 - COEInstaller S/W row cells should not be editable
+ class COEInstallerTableModel extends javax.swing.table.AbstractTableModel {
+ final String[] columnNames = {"Type", "Name", "Version", "Class", "Size", "Dir"};
+
+ private Object[][] data = {{"", "", "", "", "", ""}};
+
+ private boolean DEBUG = true;
+
+ public void setData (Object[][] tmp) {
+ data = tmp;
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public int getRowCount() {
+ //return data.length/columnNames.length;
+ return data.length;
+ }
+
+ public String getColumnName(int col) {
+ return columnNames[col];
+ }
+
+ public Object getValueAt(int row, int col) {
+ System.out.println("row: "+row);
+ System.out.println("col: "+col);
+ System.out.println("rowcnt: "+getRowCount());
+ System.out.println("colcnt: "+getColumnCount());
+ if (row < getRowCount() && col <getColumnCount()) {
+ return data[row][col];
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * JTable uses this method to determine the default renderer/
+ * editor for each cell. If we didn't implement this method,
+ * then the last column would contain text ("true"/"false"),
+ * rather than a check box.
+ */
+ public Class getColumnClass(int c) {
+ return getValueAt(0, c).getClass();
+ }
+
+ /*
+ * Don't need to implement this method unless your table's
+ * editable.
+ */
+ public boolean isCellEditable(int row, int col) {
+ return false;
+ }
+
+ /*
+ * Don't need to implement this method unless your table's
+ * data can change.
+ */
+ public void setValueAt(Object value, int row, int col) {
+ if (DEBUG) {
+ System.out.println("Setting value at " + row + "," + col
+ + " to " + value
+ + " (an instance of "
+ + value.getClass() + ")");
+ }
+
+ if (data[0][col] instanceof Integer
+ && !(value instanceof Integer)) {
+ //With JFC/Swing 1.1 and JDK 1.2, we need to create
+ //an Integer from the value; otherwise, the column
+ //switches to contain Strings. Starting with v 1.3,
+ //the table automatically converts value to an Integer,
+ //so you only need the code in the 'else' part of this
+ //'if' block.
+ //XXX: See TableEditDemo.java for a better solution!!!
+ try {
+ data[row][col] = new Integer(value.toString());
+ fireTableCellUpdated(row, col);
+ } catch (NumberFormatException e) {
+ System.err.println("The \"" + getColumnName(col) + "\" column accepts only integer values.");
+ }
+ } else {
+ data[row][col] = value;
+ fireTableCellUpdated(row, col);
+ }
+
+ if (DEBUG) {
+ System.out.println("New value of data:");
+ printDebugData();
+ }
+ }
+
+ private void printDebugData() {
+ int numRows = getRowCount();
+ int numCols = getColumnCount();
+
+ for (int i=0; i < numRows; i++) {
+ System.out.print(" row " + i + ":");
+ for (int j=0; j < numCols; j++) {
+ System.out.print(" " + data[i][j]);
+ }
+ System.out.println();
+ }
+ System.out.println("--------------------------");
+ }
+ }
+
}
+
+
|