KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > design > view > widget > OperationsWidget


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 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.design.view.widget;
21
22 import java.net.MalformedURLException JavaDoc;
23 import java.net.URL JavaDoc;
24 import org.netbeans.api.visual.widget.LayerWidget;
25 import org.netbeans.api.visual.widget.Scene;
26 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
27 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.*;
28
29 /**
30  *
31  * @author Ajit Bhate
32  */

33 public class OperationsWidget extends LayerWidget {
34     
35     private transient WsdlService wsdlService;
36     /**
37      * Creates a new instance of OperationWidget
38      * @param scene
39      * @param service
40      */

41     public OperationsWidget(Scene scene, Service service) {
42         super(scene);
43         initialize(service);
44         createContent();
45     }
46     
47     /**
48      * Initialize the model. Try to find if the Service is created from WSDL.
49      * If so find the WsdlService object representing JAXWS service
50      */

51     private void initialize(Service service) {
52         try {
53             String JavaDoc wsdlUrlStr = service.getWsdlUrl();
54             if(wsdlUrlStr==null) return;
55             URL JavaDoc wsdlUrl = new URL JavaDoc(wsdlUrlStr);
56             if(wsdlUrl==null) return;
57             WsdlModeler modeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlUrl);
58             if(modeler==null) return;
59             WsdlModel model = modeler.getAndWaitForWsdlModel();
60             if(model==null) return;
61             wsdlService = model.getServiceByName(service.getServiceName());
62         } catch(MalformedURLException JavaDoc e) {
63         }
64     }
65
66     private void createContent() {
67         if (wsdlService==null) return;
68         for(WsdlPort port:wsdlService.getPorts()) {
69             for(WsdlOperation operation:port.getOperations()) {
70                 addChild(new OperationContentWidget(getScene(),operation));
71             }
72         }
73     }
74 }
75
Popular Tags