1 19 package org.netbeans.modules.websvc.wsitconf.ui.client; 20 21 import java.util.ArrayList ; 22 import java.util.HashSet ; 23 import javax.xml.namespace.QName ; 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 ; 49 50 53 public class ClientView extends SectionView { 54 55 static final String KEYSTORE_NODE_ID = "keystore"; static final String CALLBACK_NODE_ID = "callback"; static final String STS_NODE_ID = "sts"; static final String TRANSPORT_NODE_ID = "transpotr"; static final String ADVANCEDCONFIG_NODE_ID = "advancedconfig"; 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 Children rootChildren = new Children.Array(); 82 Node root = new AbstractNode(rootChildren); 83 84 Collection <Binding> bindings = new HashSet (); 85 WSITModelSupport.fillImportedBindings(clientModel, bindings, new HashSet ()); 86 87 Collection <Port> ports = s.getPorts(); 88 for (Port p : ports) { 89 QName bqname = p.getBinding().getQName(); 90 Binding b = clientModel.findComponentByName(bqname, Binding.class); 91 bindings.add(b); 92 } 93 94 ArrayList bindingNodes = new ArrayList (); 95 if (bindings.size() > 1) { 96 for (Binding binding : bindings) { 97 ArrayList nodes = new ArrayList (); 98 99 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 nodes = new ArrayList (); 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 () { 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 source, String propertyName, Object oldValue, Object 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 |