KickJava   Java API By Example, From Geeks To Geeks.

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


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

47 public class SoapBodyConfigurator extends ExtensibilityElementConfigurator {
48
49
50     private static QName JavaDoc myQName = new QName JavaDoc("http://schemas.xmlsoap.org/wsdl/soap/", "body");
51
52     private static QName JavaDoc[] supportedQNames = {myQName};
53     /** Creates a new instance of SoapBodyConfigurator */
54     public SoapBodyConfigurator() {
55     }
56
57     @Override JavaDoc
58     public Collection JavaDoc<QName JavaDoc> getSupportedQNames() {
59         return Arrays.asList(supportedQNames);
60     }
61
62     @Override JavaDoc
63     public Node.Property getProperty(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
64         Node.Property property = null;
65         if (myQName.equals(qname)) {
66             if ("parts".equals(attributeName)) {
67                 try {
68                     property = new PartAttributeProperty(new SoapBodyMessageProvider(extensibilityElement), extensibilityElement.getModel(), new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), String JavaDoc.class, "getValue", "setValue", true);
69                     property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_BODY_PARTS"));
70                 } catch (NoSuchMethodException JavaDoc e) {
71                     ErrorManager.getDefault().notify(e);
72                 }
73             }
74         }
75         return property;
76     }
77
78
79     static class SoapBodyMessageProvider implements MessageProvider {
80         private ExtensibilityElement element;
81
82         public SoapBodyMessageProvider(ExtensibilityElement elem) {
83             element = elem;
84         }
85
86         public String JavaDoc getMessage() {
87             return null;
88         }
89
90         public Message getWSDLMessage() {
91             WSDLComponent component = element.getParent();
92             Message message = null;
93             if (component instanceof BindingInput) {
94                 BindingInput bi = (BindingInput)component;
95                 if (bi.getInput() != null) {
96                     Input input = bi.getInput().get();
97                     if (input != null && input.getMessage() != null) {
98                         message = input.getMessage().get();
99                         return message;
100                     }
101                 }
102             } else if (component instanceof BindingOutput) {
103                 BindingOutput bi = (BindingOutput)component;
104                 if (bi.getOutput() != null) {
105                     Output output = bi.getOutput().get();
106                     if (output != null && output.getMessage() != null) {
107                         message = output.getMessage().get();
108                         return message;
109                     }
110                 }
111             }
112             return null;
113         }
114
115     }
116
117
118     @Override JavaDoc
119     public String JavaDoc getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
120         // TODO Auto-generated method stub
121
return null;
122     }
123
124     @Override JavaDoc
125     public String JavaDoc getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
126         // TODO Auto-generated method stub
127
return null;
128     }
129
130     @Override JavaDoc
131     public String JavaDoc getDefaultValue(ExtensibilityElement extensibilityElement, QName JavaDoc qname, String JavaDoc attributeName) {
132         // TODO Auto-generated method stub
133
return null;
134     }
135     
136     @Override JavaDoc
137     public String JavaDoc getTypeDisplayName(ExtensibilityElement extensibilityElement, QName JavaDoc qname) {
138         return NbBundle.getMessage(SoapBodyConfigurator.class, "LBL_SoapBody_TypeDisplayName");
139     }
140 }
141
Popular Tags