1 19 20 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor.extension.bpel; 21 22 23 import java.beans.PropertyEditor ; 24 import java.util.ArrayList ; 25 import java.util.Arrays ; 26 import java.util.Collection ; 27 import java.util.List ; 28 29 import javax.xml.namespace.QName ; 30 31 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 32 import org.netbeans.modules.xml.wsdl.model.Message; 33 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 34 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELQName; 35 import org.netbeans.modules.xml.wsdl.ui.api.property.ComboBoxPropertyEditor; 36 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter; 37 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageAttributeProperty; 38 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageProvider; 39 import org.netbeans.modules.xml.wsdl.ui.api.property.PartAttributeProperty; 40 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility; 41 import org.netbeans.modules.xml.wsdl.ui.spi.ExtensibilityElementConfigurator; 42 import org.netbeans.modules.xml.xam.ui.XAMUtils; 43 import org.openide.ErrorManager; 44 import org.openide.nodes.Node; 45 import org.openide.nodes.PropertySupport; 46 import org.openide.nodes.Node.Property; 47 import org.openide.util.NbBundle; 48 49 public class PropertyAliasConfigurator extends 50 ExtensibilityElementConfigurator { 51 52 private static QName myQName = BPELQName.PROPERTY_ALIAS.getQName(); 53 private static QName queryQName = BPELQName.QUERY.getQName(); 54 private static QName propertyQName = BPELQName.PROPERTY.getQName(); 55 56 private static QName [] supportedQNames = {myQName, queryQName}; 57 58 @Override 59 public Collection <QName > getSupportedQNames() { 60 return Arrays.asList(supportedQNames); 61 } 62 63 @Override 64 public Property getProperty(ExtensibilityElement extensibilityElement, 65 QName qname, String attributeName) { 66 Node.Property property = null; 67 if (myQName.equals(qname)) { 68 if ("messageType".equals(attributeName)) { try { 70 property = new MessageAttributeProperty(new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), extensibilityElement, String .class, "getValue", "setValue"); 71 property.setName(NbBundle.getMessage(PropertyConfigurator.class, "PROPERTY_NAME_PA_MESSAGETYPE")); 72 } catch (NoSuchMethodException e) { 73 ErrorManager.getDefault().notify(e); 74 } 75 } else if ("part".equals(attributeName)) { MessageProvider prov = new MessageProviderImpl(extensibilityElement); 77 try { 78 property = new PartAttributeProperty(prov, extensibilityElement.getModel(), new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), String .class, "getValue", "setValue", false); 79 property.setName(NbBundle.getMessage(PropertyConfigurator.class, "PROPERTY_NAME_PA_PART")); 80 } catch (NoSuchMethodException e) { 81 ErrorManager.getDefault().notify(e); 82 } 83 } else if ("propertyName".equals(attributeName)) { try { 85 property = new PropertyNameProperty(new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeName), String .class, "getValue", "setValue"); 86 } catch (NoSuchMethodException e) { 87 ErrorManager.getDefault().notify(e); 88 } 89 property.setName(NbBundle.getMessage(PropertyConfigurator.class, "PROPERTY_NAME_PROPERTY_NAME")); 90 } 91 } 92 return property; 93 } 94 95 @Override 96 public String getDisplayAttributeName(ExtensibilityElement extensibilityElement, QName qname) { 97 return "propertyName"; } 99 100 101 102 static class MessageProviderImpl implements MessageProvider { 103 private ExtensibilityElement element; 104 105 public MessageProviderImpl (ExtensibilityElement elem) { 106 element = elem; 107 } 108 109 public String getMessage() { 110 return element.getAttribute("messageType"); } 112 113 public Message getWSDLMessage() { 114 return null; 115 } 116 117 } 118 119 120 class PropertyNameProperty extends PropertySupport.Reflection { 121 122 ExtensibilityElementPropertyAdapter adapter; 123 124 public PropertyNameProperty(ExtensibilityElementPropertyAdapter instance, Class valueType, String getter, String setter) throws NoSuchMethodException { 125 super(instance, valueType, getter, setter); 126 adapter = instance; 127 } 128 129 130 @Override 131 public PropertyEditor getPropertyEditor() { 132 ArrayList <String > list = new ArrayList <String >(); 133 list.add(""); 134 WSDLModel model = adapter.getExtensibilityElement().getModel(); 135 addToPropertyList(list, model); 136 137 Collection <WSDLModel> importedModels = Utility.getImportedDocuments(model); 139 for (WSDLModel imp : importedModels ) { 140 addToPropertyList(list, imp); 141 } 142 143 return new ComboBoxPropertyEditor(list.toArray(new String [list.size()])); 144 } 145 146 private void addToPropertyList(List <String > propertyList, WSDLModel model) { 147 List <ExtensibilityElement> ees = model.getDefinitions().getExtensibilityElements(); 148 String prefix = Utility.getNamespacePrefix(model.getDefinitions().getTargetNamespace(), 149 adapter.getExtensibilityElement()); 150 for (ExtensibilityElement ee : ees) { 151 if (propertyQName.equals(ee.getQName())) { 152 propertyList.add(prefix + ":" + ee.getAttribute("name")); 153 } 154 } 155 } 156 157 @Override 158 public boolean canWrite() { 159 return XAMUtils.isWritable(adapter.getExtensibilityElement().getModel()); 160 } 161 162 } 163 164 165 @Override 166 public String getAttributeUniqueValuePrefix(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 167 return null; 169 } 170 171 @Override 172 public String getDefaultValue(ExtensibilityElement extensibilityElement, QName qname, String attributeName) { 173 return null; 175 } 176 177 @Override 178 public String getTypeDisplayName(ExtensibilityElement extensibilityElement, QName qname) { 179 if (qname.equals(myQName)) 180 return NbBundle.getMessage(PropertyAliasConfigurator.class, "LBL_PropertyAlias_TypeDisplayName"); 181 else if (qname.equals(queryQName)) 182 return NbBundle.getMessage(PropertyAliasConfigurator.class, "LBL_PropertyAliasQuery_TypeDisplayName"); 183 return null; 184 } 185 186 } 187 | Popular Tags |