1 19 20 28 29 package org.netbeans.modules.websvc.customization.multiview; 30 31 import java.util.ArrayList ; 32 import java.util.Collection ; 33 import java.util.List ; 34 import java.util.Set ; 35 import org.netbeans.modules.xml.multiview.ui.InnerPanelFactory; 36 import org.netbeans.modules.xml.multiview.ui.SectionContainer; 37 import org.netbeans.modules.xml.multiview.ui.SectionContainerNode; 38 import org.netbeans.modules.xml.multiview.ui.SectionPanel; 39 import org.netbeans.modules.xml.multiview.ui.SectionView; 40 import org.netbeans.modules.xml.wsdl.model.Binding; 41 import org.netbeans.modules.xml.wsdl.model.BindingOperation; 42 import org.netbeans.modules.xml.wsdl.model.Definitions; 43 import org.netbeans.modules.xml.wsdl.model.Fault; 44 import org.netbeans.modules.xml.wsdl.model.Operation; 45 import org.netbeans.modules.xml.wsdl.model.Port; 46 import org.netbeans.modules.xml.wsdl.model.PortType; 47 import org.netbeans.modules.xml.wsdl.model.Service; 48 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 49 import org.openide.nodes.AbstractNode; 50 import org.openide.nodes.Children; 51 import org.openide.nodes.Node; 52 import org.openide.util.HelpCtx; 53 import org.openide.util.NbBundle; 54 55 59 public class WSCustomizationView extends SectionView{ 60 private Set <WSDLModel> models; 61 private Definitions primaryDefinitions; 62 63 static final String ID_PORT_TYPE = "ID_PORT_TYPE"; 64 static final String ID_PORT_TYPE_OPERATION = "ID_PORT_TYPE_OPERATION"; 65 static final String ID_PORT_TYPE_OPERATION_FAULT = "ID_PORT_TYPE_OPERATION_FAULT"; 66 static final String ID_BINDING = "ID_BINDING"; 67 static final String ID_BINDING_OPERATION = "ID_BINDING_OPERATION"; 68 static final String ID_SERVICE = "ID_SERVICE"; 69 static final String ID_PORT= "ID_PORT"; 70 static final String ID_EXTERNAL_BINDING = "ID_EXTERNAL_BINDING"; 71 72 73 public WSCustomizationView(InnerPanelFactory factory, Set <WSDLModel> models , 74 Definitions primaryDefinitions) { 75 super(factory); 76 this.models = models; 77 this.primaryDefinitions = primaryDefinitions; 78 populateData(); 79 Children rootChildren = new Children.Array(); 81 Node root = new AbstractNode(rootChildren); 82 83 Node definitionsNode = new DefinitionsNode(this, primaryDefinitions); 85 86 addSection(new SectionPanel(this, definitionsNode, primaryDefinitions), false); 88 Children portTypeChildren = new Children.Array(); 90 Node[] portTypeNodes = new Node[portTypesList.size()]; 91 int i = 0; 92 for(PortType portType : portTypesList){ 93 portTypeNodes[i++] = new PortTypeNode(this, portType); 94 } 95 portTypeChildren.add(portTypeNodes); 96 Node portTypeNodeContainer = new SectionContainerNode(portTypeChildren); 97 portTypeNodeContainer.setName(ID_PORT_TYPE); 98 portTypeNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 99 "TITLE_PORTTYPES")); 100 101 SectionContainer portTypesCont = 102 new SectionContainer(this,portTypeNodeContainer, 103 NbBundle.getMessage(WSCustomizationView.class, 104 "TITLE_PORTTYPES")); 105 SectionPanel[] portTypePanels = new SectionPanel[portTypesList.size()]; 107 i = 0; 108 for(PortType portType : portTypesList){ 109 portTypePanels[i] = new SectionPanel(this, portTypeNodes[i], portType); 110 portTypesCont.addSection(portTypePanels[i], false); 111 i++; 112 } 113 addSection(portTypesCont, false); 114 115 Children opChildren = new Children.Array(); 117 Node[] operationNodes = new Node[portTypeOperationsList.size()]; 118 i = 0; 119 for(Operation operation : portTypeOperationsList){ 120 operationNodes[i++] = new PortTypeOperationNode(this, operation); 121 } 122 opChildren.add(operationNodes); 123 Node operationNodeContainer = new SectionContainerNode(opChildren); 124 operationNodeContainer.setName(ID_PORT_TYPE_OPERATION); 125 operationNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 126 "TITLE_PORTTYPE_OPERATIONS")); 127 128 SectionContainer operationCont = 129 new SectionContainer(this,operationNodeContainer, 130 NbBundle.getMessage(WSCustomizationView.class, 131 "TITLE_PORTTYPE_OPERATIONS")); 132 SectionPanel[] operationPanels = new SectionPanel[portTypeOperationsList.size()]; 134 i = 0; 135 for(Operation op : portTypeOperationsList){ 136 operationPanels[i] = new SectionPanel(this, operationNodes[i], op); 137 operationCont.addSection(operationPanels[i], false); 138 i++; 139 } 140 addSection(operationCont, false); 141 142 Children faultChildren = new Children.Array(); 144 Node[] faultNodes = new Node[portTypeOperationFaultsList.size()]; 145 i = 0; 146 for(Fault fault : portTypeOperationFaultsList){ 147 faultNodes[i++] = new PortTypeOperationFaultNode(this, fault); 148 } 149 faultChildren.add(faultNodes); 150 Node faultNodeContainer = new SectionContainerNode(faultChildren); 151 faultNodeContainer.setName(ID_PORT_TYPE_OPERATION_FAULT); 152 faultNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 153 "TITLE_PORTTYPE_FAULTS")); 154 155 SectionContainer faultCont = 156 new SectionContainer(this,faultNodeContainer, 157 NbBundle.getMessage(WSCustomizationView.class, 158 "TITLE_PORTTYPE_FAULTS")); 159 SectionPanel[] faultPanels = new SectionPanel[portTypeOperationFaultsList.size()]; 161 i = 0; 162 for(Fault fault : portTypeOperationFaultsList){ 163 faultPanels[i] = new SectionPanel(this, faultNodes[i], fault); 164 faultCont.addSection(faultPanels[i], false); 165 i++; 166 } 167 addSection(faultCont, false); 168 169 Children bindingChildren = new Children.Array(); 171 Node[] bindingNodes = new Node[bindingsList.size()]; 172 i = 0; 173 for(Binding binding : bindingsList){ 174 bindingNodes[i++] = new BindingNode(this, binding); 175 } 176 bindingChildren.add(bindingNodes); 177 Node bindingNodeContainer = new SectionContainerNode(bindingChildren); 178 bindingNodeContainer.setName(ID_BINDING); 179 bindingNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 180 "TITLE_BINDINGS")); 181 182 SectionContainer bindingCont = 183 new SectionContainer(this,bindingNodeContainer, 184 NbBundle.getMessage(WSCustomizationView.class, 185 "TITLE_BINDINGS")); 186 SectionPanel[] bindingPanels = new SectionPanel[bindingsList.size()]; 188 i = 0; 189 for(Binding binding : bindingsList){ 190 bindingPanels[i] = new SectionPanel(this, bindingNodes[i], binding); 191 bindingCont.addSection(bindingPanels[i], false); 192 i++; 193 } 194 addSection(bindingCont, false); 195 196 Children bindingOpChildren = new Children.Array(); 198 Node[] bindingOpNodes = new Node[bindingOperationsList.size()]; 199 i = 0; 200 for(BindingOperation bindingOp : bindingOperationsList){ 201 bindingOpNodes[i++] = new BindingOperationNode(this, bindingOp); 202 } 203 bindingOpChildren.add(bindingOpNodes); 204 Node bindingOpNodeContainer = new SectionContainerNode(bindingOpChildren); 205 bindingOpNodeContainer.setName(ID_BINDING_OPERATION); 206 bindingOpNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 207 "TITLE_BINDING_OPERATIONS")); 208 209 SectionContainer bindingOpCont = 210 new SectionContainer(this,bindingOpNodeContainer, 211 NbBundle.getMessage(WSCustomizationView.class, 212 "TITLE_BINDING_OPERATIONS")); 213 SectionPanel[] bindingOpPanels = new SectionPanel[bindingOperationsList.size()]; 215 i = 0; 216 for(BindingOperation bindingOp : bindingOperationsList){ 217 bindingOpPanels[i] = new SectionPanel(this, bindingOpNodes[i], bindingOp); 218 bindingOpCont.addSection(bindingOpPanels[i], false); 219 i++; 220 } 221 addSection(bindingOpCont, false); 222 223 Children serviceChildren = new Children.Array(); 224 Node[] serviceNodes = new Node[servicesList.size()]; 225 i = 0; 226 for(Service service : servicesList){ 227 serviceNodes[i++] = new ServiceNode(this, service); 228 } 229 serviceChildren.add(serviceNodes); 230 Node serviceNodeContainer = new SectionContainerNode(serviceChildren); 231 serviceNodeContainer.setName(ID_SERVICE); 232 serviceNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 233 "TITLE_SERVICES")); 234 235 SectionContainer servicesCont = 236 new SectionContainer(this,serviceNodeContainer, 237 NbBundle.getMessage(WSCustomizationView.class, 238 "TITLE_SERVICES")); 239 SectionPanel[] servicePanels = new SectionPanel[servicesList.size()]; 241 i = 0; 242 for(Service service : servicesList){ 243 servicePanels[i] = new SectionPanel(this, serviceNodes[i], service); 244 servicesCont.addSection(servicePanels[i], false); 245 i++; 246 } 247 addSection(servicesCont, false); 248 249 Children portChildren = new Children.Array(); 250 Node[] portNodes = new Node[portsList.size()]; 251 i = 0; 252 for(Port port : portsList){ 253 portNodes[i++] = new PortNode(this, port); 254 } 255 portChildren.add(portNodes); 256 Node portNodeContainer = new SectionContainerNode(portChildren); 257 portNodeContainer.setName(ID_PORT); 258 portNodeContainer.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 259 "TITLE_PORTS")); 260 261 SectionContainer portCont = 262 new SectionContainer(this,portNodeContainer, 263 NbBundle.getMessage(WSCustomizationView.class, 264 "TITLE_PORTS")); 265 SectionPanel[] portPanels = new SectionPanel[portsList.size()]; 267 i = 0; 268 for(Port port : portsList){ 269 portPanels[i] = new SectionPanel(this, portNodes[i], port); 270 portCont.addSection(portPanels[i], false); 271 i++; 272 } 273 addSection(portCont, false); 274 275 ExternalBindingNode externalBindingNode = new ExternalBindingNode(Children.LEAF); 276 externalBindingNode.setDisplayName(NbBundle.getMessage(WSCustomizationView.class, 277 "TITLE_EXTERNAL_BINDING_FILES")); 278 addSection(new SectionPanel(this, externalBindingNode, new BindingKey()), false); 279 rootChildren.add(new Node[] {definitionsNode, portTypeNodeContainer, 280 operationNodeContainer, faultNodeContainer, 281 bindingNodeContainer, bindingOpNodeContainer, 282 serviceNodeContainer, portNodeContainer, 283 externalBindingNode}); 284 setRoot(root); 285 } 286 287 private void populateData(){ 288 portTypesList = new ArrayList <PortType>(); 289 portTypeOperationsList = new ArrayList <Operation>(); 290 portTypeOperationFaultsList = new ArrayList <Fault>(); 291 bindingsList = new ArrayList <Binding>(); 292 bindingOperationsList = new ArrayList <BindingOperation>(); 293 servicesList = new ArrayList <Service>(); 294 portsList = new ArrayList <Port>(); 295 296 for(WSDLModel wsdlModel : models){ 297 Definitions def = wsdlModel.getDefinitions(); 298 Collection <PortType> portTypes = def.getPortTypes(); 299 portTypesList.addAll(portTypes); 300 for(PortType portType : portTypes){ 301 Collection <Operation> operations = portType.getOperations(); 302 portTypeOperationsList.addAll(operations); 303 for(Operation operation : operations){ 304 Collection <Fault> faults = operation.getFaults(); 305 portTypeOperationFaultsList.addAll(faults); 306 } 307 } 308 309 Collection <Binding> bindings = def.getBindings(); 310 bindingsList.addAll(bindings); 311 for(Binding binding : bindings){ 312 Collection <BindingOperation> bindingOperations = binding.getBindingOperations(); 313 bindingOperationsList.addAll(bindingOperations); 314 } 315 316 Collection <Service> services = def.getServices(); 317 servicesList.addAll(services); 318 for(Service service : services){ 319 Collection <Port> ports = service.getPorts(); 320 portsList.addAll(ports); 321 } 322 } 323 } 324 325 private List <PortType> portTypesList; 326 private List <Operation> portTypeOperationsList; 327 private List <Fault> portTypeOperationFaultsList; 328 private List <Binding> bindingsList; 329 private List <BindingOperation> bindingOperationsList; 330 private List <Service> servicesList; 331 private List <Port> portsList; 332 333 334 static class ExternalBindingNode extends AbstractNode{ 335 public ExternalBindingNode(Children children){ 336 super(children); 337 } 338 339 public HelpCtx getHelpCtx() { 340 return new HelpCtx(ID_EXTERNAL_BINDING); 341 } 342 } 343 344 public static class BindingKey extends Object { 345 } 347 } 348 | Popular Tags |