KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > ui > WSReferenceBindingsPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui;
20
21 import java.awt.event.ItemListener JavaDoc;
22 import org.netbeans.modules.j2ee.websphere6.dd.beans.*;
23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
24 import org.netbeans.modules.j2ee.websphere6.dd.loaders.webbnd.WSWebBndDataObject;
25 import org.netbeans.modules.xml.multiview.*;
26 import org.netbeans.modules.xml.multiview.ui.*;
27 import org.netbeans.modules.xml.multiview.Error;
28 /**
29  *
30  * @author dlm198383
31  */

32 public class WSReferenceBindingsPanel extends SectionInnerPanel implements java.awt.event.ItemListener JavaDoc{
33     CommonRef reference;
34     WSMultiViewDataObject dObj;
35     /**
36      * Creates new form WSReferenceBindingsPanel
37      */

38     public WSReferenceBindingsPanel(SectionView view, WSMultiViewDataObject dObj, CommonRef reference) {
39         super(view);
40         this.dObj=dObj;
41         this.reference=reference;
42         initComponents();
43         referenceField.setText(reference.getXmiId());
44         jndiNameField.setText(reference.getJndiName());
45         hrefField.setText(reference.getHref());
46         addModifier(hrefField);
47         addModifier(jndiNameField);
48         addModifier(referenceField);
49         getSectionView().getErrorPanel().clearError();
50         typeComboBox.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(DDXmiConstants.BINDING_EJB_REF_TYPES));
51         typeComboBox.setSelectedItem(reference.getXmiType());
52         typeComboBox.addItemListener(this);
53     }
54     
55     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
56         if (source==referenceField) {
57             reference.setXmiId((String JavaDoc)value);
58         } else if(source==jndiNameField) {
59             reference.setJndiName((String JavaDoc)value);
60         } else if(source==hrefField) {
61             reference.setHref((String JavaDoc)value);
62         }
63     }
64     
65     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
66         if (comp==referenceField) {
67             String JavaDoc val = (String JavaDoc)value;
68             if (val.length()==0) {
69                 getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "id", comp));
70                 return;
71             }
72             getSectionView().getErrorPanel().clearError();
73         }
74         if(comp==jndiNameField) {
75             String JavaDoc val = (String JavaDoc)value;
76             if (val.length()==0) {
77                 getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "jndi", comp));
78                 return;
79             }
80             getSectionView().getErrorPanel().clearError();
81         }
82         if(comp==hrefField) {
83             String JavaDoc val = (String JavaDoc)value;
84             if (val.length()==0) {
85                 getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "webhref", comp));
86                 return;
87             }
88             getSectionView().getErrorPanel().clearError();
89         }
90     }
91     
92     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
93         if (referenceField==source) {
94             referenceField.setText(reference.getXmiId());
95         }
96         if (jndiNameField==source) {
97             jndiNameField.setText(reference.getJndiName());
98         }
99         if (hrefField==source) {
100             hrefField.setText(reference.getHref());
101         }
102     }
103     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
104     }
105     
106     public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
107         dObj.setChangedFromUI(true);
108         if(evt.getSource()==typeComboBox) {
109             reference.setXmiType((String JavaDoc)typeComboBox.getSelectedItem());
110         }
111         dObj.modelUpdatedFromUI();
112         //dObj.setChangedFromUI(true);
113
dObj.setChangedFromUI(false);
114     }
115     
116     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
117         if ("id".equals(errorId)) return referenceField;
118         if ("jndi".equals(errorId)) return jndiNameField;
119         if ("webhref".equals(errorId)) return hrefField;
120         return null;
121     }
122    
123     /** This will be called before model is changed from this panel
124      */

125     protected void startUIChange() {
126         dObj.setChangedFromUI(true);
127     }
128     
129     /** This will be called after model is changed from this panel
130      */

131     protected void endUIChange() {
132         dObj.modelUpdatedFromUI();
133         dObj.setChangedFromUI(false);
134     }
135     /** This method is called from within the constructor to
136      * initialize the form.
137      * WARNING: Do NOT modify this code. The content of this method is
138      * always regenerated by the Form Editor.
139      */

140     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
141
private void initComponents() {
142         jLabel1 = new javax.swing.JLabel JavaDoc();
143         jLabel2 = new javax.swing.JLabel JavaDoc();
144         jLabel3 = new javax.swing.JLabel JavaDoc();
145         referenceField = new javax.swing.JTextField JavaDoc();
146         jndiNameField = new javax.swing.JTextField JavaDoc();
147         hrefField = new javax.swing.JTextField JavaDoc();
148         typeComboBox = new javax.swing.JComboBox JavaDoc();
149         jLabel4 = new javax.swing.JLabel JavaDoc();
150
151         jLabel1.setText("Name:");
152
153         jLabel2.setText("JNDI Name:");
154
155         jLabel3.setText("Name in Web.xml :");
156
157         jLabel4.setText("Type");
158
159         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
160         this.setLayout(layout);
161         layout.setHorizontalGroup(
162             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
163             .add(layout.createSequentialGroup()
164                 .addContainerGap()
165                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
166                     .add(jLabel1)
167                     .add(jLabel2)
168                     .add(jLabel3)
169                     .add(jLabel4))
170                 .add(16, 16, 16)
171                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
172                     .add(referenceField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
173                     .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
174                     .add(jndiNameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
175                     .add(typeComboBox, 0, 338, Short.MAX_VALUE))
176                 .addContainerGap())
177         );
178         layout.setVerticalGroup(
179             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
180             .add(layout.createSequentialGroup()
181                 .addContainerGap()
182                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
183                     .add(jLabel1)
184                     .add(referenceField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
185                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
186                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
187                     .add(jLabel2)
188                     .add(jndiNameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
189                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
190                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
191                     .add(jLabel3)
192                     .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
193                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
194                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
195                     .add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
196                     .add(jLabel4))
197                 .addContainerGap())
198         );
199     }// </editor-fold>//GEN-END:initComponents
200

201     
202     // Variables declaration - do not modify//GEN-BEGIN:variables
203
private javax.swing.JTextField JavaDoc hrefField;
204     private javax.swing.JLabel JavaDoc jLabel1;
205     private javax.swing.JLabel JavaDoc jLabel2;
206     private javax.swing.JLabel JavaDoc jLabel3;
207     private javax.swing.JLabel JavaDoc jLabel4;
208     private javax.swing.JTextField JavaDoc jndiNameField;
209     private javax.swing.JTextField JavaDoc referenceField;
210     private javax.swing.JComboBox JavaDoc typeComboBox;
211     // End of variables declaration//GEN-END:variables
212

213 }
214
Popular Tags