1 19 20 package org.netbeans.modules.websvc.jaxrpc.nodes; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 import org.netbeans.modules.websvc.api.client.WebServicesClientSupport; 25 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 26 import org.openide.nodes.FilterNode; 27 import org.openide.nodes.Node; 28 import org.openide.filesystems.FileObject; 29 import org.openide.loaders.DataObject; 30 import org.openide.loaders.DataObjectNotFoundException; 31 import org.openide.util.Lookup; 32 33 import org.netbeans.modules.websvc.api.registry.WebServicesRegistryView; 34 35 41 public class ClientViewChildren extends FilterNode.Children { 42 43 public ClientViewChildren(FileObject wsdlFolder) throws DataObjectNotFoundException { 44 super(DataObject.find(wsdlFolder).getNodeDelegate()); 45 } 46 47 protected Node[] createNodes(Node origNode) { 48 Node [] results = new Node[0]; 50 DataObject wsdlDataObject = (DataObject)origNode.getCookie(DataObject.class); 51 52 if(wsdlDataObject != null && isClient(wsdlDataObject)) { 53 WebServicesRegistryView registryView = (WebServicesRegistryView) Lookup.getDefault().lookup(WebServicesRegistryView.class); 54 Node [] serviceNodes = registryView.getWebServiceNodes(wsdlDataObject.getPrimaryFile()); 55 if (serviceNodes != null) { 56 results = new Node[serviceNodes.length]; 57 for(int i = 0; i < serviceNodes.length; i++) { 58 results[i] = new ServiceClientNode(origNode, serviceNodes[i]); 59 } 60 } else { 61 results = new Node [] { new ServiceClientNode(origNode, null) }; 62 63 final FileObject wsdlFileObject = wsdlDataObject.getPrimaryFile(); 64 final WebServicesRegistryView regView = registryView; 65 Thread registerThread = new Thread (new Runnable () { 66 public void run() { 67 regView.registerService(wsdlFileObject, true); 68 } 69 }, "RegisterWSClient " + wsdlFileObject.getNameExt()); registerThread.start(); 71 } 72 } 73 74 return results; 75 } 76 77 86 private boolean isClient(DataObject dobj){ 87 FileObject wsdlFileObject = dobj.getPrimaryFile(); 88 WebServicesClientSupport wss = WebServicesClientSupport.getWebServicesClientSupport(wsdlFileObject); 89 List wsClients = wss.getServiceClients(); 90 Iterator i = wsClients.iterator(); 91 while (i.hasNext()) { 92 WsCompileClientEditorSupport.ServiceSettings wsClient = (WsCompileClientEditorSupport.ServiceSettings)i.next(); 93 String wsdlFileName = wsdlFileObject.getName(); 94 if (wsdlFileName.equals(wsClient.getServiceName())) { 95 return true; 96 } 97 } 98 return false; 99 } 100 } 101 | Popular Tags |