KickJava   Java API By Example, From Geeks To Geeks.

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


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

17
18 import java.awt.event.KeyEvent JavaDoc;
19
20 import org.apache.ojb.tools.mapping.reversedb.Utilities;
21
22 /**
23  *
24  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
25  * @version $Id: DBColumnPropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
26  */

27 public class DBColumnPropertySheet extends javax.swing.JPanel JavaDoc
28   implements PropertySheetView
29 {
30     org.apache.ojb.tools.mapping.reversedb.DBColumn aColumn;
31   /** Creates new form DBCatalogPropertySheet */
32   public DBColumnPropertySheet ()
33   {
34     initComponents ();
35   }
36   
37   private void readValuesFromColumn()
38   {
39     this.tfColumnName.setText(aColumn.getColumnName());
40     this.cbEnabled.setSelected(aColumn.isEnabled());
41     this.cbDisabledByParent.setSelected(!aColumn.getDBTable().isTreeEnabled());
42     this.cmbSQLType.setSelectedItem(org.apache.ojb.tools.mapping.reversedb.Utilities.hmJDBCTypeToName.get(new Integer JavaDoc(aColumn.getColumnType())));
43     this.tfSQLTypeName.setText(aColumn.getColumnTypeName ());
44     this.tfJavaFieldName.setText(aColumn.getJavaFieldName());
45     this.cmbJavaType.setSelectedItem(aColumn.getJavaFieldType());
46   }
47   
48   /** This method is called from within the constructor to
49    * initialize the form.
50    * WARNING: Do NOT modify this code. The content of this method is
51    * always regenerated by the Form Editor.
52    */

53     private void initComponents()//GEN-BEGIN:initComponents
54
{
55         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
56
57         jPanel1 = new javax.swing.JPanel JavaDoc();
58         lblEnabled = new javax.swing.JLabel JavaDoc();
59         cbEnabled = new javax.swing.JCheckBox JavaDoc();
60         lblDisabledByParent = new javax.swing.JLabel JavaDoc();
61         cbDisabledByParent = new javax.swing.JCheckBox JavaDoc();
62         jLabel4 = new javax.swing.JLabel JavaDoc();
63         jLabel3 = new javax.swing.JLabel JavaDoc();
64         lblColumnName = new javax.swing.JLabel JavaDoc();
65         tfColumnName = new javax.swing.JTextField JavaDoc();
66         lblJavaFieldName = new javax.swing.JLabel JavaDoc();
67         tfJavaFieldName = new javax.swing.JTextField JavaDoc();
68         lblSQLTypeName = new javax.swing.JLabel JavaDoc();
69         tfSQLTypeName = new javax.swing.JTextField JavaDoc();
70         lblSQLType = new javax.swing.JLabel JavaDoc();
71         cmbSQLType = new javax.swing.JComboBox JavaDoc();
72         lblJavaType = new javax.swing.JLabel JavaDoc();
73         cmbJavaType = new javax.swing.JComboBox JavaDoc();
74
75         setLayout(new java.awt.GridBagLayout JavaDoc());
76
77         addComponentListener(new java.awt.event.ComponentAdapter JavaDoc()
78         {
79             public void componentShown(java.awt.event.ComponentEvent JavaDoc evt)
80             {
81                 formComponentShown(evt);
82             }
83             public void componentHidden(java.awt.event.ComponentEvent JavaDoc evt)
84             {
85                 formComponentHidden(evt);
86             }
87         });
88
89         addHierarchyListener(new java.awt.event.HierarchyListener JavaDoc()
90         {
91             public void hierarchyChanged(java.awt.event.HierarchyEvent JavaDoc evt)
92             {
93                 formHierarchyChanged(evt);
94             }
95         });
96
97         jPanel1.setLayout(new java.awt.GridLayout JavaDoc(8, 2));
98
99         lblEnabled.setDisplayedMnemonic('e');
100         lblEnabled.setText("enabled:");
101         jPanel1.add(lblEnabled);
102
103         cbEnabled.setMnemonic('e');
104         cbEnabled.addActionListener(new java.awt.event.ActionListener JavaDoc()
105         {
106             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
107             {
108                 cbEnabledActionPerformed(evt);
109             }
110         });
111
112         jPanel1.add(cbEnabled);
113
114         lblDisabledByParent.setText("disabled by Parent:");
115         jPanel1.add(lblDisabledByParent);
116
117         cbDisabledByParent.setMnemonic('d');
118         cbDisabledByParent.setEnabled(false);
119         jPanel1.add(cbDisabledByParent);
120
121         jPanel1.add(jLabel4);
122
123         jPanel1.add(jLabel3);
124
125         lblColumnName.setLabelFor(tfColumnName);
126         lblColumnName.setText("Column Name:");
127         jPanel1.add(lblColumnName);
128
129         tfColumnName.setEditable(false);
130         tfColumnName.setText("jTextField1");
131         tfColumnName.setBorder(null);
132         tfColumnName.setDisabledTextColor((java.awt.Color JavaDoc) javax.swing.UIManager.getDefaults().get("windowText"));
133         tfColumnName.setEnabled(false);
134         jPanel1.add(tfColumnName);
135
136         lblJavaFieldName.setLabelFor(tfColumnName);
137         lblJavaFieldName.setText("Java Field Name:");
138         jPanel1.add(lblJavaFieldName);
139
140         tfJavaFieldName.setText("jTextField1");
141         tfJavaFieldName.addActionListener(new java.awt.event.ActionListener JavaDoc()
142         {
143             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
144             {
145                 tfJavaFieldNameActionPerformed(evt);
146             }
147         });
148
149         tfJavaFieldName.addFocusListener(new java.awt.event.FocusAdapter JavaDoc()
150         {
151             public void focusLost(java.awt.event.FocusEvent JavaDoc evt)
152             {
153                 tfJavaFieldNameFocusLost(evt);
154             }
155         });
156
157         tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter JavaDoc()
158         {
159             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt)
160             {
161                 tfJavaFieldNameKeyTyped(evt);
162             }
163         });
164
165         jPanel1.add(tfJavaFieldName);
166
167         lblSQLTypeName.setLabelFor(tfColumnName);
168         lblSQLTypeName.setText("SQL Type Name:");
169         jPanel1.add(lblSQLTypeName);
170
171         tfSQLTypeName.setEditable(false);
172         tfSQLTypeName.setText("jTextField1");
173         tfSQLTypeName.setBorder(null);
174         tfSQLTypeName.setDisabledTextColor((java.awt.Color JavaDoc) javax.swing.UIManager.getDefaults().get("windowText"));
175         tfSQLTypeName.setEnabled(false);
176         jPanel1.add(tfSQLTypeName);
177
178         lblSQLType.setText("Java SQL Type:");
179         jPanel1.add(lblSQLType);
180
181         cmbSQLType.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(Utilities.vJDBCTypeNames));
182         cmbSQLType.addActionListener(new java.awt.event.ActionListener JavaDoc()
183         {
184             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
185             {
186                 cmbSQLTypeActionPerformed(evt);
187             }
188         });
189
190         jPanel1.add(cmbSQLType);
191
192         lblJavaType.setText("Java Type:");
193         jPanel1.add(lblJavaType);
194
195         cmbJavaType.setEditable(true);
196         cmbJavaType.setModel( new org.apache.ojb.tools.swing.SortingComboBoxModel(Utilities.vJavaTypes)
197             /*new javax.swing.DefaultComboBoxModel(at.citec.ojb.schemegenerator.Utilities.vJavaTypes)*/);
198         cmbJavaType.addActionListener(new java.awt.event.ActionListener JavaDoc()
199         {
200             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
201             {
202                 cmbJavaTypeActionPerformed(evt);
203             }
204         });
205
206         jPanel1.add(cmbJavaType);
207
208         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
209         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
210         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
211         gridBagConstraints.weightx = 1.0;
212         gridBagConstraints.weighty = 1.0;
213         add(jPanel1, gridBagConstraints);
214
215     }//GEN-END:initComponents
216

217     private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameKeyTyped
218
{//GEN-HEADEREND:event_tfJavaFieldNameKeyTyped
219
// Revert to original value if ESC is pressed.
220
if (evt.getKeyChar() == KeyEvent.VK_ESCAPE)
221         {
222             this.tfJavaFieldName.setText(aColumn.getJavaFieldName());
223         }
224     }//GEN-LAST:event_tfJavaFieldNameKeyTyped
225

226     private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameFocusLost
227
{//GEN-HEADEREND:event_tfJavaFieldNameFocusLost
228
// Commit the new value to the column if the focus is lost
229
aColumn.setJavaFieldName(tfJavaFieldName.getText());
230     }//GEN-LAST:event_tfJavaFieldNameFocusLost
231

232     private void tfJavaFieldNameActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_tfJavaFieldNameActionPerformed
233
{//GEN-HEADEREND:event_tfJavaFieldNameActionPerformed
234
// Commit value to column object if ENTER is pressed
235
aColumn.setJavaFieldName(tfJavaFieldName.getText());
236     }//GEN-LAST:event_tfJavaFieldNameActionPerformed
237

238   private void cmbJavaTypeActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cmbJavaTypeActionPerformed
239
{//GEN-HEADEREND:event_cmbJavaTypeActionPerformed
240
// Add your handling code here:
241
aColumn.setJavaFieldType(cmbJavaType.getSelectedItem().toString());
242     if (cmbJavaType.getModel() instanceof org.apache.ojb.tools.swing.SortingComboBoxModel)
243     {
244       org.apache.ojb.tools.swing.SortingComboBoxModel cmbModel =
245         (org.apache.ojb.tools.swing.SortingComboBoxModel)this.cmbJavaType.getModel();
246       if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1 )
247         cmbJavaType.addItem(cmbJavaType.getSelectedItem());
248     }
249     else if (cmbJavaType.getModel() instanceof javax.swing.DefaultComboBoxModel JavaDoc)
250     {
251       javax.swing.DefaultComboBoxModel JavaDoc cmbModel =
252         (javax.swing.DefaultComboBoxModel JavaDoc)this.cmbJavaType.getModel();
253       if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1 )
254         cmbJavaType.addItem(cmbJavaType.getSelectedItem());
255     }
256   }//GEN-LAST:event_cmbJavaTypeActionPerformed
257

258   private void cbEnabledActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cbEnabledActionPerformed
259
{//GEN-HEADEREND:event_cbEnabledActionPerformed
260
// Add your handling code here:
261
this.aColumn.setEnabled(this.cbEnabled.isSelected());
262   }//GEN-LAST:event_cbEnabledActionPerformed
263

264   private void cmbSQLTypeActionPerformed (java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cmbSQLTypeActionPerformed
265
{//GEN-HEADEREND:event_cmbSQLTypeActionPerformed
266
// Add your handling code here:
267
// System.out.println(this.jComboBox1.getSelectedItem());
268
aColumn.setColumnType(this.cmbSQLType.getSelectedItem().toString());
269   }//GEN-LAST:event_cmbSQLTypeActionPerformed
270

271   private void formHierarchyChanged (java.awt.event.HierarchyEvent JavaDoc evt)//GEN-FIRST:event_formHierarchyChanged
272
{//GEN-HEADEREND:event_formHierarchyChanged
273
// Add your handling code here:
274
readValuesFromColumn();
275   }//GEN-LAST:event_formHierarchyChanged
276

277   private void formComponentHidden (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentHidden
278
{//GEN-HEADEREND:event_formComponentHidden
279
// Add your handling code here:
280
}//GEN-LAST:event_formComponentHidden
281

282   private void formComponentShown (java.awt.event.ComponentEvent JavaDoc evt)//GEN-FIRST:event_formComponentShown
283
{//GEN-HEADEREND:event_formComponentShown
284
// Add your handling code here:
285
}//GEN-LAST:event_formComponentShown
286

287   public void setModel (PropertySheetModel pm)
288   {
289     if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBColumn)
290     {
291       this.aColumn = (org.apache.ojb.tools.mapping.reversedb.DBColumn)pm;
292       this.readValuesFromColumn();
293     }
294     else
295       throw new IllegalArgumentException JavaDoc();
296   }
297   
298   
299     // Variables declaration - do not modify//GEN-BEGIN:variables
300
private javax.swing.JLabel JavaDoc jLabel4;
301     private javax.swing.JLabel JavaDoc lblSQLTypeName;
302     private javax.swing.JLabel JavaDoc jLabel3;
303     private javax.swing.JComboBox JavaDoc cmbSQLType;
304     private javax.swing.JLabel JavaDoc lblJavaType;
305     private javax.swing.JLabel JavaDoc lblEnabled;
306     private javax.swing.JCheckBox JavaDoc cbEnabled;
307     private javax.swing.JTextField JavaDoc tfJavaFieldName;
308     private javax.swing.JCheckBox JavaDoc cbDisabledByParent;
309     private javax.swing.JTextField JavaDoc tfColumnName;
310     private javax.swing.JLabel JavaDoc lblDisabledByParent;
311     private javax.swing.JLabel JavaDoc lblColumnName;
312     private javax.swing.JComboBox JavaDoc cmbJavaType;
313     private javax.swing.JPanel JavaDoc jPanel1;
314     private javax.swing.JLabel JavaDoc lblJavaFieldName;
315     private javax.swing.JLabel JavaDoc lblSQLType;
316     private javax.swing.JTextField JavaDoc tfSQLTypeName;
317     // End of variables declaration//GEN-END:variables
318

319 }
320
321
322 /***************************** Changelog *****************************
323 // $Log: DBColumnPropertySheet.java,v $
324 // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
325 // Updated license
326 //
327 // Revision 1.1 2004/05/05 16:38:49 arminw
328 // fix fault
329 // wrong package structure used:
330 // org.apache.ojb.tools.reversdb
331 // org.apache.ojb.tools.reversdb2
332 //
333 // instead of
334 // org.apache.ojb.tools.mapping.reversdb
335 // org.apache.ojb.tools.mapping.reversdb2
336 //
337 // Revision 1.1 2004/05/04 13:44:59 arminw
338 // move reverseDB stuff
339 //
340 // Revision 1.9 2004/04/05 12:16:23 tomdz
341 // Fixed/updated license in files leftover from automatic license transition
342 //
343 // Revision 1.8 2004/04/04 23:53:42 brianm
344 // Fixed initial copyright dates to match cvs repository
345 //
346 // Revision 1.7 2004/03/11 18:16:22 brianm
347 // ASL 2.0
348 //
349 // Revision 1.6 2003/06/21 10:21:55 florianbruckner
350 // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
351 //
352 // Revision 1.5 2003/06/07 10:11:50 brj
353 // some style fixes
354 //
355 // Revision 1.4 2003/02/21 12:47:03 florianbruckner
356 // corrected event handling of JInputField objects, value of field was
357 // not written back to the model object.
358 //
359 // Revision 1.3 2002/06/18 12:26:41 florianbruckner
360 // changes in Netbeans Form definitions after move to jakarta.
361 //
362 // Revision 1.2 2002/06/17 19:34:34 jvanzyl
363 // Correcting all the package references.
364 // PR:
365 // Obtained from:
366 // Submitted by:
367 // Reviewed by:
368 //
369 // Revision 1.1.1.1 2002/06/17 18:16:52 jvanzyl
370 // Initial OJB import
371 //
372 // Revision 1.2 2002/05/16 11:47:09 florianbruckner
373 // fix CR/LF issue, change license to ASL
374 //
375 // Revision 1.1 2002/04/18 11:44:16 mpoeschl
376 //
377 // move files to new location
378 //
379 // Revision 1.4 2002/04/07 09:05:17 thma
380 // *** empty log message ***
381 //
382 // Revision 1.3 2002/03/11 18:40:26 florianbruckner
383 // modify .form files so the use the correct package name
384 //
385 // Revision 1.2 2002/03/11 17:36:26 florianbruckner
386 // fix line break issue for these files that were previously checked in with -kb
387 //
388 // Revision 1.1 2002/03/04 17:19:32 thma
389 // initial checking for Florians Reverse engineering tool
390 //
391 // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
392 // initial import
393 //
394 /***************************** Changelog *****************************/

395
Popular Tags