KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.netbeans.modules.websvc.wsitconf.ui.client;
20
21 import javax.swing.JCheckBox JavaDoc;
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.TransportModelHelper;
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 TransportPanelClient extends SectionInnerPanel {
37
38     private WSDLModel clientModel;
39     private WSDLModel serviceModel;
40     
41     private Node node;
42     private Binding binding;
43     private boolean inSync = false;
44     private JaxWsModel jaxwsmodel;
45    
46     public TransportPanelClient(SectionView view, Node node, Binding binding, WSDLModel serviceModel, JaxWsModel jaxWsModel) {
47         super(view);
48         this.clientModel = binding.getModel();
49         this.serviceModel = serviceModel;
50         this.node = node;
51         this.binding = binding;
52         this.jaxwsmodel = jaxWsModel;
53         
54         initComponents();
55
56         optimalEncChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
57         optimalTransportChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
58
59         addImmediateModifier(optimalEncChBox);
60         addImmediateModifier(optimalTransportChBox);
61
62         sync();
63     }
64
65     public void sync() {
66         inSync = true;
67
68         setChBox(optimalEncChBox, TransportModelHelper.isAutoEncodingEnabled(binding));
69         setChBox(optimalTransportChBox, TransportModelHelper.isAutoTransportEnabled(binding));
70         
71         enableDisable();
72         
73         inSync = false;
74     }
75
76     @Override JavaDoc
77     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
78         if (!inSync) {
79             if (source.equals(optimalEncChBox)) {
80                 TransportModelHelper.setAutoEncoding(binding, optimalEncChBox.isSelected());
81             }
82
83             if (source.equals(optimalTransportChBox)) {
84                 TransportModelHelper.setAutoTransport(binding, optimalTransportChBox.isSelected());
85             }
86             enableDisable();
87         }
88     }
89
90     private void enableDisable() {
91         boolean amSec = SecurityCheckerRegistry.getDefault().isNonWsitSecurityEnabled(node, jaxwsmodel);
92
93         optimalEncChBox.setEnabled(!amSec);
94         optimalTransportChBox.setEnabled(!amSec);
95     }
96     
97     private void setChBox(JCheckBox JavaDoc chBox, Boolean JavaDoc enable) {
98         if (enable == null) {
99             chBox.setSelected(false);
100         } else {
101             chBox.setSelected(enable);
102         }
103     }
104     
105     @Override JavaDoc
106     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
107     }
108
109     @Override JavaDoc
110     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
111     }
112     
113     @Override JavaDoc
114     protected void endUIChange() {
115     }
116
117     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
118     }
119
120     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
121         return null;
122     }
123
124     /** This method is called from within the constructor to
125      * initialize the form.
126      * WARNING: Do NOT modify this code. The content of this method is
127      * always regenerated by the Form Editor.
128      */

129     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
130
private void initComponents() {
131
132         optimalEncChBox = new javax.swing.JCheckBox JavaDoc();
133         optimalTransportChBox = new javax.swing.JCheckBox JavaDoc();
134
135         addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
136             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
137                 formFocusGained(evt);
138             }
139         });
140         addAncestorListener(new javax.swing.event.AncestorListener JavaDoc() {
141             public void ancestorMoved(javax.swing.event.AncestorEvent JavaDoc evt) {
142             }
143             public void ancestorAdded(javax.swing.event.AncestorEvent JavaDoc evt) {
144                 formAncestorAdded(evt);
145             }
146             public void ancestorRemoved(javax.swing.event.AncestorEvent JavaDoc evt) {
147             }
148         });
149
150         org.openide.awt.Mnemonics.setLocalizedText(optimalEncChBox, org.openide.util.NbBundle.getMessage(TransportPanelClient.class, "LBL_Transport_OptimalEncoding")); // NOI18N
151
optimalEncChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
152         optimalEncChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
153
154         org.openide.awt.Mnemonics.setLocalizedText(optimalTransportChBox, org.openide.util.NbBundle.getMessage(TransportPanelClient.class, "LBL_Transport_OptimalTransport")); // NOI18N
155
optimalTransportChBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
156         optimalTransportChBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
157
158         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
159         this.setLayout(layout);
160         layout.setHorizontalGroup(
161             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
162             .add(layout.createSequentialGroup()
163                 .addContainerGap()
164                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
165                     .add(optimalTransportChBox)
166                     .add(optimalEncChBox))
167                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
168         );
169         layout.setVerticalGroup(
170             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
171             .add(layout.createSequentialGroup()
172                 .addContainerGap()
173                 .add(optimalEncChBox)
174                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
175                 .add(optimalTransportChBox)
176                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
177         );
178     }// </editor-fold>//GEN-END:initComponents
179

180 private void formFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_formFocusGained
181
enableDisable();
182 }//GEN-LAST:event_formFocusGained
183

184 private void formAncestorAdded(javax.swing.event.AncestorEvent JavaDoc evt) {//GEN-FIRST:event_formAncestorAdded
185
enableDisable();
186 }//GEN-LAST:event_formAncestorAdded
187

188     
189     // Variables declaration - do not modify//GEN-BEGIN:variables
190
private javax.swing.JCheckBox JavaDoc optimalEncChBox;
191     private javax.swing.JCheckBox JavaDoc optimalTransportChBox;
192     // End of variables declaration//GEN-END:variables
193

194 }
195
Popular Tags