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.api.project.FileOwnerQuery; 29 import org.netbeans.api.project.Project; 30 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 31 import org.netbeans.modules.xml.wsdl.model.Port; 32 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 33 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter; 34 import org.netbeans.modules.xml.wsdl.ui.api.property.StringAttributeProperty; 35 import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator; 36 import org.netbeans.modules.xml.xam.ModelSource; 37 import org.openide.ErrorManager; 38 import org.openide.filesystems.FileObject; 39 import org.openide.nodes.Node; 40 import org.openide.util.NbBundle; 41 42 46 public class SoapAddressConfigurator extends ExtensibilityElementConfigurator { 47 48 49 private static QName addressQName = new QName ("http://schemas.xmlsoap.org/wsdl/soap/", "address"); 50 51 private static QName [] supportedQNames = {addressQName}; 52 53 public SoapAddressConfigurator() { 54 } 55 56 @Override 57 public Collection <QName > getSupportedQNames() { 58 return Arrays.asList(supportedQNames); 59 } 60 61 @Override 62 public Node.Property getProperty(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 63 Node.Property property = null; 64 if (addressQName.equals(qname)) { 65 if ("location".equals(attributeName)) { 66 ExtensibilityElementPropertyAdapter adapter = new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName, generateAddressLocation(extensibilityElement)); 67 try { 68 property = new StringAttributeProperty(adapter, String .class, "getValue", "setValue"); 69 property.setName(NbBundle.getMessage(SoapAddressConfigurator.class, "PROP_NAME_ADDRESS_LOCATION")); 70 } catch (NoSuchMethodException e) { 71 ErrorManager.getDefault().notify(e); 72 } 73 } 74 } 75 return property; 76 } 77 78 79 @Override 80 public String getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName qname) { 81 return null; 83 } 84 85 86 public String generateAddressLocation(ExtensibilityElement element) { 87 WSDLModel model = element.getModel(); 89 ModelSource ms = model.getModelSource(); 90 FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class); 91 if (fo != null) { 92 Project prj = FileOwnerQuery.getOwner(fo); 93 96 99 Port port = (Port) element.getParent(); 101 return "http://localhost:18181/" + prj.getProjectDirectory().getName() + "/" + fo.getName() + "/" + port.getName(); 102 } 103 return "http://localhost:18181/service"; 104 } 105 106 @Override 107 public String getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 108 return null; 110 } 111 112 @Override 113 public String getDefaultValue(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 114 if (attributeName.equals("location")) { 115 return generateAddressLocation(extensibilityElement); 116 } 117 return null; 118 } 119 120 @Override 121 public String getTypeDisplayName(ExtensibilityElement extensibilityElement, QName qname) { 122 return NbBundle.getMessage(SoapAddressConfigurator.class, "LBL_SoapAddress_TypeDisplayName"); 123 } 124 125 126 } 127 128 | Popular Tags |