001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.wsdlextui.property;
043:
044: import java.util.Arrays;
045: import java.util.Collection;
046:
047: import javax.xml.namespace.QName;
048:
049: import org.netbeans.modules.xml.wsdl.model.BindingInput;
050: import org.netbeans.modules.xml.wsdl.model.BindingOutput;
051: import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
052: import org.netbeans.modules.xml.wsdl.model.Input;
053: import org.netbeans.modules.xml.wsdl.model.Message;
054: import org.netbeans.modules.xml.wsdl.model.Output;
055: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
056: import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody;
057: import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter;
058: import org.netbeans.modules.xml.wsdl.ui.api.property.MessageProvider;
059: import org.netbeans.modules.xml.wsdl.ui.api.property.PartAttributeProperty;
060: import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator;
061: import org.openide.ErrorManager;
062: import org.openide.nodes.Node;
063: import org.openide.util.NbBundle;
064:
065: /**
066: *
067: * @author skini
068: */
069: public class SoapBodyConfigurator extends
070: ExtensibilityElementConfigurator {
071:
072: private static QName myQName = new QName(
073: "http://schemas.xmlsoap.org/wsdl/soap/", "body");
074:
075: private static QName[] supportedQNames = { myQName };
076:
077: /** Creates a new instance of SoapBodyConfigurator */
078: public SoapBodyConfigurator() {
079: }
080:
081: @Override
082: public Collection<QName> getSupportedQNames() {
083: return Arrays.asList(supportedQNames);
084: }
085:
086: @Override
087: public Node.Property getProperty(
088: ExtensibilityElement extensibilityElement, QName qname,
089: String attributeName) {
090: Node.Property property = null;
091: if (myQName.equals(qname)) {
092: if ("parts".equals(attributeName)) {
093: try {
094: property = new PartAttributeProperty(
095: new SoapBodyMessageProvider(
096: extensibilityElement),
097: extensibilityElement.getModel(),
098: new ExtensibilityElementPropertyAdapter(
099: extensibilityElement, attributeName),
100: String.class, "getValue", "setValue", true);
101: property.setName(SOAPBody.PARTS_PROPERTY);
102: property.setDisplayName(NbBundle.getMessage(
103: SoapAddressConfigurator.class,
104: "PROP_NAME_BODY_PARTS"));
105: } catch (NoSuchMethodException e) {
106: ErrorManager.getDefault().notify(e);
107: }
108: }
109: }
110: return property;
111: }
112:
113: static class SoapBodyMessageProvider implements MessageProvider {
114: private ExtensibilityElement element;
115:
116: public SoapBodyMessageProvider(ExtensibilityElement elem) {
117: element = elem;
118: }
119:
120: public String getMessage() {
121: return null;
122: }
123:
124: public Message getWSDLMessage() {
125: WSDLComponent component = element.getParent();
126: Message message = null;
127: if (component instanceof BindingInput) {
128: BindingInput bi = (BindingInput) component;
129: if (bi.getInput() != null) {
130: Input input = bi.getInput().get();
131: if (input != null && input.getMessage() != null) {
132: message = input.getMessage().get();
133: return message;
134: }
135: }
136: } else if (component instanceof BindingOutput) {
137: BindingOutput bi = (BindingOutput) component;
138: if (bi.getOutput() != null) {
139: Output output = bi.getOutput().get();
140: if (output != null && output.getMessage() != null) {
141: message = output.getMessage().get();
142: return message;
143: }
144: }
145: }
146: return null;
147: }
148:
149: }
150:
151: @Override
152: public String getDisplayAttributeName(
153: ExtensibilityElement extensibilityElement, QName qname) {
154: // TODO Auto-generated method stub
155: return null;
156: }
157:
158: @Override
159: public String getAttributeUniqueValuePrefix(
160: ExtensibilityElement extensibilityElement, QName qname,
161: String attributeName) {
162: // TODO Auto-generated method stub
163: return null;
164: }
165:
166: @Override
167: public String getDefaultValue(
168: ExtensibilityElement extensibilityElement, QName qname,
169: String attributeName) {
170: // TODO Auto-generated method stub
171: return null;
172: }
173:
174: @Override
175: public String getTypeDisplayName(
176: ExtensibilityElement extensibilityElement, QName qname) {
177: return NbBundle.getMessage(SoapBodyConfigurator.class,
178: "LBL_SoapBody_TypeDisplayName");
179: }
180: }
|