KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > service > OperationPanel


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.service;
21
22 import java.awt.Dialog JavaDoc;
23 import javax.swing.undo.UndoManager JavaDoc;
24 import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
25 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper;
26 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.TxModelHelper;
27 import org.netbeans.modules.xml.multiview.ui.SectionInnerPanel;
28 import org.netbeans.modules.xml.multiview.ui.SectionView;
29 import org.netbeans.modules.xml.multiview.ui.SectionVisualTheme;
30 import org.netbeans.modules.xml.wsdl.model.BindingOperation;
31 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
32 import org.netbeans.modules.xml.xam.ComponentEvent;
33 import org.netbeans.modules.xml.xam.ComponentListener;
34 import org.openide.nodes.Node;
35 import javax.swing.*;
36 import org.netbeans.api.project.Project;
37 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
38 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
39 import org.netbeans.modules.websvc.wsitconf.ui.service.subpanels.TargetsPanel;
40 import org.netbeans.modules.websvc.wsitconf.util.UndoCounter;
41 import org.netbeans.modules.websvc.wsitconf.util.Util;
42 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProfilesModelHelper;
43 import org.netbeans.modules.xml.wsdl.model.Binding;
44 import org.netbeans.modules.xml.wsdl.model.BindingInput;
45 import org.netbeans.modules.xml.wsdl.model.BindingOutput;
46 import org.openide.DialogDescriptor;
47 import org.openide.DialogDisplayer;
48 import org.openide.util.NbBundle;
49
50 /**
51  *
52  * @author Martin Grebac
53  */

54 public class OperationPanel extends SectionInnerPanel {
55
56     private WSDLModel model;
57     private Node node;
58     private Binding binding;
59     private BindingOperation operation;
60     private UndoManager JavaDoc undoManager;
61     private boolean inSync = false;
62     private Project project;
63     private JaxWsModel jaxwsmodel;
64     
65     public OperationPanel(SectionView view, Node node, Project p, BindingOperation operation, UndoManager JavaDoc undoManager, JaxWsModel jaxwsmodel) {
66         super(view);
67         this.model = operation.getModel();
68         this.node = node;
69         this.binding = (Binding)operation.getParent();
70         this.undoManager = undoManager;
71         this.project = p;
72         this.operation = operation;
73         this.jaxwsmodel = jaxwsmodel;
74         initComponents();
75         
76         txCombo.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
77         txLbl.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
78 // securityChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
79
// profileComboLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
80
// profileCombo.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
81
// profileInfoField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
82
// profileInfoField.setFont(securityChBox.getFont());
83
// jSeparator2.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
84
//
85
// addImmediateModifier(securityChBox);
86
// addImmediateModifier(profileCombo);
87
addImmediateModifier(txCombo);
88
89         inSync = true;
90         txCombo.removeAllItems();
91 // txCombo.addItem(ComboConstants.TX_NEVER);
92
txCombo.addItem(ComboConstants.TX_NOTSUPPORTED);
93         txCombo.addItem(ComboConstants.TX_MANDATORY);
94         txCombo.addItem(ComboConstants.TX_REQUIRED);
95         txCombo.addItem(ComboConstants.TX_REQUIRESNEW);
96         txCombo.addItem(ComboConstants.TX_SUPPORTED);
97
98 // profileCombo.removeAllItems();
99
// profileCombo.addItem(ComboConstants.PROF_USERNAME);
100
// profileCombo.addItem(ComboConstants.PROF_MUTUALCERT);
101
// profileCombo.addItem(ComboConstants.PROF_TRANSPORT);
102
// profileCombo.addItem(ComboConstants.PROF_MSGAUTHSSL);
103
// profileCombo.addItem(ComboConstants.PROF_SAMLSSL);
104
// profileCombo.addItem(ComboConstants.PROF_ENDORSCERT);
105
// profileCombo.addItem(ComboConstants.PROF_SAMLSENDER);
106
// profileCombo.addItem(ComboConstants.PROF_SAMLHOLDER);
107
//// profileCombo.addItem(ComboConstants.PROF_KERBEROS);
108
// profileCombo.addItem(ComboConstants.PROF_STSISSUED);
109
// profileCombo.addItem(ComboConstants.PROF_STSISSUEDCERT);
110
// profileCombo.addItem(ComboConstants.PROF_STSISSUEDENDORSE);
111
//// profileCombo.addItem(ComboConstants.PROF_GENERIC);
112

113         inSync = false;
114         sync();
115         
116         model.addComponentListener(new ComponentListener() {
117             public void valueChanged(ComponentEvent evt) {
118                 sync();
119             }
120             public void childrenAdded(ComponentEvent evt) {
121                 sync();
122             }
123             public void childrenDeleted(ComponentEvent evt) {
124                 sync();
125             }
126         });
127     }
128
129     private void sync() {
130         inSync = true;
131         
132         String JavaDoc txValue = TxModelHelper.getTx(operation, node);
133         txCombo.setSelectedItem(txValue);
134                 
135 // boolean securityEnabled = SecurityPolicyModelHelper.isSecurityEnabled(operation);
136
// setSecurity(securityEnabled);
137
// if (securityEnabled) {
138
// setSecurityProfile(ProfilesModelHelper.getSecurityProfile(operation));
139
// } else {
140
// setSecurityProfile(ComboConstants.PROF_USERNAME);
141
// }
142
//
143
enableDisable();
144         inSync = false;
145     }
146
147 // // SECURITY
148
// private void setSecurity(Boolean enable) {
149
// if (enable == null) {
150
// this.securityChBox.setSelected(false);
151
// } else {
152
// this.securityChBox.setSelected(enable);
153
// }
154
// }
155
//
156
// public Boolean getSecurity() {
157
// if (securityChBox.isSelected()) {
158
// return Boolean.TRUE;
159
// }
160
// return Boolean.FALSE;
161
// }
162
//
163
@Override JavaDoc
164     public void setValue(javax.swing.JComponent JavaDoc source, Object JavaDoc value) {
165         if (inSync) return;
166         if (source.equals(txCombo)) {
167             String JavaDoc selected = (String JavaDoc) txCombo.getSelectedItem();
168             if ((selected != null) && (!selected.equals(TxModelHelper.getTx(operation, node)))) {
169                 TxModelHelper.setTx(operation, node, selected);
170             }
171         }
172
173 // if (source.equals(securityChBox)) {
174
// if (securityChBox.isSelected()) {
175
// profileCombo.setSelectedItem((String) profileCombo.getSelectedItem());
176
// } else {
177
// SecurityPolicyModelHelper.disableSecurity(operation);
178
// }
179
// }
180
//
181
// if (source.equals(profileCombo)) {
182
// ProfilesModelHelper.setSecurityProfile(operation, (String) profileCombo.getSelectedItem());
183
// }
184
enableDisable();
185     }
186     
187     @Override JavaDoc
188     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
189         SectionView view = getSectionView();
190         enableDisable();
191         if (view != null) {
192             view.getErrorPanel().clearError();
193         }
194     }
195
196     @Override JavaDoc
197     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
198     }
199     
200     @Override JavaDoc
201     protected void endUIChange() { }
202
203     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) { }
204
205     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
206         return new JButton();
207     }
208
209     private void enableDisable() {
210     
211         boolean isTomcat = Util.isTomcat(project);
212         boolean isWebProject = Util.isWebProject(project);
213         
214         boolean txConfigEnabled = !isTomcat && isWebProject;
215         txCombo.setEnabled(txConfigEnabled);
216         txLbl.setEnabled(txConfigEnabled);
217         
218 // boolean serviceSecurityEnabled = SecurityPolicyModelHelper.isSecurityEnabled(binding);
219
// securityChBox.setEnabled(!(serviceSecurityEnabled || amSec));
220
//
221
// boolean secSelected = securityChBox.isSelected();
222
// profileComboLabel.setEnabled(secSelected);
223
// profileCombo.setEnabled(secSelected);
224
// profileInfoField.setEnabled(secSelected);
225
// profConfigButton.setEnabled(secSelected);
226

227 // boolean storeConfigRequired = isStoreConfigRequired();
228
// keystoreButton.setEnabled(storeConfigRequired && secSelected);
229
// trustButton.setEnabled(storeConfigRequired && secSelected);
230
}
231
232 // private boolean isStoreConfigRequired() {
233
// if (project != null) {
234
// J2eeModuleProvider mp = (J2eeModuleProvider)project.getLookup().lookup(J2eeModuleProvider.class);
235
// if (mp != null) {
236
// String id = mp.getServerID();
237
// String instid = mp.getServerInstanceID();
238
// if ((instid != null) && (instid.toLowerCase().contains("sun:appserver"))) { //NOI18N
239
// // TODO - when this gets clarified
240
// // return false;
241
// }
242
// }
243
// }
244
// return true;
245
// }
246

247 // // SECURITY PROFILE
248
// private void setSecurityProfile(String profile) {
249
// this.profileCombo.setSelectedItem(profile);
250
// this.profileInfoField.setText(ProfileUtil.getProfileInfo(profile));
251
// }
252

253     /** This method is called from within the constructor to
254      * initialize the form.
255      * WARNING: Do NOT modify this code. The content of this method is
256      * always regenerated by the Form Editor.
257      */

258     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
259
private void initComponents() {
260
261         txLbl = new javax.swing.JLabel JavaDoc();
262         txCombo = new javax.swing.JComboBox JavaDoc();
263
264         txLbl.setLabelFor(txCombo);
265         org.openide.awt.Mnemonics.setLocalizedText(txLbl, org.openide.util.NbBundle.getMessage(OperationPanel.class, "LBL_Section_Operation_Tx")); // NOI18N
266

267         txCombo.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[] { "None", "Not Supported", "Required", "Requires New", "Mandatory", "Supported" }));
268
269         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
270         this.setLayout(layout);
271         layout.setHorizontalGroup(
272             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
273             .add(layout.createSequentialGroup()
274                 .addContainerGap()
275                 .add(txLbl)
276                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
277                 .add(txCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
278                 .addContainerGap(156, Short.MAX_VALUE))
279         );
280         layout.setVerticalGroup(
281             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
282             .add(layout.createSequentialGroup()
283                 .addContainerGap()
284                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
285                     .add(txLbl)
286                     .add(txCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
287                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
288         );
289     }// </editor-fold>//GEN-END:initComponents
290

291     // Variables declaration - do not modify//GEN-BEGIN:variables
292
private javax.swing.JComboBox JavaDoc txCombo;
293     private javax.swing.JLabel JavaDoc txLbl;
294     // End of variables declaration//GEN-END:variables
295

296 }
297
Popular Tags