1 19 package org.netbeans.modules.websvc.wsitconf.ui.service; 20 21 import java.util.ArrayList ; 22 import java.util.HashSet ; 23 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 24 import org.netbeans.modules.websvc.wsitconf.ui.nodes.BindingFaultNode; 25 import org.netbeans.modules.websvc.wsitconf.ui.nodes.OperationNode; 26 import org.netbeans.modules.websvc.wsitconf.ui.nodes.ServiceNode; 27 import org.netbeans.modules.websvc.wsitconf.ui.nodes.OperationContainerServiceNode; 28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.WSITModelSupport; 29 import org.netbeans.modules.xml.multiview.SectionNode; 30 import org.netbeans.modules.xml.multiview.ui.*; 31 import org.netbeans.modules.xml.wsdl.model.Binding; 32 import org.netbeans.modules.xml.wsdl.model.BindingFault; 33 import org.netbeans.modules.xml.wsdl.model.BindingInput; 34 import org.netbeans.modules.xml.wsdl.model.BindingOperation; 35 import org.netbeans.modules.xml.wsdl.model.BindingOutput; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 import org.openide.nodes.AbstractNode; 38 import org.openide.nodes.Children; 39 import org.openide.nodes.Node; 40 import org.openide.util.RequestProcessor; 41 42 import java.util.Collection ; 43 import org.netbeans.modules.websvc.wsitconf.ui.nodes.BindingContainerServiceNode; 44 import org.netbeans.modules.websvc.wsitconf.ui.nodes.BindingInputNode; 45 import org.netbeans.modules.websvc.wsitconf.ui.nodes.BindingOutputNode; 46 import org.netbeans.modules.websvc.wsitconf.util.Util; 47 import org.openide.filesystems.FileObject; 48 49 52 public class ServiceView extends SectionView { 53 54 private SectionNode rootNode; 55 56 private static final int REFRESH_DELAY = 40; 57 58 private WSDLModel model; 59 60 ServiceView(InnerPanelFactory factory, WSDLModel model, Node node, Service s) { 61 this(factory, model, node, s, null); 62 } 63 64 ServiceView(InnerPanelFactory factory, WSDLModel model, Node node, Service s, Collection <Binding> bs) { 65 super(factory); 66 this.model = model; 67 68 if (model == null) return; 69 70 Collection <Binding> bindings = bs; 71 if (bindings == null) { 72 bindings = new HashSet (); 73 WSITModelSupport.fillImportedBindings(model, bindings, new HashSet ()); 74 } 75 76 Node[] bindingNodes = new Node[bindings.size()]; 78 Children rootChildren = new Children.Array(); 79 80 FileObject jc = null; 81 if (s != null) { 82 String wsdlUrl = s.getWsdlUrl(); 83 if (wsdlUrl == null) { jc = (FileObject)node.getLookup().lookup(FileObject.class); 85 } 86 } 87 88 if (bindingNodes.length > 1) { 90 Node root = new AbstractNode(rootChildren); 91 int i = 0; 92 setRoot(root); 93 94 for (Binding binding : bindings) { 95 96 if (jc != null) { 97 Util.refreshOperations(binding, jc); 98 } 99 100 Children bindingChildren = new Children.Array(); 102 Node bindingNodeContainer = new BindingContainerServiceNode(bindingChildren); 103 SectionContainer bindingCont = new SectionContainer(this, 104 bindingNodeContainer, binding.getName() + " Binding"); addSection(bindingCont, false); 106 107 ArrayList nodes = new ArrayList (); 108 109 Node serviceNode = new ServiceNode(this, binding); 110 nodes.add(serviceNode); 111 SectionPanel servicePanel = new SectionPanel(this, serviceNode, binding, true); 112 bindingCont.addSection(servicePanel, false); 113 114 Collection <BindingOperation> operations = binding.getBindingOperations(); 115 for (BindingOperation op : operations) { 116 Children opChildren = new Children.Array(); 117 Node opNodeContainer = new OperationContainerServiceNode(opChildren); 118 SectionContainer opCont = new SectionContainer(this, opNodeContainer, op.getName() + " Operation"); bindingCont.addSection(opCont, false); 120 121 ArrayList subNodes = new ArrayList (); 122 123 Node opNode = new OperationNode(this, op); 124 subNodes.add(opNode); 125 SectionPanel opPanel = new SectionPanel(this, opNode, op, false); 126 opCont.addSection(opPanel, false); 127 128 BindingInput bi = op.getBindingInput(); 129 if (bi != null) { 130 Node biNode = new BindingInputNode(this, bi); 131 subNodes.add(biNode); 132 SectionPanel biPanel = new SectionPanel(this, biNode, bi, false); 133 opCont.addSection(biPanel, false); 134 } 135 BindingOutput bo = op.getBindingOutput(); 136 if (bo != null) { 137 Node boNode = new BindingOutputNode(this, bo); 138 subNodes.add(boNode); 139 SectionPanel boPanel = new SectionPanel(this, boNode, bo, false); 140 opCont.addSection(boPanel, false); 141 } 142 Collection <BindingFault> bfs = op.getBindingFaults(); 143 for (BindingFault bf : bfs) { 144 Node bfNode = new BindingFaultNode(this, bf); 145 subNodes.add(bfNode); 146 SectionPanel bfPanel = new SectionPanel(this, bfNode, bf, false); 147 opCont.addSection(bfPanel, false); 148 } 149 opChildren.add((Node[]) subNodes.toArray(new Node[subNodes.size()])); 150 nodes.add(opNodeContainer); 151 } 152 153 bindingChildren.add((Node[]) nodes.toArray(new Node[nodes.size()])); 154 155 bindingNodes[i++] = bindingNodeContainer; 156 } 157 rootChildren.add(bindingNodes); 158 } else { 159 Binding b = (Binding) bindings.toArray()[0]; 160 if (jc != null) { 161 Util.refreshOperations(b, jc); 162 } 163 Node root = new AbstractNode(rootChildren); 164 setRoot(root); 165 166 Node serviceNode = new ServiceNode(this, b); 167 ArrayList nodes = new ArrayList (); 168 nodes.add(serviceNode); 169 170 SectionPanel servicePanel = new SectionPanel(this, serviceNode, b, true); 171 addSection(servicePanel, false); 172 173 Collection <BindingOperation> operations = b.getBindingOperations(); 174 for (BindingOperation op : operations) { 175 176 Children opChildren = new Children.Array(); 177 Node opNodeContainer = new OperationContainerServiceNode(opChildren); 178 SectionContainer opCont = new SectionContainer(this, opNodeContainer, op.getName() + " Operation"); addSection(opCont, false); 180 181 ArrayList subNodes = new ArrayList (); 182 183 Node opNode = new OperationNode(this, op); 184 subNodes.add(opNode); 185 SectionPanel opPanel = new SectionPanel(this, opNode, op, false); 186 opCont.addSection(opPanel, false); 187 188 BindingInput bi = op.getBindingInput(); 189 if (bi != null) { 190 Node biNode = new BindingInputNode(this, bi); 191 subNodes.add(biNode); 192 SectionPanel biPanel = new SectionPanel(this, biNode, bi, false); 193 opCont.addSection(biPanel, false); 194 } 195 BindingOutput bo = op.getBindingOutput(); 196 if (bo != null) { 197 Node boNode = new BindingOutputNode(this, bo); 198 subNodes.add(boNode); 199 SectionPanel boPanel = new SectionPanel(this, boNode, bo, false); 200 opCont.addSection(boPanel, false); 201 } 202 Collection <BindingFault> bfs = op.getBindingFaults(); 203 for (BindingFault bf : bfs) { 204 Node bfNode = new BindingFaultNode(this, bf); 205 subNodes.add(bfNode); 206 SectionPanel bfPanel = new SectionPanel(this, bfNode, bf, false); 207 opCont.addSection(bfPanel, false); 208 } 209 opChildren.add((Node[]) subNodes.toArray(new Node[subNodes.size()])); 210 nodes.add(opNodeContainer); 211 } 212 rootChildren.add((Node[]) nodes.toArray(new Node[nodes.size()])); 213 servicePanel.open(); 214 } 215 } 216 217 private final RequestProcessor.Task refreshTask = RequestProcessor.getDefault().create(new Runnable () { 218 public void run() { 219 getRootNode().refreshSubtree(); 220 } 221 }); 222 223 public void refreshView() { 224 rootNode.refreshSubtree(); 225 } 226 227 public void scheduleRefreshView() { 228 refreshTask.schedule(REFRESH_DELAY); 229 } 230 231 public void dataModelPropertyChange(Object source, String propertyName, Object oldValue, Object newValue) { 232 rootNode.dataModelPropertyChange(source, propertyName, oldValue, newValue); 233 } 234 235 public SectionNode getRootNode() { 236 return rootNode; 237 } 238 239 } 240 | Popular Tags |