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.ExtensibilityElement;
050: import org.netbeans.modules.xml.wsdl.model.Message;
051: import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeader;
052: import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter;
053: import org.netbeans.modules.xml.wsdl.ui.api.property.MessageAttributeProperty;
054: import org.netbeans.modules.xml.wsdl.ui.api.property.MessageProvider;
055: import org.netbeans.modules.xml.wsdl.ui.api.property.PartAttributeProperty;
056: import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator;
057: import org.openide.ErrorManager;
058: import org.openide.nodes.Node;
059: import org.openide.util.NbBundle;
060:
061: /**
062: *
063: * @author skini
064: */
065: public class SoapHeaderConfigurator extends
066: ExtensibilityElementConfigurator {
067:
068: private static QName headerQName = new QName(
069: "http://schemas.xmlsoap.org/wsdl/soap/", "header");
070: private static QName headerFaultQName = new QName(
071: "http://schemas.xmlsoap.org/wsdl/soap/", "headerfault");
072:
073: private static QName[] supportedQNames = { headerQName,
074: headerFaultQName };
075:
076: /** Creates a new instance of SoapHeaderConfigurator */
077: public SoapHeaderConfigurator() {
078: }
079:
080: @Override
081: public Collection<QName> getSupportedQNames() {
082: return Arrays.asList(supportedQNames);
083: }
084:
085: @Override
086: public Node.Property getProperty(
087: ExtensibilityElement extensibilityElement, QName qname,
088: String attributeName) {
089: Node.Property property = null;
090: if (headerQName.equals(qname) || headerFaultQName.equals(qname)) {
091: if ("message".equals(attributeName)) {
092: try {
093: property = new MessageAttributeProperty(
094: new ExtensibilityElementPropertyAdapter(
095: extensibilityElement, attributeName),
096: extensibilityElement, String.class,
097: "getValue", "setValue");
098: property.setName(SOAPHeader.MESSAGE_PROPERTY);
099: property.setDisplayName(NbBundle.getMessage(
100: SoapAddressConfigurator.class,
101: "PROP_NAME_HEADER_MESSAGE"));
102: } catch (NoSuchMethodException e) {
103: ErrorManager.getDefault().notify(e);
104: }
105: } else if ("part".equals(attributeName)) {
106: MessageProvider prov = new SoapHeaderMessageProvider(
107: extensibilityElement);
108: try {
109: property = new PartAttributeProperty(
110: prov,
111: extensibilityElement.getModel(),
112: new ExtensibilityElementPropertyAdapter(
113: extensibilityElement, attributeName),
114: String.class, "getValue", "setValue", false);
115: property.setName(SOAPHeader.PART_PROPERTY);
116: property.setDisplayName(NbBundle.getMessage(
117: SoapAddressConfigurator.class,
118: "PROP_NAME_HEADER_PART"));
119: } catch (NoSuchMethodException e) {
120: ErrorManager.getDefault().notify(e);
121: }
122: }
123: }
124: return property;
125: }
126:
127: static class SoapHeaderMessageProvider implements MessageProvider {
128: private ExtensibilityElement element;
129:
130: public SoapHeaderMessageProvider(ExtensibilityElement elem) {
131: element = elem;
132: }
133:
134: public String getMessage() {
135: return element.getAttribute("message");
136: }
137:
138: public Message getWSDLMessage() {
139: return null;
140: }
141:
142: }
143:
144: @Override
145: public String getDisplayAttributeName(
146: ExtensibilityElement extensibilityElement, QName qname) {
147: // TODO Auto-generated method stub
148: return null;
149: }
150:
151: @Override
152: public String getAttributeUniqueValuePrefix(
153: ExtensibilityElement extensibilityElement, QName qname,
154: String attributeName) {
155: // TODO Auto-generated method stub
156: return null;
157: }
158:
159: @Override
160: public String getDefaultValue(
161: ExtensibilityElement extensibilityElement, QName qname,
162: String attributeName) {
163: // TODO Auto-generated method stub
164: return null;
165: }
166:
167: @Override
168: public String getTypeDisplayName(
169: ExtensibilityElement extensibilityElement, QName qname) {
170: if (qname.equals(headerQName))
171: return NbBundle.getMessage(SoapHeaderConfigurator.class,
172: "LBL_SoapHeader_TypeDisplayName");
173: else if (qname.equals(headerFaultQName))
174: return NbBundle.getMessage(SoapHeaderConfigurator.class,
175: "LBL_SoapHeaderFault_TypeDisplayName");
176: return null;
177: }
178:
179: }
|