KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > client > STSClientPanel


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui.client;
21
22 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
23 import org.netbeans.modules.websvc.wsitconf.spi.SecurityCheckerRegistry;
24 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProprietarySecurityPolicyModelHelper;
25 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel;
26 import org.netbeans.modules.xml.multiview.ui.SectionView;
27 import org.netbeans.modules.xml.multiview.ui.SectionVisualTheme;
28 import org.netbeans.modules.xml.wsdl.model.Binding;
29 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
30 import org.openide.nodes.Node;
31
32 /**
33  *
34  * @author Martin Grebac
35  */

36 public class STSClientPanel extends SectionInnerPanel {
37
38     private WSDLModel model;
39     private Node node;
40     private Binding binding;
41     private boolean inSync = false;
42     private JaxWsModel jaxwsmodel;
43
44     public STSClientPanel(SectionView view, Node node, Binding binding, JaxWsModel jaxWsModel) {
45         super(view);
46         this.model = binding.getModel();
47         this.node = node;
48         this.binding = binding;
49         this.jaxwsmodel = jaxWsModel;
50         
51         initComponents();
52
53         endpointLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
54         endpointTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
55         metadataLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
56         metadataField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
57         namespaceLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
58         namespaceTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
59         portNameLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
60         portNameTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
61         serviceNameLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
62         serviceNameTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
63         wsdlLocationLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
64         wsdlLocationTextField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
65
66         addImmediateModifier(endpointTextField);
67         addImmediateModifier(namespaceTextField);
68         addImmediateModifier(portNameTextField);
69         addImmediateModifier(serviceNameTextField);
70         addImmediateModifier(wsdlLocationTextField);
71         addImmediateModifier(metadataField);
72
73         sync();
74     }
75
76     public void sync() {
77         inSync = true;
78
79         String JavaDoc endpoint = ProprietarySecurityPolicyModelHelper.getPreSTSEndpoint(binding);
80         if (endpoint != null) {
81             setEndpoint(endpoint);
82         }
83
84         String JavaDoc metadata = ProprietarySecurityPolicyModelHelper.getPreSTSMetadata(binding);
85         if (metadata != null) {
86             setMetadata(metadata);
87         }
88         
89         String JavaDoc namespace = ProprietarySecurityPolicyModelHelper.getPreSTSNamespace(binding);
90         if (namespace != null) {
91             setNamespace(namespace);
92         }
93
94         String JavaDoc portName = ProprietarySecurityPolicyModelHelper.getPreSTSPortName(binding);
95         if (portName != null) {
96             setPortName(portName);
97         }
98
99         String JavaDoc serviceName = ProprietarySecurityPolicyModelHelper.getPreSTSServiceName(binding);
100         if (serviceName != null) {
101             setServiceName(serviceName);
102         }
103
104         String JavaDoc wsdlLocation = ProprietarySecurityPolicyModelHelper.getPreSTSWsdlLocation(binding);
105         if (wsdlLocation != null) {
106             setWsdlLocation(wsdlLocation);
107         }
108         
109         inSync = false;
110     }
111
112     private String JavaDoc getEndpoint() {
113         return this.endpointTextField.getText();
114     }
115
116     private void setEndpoint(String JavaDoc url) {
117         this.endpointTextField.setText(url);
118     }
119
120     private String JavaDoc getMetadata() {
121         return this.metadataField.getText();
122     }
123
124     private void setMetadata(String JavaDoc url) {
125         this.metadataField.setText(url);
126     }
127     
128     private String JavaDoc getNamespace() {
129         return this.namespaceTextField.getText();
130     }
131
132     private void setNamespace(String JavaDoc ns) {
133         this.namespaceTextField.setText(ns);
134     }
135     
136     private String JavaDoc getServiceName() {
137         return this.serviceNameTextField.getText();
138     }
139
140     private void setServiceName(String JavaDoc sname) {
141         this.serviceNameTextField.setText(sname);
142     }
143     
144     private String JavaDoc getPortName() {
145         return this.portNameTextField.getText();
146     }
147
148     private void setPortName(String JavaDoc pname) {
149         this.portNameTextField.setText(pname);
150     }
151
152     private String JavaDoc getWsdlLocation() {
153         return this.wsdlLocationTextField.getText();
154     }
155
156     private void setWsdlLocation(String JavaDoc wsdlLocation) {
157         this.wsdlLocationTextField.setText(wsdlLocation);
158     }
159     
160     @Override JavaDoc
161     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
162         if (!inSync) {
163             if (source.equals(endpointTextField)) {
164                 String JavaDoc endpoint = getEndpoint();
165                 if ((endpoint != null) && (endpoint.length() == 0)) {
166                     ProprietarySecurityPolicyModelHelper.setPreSTSEndpoint(binding, null);
167                 } else {
168                     ProprietarySecurityPolicyModelHelper.setPreSTSEndpoint(binding, endpoint);
169                 }
170                 return;
171             }
172
173             if (source.equals(metadataField)) {
174                 String JavaDoc metad = getMetadata();
175                 if ((metad != null) && (metad.length() == 0)) {
176                     ProprietarySecurityPolicyModelHelper.setPreSTSMetadata(binding, null);
177                 } else {
178                     ProprietarySecurityPolicyModelHelper.setPreSTSMetadata(binding, metad);
179                 }
180                 return;
181             }
182
183             if (source.equals(namespaceTextField)) {
184                 String JavaDoc ns = getNamespace();
185                 if ((ns != null) && (ns.length() == 0)) {
186                     ProprietarySecurityPolicyModelHelper.setPreSTSNamespace(binding, null);
187                 } else {
188                     ProprietarySecurityPolicyModelHelper.setPreSTSNamespace(binding, ns);
189                 }
190                 return;
191             }
192
193             if (source.equals(serviceNameTextField)) {
194                 String JavaDoc sname = getServiceName();
195                 if ((sname != null) && (sname.length() == 0)) {
196                     ProprietarySecurityPolicyModelHelper.setPreSTSServiceName(binding, null);
197                 } else {
198                     ProprietarySecurityPolicyModelHelper.setPreSTSServiceName(binding, sname);
199                 }
200                 return;
201             }
202
203             if (source.equals(portNameTextField)) {
204                 String JavaDoc pname = getPortName();
205                 if ((pname != null) && (pname.length() == 0)) {
206                     ProprietarySecurityPolicyModelHelper.setPreSTSPortName(binding, null);
207                 } else {
208                     ProprietarySecurityPolicyModelHelper.setPreSTSPortName(binding, pname);
209                 }
210                 return;
211             }
212
213             if (source.equals(wsdlLocationTextField)) {
214                 String JavaDoc wsdlLoc = getWsdlLocation();
215                 if ((wsdlLoc != null) && (wsdlLoc.length() == 0)) {
216                     ProprietarySecurityPolicyModelHelper.setPreSTSWsdlLocation(binding, null);
217                 } else {
218                     ProprietarySecurityPolicyModelHelper.setPreSTSWsdlLocation(binding, wsdlLoc);
219                 }
220                 return;
221             }
222             enableDisable();
223         }
224     }
225     
226     @Override JavaDoc
227     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
228         enableDisable();
229     }
230
231     @Override JavaDoc
232     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
233     }
234     
235     @Override JavaDoc
236     protected void endUIChange() {
237     }
238
239     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
240     }
241
242     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
243         return null;
244     }
245
246     private void enableDisable() {
247         
248         boolean amSec = SecurityCheckerRegistry.getDefault().isNonWsitSecurityEnabled(node, jaxwsmodel);
249
250         endpointLabel.setEnabled(!amSec);
251         endpointTextField.setEnabled(!amSec);
252         metadataField.setEnabled(!amSec);
253         metadataLabel.setEnabled(!amSec);
254         namespaceLabel.setEnabled(!amSec);
255         namespaceLabel.setEnabled(!amSec);
256         portNameLabel.setEnabled(!amSec);
257         portNameTextField.setEnabled(!amSec);
258         serviceNameLabel.setEnabled(!amSec);
259         serviceNameTextField.setEnabled(!amSec);
260         wsdlLocationLabel.setEnabled(!amSec);
261         wsdlLocationTextField.setEnabled(!amSec);
262     }
263     
264     /** This method is called from within the constructor to
265      * initialize the form.
266      * WARNING: Do NOT modify this code. The content of this method is
267      * always regenerated by the Form Editor.
268      */

269     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
270
private void initComponents() {
271
272         endpointLabel = new javax.swing.JLabel JavaDoc();
273         wsdlLocationLabel = new javax.swing.JLabel JavaDoc();
274         endpointTextField = new javax.swing.JTextField JavaDoc();
275         wsdlLocationTextField = new javax.swing.JTextField JavaDoc();
276         serviceNameLabel = new javax.swing.JLabel JavaDoc();
277         serviceNameTextField = new javax.swing.JTextField JavaDoc();
278         portNameLabel = new javax.swing.JLabel JavaDoc();
279         namespaceLabel = new javax.swing.JLabel JavaDoc();
280         portNameTextField = new javax.swing.JTextField JavaDoc();
281         namespaceTextField = new javax.swing.JTextField JavaDoc();
282         metadataLabel = new javax.swing.JLabel JavaDoc();
283         metadataField = new javax.swing.JTextField JavaDoc();
284
285         addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
286             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
287                 formFocusGained(evt);
288             }
289         });
290         addAncestorListener(new javax.swing.event.AncestorListener JavaDoc() {
291             public void ancestorMoved(javax.swing.event.AncestorEvent JavaDoc evt) {
292             }
293             public void ancestorAdded(javax.swing.event.AncestorEvent JavaDoc evt) {
294                 formAncestorAdded(evt);
295             }
296             public void ancestorRemoved(javax.swing.event.AncestorEvent JavaDoc evt) {
297             }
298         });
299
300         endpointLabel.setLabelFor(endpointTextField);
301         org.openide.awt.Mnemonics.setLocalizedText(endpointLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Endpoint")); // NOI18N
302
endpointLabel.setToolTipText("The maximum number of seconds the time stamp remains valid.");
303
304         wsdlLocationLabel.setLabelFor(wsdlLocationTextField);
305         org.openide.awt.Mnemonics.setLocalizedText(wsdlLocationLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_WsdlLocation")); // NOI18N
306
wsdlLocationLabel.setToolTipText("The maximum number of seconds the sending clock can deviate from the receiving clock.");
307
308         endpointTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
309
310         wsdlLocationTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
311
312         serviceNameLabel.setLabelFor(serviceNameTextField);
313         org.openide.awt.Mnemonics.setLocalizedText(serviceNameLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_ServiceName")); // NOI18N
314

315         serviceNameTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
316
317         portNameLabel.setLabelFor(portNameTextField);
318         org.openide.awt.Mnemonics.setLocalizedText(portNameLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_PortName")); // NOI18N
319

320         namespaceLabel.setLabelFor(namespaceTextField);
321         org.openide.awt.Mnemonics.setLocalizedText(namespaceLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Namespace")); // NOI18N
322

323         portNameTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
324
325         namespaceTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
326
327         metadataLabel.setLabelFor(metadataField);
328         org.openide.awt.Mnemonics.setLocalizedText(metadataLabel, org.openide.util.NbBundle.getMessage(STSClientPanel.class, "LBL_STSPanel_Metadata")); // NOI18N
329

330         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
331         this.setLayout(layout);
332         layout.setHorizontalGroup(
333             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
334             .add(layout.createSequentialGroup()
335                 .addContainerGap()
336                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
337                     .add(namespaceLabel)
338                     .add(endpointLabel)
339                     .add(wsdlLocationLabel)
340                     .add(metadataLabel)
341                     .add(serviceNameLabel)
342                     .add(portNameLabel))
343                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
344                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
345                     .add(namespaceTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
346                     .add(portNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
347                     .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
348                     .add(wsdlLocationTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
349                     .add(endpointTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
350                     .add(metadataField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 383, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
351                 .addContainerGap())
352         );
353
354         layout.linkSize(new java.awt.Component JavaDoc[] {endpointTextField, metadataField, namespaceTextField, portNameTextField, serviceNameTextField, wsdlLocationTextField}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
355
356         layout.setVerticalGroup(
357             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
358             .add(layout.createSequentialGroup()
359                 .addContainerGap()
360                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
361                     .add(endpointLabel)
362                     .add(endpointTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
363                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
364                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
365                     .add(wsdlLocationLabel)
366                     .add(wsdlLocationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
367                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
368                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
369                     .add(metadataLabel)
370                     .add(metadataField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
371                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
372                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
373                     .add(serviceNameLabel)
374                     .add(serviceNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
375                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
376                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
377                     .add(portNameLabel)
378                     .add(portNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
379                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
380                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
381                     .add(namespaceLabel)
382                     .add(namespaceTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
383                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
384         );
385     }// </editor-fold>//GEN-END:initComponents
386

387 private void formFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_formFocusGained
388
enableDisable();
389 }//GEN-LAST:event_formFocusGained
390

391 private void formAncestorAdded(javax.swing.event.AncestorEvent JavaDoc evt) {//GEN-FIRST:event_formAncestorAdded
392
enableDisable();
393 }//GEN-LAST:event_formAncestorAdded
394

395     
396     // Variables declaration - do not modify//GEN-BEGIN:variables
397
private javax.swing.JLabel JavaDoc endpointLabel;
398     private javax.swing.JTextField JavaDoc endpointTextField;
399     private javax.swing.JTextField JavaDoc metadataField;
400     private javax.swing.JLabel JavaDoc metadataLabel;
401     private javax.swing.JLabel JavaDoc namespaceLabel;
402     private javax.swing.JTextField JavaDoc namespaceTextField;
403     private javax.swing.JLabel JavaDoc portNameLabel;
404     private javax.swing.JTextField JavaDoc portNameTextField;
405     private javax.swing.JLabel JavaDoc serviceNameLabel;
406     private javax.swing.JTextField JavaDoc serviceNameTextField;
407     private javax.swing.JLabel JavaDoc wsdlLocationLabel;
408     private javax.swing.JTextField JavaDoc wsdlLocationTextField;
409     // End of variables declaration//GEN-END:variables
410

411 }
412
Popular Tags