01: package org.apache.ojb.tools.mapping.reversedb2.propertyEditors;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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.DBMetaTableNode;
19:
20: /**
21: * This is an implementation of a PropertyEditor for the DBMetaTableNode.
22: *
23: * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
24: * @version $Id: JPnlPropertyEditorDBMetaTable.java,v 1.1.2.1 2005/12/21 22:33:27 tomdz Exp $
25: */
26: public class JPnlPropertyEditorDBMetaTable extends PropertyEditor {
27:
28: /** Creates new form JPnlPropertyEditorDBMetaCatalog */
29: public JPnlPropertyEditorDBMetaTable() {
30: initComponents();
31: }
32:
33: /** This method is called from within the constructor to
34: * initialize the form.
35: * WARNING: Do NOT modify this code. The content of this method is
36: * always regenerated by the Form Editor.
37: */
38: private void initComponents()//GEN-BEGIN:initComponents
39: {
40: java.awt.GridBagConstraints gridBagConstraints;
41:
42: lblTableName = new javax.swing.JLabel();
43: tfTableName = new javax.swing.JTextField();
44:
45: setLayout(new java.awt.GridBagLayout());
46:
47: lblTableName.setText("Table Name:");
48: gridBagConstraints = new java.awt.GridBagConstraints();
49: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
50: add(lblTableName, gridBagConstraints);
51:
52: tfTableName.setEditable(false);
53: tfTableName.setText("jTextField1");
54: tfTableName.setBorder(null);
55: gridBagConstraints = new java.awt.GridBagConstraints();
56: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
57: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
58: gridBagConstraints.weightx = 1.0;
59: gridBagConstraints.weighty = 1.0;
60: add(tfTableName, gridBagConstraints);
61:
62: }//GEN-END:initComponents
63:
64: public void setEditorTarget(PropertyEditorTarget target) {
65: if (target instanceof DBMetaTableNode) {
66: super .setEditorTarget(target);
67: this .tfTableName.setText((String) target
68: .getAttribute(DBMetaTableNode.ATT_TABLE_NAME));
69: } else {
70: throw new UnsupportedOperationException(
71: "This editor can only edit DBMetaTableNode objects");
72: }
73: }
74:
75: // Variables declaration - do not modify//GEN-BEGIN:variables
76: private javax.swing.JTextField tfTableName;
77: private javax.swing.JLabel lblTableName;
78:
79: // End of variables declaration//GEN-END:variables
80:
81: public class CatalogPropertyChangeListener implements
82: java.beans.PropertyChangeListener {
83: public void propertyChange(
84: java.beans.PropertyChangeEvent propertyChangeEvent) {
85: if (propertyChangeEvent.getPropertyName() == (DBMetaTableNode.ATT_TABLE_NAME)) {
86: tfTableName.setText((String) propertyChangeEvent
87: .getNewValue());
88: }
89: }
90: }
91:
92: }
|