KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import javax.xml.namespace.QName JavaDoc;
24 import org.netbeans.api.project.Project;
25 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.AdvancedConfigurationClientNode;
26 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.CallbackClientNode;
27 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.BindingContainerClientNode;
28 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.KeystoreClientNode;
29 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.STSClientNode;
30 import org.netbeans.modules.websvc.wsitconf.ui.client.nodes.TransportClientNode;
31 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.PolicyModelHelper;
32 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper;
33 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RequiredConfigurationHelper;
34 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper;
35 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.WSITModelSupport;
36 import org.netbeans.modules.xml.multiview.SectionNode;
37 import org.netbeans.modules.xml.multiview.ui.*;
38 import org.netbeans.modules.xml.wsdl.model.Binding;
39 import org.netbeans.modules.xml.wsdl.model.Port;
40 import org.netbeans.modules.xml.wsdl.model.Service;
41 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
42 import org.openide.nodes.AbstractNode;
43 import org.openide.nodes.Children;
44 import org.openide.nodes.Node;
45 import org.openide.util.NbBundle;
46 import org.openide.util.RequestProcessor;
47
48 import java.util.Collection JavaDoc;
49
50 /**
51  * @author Martin Grebac
52  */

53 public class ClientView extends SectionView {
54
55     static final String JavaDoc KEYSTORE_NODE_ID = "keystore"; //NOI18N
56
static final String JavaDoc CALLBACK_NODE_ID = "callback"; //NOI18N
57
static final String JavaDoc STS_NODE_ID = "sts"; //NOI18N
58
static final String JavaDoc TRANSPORT_NODE_ID = "transpotr"; //NOI18N
59
static final String JavaDoc ADVANCEDCONFIG_NODE_ID = "advancedconfig"; //NOI18N
60

61     private SectionNode rootNode = null;
62     
63     private static final int REFRESH_DELAY = 40;
64             
65     private WSDLModel clientModel = null;
66     private WSDLModel serviceModel = null;
67     private Service service = null;
68     private Node node = null;
69     private Project project = null;
70     
71     ClientView(InnerPanelFactory factory, WSDLModel clientModel, WSDLModel serviceModel, Service s, Project project, Node node) {
72     
73         super(factory);
74         this.clientModel = clientModel;
75         this.serviceModel = serviceModel;
76         this.service = s;
77         this.node = node;
78         this.project = project;
79
80         //create root node
81
Children rootChildren = new Children.Array();
82         Node root = new AbstractNode(rootChildren);
83
84         Collection JavaDoc<Binding> bindings = new HashSet JavaDoc();
85         WSITModelSupport.fillImportedBindings(clientModel, bindings, new HashSet JavaDoc());
86         
87         Collection JavaDoc<Port> ports = s.getPorts();
88         for (Port p : ports) {
89             QName JavaDoc bqname = p.getBinding().getQName();
90             Binding b = clientModel.findComponentByName(bqname, Binding.class);
91             bindings.add(b);
92         }
93
94         ArrayList JavaDoc bindingNodes = new ArrayList JavaDoc();
95         if (bindings.size() > 1) {
96             for (Binding binding : bindings) {
97                 ArrayList JavaDoc nodes = new ArrayList JavaDoc();
98
99                 // main node container for a specific binding
100
Children bindingChildren = new Children.Array();
101                 Node bindingNodeContainer = new BindingContainerClientNode(bindingChildren);
102                 SectionContainer bindingCont = new SectionContainer(this,
103                         bindingNodeContainer,
104                         NbBundle.getMessage(ClientView.class, "LBL_Binding", binding.getName()));
105
106                 Node transportNode = new TransportClientNode(this, binding);
107                 SectionPanel transportPanel = new SectionPanel(this, transportNode,
108                         TRANSPORT_NODE_ID + binding.getName());
109                 bindingCont.addSection(transportPanel);
110                 nodes.add(transportNode);
111                 
112                 Node keystoreNode = new KeystoreClientNode(this, binding);
113                 SectionPanel keystorePanel = new SectionPanel(this, keystoreNode,
114                         KEYSTORE_NODE_ID + binding.getName());
115                 bindingCont.addSection(keystorePanel);
116                 nodes.add(keystoreNode);
117
118                 Node callbackNode = new CallbackClientNode(this, binding);
119                 SectionPanel callbackPanel = new SectionPanel(this, callbackNode,
120                         CALLBACK_NODE_ID + binding.getName());
121                 bindingCont.addSection(callbackPanel);
122                 nodes.add(callbackNode);
123
124                 if (isClientSTSConfigRequired(binding)) {
125                     Node stsNode = new STSClientNode(this, binding);
126                     SectionPanel stsPanel = new SectionPanel(this, stsNode,
127                             STS_NODE_ID + binding.getName());
128                     bindingCont.addSection(stsPanel);
129                     nodes.add(stsNode);
130                 }
131
132                 if (isClientAdvancedConfigRequired(binding, serviceModel)) {
133                     Node advancedConfigNode = new AdvancedConfigurationClientNode(this, binding);
134                     SectionPanel advancedConfigPanel = new SectionPanel(this, advancedConfigNode,
135                             ADVANCEDCONFIG_NODE_ID + binding.getName());
136                     bindingCont.addSection(advancedConfigPanel);
137                     nodes.add(advancedConfigNode);
138                 }
139                 
140                 bindingChildren.add((Node[]) nodes.toArray(new Node[nodes.size()]));
141                 addSection(bindingCont, false);
142                 bindingNodes.add(bindingNodeContainer);
143             }
144             rootChildren.add((Node[]) bindingNodes.toArray(new Node[bindingNodes.size()]));
145         } else {
146             Binding binding = (Binding) bindings.toArray()[0];
147             ArrayList JavaDoc nodes = new ArrayList JavaDoc();
148
149             Node transportNode = new TransportClientNode(this, binding);
150             SectionPanel transportPanel = new SectionPanel(this, transportNode,
151                     TRANSPORT_NODE_ID + binding.getName());
152             addSection(transportPanel);
153             nodes.add(transportNode);
154             
155             Node keystoreNode = new KeystoreClientNode(this, binding);
156             SectionPanel keystorePanel = new SectionPanel(this, keystoreNode,
157                     KEYSTORE_NODE_ID + binding.getName());
158             addSection(keystorePanel);
159             nodes.add(keystoreNode);
160
161             Node callbackNode = new CallbackClientNode(this, binding);
162             SectionPanel callbackPanel = new SectionPanel(this, callbackNode,
163                     CALLBACK_NODE_ID + binding.getName());
164             addSection(callbackPanel);
165             nodes.add(callbackNode);
166
167             if (isClientSTSConfigRequired(binding)) {
168                 Node stsNode = new STSClientNode(this, binding);
169                 SectionPanel stsPanel = new SectionPanel(this, stsNode,
170                         STS_NODE_ID + binding.getName());
171                 addSection(stsPanel);
172                 nodes.add(stsNode);
173             }
174
175             if (isClientAdvancedConfigRequired(binding, serviceModel)) {
176                 Node advancedConfigNode = new AdvancedConfigurationClientNode(this, binding);
177                 SectionPanel advancedConfigPanel = new SectionPanel(this, advancedConfigNode,
178                         ADVANCEDCONFIG_NODE_ID + binding.getName());
179                 addSection(advancedConfigPanel);
180                 nodes.add(advancedConfigNode);
181             }
182
183             rootChildren.add((Node[]) nodes.toArray(new Node[nodes.size()]));
184             
185         }
186         setRoot(root);
187     }
188     
189     private final RequestProcessor.Task refreshTask = RequestProcessor.getDefault().create(new Runnable JavaDoc() {
190         public void run() {
191             getRootNode().refreshSubtree();
192         }
193     });
194
195     public void refreshView() {
196         rootNode.refreshSubtree();
197     }
198     
199     public void scheduleRefreshView() {
200         refreshTask.schedule(REFRESH_DELAY);
201     }
202
203     public void dataModelPropertyChange(Object JavaDoc source, String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue) {
204         rootNode.dataModelPropertyChange(source, propertyName, oldValue, newValue);
205     }
206     
207     public SectionNode getRootNode() {
208         return rootNode;
209     }
210
211     private boolean isClientSTSConfigRequired(Binding binding) {
212         return true;
213     }
214
215     private boolean isClientAdvancedConfigRequired(Binding binding, WSDLModel serviceModel) {
216         Binding serviceBinding = PolicyModelHelper.getBinding(serviceModel, binding.getName());
217         boolean rmEnabled = RMModelHelper.isRMEnabled(serviceBinding);
218         boolean timestampEnabled = SecurityPolicyModelHelper.isIncludeTimestamp(serviceBinding);
219         boolean secConvRequired = RequiredConfigurationHelper.isSecureConversationParamRequired(serviceBinding);
220         return rmEnabled || secConvRequired || timestampEnabled;
221     }
222
223 }
224
Popular Tags