KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > create > CreateVisualPanel


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

16
17 package org.mc4j.console.connection.create;
18
19 import org.mc4j.ems.connection.EmsMalformedObjectNameException;
20 import org.openide.WizardDescriptor;
21 import org.openide.util.HelpCtx;
22
23 import javax.swing.event.ChangeListener JavaDoc;
24 import java.awt.*;
25
26 /**
27  *
28  * @author ghinkle
29  */

30 public class CreateVisualPanel extends javax.swing.JPanel JavaDoc implements WizardDescriptor.Panel{
31     
32     CreateWizardDescriptor descriptor;
33
34     public CreateVisualPanel(CreateWizardDescriptor descriptor) {
35         this.descriptor = descriptor;
36         initComponents();
37     }
38
39     public boolean isValid() {
40         return true;
41     }
42     
43     public Component getComponent() {
44         return this;
45     }
46
47     public HelpCtx getHelp() {
48         return null;
49     }
50
51     public void readSettings(Object JavaDoc o) {
52
53     }
54
55     public void storeSettings(Object JavaDoc o) {
56         this.descriptor.getData().setClassName(this.classNameTextField.getText());
57         this.descriptor.getData().setObjectName(this.objectNameTextLabel.getText());
58     }
59
60     public void addChangeListener(ChangeListener JavaDoc changeListener) {
61
62     }
63
64     public void removeChangeListener(ChangeListener JavaDoc changeListener) {
65
66     }
67
68     /** This method is called from within the constructor to
69      * initialize the form.
70      * WARNING: Do NOT modify this code. The content of this method is
71      * always regenerated by the Form Editor.
72      */

73     private void initComponents() {//GEN-BEGIN:initComponents
74
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
75
76         classNameLabel = new javax.swing.JLabel JavaDoc();
77         classNameTextField = new javax.swing.JTextField JavaDoc();
78         objectNameLabel = new javax.swing.JLabel JavaDoc();
79         objectNameTextLabel = new javax.swing.JTextField JavaDoc();
80
81         setLayout(new java.awt.GridBagLayout JavaDoc());
82
83         classNameLabel.setText("Class Name:");
84         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
85         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
86         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
87         add(classNameLabel, gridBagConstraints);
88
89         classNameTextField.setText("class");
90         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
91         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
92         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
93         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
94         gridBagConstraints.weightx = 1.0;
95         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
96         add(classNameTextField, gridBagConstraints);
97
98         objectNameLabel.setText("Object Name:");
99         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
100         gridBagConstraints.gridx = 0;
101         gridBagConstraints.gridy = 1;
102         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
103         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
104         add(objectNameLabel, gridBagConstraints);
105
106         objectNameTextLabel.setText("object");
107         objectNameTextLabel.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
108             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
109                 objectNameTextLabelKeyTyped(evt);
110             }
111         });
112
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.gridx = 1;
115         gridBagConstraints.gridy = 1;
116         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
117         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
118         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
119         gridBagConstraints.weightx = 1.0;
120         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 5, 5);
121         add(objectNameTextLabel, gridBagConstraints);
122
123     }//GEN-END:initComponents
124

125     private void objectNameTextLabelKeyTyped(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_objectNameTextLabelKeyTyped
126
try {
127
128             this.descriptor.getConnection().buildObjectName(
129                     this.objectNameTextLabel.getText());
130         } catch (EmsMalformedObjectNameException e) {
131             this.objectNameTextLabel.setForeground(Color.red);
132         }
133         this.objectNameTextLabel.setForeground(Color.black);
134     }//GEN-LAST:event_objectNameTextLabelKeyTyped
135

136     
137     // Variables declaration - do not modify//GEN-BEGIN:variables
138
private javax.swing.JLabel JavaDoc classNameLabel;
139     private javax.swing.JTextField JavaDoc classNameTextField;
140     private javax.swing.JLabel JavaDoc objectNameLabel;
141     private javax.swing.JTextField JavaDoc objectNameTextLabel;
142     // End of variables declaration//GEN-END:variables
143

144 }
145
Popular Tags