KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb > gui > DBFKRelationPropertySheet


1 package org.apache.ojb.tools.mapping.reversedb.gui;
2
3 import java.awt.event.KeyEvent JavaDoc;
4
5 /* Copyright 2002-2005 The Apache Software Foundation
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 /**
21  *
22  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
23  * @version $Id: DBFKRelationPropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
24  */

25 public class DBFKRelationPropertySheet extends javax.swing.JPanel JavaDoc implements PropertySheetView
26 {
27     org.apache.ojb.tools.mapping.reversedb.DBFKRelation aRelation;
28   /** Creates new form DBCatalogPropertySheet */
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   /** This method is called from within the constructor to
68    * initialize the form.
69    * WARNING: Do NOT modify this code. The content of this method is
70    * always regenerated by the Form Editor.
71    */

72     private void initComponents()//GEN-BEGIN:initComponents
73
{
74         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
75
76         jPanel1 = new javax.swing.JPanel JavaDoc();
77         lblEnabled = new javax.swing.JLabel JavaDoc();
78         cbEnabled = new javax.swing.JCheckBox JavaDoc();
79         lblDisabledByParent = new javax.swing.JLabel JavaDoc();
80         cbDisabledByParent = new javax.swing.JCheckBox JavaDoc();
81         jLabel4 = new javax.swing.JLabel JavaDoc();
82         jLabel3 = new javax.swing.JLabel JavaDoc();
83         lblPKTableName = new javax.swing.JLabel JavaDoc();
84         tfPKTableName = new javax.swing.JTextField JavaDoc();
85         lblFKTableName = new javax.swing.JLabel JavaDoc();
86         tfFKTableName = new javax.swing.JTextField JavaDoc();
87         lblReferenceType = new javax.swing.JLabel JavaDoc();
88         tfReferenceType = new javax.swing.JTextField JavaDoc();
89         jLabel5 = new javax.swing.JLabel JavaDoc();
90         jLabel6 = new javax.swing.JLabel JavaDoc();
91         lblAutoRetrieve = new javax.swing.JLabel JavaDoc();
92         cbAutoRetrieve = new javax.swing.JCheckBox JavaDoc();
93         lblAutoUpdate = new javax.swing.JLabel JavaDoc();
94         cbAutoUpdate = new javax.swing.JCheckBox JavaDoc();
95         lblAutoDelete = new javax.swing.JLabel JavaDoc();
96         cbAutoDelete = new javax.swing.JCheckBox JavaDoc();
97         jLabel10 = new javax.swing.JLabel JavaDoc();
98         jLabel11 = new javax.swing.JLabel JavaDoc();
99         lblJavaFieldName = new javax.swing.JLabel JavaDoc();
100         tfJavaFieldName = new javax.swing.JTextField JavaDoc();
101         lblJavaFieldType = new javax.swing.JLabel JavaDoc();
102         tfJavaFieldType = new javax.swing.JTextField JavaDoc();
103
104         setLayout(new java.awt.GridBagLayout JavaDoc());
105
106         addComponentListener(new java.awt.event.ComponentAdapter JavaDoc()
107         {
108             public void componentShown(java.awt.event.ComponentEvent JavaDoc evt)
109             {
110                 formComponentShown(evt);
111             }
112             public void componentHidden(java.awt.event.ComponentEvent JavaDoc evt)
113             {
114                 formComponentHidden(evt);
115             }
116         });
117
118         addHierarchyListener(new java.awt.event.HierarchyListener JavaDoc()
119         {
120             public void hierarchyChanged(java.awt.event.HierarchyEvent JavaDoc evt)
121             {
122                 formHierarchyChanged(evt);
123             }
124         });
125
126         jPanel1.setLayout(new java.awt.GridLayout JavaDoc(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 JavaDoc()
134         {
135             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc) 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 JavaDoc) 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 JavaDoc) 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 JavaDoc()
196         {
197             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
211         {
212             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
226         {
227             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
246         {
247             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
248             {
249                 tfJavaFieldNameActionPerformed(evt);
250             }
251         });
252
253         tfJavaFieldName.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
254         {
255             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
256             {
257                 tfJavaFieldNameFocusLost(evt);
258             }
259         });
260
261         tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
262         {
263             public void keyTyped(java.awt.event.KeyEvent JavaDoc 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 JavaDoc()
278         {
279             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
280             {
281                 tfJavaFieldTypeActionPerformed(evt);
282             }
283         });
284
285         tfJavaFieldType.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
286         {
287             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
288             {
289                 tfJavaFieldTypeFocusLost(evt);
290             }
291         });
292
293         tfJavaFieldType.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
294         {
295             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt)
296             {
297                 tfJavaFieldTypeKeyTyped(evt);
298             }
299         });
300
301         jPanel1.add(tfJavaFieldType);
302
303         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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     }//GEN-END:initComponents
311

312     private void tfJavaFieldTypeKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldTypeKeyTyped
313
{//GEN-HEADEREND:event_tfJavaFieldTypeKeyTyped
314
// Revert on ESC
315
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
316         {
317             this.tfJavaFieldType.setText(aRelation.getFieldType());
318         }
319     }//GEN-LAST:event_tfJavaFieldTypeKeyTyped
320

321     private void tfJavaFieldTypeFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldTypeFocusLost
322
{//GEN-HEADEREND:event_tfJavaFieldTypeFocusLost
323
// Commit on lost focus
324
this.aRelation.setFieldType(tfJavaFieldType.getText());
325     }//GEN-LAST:event_tfJavaFieldTypeFocusLost
326

327     private void tfJavaFieldTypeActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldTypeActionPerformed
328
{//GEN-HEADEREND:event_tfJavaFieldTypeActionPerformed
329
// Commit on ENTER
330
this.aRelation.setFieldType(tfJavaFieldType.getText());
331     }//GEN-LAST:event_tfJavaFieldTypeActionPerformed
332

333     private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameKeyTyped
334
{//GEN-HEADEREND:event_tfJavaFieldNameKeyTyped
335
// Revert to original value if ESC is typed
336
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
337         {
338             this.tfJavaFieldName.setText(aRelation.getFieldName());
339         }
340     }//GEN-LAST:event_tfJavaFieldNameKeyTyped
341

342     private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameFocusLost
343
{//GEN-HEADEREND:event_tfJavaFieldNameFocusLost
344
// Commit value if focus is lost
345
aRelation.setFieldName(tfJavaFieldName.getText());
346     }//GEN-LAST:event_tfJavaFieldNameFocusLost
347

348     private void tfJavaFieldNameActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameActionPerformed
349
{//GEN-HEADEREND:event_tfJavaFieldNameActionPerformed
350
// Commit value if ENTER is typed
351
aRelation.setFieldName(tfJavaFieldName.getText());
352     }//GEN-LAST:event_tfJavaFieldNameActionPerformed
353

354   private void cbAutoDeleteActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbAutoDeleteActionPerformed
355
{//GEN-HEADEREND:event_cbAutoDeleteActionPerformed
356
// Add your handling code here:
357
this.aRelation.setAutoDelete(this.cbAutoDelete.isSelected());
358   }//GEN-LAST:event_cbAutoDeleteActionPerformed
359

360   private void cbAutoUpdateActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbAutoUpdateActionPerformed
361
{//GEN-HEADEREND:event_cbAutoUpdateActionPerformed
362
// Add your handling code here:
363
this.aRelation.setAutoUpdate(this.cbAutoUpdate.isSelected());
364   }//GEN-LAST:event_cbAutoUpdateActionPerformed
365

366   private void cbAutoRetrieveActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbAutoRetrieveActionPerformed
367
{//GEN-HEADEREND:event_cbAutoRetrieveActionPerformed
368
// Add your handling code here:
369
aRelation.setAutoRetrieve(cbAutoRetrieve.isSelected());
370   }//GEN-LAST:event_cbAutoRetrieveActionPerformed
371

372   private void cbEnabledActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbEnabledActionPerformed
373
{//GEN-HEADEREND:event_cbEnabledActionPerformed
374
// Add your handling code here:
375
aRelation.setEnabled(this.cbEnabled.isSelected());
376   }//GEN-LAST:event_cbEnabledActionPerformed
377

378   private void formHierarchyChanged (java.awt.event.HierarchyEvent JavaDoc evt)//GEN-FIRST:event_formHierarchyChanged
379
{//GEN-HEADEREND:event_formHierarchyChanged
380
// Add your handling code here:
381
readValuesFromReference();
382   }//GEN-LAST:event_formHierarchyChanged
383

384   private void formComponentHidden (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentHidden
385
{//GEN-HEADEREND:event_formComponentHidden
386
// Add your handling code here:
387
}//GEN-LAST:event_formComponentHidden
388

389   private void formComponentShown (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentShown
390
{//GEN-HEADEREND:event_formComponentShown
391
// Add your handling code here:
392
}//GEN-LAST:event_formComponentShown
393

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 JavaDoc();
403   }
404   
405   
406     // Variables declaration - do not modify//GEN-BEGIN:variables
407
private javax.swing.JLabel JavaDoc jLabel4;
408     private javax.swing.JLabel JavaDoc lblAutoUpdate;
409     private javax.swing.JLabel JavaDoc jLabel3;
410     private javax.swing.JCheckBox JavaDoc cbAutoRetrieve;
411     private javax.swing.JLabel JavaDoc lblEnabled;
412     private javax.swing.JCheckBox JavaDoc cbEnabled;
413     private javax.swing.JTextField JavaDoc tfJavaFieldName;
414     private javax.swing.JLabel JavaDoc lblAutoRetrieve;
415     private javax.swing.JCheckBox JavaDoc cbAutoUpdate;
416     private javax.swing.JCheckBox JavaDoc cbDisabledByParent;
417     private javax.swing.JLabel JavaDoc lblJavaFieldType;
418     private javax.swing.JTextField JavaDoc tfReferenceType;
419     private javax.swing.JLabel JavaDoc lblPKTableName;
420     private javax.swing.JLabel JavaDoc lblFKTableName;
421     private javax.swing.JLabel JavaDoc jLabel11;
422     private javax.swing.JTextField JavaDoc tfJavaFieldType;
423     private javax.swing.JTextField JavaDoc tfPKTableName;
424     private javax.swing.JLabel JavaDoc lblDisabledByParent;
425     private javax.swing.JLabel JavaDoc lblReferenceType;
426     private javax.swing.JPanel JavaDoc jPanel1;
427     private javax.swing.JCheckBox JavaDoc cbAutoDelete;
428     private javax.swing.JLabel JavaDoc lblAutoDelete;
429     private javax.swing.JLabel JavaDoc lblJavaFieldName;
430     private javax.swing.JLabel JavaDoc jLabel6;
431     private javax.swing.JTextField JavaDoc tfFKTableName;
432     private javax.swing.JLabel JavaDoc jLabel10;
433     private javax.swing.JLabel JavaDoc jLabel5;
434     // End of variables declaration//GEN-END:variables
435

436 }
437
438 /***************************** Changelog *****************************
439 // $Log: DBFKRelationPropertySheet.java,v $
440 // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
441 // Updated license
442 //
443 // Revision 1.1 2004/05/05 16:38:49 arminw
444 // fix fault
445 // wrong package structure used:
446 // org.apache.ojb.tools.reversdb
447 // org.apache.ojb.tools.reversdb2
448 //
449 // instead of
450 // org.apache.ojb.tools.mapping.reversdb
451 // org.apache.ojb.tools.mapping.reversdb2
452 //
453 // Revision 1.1 2004/05/04 13:44:59 arminw
454 // move reverseDB stuff
455 //
456 // Revision 1.9 2004/04/05 12:16:23 tomdz
457 // Fixed/updated license in files leftover from automatic license transition
458 //
459 // Revision 1.8 2004/04/04 23:53:42 brianm
460 // Fixed initial copyright dates to match cvs repository
461 //
462 // Revision 1.7 2004/03/11 18:16:22 brianm
463 // ASL 2.0
464 //
465 // Revision 1.6 2003/12/12 16:37:16 brj
466 // removed unnecessary casts, semicolons etc.
467 //
468 // Revision 1.5 2003/06/21 10:21:55 florianbruckner
469 // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
470 //
471 // Revision 1.4 2003/02/21 12:47:53 florianbruckner
472 // corrected event handling of JInputField objects, value of field was
473 // not written back to the model object.
474 //
475 // Revision 1.3 2002/06/18 12:26:41 florianbruckner
476 // changes in Netbeans Form definitions after move to jakarta.
477 //
478 // Revision 1.2 2002/06/17 19:34:34 jvanzyl
479 // Correcting all the package references.
480 // PR:
481 // Obtained from:
482 // Submitted by:
483 // Reviewed by:
484 //
485 // Revision 1.1.1.1 2002/06/17 18:16:52 jvanzyl
486 // Initial OJB import
487 //
488 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
489 // fix CR/LF issue, change license to ASL
490 //
491 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
492 //
493 // move files to new location
494 //
495 // Revision 1.3 2002/04/07 09:05:17 thma
496 // *** empty log message ***
497 //
498 // Revision 1.2 2002/03/11 17:36:26 florianbruckner
499 // fix line break issue for these files that were previously checked in with -kb
500 //
501 // Revision 1.1 2002/03/04 17:19:32 thma
502 // initial checking for Florians Reverse engineering tool
503 //
504 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
505 // initial import
506 //
507 /***************************** Changelog *****************************/

508  
509
Popular Tags