KickJava   Java API By Example, From Geeks To Geeks.

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


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.modules.xml.wsdl.model.ExtensibilityElement;
29 import org.netbeans.modules.xml.wsdl.model.Message;
30 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter;
31 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageAttributeProperty;
32 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageProvider;
33 import org.netbeans.modules.xml.wsdl.ui.api.property.PartAttributeProperty;
34 import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator;
35 import org.openide.ErrorManager;
36 import org.openide.nodes.Node;
37 import org.openide.util.NbBundle;
38
39 /**
40  *
41  * @author skini
42  */

43 public class SoapHeaderConfigurator extends ExtensibilityElementConfigurator {
44     
45     
46     private static QName JavaDoc headerQName = new QName JavaDoc("http://schemas.xmlsoap.org/wsdl/soap/", "header");
47     private static QName JavaDoc headerFaultQName = new QName JavaDoc("http://schemas.xmlsoap.org/wsdl/soap/", "headerfault");
48     
49     private static QName JavaDoc[] supportedQNames = {headerQName, headerFaultQName};
50     /** Creates a new instance of SoapHeaderConfigurator */
51     public SoapHeaderConfigurator() {
52     }
53     
54     @Override JavaDoc
55     public Collection JavaDoc<QName JavaDoc> getSupportedQNames() {
56         return Arrays.asList(supportedQNames);
57     }
58     
59     @Override JavaDoc
60     public Node.Property getProperty(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
61         Node.Property property = null;
62         if (headerQName.equals(qname) || headerFaultQName.equals(qname)) {
63             if ("message".equals(attributeName)) {
64                 try {
65                     property = new MessageAttributeProperty(new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), extensibilityElement, String JavaDoc.class, "getValue", "setValue");
66                     property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_HEADER_MESSAGE"));
67                 } catch (NoSuchMethodException JavaDoc e) {
68                     ErrorManager.getDefault().notify(e);
69                 }
70             } else if ("part".equals(attributeName)) {
71                 MessageProvider prov = new SoapHeaderMessageProvider(extensibilityElement);
72                 try {
73                     property = new PartAttributeProperty(prov, extensibilityElement.getModel(), new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), String JavaDoc.class, "getValue", "setValue", false);
74                     property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_HEADER_PART"));
75                 } catch (NoSuchMethodException JavaDoc e) {
76                     ErrorManager.getDefault().notify(e);
77                 }
78             }
79         }
80         return property;
81     }
82     
83     
84     static class SoapHeaderMessageProvider implements MessageProvider {
85         private ExtensibilityElement element;
86         
87         public SoapHeaderMessageProvider(ExtensibilityElement elem) {
88             element = elem;
89         }
90         
91         public String JavaDoc getMessage() {
92             return element.getAttribute("message");
93         }
94
95         public Message getWSDLMessage() {
96             return null;
97         }
98         
99     }
100     
101     
102     @Override JavaDoc
103     public String JavaDoc getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
104         // TODO Auto-generated method stub
105
return null;
106     }
107
108     @Override JavaDoc
109     public String JavaDoc getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
110         // TODO Auto-generated method stub
111
return null;
112     }
113
114     @Override JavaDoc
115     public String JavaDoc getDefaultValue(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
116         // TODO Auto-generated method stub
117
return null;
118     }
119     
120     @Override JavaDoc
121     public String JavaDoc getTypeDisplayName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
122         if (qname.equals(headerQName))
123             return NbBundle.getMessage(SoapHeaderConfigurator.class, "LBL_SoapHeader_TypeDisplayName");
124         else if (qname.equals(headerFaultQName))
125             return NbBundle.getMessage(SoapHeaderConfigurator.class, "LBL_SoapHeaderFault_TypeDisplayName");
126         return null;
127     }
128     
129 }
130
131
Popular Tags