1 package org.apache.ojb.tools.mapping.reversedb.gui; 2 3 import java.awt.event.KeyEvent ; 4 5 19 20 25 public class DBTablePropertySheet extends javax.swing.JPanel 26 implements PropertySheetView 27 { 28 org.apache.ojb.tools.mapping.reversedb.DBTable aTable; 29 30 public DBTablePropertySheet () 31 { 32 initComponents (); 33 } 34 35 private void readValuesFromTable() 36 { 37 this.cbEnabled.setSelected(aTable.isEnabled()); 38 this.cbDisabledByParent.setSelected(!aTable.getDBSchema().isTreeEnabled ()); 39 this.tfTableName.setText(aTable.getTableName()); 40 this.tfClassName.setText(aTable.getClassName()); 41 this.tfPackageName.setText(aTable.getPackageName()); 42 this.cbDynamicProxy.setSelected(aTable.hasDynamicProxy()); 43 this.tfConversionStrategyClass.setText(aTable.getConversionStrategyClass()); 44 } 45 46 51 private void initComponents() { 53 java.awt.GridBagConstraints gridBagConstraints; 54 55 jPanel1 = new javax.swing.JPanel (); 56 lblEnabled = new javax.swing.JLabel (); 57 cbEnabled = new javax.swing.JCheckBox (); 58 lblDisabledByParent = new javax.swing.JLabel (); 59 cbDisabledByParent = new javax.swing.JCheckBox (); 60 jLabel3 = new javax.swing.JLabel (); 61 jLabel4 = new javax.swing.JLabel (); 62 lblTableName = new javax.swing.JLabel (); 63 tfTableName = new javax.swing.JTextField (); 64 lblClassName = new javax.swing.JLabel (); 65 tfClassName = new javax.swing.JTextField (); 66 lblPackageName = new javax.swing.JLabel (); 67 tfPackageName = new javax.swing.JTextField (); 68 lblDynamicProxy = new javax.swing.JLabel (); 69 cbDynamicProxy = new javax.swing.JCheckBox (); 70 lblConversionStrategyClass = new javax.swing.JLabel (); 71 tfConversionStrategyClass = new javax.swing.JTextField (); 72 73 setLayout(new java.awt.GridBagLayout ()); 74 75 addComponentListener(new java.awt.event.ComponentAdapter () 76 { 77 public void componentShown(java.awt.event.ComponentEvent evt) 78 { 79 formComponentShown(evt); 80 } 81 public void componentHidden(java.awt.event.ComponentEvent evt) 82 { 83 formComponentHidden(evt); 84 } 85 }); 86 87 addHierarchyListener(new java.awt.event.HierarchyListener () 88 { 89 public void hierarchyChanged(java.awt.event.HierarchyEvent evt) 90 { 91 formHierarchyChanged(evt); 92 } 93 }); 94 95 jPanel1.setLayout(new java.awt.GridLayout (8, 2)); 96 97 lblEnabled.setDisplayedMnemonic('e'); 98 lblEnabled.setText("enabled"); 99 jPanel1.add(lblEnabled); 100 101 cbEnabled.setMnemonic('e'); 102 cbEnabled.addActionListener(new java.awt.event.ActionListener () 103 { 104 public void actionPerformed(java.awt.event.ActionEvent evt) 105 { 106 cbEnabledActionPerformed(evt); 107 } 108 }); 109 110 jPanel1.add(cbEnabled); 111 112 lblDisabledByParent.setText("disabled by Parent:"); 113 jPanel1.add(lblDisabledByParent); 114 115 cbDisabledByParent.setEnabled(false); 116 jPanel1.add(cbDisabledByParent); 117 118 jPanel1.add(jLabel3); 119 120 jPanel1.add(jLabel4); 121 122 lblTableName.setLabelFor(tfTableName); 123 lblTableName.setText("Table Name:"); 124 jPanel1.add(lblTableName); 125 126 tfTableName.setEditable(false); 127 tfTableName.setText("jTextField1"); 128 tfTableName.setBorder(null); 129 tfTableName.setDisabledTextColor(new java.awt.Color (0, 51, 51)); 130 tfTableName.setEnabled(false); 131 jPanel1.add(tfTableName); 132 133 lblClassName.setDisplayedMnemonic('c'); 134 lblClassName.setLabelFor(tfClassName); 135 lblClassName.setText("Class Name:"); 136 jPanel1.add(lblClassName); 137 138 tfClassName.setText("jTextField1"); 139 tfClassName.addActionListener(new java.awt.event.ActionListener () 140 { 141 public void actionPerformed(java.awt.event.ActionEvent evt) 142 { 143 tfClassNameActionPerformed(evt); 144 } 145 }); 146 147 tfClassName.addFocusListener(new java.awt.event.FocusAdapter () 148 { 149 public void focusLost(java.awt.event.FocusEvent evt) 150 { 151 tfClassNameFocusLost(evt); 152 } 153 }); 154 155 tfClassName.addKeyListener(new java.awt.event.KeyAdapter () 156 { 157 public void keyTyped(java.awt.event.KeyEvent evt) 158 { 159 tfClassNameKeyTyped(evt); 160 } 161 }); 162 163 jPanel1.add(tfClassName); 164 165 lblPackageName.setDisplayedMnemonic('p'); 166 lblPackageName.setLabelFor(tfPackageName); 167 lblPackageName.setText("Package:"); 168 jPanel1.add(lblPackageName); 169 170 tfPackageName.setText("jTextField2"); 171 tfPackageName.addActionListener(new java.awt.event.ActionListener () 172 { 173 public void actionPerformed(java.awt.event.ActionEvent evt) 174 { 175 tfPackageNameActionPerformed(evt); 176 } 177 }); 178 179 tfPackageName.addFocusListener(new java.awt.event.FocusAdapter () 180 { 181 public void focusLost(java.awt.event.FocusEvent evt) 182 { 183 tfPackageNameFocusLost(evt); 184 } 185 }); 186 187 tfPackageName.addKeyListener(new java.awt.event.KeyAdapter () 188 { 189 public void keyTyped(java.awt.event.KeyEvent evt) 190 { 191 tfPackageNameKeyTyped(evt); 192 } 193 }); 194 195 jPanel1.add(tfPackageName); 196 197 lblDynamicProxy.setDisplayedMnemonic('u'); 198 lblDynamicProxy.setText("Use Dynamic Proxy:"); 199 jPanel1.add(lblDynamicProxy); 200 201 cbDynamicProxy.setMnemonic('u'); 202 cbDynamicProxy.addActionListener(new java.awt.event.ActionListener () 203 { 204 public void actionPerformed(java.awt.event.ActionEvent evt) 205 { 206 cbDynamicProxyActionPerformed(evt); 207 } 208 }); 209 210 jPanel1.add(cbDynamicProxy); 211 212 lblConversionStrategyClass.setDisplayedMnemonic('s'); 213 lblConversionStrategyClass.setLabelFor(tfConversionStrategyClass); 214 lblConversionStrategyClass.setText("Conversion Strategy Class:"); 215 jPanel1.add(lblConversionStrategyClass); 216 217 tfConversionStrategyClass.setText("jTextField1"); 218 tfConversionStrategyClass.addActionListener(new java.awt.event.ActionListener () 219 { 220 public void actionPerformed(java.awt.event.ActionEvent evt) 221 { 222 tfConversionStrategyClassActionPerformed(evt); 223 } 224 }); 225 226 tfConversionStrategyClass.addFocusListener(new java.awt.event.FocusAdapter () 227 { 228 public void focusLost(java.awt.event.FocusEvent evt) 229 { 230 tfConversionStrategyClassFocusLost(evt); 231 } 232 }); 233 234 tfConversionStrategyClass.addKeyListener(new java.awt.event.KeyAdapter () 235 { 236 public void keyTyped(java.awt.event.KeyEvent evt) 237 { 238 tfConversionStrategyClassKeyTyped(evt); 239 } 240 }); 241 242 jPanel1.add(tfConversionStrategyClass); 243 244 gridBagConstraints = new java.awt.GridBagConstraints (); 245 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 246 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 247 gridBagConstraints.weightx = 1.0; 248 gridBagConstraints.weighty = 1.0; 249 add(jPanel1, gridBagConstraints); 250 251 } 253 private void tfConversionStrategyClassKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 257 { 258 this.tfConversionStrategyClass.setText(aTable.getConversionStrategyClass()); 259 } 260 } 262 private void tfConversionStrategyClassFocusLost(java.awt.event.FocusEvent evt) { aTable.setConversionStrategyClass(this.tfConversionStrategyClass.getText()); 266 } 268 private void tfConversionStrategyClassActionPerformed(java.awt.event.ActionEvent evt) { aTable.setConversionStrategyClass(this.tfConversionStrategyClass.getText()); 272 } 274 private void tfPackageNameKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 278 { 279 this.tfPackageName.setText(aTable.getPackageName()); 280 } 281 } 283 private void tfPackageNameFocusLost(java.awt.event.FocusEvent evt) { aTable.setPackageName(tfPackageName.getText()); 287 } 289 private void tfPackageNameActionPerformed(java.awt.event.ActionEvent evt) { aTable.setPackageName(tfPackageName.getText()); 293 } 295 private void tfClassNameKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 299 { 300 this.tfClassName.setText(aTable.getClassName()); 301 } 302 } 304 private void tfClassNameFocusLost(java.awt.event.FocusEvent evt) { aTable.setClassName(tfClassName.getText()); 308 } 310 private void tfClassNameActionPerformed(java.awt.event.ActionEvent evt) { aTable.setClassName(tfClassName.getText()); 314 } 316 private void cbDynamicProxyActionPerformed (java.awt.event.ActionEvent evt) { aTable.setDynamicProxy(this.cbDynamicProxy.isSelected()); 320 } 322 private void cbEnabledActionPerformed (java.awt.event.ActionEvent evt) { this.aTable.setEnabled(this.cbEnabled.isSelected()); 326 } 328 private void formHierarchyChanged (java.awt.event.HierarchyEvent evt) { readValuesFromTable(); 332 } 334 private void formComponentHidden (java.awt.event.ComponentEvent evt) { } 339 private void formComponentShown (java.awt.event.ComponentEvent evt) { } 344 public void setModel (PropertySheetModel pm) 345 { 346 if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBTable) 347 { 348 this.aTable = (org.apache.ojb.tools.mapping.reversedb.DBTable)pm; 349 this.readValuesFromTable(); 350 } 351 else 352 throw new IllegalArgumentException (); 353 } 354 355 356 private javax.swing.JLabel lblConversionStrategyClass; 358 private javax.swing.JLabel jLabel4; 359 private javax.swing.JLabel lblClassName; 360 private javax.swing.JLabel lblTableName; 361 private javax.swing.JLabel jLabel3; 362 private javax.swing.JLabel lblEnabled; 363 private javax.swing.JCheckBox cbEnabled; 364 private javax.swing.JCheckBox cbDisabledByParent; 365 private javax.swing.JTextField tfConversionStrategyClass; 366 private javax.swing.JCheckBox cbDynamicProxy; 367 private javax.swing.JTextField tfTableName; 368 private javax.swing.JTextField tfPackageName; 369 private javax.swing.JLabel lblDisabledByParent; 370 private javax.swing.JTextField tfClassName; 371 private javax.swing.JLabel lblPackageName; 372 private javax.swing.JPanel jPanel1; 373 private javax.swing.JLabel lblDynamicProxy; 374 376 } 377 378 448 449 | Popular Tags |