1 package org.apache.ojb.tools.mapping.reversedb.gui; 2 3 import java.awt.event.KeyEvent ; 4 5 19 20 25 public class DBFKRelationPropertySheet extends javax.swing.JPanel implements PropertySheetView 26 { 27 org.apache.ojb.tools.mapping.reversedb.DBFKRelation aRelation; 28 29 public DBFKRelationPropertySheet () 30 { 31 initComponents (); 32 } 33 34 private void readValuesFromReference() 35 { 36 if (aRelation.getPKTable() != null) 37 this.tfPKTableName.setText(aRelation.getPKTable().getTableName()); 38 if (aRelation.getFKTable() != null) 39 this.tfFKTableName.setText(aRelation.getFKTable().getTableName()); 40 if (aRelation.isPkTableParent()) 41 { 42 this.tfReferenceType.setText("Collection"); 43 this.tfJavaFieldType.setEditable(true); 44 this.tfJavaFieldType.setText(aRelation.getFieldType()); 45 if (aRelation.getFKTable() != null) 46 this.cbDisabledByParent.setSelected(!aRelation.getPKTable().isTreeEnabled()); 47 } 48 else 49 { 50 this.tfReferenceType.setText ("Reference"); 51 this.tfJavaFieldType.setEditable(false); 52 if (aRelation.getPKTable() != null) 53 { 54 this.tfJavaFieldType.setText(aRelation.getPKTable().getClassName()); 55 this.cbDisabledByParent.setSelected(!aRelation.getFKTable().isTreeEnabled()); 56 } 57 } 58 this.cbEnabled.setSelected(aRelation.isEnabled()); 59 60 this.cbAutoDelete.setSelected(aRelation.getAutoDelete ()); 61 this.cbAutoRetrieve.setSelected(aRelation.getAutoRetrieve()); 62 this.cbAutoUpdate.setSelected(aRelation.getAutoUpdate()); 63 64 this.tfJavaFieldName.setText(aRelation.getFieldName()); 65 } 66 67 72 private void initComponents() { 74 java.awt.GridBagConstraints gridBagConstraints; 75 76 jPanel1 = new javax.swing.JPanel (); 77 lblEnabled = new javax.swing.JLabel (); 78 cbEnabled = new javax.swing.JCheckBox (); 79 lblDisabledByParent = new javax.swing.JLabel (); 80 cbDisabledByParent = new javax.swing.JCheckBox (); 81 jLabel4 = new javax.swing.JLabel (); 82 jLabel3 = new javax.swing.JLabel (); 83 lblPKTableName = new javax.swing.JLabel (); 84 tfPKTableName = new javax.swing.JTextField (); 85 lblFKTableName = new javax.swing.JLabel (); 86 tfFKTableName = new javax.swing.JTextField (); 87 lblReferenceType = new javax.swing.JLabel (); 88 tfReferenceType = new javax.swing.JTextField (); 89 jLabel5 = new javax.swing.JLabel (); 90 jLabel6 = new javax.swing.JLabel (); 91 lblAutoRetrieve = new javax.swing.JLabel (); 92 cbAutoRetrieve = new javax.swing.JCheckBox (); 93 lblAutoUpdate = new javax.swing.JLabel (); 94 cbAutoUpdate = new javax.swing.JCheckBox (); 95 lblAutoDelete = new javax.swing.JLabel (); 96 cbAutoDelete = new javax.swing.JCheckBox (); 97 jLabel10 = new javax.swing.JLabel (); 98 jLabel11 = new javax.swing.JLabel (); 99 lblJavaFieldName = new javax.swing.JLabel (); 100 tfJavaFieldName = new javax.swing.JTextField (); 101 lblJavaFieldType = new javax.swing.JLabel (); 102 tfJavaFieldType = new javax.swing.JTextField (); 103 104 setLayout(new java.awt.GridBagLayout ()); 105 106 addComponentListener(new java.awt.event.ComponentAdapter () 107 { 108 public void componentShown(java.awt.event.ComponentEvent evt) 109 { 110 formComponentShown(evt); 111 } 112 public void componentHidden(java.awt.event.ComponentEvent evt) 113 { 114 formComponentHidden(evt); 115 } 116 }); 117 118 addHierarchyListener(new java.awt.event.HierarchyListener () 119 { 120 public void hierarchyChanged(java.awt.event.HierarchyEvent evt) 121 { 122 formHierarchyChanged(evt); 123 } 124 }); 125 126 jPanel1.setLayout(new java.awt.GridLayout (15, 2)); 127 128 lblEnabled.setDisplayedMnemonic('e'); 129 lblEnabled.setText("enabled:"); 130 jPanel1.add(lblEnabled); 131 132 cbEnabled.setMnemonic('e'); 133 cbEnabled.addActionListener(new java.awt.event.ActionListener () 134 { 135 public void actionPerformed(java.awt.event.ActionEvent evt) 136 { 137 cbEnabledActionPerformed(evt); 138 } 139 }); 140 141 jPanel1.add(cbEnabled); 142 143 lblDisabledByParent.setText("disabled by parent:"); 144 jPanel1.add(lblDisabledByParent); 145 146 cbDisabledByParent.setEnabled(false); 147 jPanel1.add(cbDisabledByParent); 148 149 jPanel1.add(jLabel4); 150 151 jPanel1.add(jLabel3); 152 153 lblPKTableName.setLabelFor(tfPKTableName); 154 lblPKTableName.setText("Primary Key Table:"); 155 jPanel1.add(lblPKTableName); 156 157 tfPKTableName.setEditable(false); 158 tfPKTableName.setText("jTextField1"); 159 tfPKTableName.setBorder(null); 160 tfPKTableName.setDisabledTextColor((java.awt.Color ) javax.swing.UIManager.getDefaults().get("TextField.foreground")); 161 tfPKTableName.setEnabled(false); 162 jPanel1.add(tfPKTableName); 163 164 lblFKTableName.setLabelFor(tfFKTableName); 165 lblFKTableName.setText("Foreign Key Table:"); 166 jPanel1.add(lblFKTableName); 167 168 tfFKTableName.setEditable(false); 169 tfFKTableName.setText("jTextField1"); 170 tfFKTableName.setBorder(null); 171 tfFKTableName.setDisabledTextColor((java.awt.Color ) javax.swing.UIManager.getDefaults().get("TextField.foreground")); 172 tfFKTableName.setEnabled(false); 173 jPanel1.add(tfFKTableName); 174 175 lblReferenceType.setLabelFor(tfReferenceType); 176 lblReferenceType.setText("Type:"); 177 jPanel1.add(lblReferenceType); 178 179 tfReferenceType.setEditable(false); 180 tfReferenceType.setText("jTextField1"); 181 tfReferenceType.setBorder(null); 182 tfReferenceType.setDisabledTextColor((java.awt.Color ) javax.swing.UIManager.getDefaults().get("TextField.foreground")); 183 tfReferenceType.setEnabled(false); 184 jPanel1.add(tfReferenceType); 185 186 jPanel1.add(jLabel5); 187 188 jPanel1.add(jLabel6); 189 190 lblAutoRetrieve.setDisplayedMnemonic('r'); 191 lblAutoRetrieve.setText("Auto retrieve:"); 192 jPanel1.add(lblAutoRetrieve); 193 194 cbAutoRetrieve.setMnemonic('r'); 195 cbAutoRetrieve.addActionListener(new java.awt.event.ActionListener () 196 { 197 public void actionPerformed(java.awt.event.ActionEvent evt) 198 { 199 cbAutoRetrieveActionPerformed(evt); 200 } 201 }); 202 203 jPanel1.add(cbAutoRetrieve); 204 205 lblAutoUpdate.setDisplayedMnemonic('u'); 206 lblAutoUpdate.setText("Auto update:"); 207 jPanel1.add(lblAutoUpdate); 208 209 cbAutoUpdate.setMnemonic('u'); 210 cbAutoUpdate.addActionListener(new java.awt.event.ActionListener () 211 { 212 public void actionPerformed(java.awt.event.ActionEvent evt) 213 { 214 cbAutoUpdateActionPerformed(evt); 215 } 216 }); 217 218 jPanel1.add(cbAutoUpdate); 219 220 lblAutoDelete.setDisplayedMnemonic('d'); 221 lblAutoDelete.setText("Auto delete:"); 222 jPanel1.add(lblAutoDelete); 223 224 cbAutoDelete.setMnemonic('d'); 225 cbAutoDelete.addActionListener(new java.awt.event.ActionListener () 226 { 227 public void actionPerformed(java.awt.event.ActionEvent evt) 228 { 229 cbAutoDeleteActionPerformed(evt); 230 } 231 }); 232 233 jPanel1.add(cbAutoDelete); 234 235 jPanel1.add(jLabel10); 236 237 jPanel1.add(jLabel11); 238 239 lblJavaFieldName.setDisplayedMnemonic('n'); 240 lblJavaFieldName.setLabelFor(tfJavaFieldName); 241 lblJavaFieldName.setText("Java Field Name:"); 242 jPanel1.add(lblJavaFieldName); 243 244 tfJavaFieldName.setText("jTextField1"); 245 tfJavaFieldName.addActionListener(new java.awt.event.ActionListener () 246 { 247 public void actionPerformed(java.awt.event.ActionEvent evt) 248 { 249 tfJavaFieldNameActionPerformed(evt); 250 } 251 }); 252 253 tfJavaFieldName.addFocusListener(new java.awt.event.FocusAdapter () 254 { 255 public void focusLost(java.awt.event.FocusEvent evt) 256 { 257 tfJavaFieldNameFocusLost(evt); 258 } 259 }); 260 261 tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter () 262 { 263 public void keyTyped(java.awt.event.KeyEvent evt) 264 { 265 tfJavaFieldNameKeyTyped(evt); 266 } 267 }); 268 269 jPanel1.add(tfJavaFieldName); 270 271 lblJavaFieldType.setDisplayedMnemonic('t'); 272 lblJavaFieldType.setLabelFor(tfJavaFieldType); 273 lblJavaFieldType.setText("Java Field Type:"); 274 jPanel1.add(lblJavaFieldType); 275 276 tfJavaFieldType.setText("jTextField2"); 277 tfJavaFieldType.addActionListener(new java.awt.event.ActionListener () 278 { 279 public void actionPerformed(java.awt.event.ActionEvent evt) 280 { 281 tfJavaFieldTypeActionPerformed(evt); 282 } 283 }); 284 285 tfJavaFieldType.addFocusListener(new java.awt.event.FocusAdapter () 286 { 287 public void focusLost(java.awt.event.FocusEvent evt) 288 { 289 tfJavaFieldTypeFocusLost(evt); 290 } 291 }); 292 293 tfJavaFieldType.addKeyListener(new java.awt.event.KeyAdapter () 294 { 295 public void keyTyped(java.awt.event.KeyEvent evt) 296 { 297 tfJavaFieldTypeKeyTyped(evt); 298 } 299 }); 300 301 jPanel1.add(tfJavaFieldType); 302 303 gridBagConstraints = new java.awt.GridBagConstraints (); 304 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 305 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 306 gridBagConstraints.weightx = 1.0; 307 gridBagConstraints.weighty = 1.0; 308 add(jPanel1, gridBagConstraints); 309 310 } 312 private void tfJavaFieldTypeKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 316 { 317 this.tfJavaFieldType.setText(aRelation.getFieldType()); 318 } 319 } 321 private void tfJavaFieldTypeFocusLost(java.awt.event.FocusEvent evt) { this.aRelation.setFieldType(tfJavaFieldType.getText()); 325 } 327 private void tfJavaFieldTypeActionPerformed(java.awt.event.ActionEvent evt) { this.aRelation.setFieldType(tfJavaFieldType.getText()); 331 } 333 private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 337 { 338 this.tfJavaFieldName.setText(aRelation.getFieldName()); 339 } 340 } 342 private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent evt) { aRelation.setFieldName(tfJavaFieldName.getText()); 346 } 348 private void tfJavaFieldNameActionPerformed(java.awt.event.ActionEvent evt) { aRelation.setFieldName(tfJavaFieldName.getText()); 352 } 354 private void cbAutoDeleteActionPerformed (java.awt.event.ActionEvent evt) { this.aRelation.setAutoDelete(this.cbAutoDelete.isSelected()); 358 } 360 private void cbAutoUpdateActionPerformed (java.awt.event.ActionEvent evt) { this.aRelation.setAutoUpdate(this.cbAutoUpdate.isSelected()); 364 } 366 private void cbAutoRetrieveActionPerformed (java.awt.event.ActionEvent evt) { aRelation.setAutoRetrieve(cbAutoRetrieve.isSelected()); 370 } 372 private void cbEnabledActionPerformed (java.awt.event.ActionEvent evt) { aRelation.setEnabled(this.cbEnabled.isSelected()); 376 } 378 private void formHierarchyChanged (java.awt.event.HierarchyEvent evt) { readValuesFromReference(); 382 } 384 private void formComponentHidden (java.awt.event.ComponentEvent evt) { } 389 private void formComponentShown (java.awt.event.ComponentEvent evt) { } 394 public void setModel (PropertySheetModel pm) 395 { 396 if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBFKRelation) 397 { 398 this.aRelation = (org.apache.ojb.tools.mapping.reversedb.DBFKRelation)pm; 399 this.readValuesFromReference(); 400 } 401 else 402 throw new IllegalArgumentException (); 403 } 404 405 406 private javax.swing.JLabel jLabel4; 408 private javax.swing.JLabel lblAutoUpdate; 409 private javax.swing.JLabel jLabel3; 410 private javax.swing.JCheckBox cbAutoRetrieve; 411 private javax.swing.JLabel lblEnabled; 412 private javax.swing.JCheckBox cbEnabled; 413 private javax.swing.JTextField tfJavaFieldName; 414 private javax.swing.JLabel lblAutoRetrieve; 415 private javax.swing.JCheckBox cbAutoUpdate; 416 private javax.swing.JCheckBox cbDisabledByParent; 417 private javax.swing.JLabel lblJavaFieldType; 418 private javax.swing.JTextField tfReferenceType; 419 private javax.swing.JLabel lblPKTableName; 420 private javax.swing.JLabel lblFKTableName; 421 private javax.swing.JLabel jLabel11; 422 private javax.swing.JTextField tfJavaFieldType; 423 private javax.swing.JTextField tfPKTableName; 424 private javax.swing.JLabel lblDisabledByParent; 425 private javax.swing.JLabel lblReferenceType; 426 private javax.swing.JPanel jPanel1; 427 private javax.swing.JCheckBox cbAutoDelete; 428 private javax.swing.JLabel lblAutoDelete; 429 private javax.swing.JLabel lblJavaFieldName; 430 private javax.swing.JLabel jLabel6; 431 private javax.swing.JTextField tfFKTableName; 432 private javax.swing.JLabel jLabel10; 433 private javax.swing.JLabel jLabel5; 434 436 } 437 438 508 509 | Popular Tags |