1 19 20 package org.netbeans.modules.xml.wsdlextui.property; 21 22 23 import java.util.Arrays ; 24 import java.util.Collection ; 25 26 import javax.xml.namespace.QName ; 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 43 public class SoapHeaderConfigurator extends ExtensibilityElementConfigurator { 44 45 46 private static QName headerQName = new QName ("http://schemas.xmlsoap.org/wsdl/soap/", "header"); 47 private static QName headerFaultQName = new QName ("http://schemas.xmlsoap.org/wsdl/soap/", "headerfault"); 48 49 private static QName [] supportedQNames = {headerQName, headerFaultQName}; 50 51 public SoapHeaderConfigurator() { 52 } 53 54 @Override 55 public Collection <QName > getSupportedQNames() { 56 return Arrays.asList(supportedQNames); 57 } 58 59 @Override 60 public Node.Property getProperty(ExtensibilityElement extensibilityElement, QName qname, String 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 .class, "getValue", "setValue"); 66 property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_HEADER_MESSAGE")); 67 } catch (NoSuchMethodException 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 .class, "getValue", "setValue", false); 74 property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_HEADER_PART")); 75 } catch (NoSuchMethodException 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 getMessage() { 92 return element.getAttribute("message"); 93 } 94 95 public Message getWSDLMessage() { 96 return null; 97 } 98 99 } 100 101 102 @Override 103 public String getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName qname) { 104 return null; 106 } 107 108 @Override 109 public String getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 110 return null; 112 } 113 114 @Override 115 public String getDefaultValue(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 116 return null; 118 } 119 120 @Override 121 public String getTypeDisplayName(ExtensibilityElement extensibilityElement, QName 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 |