1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.property.view; 30 31 import java.util.logging.Level ; 32 import java.util.logging.Logger ; 33 34 import javax.xml.namespace.QName ; 35 36 import org.netbeans.modules.xml.wsdl.model.BindingFault; 37 import org.netbeans.modules.xml.wsdl.model.BindingInput; 38 import org.netbeans.modules.xml.wsdl.model.BindingOutput; 39 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 40 import org.netbeans.modules.xml.wsdl.model.Message; 41 import org.netbeans.modules.xml.wsdl.model.OperationParameter; 42 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 43 import org.netbeans.modules.xml.wsdl.ui.api.property.ExtensibilityElementPropertyAdapter; 44 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageAttributeProperty; 45 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageProvider; 46 import org.netbeans.modules.xml.wsdl.ui.api.property.PartAttributeProperty; 47 import org.netbeans.modules.xml.wsdl.ui.api.property.PortTypeAttributeProperty; 48 import org.openide.nodes.Node; 49 import org.openide.nodes.Node.Property; 50 51 55 public class BuiltInCustomizerFactory { 56 57 public static final String BUILTIN_MESSAGE_CHOOSER = "MessageChooser"; 59 public static final String BUILTIN_PART_CHOOSER = "PartChooser"; public static final String BUILTIN_PARTS_CHOOSER = "PartsChooser"; public static final String BUILTIN_PORTTYPE_CHOOSER = "PortTypeChooser"; 63 64 65 public BuiltInCustomizerFactory() { 66 } 67 68 76 public static Node.Property getProperty(ExtensibilityElement extensibilityElement, 77 QName attributeQName, 78 String chooserType, boolean isOptional) { 79 Node.Property property = null; 80 ExtensibilityElementPropertyAdapter adapter = new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeQName.getLocalPart(), isOptional); 81 try { 82 if(chooserType.equals(BUILTIN_PART_CHOOSER)) { 83 MessageProvider prov = new MessageProviderImpl(extensibilityElement); 84 property = new PartAttributeProperty(prov, extensibilityElement.getModel(), adapter, String .class, "getValue", "setValue", false); 85 property.setName(attributeQName.getLocalPart()); 86 } else if(chooserType.equals(BUILTIN_PARTS_CHOOSER)) { 87 MessageProvider prov = new MessageProviderImpl(extensibilityElement); 88 property = new PartAttributeProperty(prov, extensibilityElement.getModel(), adapter, String .class, "getValue", "setValue", true); 89 property.setName(attributeQName.getLocalPart()); 90 } else if(chooserType.equals(BUILTIN_MESSAGE_CHOOSER)) { 91 property = new MessageAttributeProperty(adapter, extensibilityElement, String .class, "getValue", "setValue"); 92 property.setName(attributeQName.getLocalPart()); 93 } else if(chooserType.equals(BUILTIN_PORTTYPE_CHOOSER)) { 94 property = new PortTypeAttributeProperty(adapter, String .class, "getValue", "setValue"); 95 property.setName(attributeQName.getLocalPart()); 96 } else { 97 Logger.getLogger(BuiltInCustomizerFactory.class.getName()).log(Level.INFO, "Not a recognized builtin in chooser"); 98 } 99 } catch (Exception e) { 100 e.printStackTrace(); 102 } 103 104 return property; 105 } 106 107 108 117 public static Node.Property getProperty(ExtensibilityElement extensibilityElement, 118 QName attributeQName, QName dependsOnAttributeQName, 119 String chooserType, boolean isOptional) { 120 Node.Property property = null; 121 try { 122 if(chooserType.equals(BUILTIN_PART_CHOOSER)) { 123 MessageProvider prov = new DependsOnMessageProviderImpl(extensibilityElement, dependsOnAttributeQName); 124 property = new PartAttributeProperty(prov, extensibilityElement.getModel(), new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeQName.getLocalPart(), isOptional), String .class, "getValue", "setValue", false); 125 property.setName(attributeQName.getLocalPart()); 126 127 } else { 128 Logger.getLogger(BuiltInCustomizerFactory.class.getName()).log(Level.INFO, "Not a recognized builtin in chooser"); 129 } 130 } catch (Exception e) { 131 e.printStackTrace(); 133 } 134 135 return property; 136 } 137 138 139 149 public static Property getProperty(ExtensibilityElement extensibilityElement, QName attributeQName, String nameOfCustomizer, String className, String valueType, boolean isOptional) { 150 Node.Property property = null; 151 try { 152 if(nameOfCustomizer.equals(BUILTIN_PART_CHOOSER)) { 153 MessageProvider prov = null; property = new PartAttributeProperty(prov, extensibilityElement.getModel(), new ExtensibilityElementPropertyAdapter(extensibilityElement, attributeQName.getLocalPart(), isOptional), String .class, "getValue", "setValue", false); 155 property.setName(attributeQName.getLocalPart()); 156 157 } else { 158 Logger.getLogger(BuiltInCustomizerFactory.class.getName()).log(Level.INFO, "Not a recognized builtin in chooser"); 159 } 160 } catch (Exception e) { 161 e.printStackTrace(); 163 } 164 165 return property; 166 } 167 168 171 static class MessageProviderImpl implements MessageProvider { 172 173 private ExtensibilityElement element; 174 175 176 public MessageProviderImpl (ExtensibilityElement elem) { 177 element = elem; 178 } 179 180 public String getMessage() { 181 return null; 182 } 183 184 public Message getWSDLMessage() { 185 Message message = null; 189 WSDLComponent parent = element; 190 while (parent != null) { 191 if (parent instanceof BindingOutput) { 192 BindingOutput output = (BindingOutput) parent; 193 OperationParameter op = output.getOutput() != null ? output.getOutput().get() : null; 194 return op == null ? null : (op.getMessage() == null ? null : op.getMessage().get()); 195 } else if (parent instanceof BindingInput) { 196 BindingInput input = (BindingInput) parent; 197 OperationParameter op = input.getInput() != null ? input.getInput().get() : null; 198 return op == null ? null : (op.getMessage() == null ? null : op.getMessage().get()); 199 } else if (parent instanceof BindingFault) { 200 BindingFault fault = (BindingFault) parent; 201 OperationParameter op = fault.getFault() != null ? fault.getFault().get() : null; 202 return op == null ? null : (op.getMessage() == null ? null : op.getMessage().get()); 203 } 204 parent = parent.getParent(); 205 } 206 207 return message; 208 } 209 210 } 211 212 static class DependsOnMessageProviderImpl implements MessageProvider { 213 214 private ExtensibilityElement element; 215 private QName dependsOnAttributeQName; 216 217 218 public DependsOnMessageProviderImpl (ExtensibilityElement elem, QName dependsOnAttributeQName) { 219 element = elem; 220 this.dependsOnAttributeQName = dependsOnAttributeQName; 221 } 222 223 public String getMessage() { 224 return element.getAttribute(dependsOnAttributeQName.getLocalPart()); 225 } 226 227 public Message getWSDLMessage() { 228 return null; 229 } 230 231 } 232 233 234 } 235 | Popular Tags |