1 19 20 24 25 package org.netbeans.modules.db.sql.visualeditor.querybuilder; 26 27 import javax.swing.JTable ; 28 29 import javax.swing.table.DefaultTableModel ; 30 31 33 39 public class QueryBuilderTableModel extends DefaultTableModel { 40 41 43 private boolean DEBUG = false; 44 45 private String _tableName = null; 47 private String _corrName = null; 48 private String _schemaName = null; 49 50 52 public QueryBuilderTableModel ( String fullTableName, String corrName, 53 String [] iColumnNames, Object [][] iData ) 54 { 55 super ( iData, iColumnNames ); 56 String [] table = fullTableName.split("\\."); if (table.length>1) { 58 _schemaName=table[0]; 59 _tableName = table[1]; 60 } else 61 _tableName=table[0]; 62 63 _corrName = corrName; 64 } 65 66 72 public Class getColumnClass(int c) { 73 if ( c == 1 ) 74 return javax.swing.ImageIcon .class; 75 Object o = getValueAt(0, c); 76 if ( o != null ) 77 { 78 return o.getClass(); 79 } 80 else return Object .class; 81 } 82 83 public String getTableName () { 84 return ( _tableName ); 85 } 86 87 public String getFullTableName () { 88 return ( (_schemaName!=null ? _schemaName+"." : "") + _tableName); 90 } 91 92 public String getCorrName () { 93 return ( _corrName ); 94 } 95 96 public String getTableSpec () { 97 return ( (_corrName!=null) ? 98 _corrName : 99 getFullTableName()); 100 } 101 102 void selectColumn (String columnName, Boolean select) { 104 int row=-1; 105 int size = getRowCount(); 106 for (int i=0; i<size; i++) 107 if (getValueAt(i,2).equals(columnName)) { 108 row=i; 109 break; 110 } 111 112 if (row!=-1) { 113 if ((select==Boolean.TRUE) && (getValueAt(row,0)!=Boolean.TRUE)) 115 setValueAt(Boolean.TRUE,row,0); 116 else if ((select==Boolean.FALSE) && (getValueAt(row,0)!=Boolean.FALSE)) 117 setValueAt(Boolean.FALSE,row,0); 118 } 119 } 120 121 125 public boolean isCellEditable(int row, int col) { 126 131 if (col > 0) { 134 return false; 135 } else { 136 return true; 137 } 138 } 139 } 140 141 | Popular Tags |