1 2 24 25 package org.enhydra.tool.archive.wizard; 26 27 import org.enhydra.tool.archive.Descriptor; 29 30 import javax.swing.table.DefaultTableModel ; 32 public class DDTableModel extends DefaultTableModel { 34 public DDTableModel() { 35 super(); 36 addColumn("Required"); 37 addColumn("Type"); 38 addColumn("Path"); 39 } 40 41 public boolean isCellEditable(int row, int col) { 42 return false; 43 } 44 45 protected void setDescriptor(int row, Descriptor ddRow) { 46 Boolean b = new Boolean (ddRow.isRequired()); 47 48 setValueAt(b, row, 0); 49 setValueAt(ddRow.getType(), row, 1); 50 setValueAt(ddRow.getPath(), row, 2); 51 } 52 53 protected Descriptor getDescriptor(int row) { 54 Descriptor dd = null; 55 Boolean req = (Boolean ) getValueAt(row, 0); 56 String type = (String ) getValueAt(row, 1); 57 String path = (String ) getValueAt(row, 2); 58 dd = new Descriptor(req.booleanValue(), type); 59 dd.setPath(path); 60 return dd; 61 } 62 63 protected Descriptor[] getDescriptors() { 64 Descriptor[] dd = new Descriptor[getRowCount()]; 65 for (int i = 0 ; i < dd.length ; i++) { 66 dd[i] = getDescriptor(i); 67 } 68 return dd; 69 } 70 71 protected void addDescriptor(Descriptor ddRow) { 72 Object [] row = new Object [3]; 73 74 row[0] = new Boolean (ddRow.isRequired()); 75 row[1] = ddRow.getType(); 76 row[2] = ddRow.getPath(); 77 addRow(row); 78 } 79 80 protected void clear() { 81 while (getRowCount() > 0) { 82 removeRow(0); 83 } 84 } 85 86 } 87 | Popular Tags |