KickJava   Java API By Example, From Geeks To Geeks.

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


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: DBTablePropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
24  */

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

51     private void initComponents()//GEN-BEGIN:initComponents
52
{
53         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
54
55         jPanel1 = new javax.swing.JPanel JavaDoc();
56         lblEnabled = new javax.swing.JLabel JavaDoc();
57         cbEnabled = new javax.swing.JCheckBox JavaDoc();
58         lblDisabledByParent = new javax.swing.JLabel JavaDoc();
59         cbDisabledByParent = new javax.swing.JCheckBox JavaDoc();
60         jLabel3 = new javax.swing.JLabel JavaDoc();
61         jLabel4 = new javax.swing.JLabel JavaDoc();
62         lblTableName = new javax.swing.JLabel JavaDoc();
63         tfTableName = new javax.swing.JTextField JavaDoc();
64         lblClassName = new javax.swing.JLabel JavaDoc();
65         tfClassName = new javax.swing.JTextField JavaDoc();
66         lblPackageName = new javax.swing.JLabel JavaDoc();
67         tfPackageName = new javax.swing.JTextField JavaDoc();
68         lblDynamicProxy = new javax.swing.JLabel JavaDoc();
69         cbDynamicProxy = new javax.swing.JCheckBox JavaDoc();
70         lblConversionStrategyClass = new javax.swing.JLabel JavaDoc();
71         tfConversionStrategyClass = new javax.swing.JTextField JavaDoc();
72
73         setLayout(new java.awt.GridBagLayout JavaDoc());
74
75         addComponentListener(new java.awt.event.ComponentAdapter JavaDoc()
76         {
77             public void componentShown(java.awt.event.ComponentEvent JavaDoc evt)
78             {
79                 formComponentShown(evt);
80             }
81             public void componentHidden(java.awt.event.ComponentEvent JavaDoc evt)
82             {
83                 formComponentHidden(evt);
84             }
85         });
86
87         addHierarchyListener(new java.awt.event.HierarchyListener JavaDoc()
88         {
89             public void hierarchyChanged(java.awt.event.HierarchyEvent JavaDoc evt)
90             {
91                 formHierarchyChanged(evt);
92             }
93         });
94
95         jPanel1.setLayout(new java.awt.GridLayout JavaDoc(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 JavaDoc()
103         {
104             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc(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 JavaDoc()
140         {
141             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
142             {
143                 tfClassNameActionPerformed(evt);
144             }
145         });
146
147         tfClassName.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
148         {
149             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
150             {
151                 tfClassNameFocusLost(evt);
152             }
153         });
154
155         tfClassName.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
156         {
157             public void keyTyped(java.awt.event.KeyEvent JavaDoc 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 JavaDoc()
172         {
173             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
174             {
175                 tfPackageNameActionPerformed(evt);
176             }
177         });
178
179         tfPackageName.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
180         {
181             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
182             {
183                 tfPackageNameFocusLost(evt);
184             }
185         });
186
187         tfPackageName.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
188         {
189             public void keyTyped(java.awt.event.KeyEvent JavaDoc 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 JavaDoc()
203         {
204             public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
219         {
220             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
221             {
222                 tfConversionStrategyClassActionPerformed(evt);
223             }
224         });
225
226         tfConversionStrategyClass.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
227         {
228             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
229             {
230                 tfConversionStrategyClassFocusLost(evt);
231             }
232         });
233
234         tfConversionStrategyClass.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
235         {
236             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt)
237             {
238                 tfConversionStrategyClassKeyTyped(evt);
239             }
240         });
241
242         jPanel1.add(tfConversionStrategyClass);
243
244         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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     }//GEN-END:initComponents
252

253     private void tfConversionStrategyClassKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfConversionStrategyClassKeyTyped
254
{//GEN-HEADEREND:event_tfConversionStrategyClassKeyTyped
255
// Revert on ESC
256
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
257         {
258             this.tfConversionStrategyClass.setText(aTable.getConversionStrategyClass());
259         }
260     }//GEN-LAST:event_tfConversionStrategyClassKeyTyped
261

262     private void tfConversionStrategyClassFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfConversionStrategyClassFocusLost
263
{//GEN-HEADEREND:event_tfConversionStrategyClassFocusLost
264
// Commit on lost focus
265
aTable.setConversionStrategyClass(this.tfConversionStrategyClass.getText());
266     }//GEN-LAST:event_tfConversionStrategyClassFocusLost
267

268     private void tfConversionStrategyClassActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfConversionStrategyClassActionPerformed
269
{//GEN-HEADEREND:event_tfConversionStrategyClassActionPerformed
270
// Commit on ENTER
271
aTable.setConversionStrategyClass(this.tfConversionStrategyClass.getText());
272     }//GEN-LAST:event_tfConversionStrategyClassActionPerformed
273

274     private void tfPackageNameKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfPackageNameKeyTyped
275
{//GEN-HEADEREND:event_tfPackageNameKeyTyped
276
// Revert on ESC
277
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
278         {
279             this.tfPackageName.setText(aTable.getPackageName());
280         }
281     }//GEN-LAST:event_tfPackageNameKeyTyped
282

283     private void tfPackageNameFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfPackageNameFocusLost
284
{//GEN-HEADEREND:event_tfPackageNameFocusLost
285
// Commit on lost focus
286
aTable.setPackageName(tfPackageName.getText());
287     }//GEN-LAST:event_tfPackageNameFocusLost
288

289     private void tfPackageNameActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfPackageNameActionPerformed
290
{//GEN-HEADEREND:event_tfPackageNameActionPerformed
291
// Commit on ENTER
292
aTable.setPackageName(tfPackageName.getText());
293     }//GEN-LAST:event_tfPackageNameActionPerformed
294

295     private void tfClassNameKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfClassNameKeyTyped
296
{//GEN-HEADEREND:event_tfClassNameKeyTyped
297
// Revert on ESC
298
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
299         {
300             this.tfClassName.setText(aTable.getClassName());
301         }
302     }//GEN-LAST:event_tfClassNameKeyTyped
303

304     private void tfClassNameFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfClassNameFocusLost
305
{//GEN-HEADEREND:event_tfClassNameFocusLost
306
// Commit on lost focus
307
aTable.setClassName(tfClassName.getText());
308     }//GEN-LAST:event_tfClassNameFocusLost
309

310     private void tfClassNameActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfClassNameActionPerformed
311
{//GEN-HEADEREND:event_tfClassNameActionPerformed
312
// Commit on ENTER
313
aTable.setClassName(tfClassName.getText());
314     }//GEN-LAST:event_tfClassNameActionPerformed
315

316   private void cbDynamicProxyActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbDynamicProxyActionPerformed
317
{//GEN-HEADEREND:event_cbDynamicProxyActionPerformed
318
// Add your handling code here:
319
aTable.setDynamicProxy(this.cbDynamicProxy.isSelected());
320   }//GEN-LAST:event_cbDynamicProxyActionPerformed
321

322   private void cbEnabledActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbEnabledActionPerformed
323
{//GEN-HEADEREND:event_cbEnabledActionPerformed
324
// Add your handling code here:
325
this.aTable.setEnabled(this.cbEnabled.isSelected());
326   }//GEN-LAST:event_cbEnabledActionPerformed
327

328   private void formHierarchyChanged (java.awt.event.HierarchyEvent JavaDoc evt)//GEN-FIRST:event_formHierarchyChanged
329
{//GEN-HEADEREND:event_formHierarchyChanged
330
// Add your handling code here:
331
readValuesFromTable();
332   }//GEN-LAST:event_formHierarchyChanged
333

334   private void formComponentHidden (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentHidden
335
{//GEN-HEADEREND:event_formComponentHidden
336
// Add your handling code here:
337
}//GEN-LAST:event_formComponentHidden
338

339   private void formComponentShown (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentShown
340
{//GEN-HEADEREND:event_formComponentShown
341
// Add your handling code here:
342
}//GEN-LAST:event_formComponentShown
343

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 JavaDoc();
353   }
354   
355   
356     // Variables declaration - do not modify//GEN-BEGIN:variables
357
private javax.swing.JLabel JavaDoc lblConversionStrategyClass;
358     private javax.swing.JLabel JavaDoc jLabel4;
359     private javax.swing.JLabel JavaDoc lblClassName;
360     private javax.swing.JLabel JavaDoc lblTableName;
361     private javax.swing.JLabel JavaDoc jLabel3;
362     private javax.swing.JLabel JavaDoc lblEnabled;
363     private javax.swing.JCheckBox JavaDoc cbEnabled;
364     private javax.swing.JCheckBox JavaDoc cbDisabledByParent;
365     private javax.swing.JTextField JavaDoc tfConversionStrategyClass;
366     private javax.swing.JCheckBox JavaDoc cbDynamicProxy;
367     private javax.swing.JTextField JavaDoc tfTableName;
368     private javax.swing.JTextField JavaDoc tfPackageName;
369     private javax.swing.JLabel JavaDoc lblDisabledByParent;
370     private javax.swing.JTextField JavaDoc tfClassName;
371     private javax.swing.JLabel JavaDoc lblPackageName;
372     private javax.swing.JPanel JavaDoc jPanel1;
373     private javax.swing.JLabel JavaDoc lblDynamicProxy;
374     // End of variables declaration//GEN-END:variables
375

376 }
377
378 /***************************** Changelog *****************************
379 // $Log: DBTablePropertySheet.java,v $
380 // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
381 // Updated license
382 //
383 // Revision 1.1 2004/05/05 16:38:49 arminw
384 // fix fault
385 // wrong package structure used:
386 // org.apache.ojb.tools.reversdb
387 // org.apache.ojb.tools.reversdb2
388 //
389 // instead of
390 // org.apache.ojb.tools.mapping.reversdb
391 // org.apache.ojb.tools.mapping.reversdb2
392 //
393 // Revision 1.1 2004/05/04 13:44:59 arminw
394 // move reverseDB stuff
395 //
396 // Revision 1.9 2004/04/05 12:16:23 tomdz
397 // Fixed/updated license in files leftover from automatic license transition
398 //
399 // Revision 1.8 2004/04/04 23:53:42 brianm
400 // Fixed initial copyright dates to match cvs repository
401 //
402 // Revision 1.7 2004/03/11 18:16:22 brianm
403 // ASL 2.0
404 //
405 // Revision 1.6 2003/06/21 10:21:55 florianbruckner
406 // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
407 //
408 // Revision 1.5 2003/06/07 10:11:50 brj
409 // some style fixes
410 //
411 // Revision 1.4 2003/02/21 12:48:07 florianbruckner
412 // corrected event handling of JInputField objects, value of field was
413 // not written back to the model object.
414 //
415 // Revision 1.3 2002/06/18 12:26:41 florianbruckner
416 // changes in Netbeans Form definitions after move to jakarta.
417 //
418 // Revision 1.2 2002/06/17 19:34:34 jvanzyl
419 // Correcting all the package references.
420 // PR:
421 // Obtained from:
422 // Submitted by:
423 // Reviewed by:
424 //
425 // Revision 1.1.1.1 2002/06/17 18:16:54 jvanzyl
426 // Initial OJB import
427 //
428 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
429 // fix CR/LF issue, change license to ASL
430 //
431 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
432 //
433 // move files to new location
434 //
435 // Revision 1.3 2002/04/07 09:05:17 thma
436 // *** empty log message ***
437 //
438 // Revision 1.2 2002/03/11 17:36:26 florianbruckner
439 // fix line break issue for these files that were previously checked in with -kb
440 //
441 // Revision 1.1 2002/03/04 17:19:32 thma
442 // initial checking for Florians Reverse engineering tool
443 //
444 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
445 // initial import
446 //
447 /***************************** Changelog *****************************/

448  
449
Popular Tags