KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdlextui > property > SoapAddressConfigurator


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.xml.wsdlextui.property;
21
22
23 import java.util.Arrays JavaDoc;
24 import java.util.Collection JavaDoc;
25
26 import javax.xml.namespace.QName JavaDoc;
27
28 import org.netbeans.api.project.FileOwnerQuery;
29 import org.netbeans.api.project.Project;
30 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
31 import org.netbeans.modules.xml.wsdl.model.Port;
32 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
33 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter;
34 import org.netbeans.modules.xml.wsdl.ui.api.property.StringAttributeProperty;
35 import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator;
36 import org.netbeans.modules.xml.xam.ModelSource;
37 import org.openide.ErrorManager;
38 import org.openide.filesystems.FileObject;
39 import org.openide.nodes.Node;
40 import org.openide.util.NbBundle;
41
42 /**
43  *
44  * @author skini
45  */

46 public class SoapAddressConfigurator extends ExtensibilityElementConfigurator {
47     
48     
49     private static QName JavaDoc addressQName = new QName JavaDoc("http://schemas.xmlsoap.org/wsdl/soap/", "address");
50     
51     private static QName JavaDoc[] supportedQNames = {addressQName};
52     /** Creates a new instance of SoapHeaderConfigurator */
53     public SoapAddressConfigurator() {
54     }
55     
56     @Override JavaDoc
57     public Collection JavaDoc<QName JavaDoc> getSupportedQNames() {
58         return Arrays.asList(supportedQNames);
59     }
60     
61     @Override JavaDoc
62     public Node.Property getProperty(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
63         Node.Property property = null;
64         if (addressQName.equals(qname)) {
65             if ("location".equals(attributeName)) {
66                 ExtensibilityElementPropertyAdapter adapter = new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName, generateAddressLocation(extensibilityElement));
67                 try {
68                     property = new StringAttributeProperty(adapter, String JavaDoc.class, "getValue", "setValue");
69                     property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_ADDRESS_LOCATION"));
70                 } catch (NoSuchMethodException JavaDoc e) {
71                     ErrorManager.getDefault().notify(e);
72                 }
73             }
74         }
75         return property;
76     }
77     
78     
79     @Override JavaDoc
80     public String JavaDoc getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
81         // TODO Auto-generated method stub
82
return null;
83     }
84    
85     
86     public String JavaDoc generateAddressLocation(ExtensibilityElement element) {
87         //TODO:Complete this once decision is made.
88
WSDLModel model = element.getModel();
89         ModelSource ms = model.getModelSource();
90         FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class);
91         if (fo != null) {
92             Project prj = FileOwnerQuery.getOwner(fo);
93             //String prjPath = prj.getProjectDirectory().getPath();
94
//String filePath = fo.getPath();
95

96             //String path = filePath.substring(prjPath.length());
97
//String path = FileUtil.getRelativePath(prj.getProjectDirectory().getParent(), fo);
98

99             //URL url = new URL("http", "localhost", 18181, path);
100
Port port = (Port) element.getParent();
101             return "http://localhost:18181/" + prj.getProjectDirectory().getName() + "/" + fo.getName() + "/" + port.getName();
102         }
103         return "http://localhost:18181/service";
104     }
105
106     @Override JavaDoc
107     public String JavaDoc getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
108         // TODO Auto-generated method stub
109
return null;
110     }
111
112     @Override JavaDoc
113     public String JavaDoc getDefaultValue(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
114         if (attributeName.equals("location")) {
115             return generateAddressLocation(extensibilityElement);
116         }
117         return null;
118     }
119
120     @Override JavaDoc
121     public String JavaDoc getTypeDisplayName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
122         return NbBundle.getMessage(SoapAddressConfigurator.class, "LBL_SoapAddress_TypeDisplayName");
123     }
124     
125     
126 }
127
128
Popular Tags