KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > tools > mapping > reversedb2 > propertyEditors > JPnlPropertyEditorDBMetaSchema


1 package org.apache.ojb.tools.mapping.reversedb2.propertyEditors;
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 org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel.DBMetaSchemaNode;
19
20 /**
21  * This is an implementation of a PropertyEditor for the DBMetaSchemaNode class.
22  *
23  * @author <a HREF="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
24  * @version $Id: JPnlPropertyEditorDBMetaSchema.java,v 1.1.2.1 2005/12/21 22:33:27 tomdz Exp $
25  */

26 public class JPnlPropertyEditorDBMetaSchema extends PropertyEditor
27 {
28     
29     
30     /** Creates new form JPnlPropertyEditorDBMetaCatalog */
31     public JPnlPropertyEditorDBMetaSchema ()
32     {
33         initComponents ();
34         setPropertyChangeListener(new SchemaPropertyChangeListener());
35     }
36     
37     /** This method is called from within the constructor to
38      * initialize the form.
39      * WARNING: Do NOT modify this code. The content of this method is
40      * always regenerated by the Form Editor.
41      */

42     private void initComponents()//GEN-BEGIN:initComponents
43
{
44         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
45
46         lblSchemaName = new javax.swing.JLabel JavaDoc();
47         tfSchemaName = new javax.swing.JTextField JavaDoc();
48
49         setLayout(new java.awt.GridBagLayout JavaDoc());
50
51         lblSchemaName.setText("Schema Name:");
52         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
53         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
54         add(lblSchemaName, gridBagConstraints);
55
56         tfSchemaName.setEditable(false);
57         tfSchemaName.setText("jTextField1");
58         tfSchemaName.setBorder(null);
59         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
60         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
61         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
62         gridBagConstraints.weightx = 1.0;
63         gridBagConstraints.weighty = 1.0;
64         add(tfSchemaName, gridBagConstraints);
65
66     }//GEN-END:initComponents
67

68     public void setEditorTarget (PropertyEditorTarget target)
69     {
70         if (target instanceof DBMetaSchemaNode)
71         {
72             super.setEditorTarget(target);
73             this.tfSchemaName.setText((String JavaDoc)target.getAttribute(DBMetaSchemaNode.ATT_SCHEMA_NAME));
74         }
75         else
76         {
77             throw new UnsupportedOperationException JavaDoc("This editor can only edit DBSchemaCatalogNode objects");
78         }
79     }
80     
81     
82     // Variables declaration - do not modify//GEN-BEGIN:variables
83
private javax.swing.JLabel JavaDoc lblSchemaName;
84     private javax.swing.JTextField JavaDoc tfSchemaName;
85     // End of variables declaration//GEN-END:variables
86

87     public class SchemaPropertyChangeListener implements java.beans.PropertyChangeListener JavaDoc
88     {
89         public void propertyChange (java.beans.PropertyChangeEvent JavaDoc propertyChangeEvent)
90         {
91             if (propertyChangeEvent.getPropertyName() == (DBMetaSchemaNode.ATT_SCHEMA_NAME))
92             {
93                 tfSchemaName.setText((String JavaDoc)propertyChangeEvent.getNewValue());
94             }
95         }
96     }
97     
98 }
99
Popular Tags