1 19 20 26 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor; 27 28 import java.awt.Image ; 29 import java.util.ArrayList ; 30 import java.util.Arrays ; 31 import java.util.List ; 32 import java.util.logging.Level ; 33 34 import javax.xml.namespace.QName ; 35 36 import org.netbeans.modules.xml.wsdl.model.BindingOutput; 37 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 38 import org.netbeans.modules.xml.wsdl.ui.api.property.PropertyAdapter; 39 import org.netbeans.modules.xml.wsdl.ui.commands.NamedPropertyAdapter; 40 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElements; 41 import org.netbeans.modules.xml.wsdl.ui.view.property.BaseAttributeProperty; 42 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.DocumentationNewType; 43 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.ExtensibilityElementNewTypesFactory; 44 import org.netbeans.modules.xml.wsdl.ui.view.treeeditor.newtype.NewTypesFactory; 45 import org.openide.ErrorManager; 46 import org.openide.nodes.Node; 47 import org.openide.util.NbBundle; 48 import org.openide.util.Utilities; 49 import org.openide.util.datatransfer.NewType; 50 51 52 58 public class BindingOperationOutputNode extends WSDLExtensibilityElementNode { 59 60 private BindingOutput mWSDLConstruct; 61 62 private BindingOperationOutputPropertyAdapter mPropertyAdapter = null; 63 64 private static Image ICON = Utilities.loadImage 65 ("org/netbeans/modules/xml/wsdl/ui/view/resources/bindingoutput.png"); 66 67 public BindingOperationOutputNode(BindingOutput wsdlConstruct) { 68 super(new GenericWSDLComponentChildren(wsdlConstruct), wsdlConstruct, new BindingOperationOutputNewTypesFactory()); 69 mWSDLConstruct = wsdlConstruct; 70 71 this.mPropertyAdapter = new BindingOperationOutputPropertyAdapter(); 72 super.setNamedPropertyAdapter(this.mPropertyAdapter); 73 } 74 75 @Override 76 public String getNameInLayer() { 77 return WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT; 78 } 79 80 @Override 81 public Image getIcon(int type) { 82 return ICON; 83 } 84 85 @Override 86 public Image getOpenedIcon(int type) { 87 return ICON; 88 } 89 90 @Override 91 protected Node.Property createAttributeProperty(QName attrQName) { 92 Node.Property attrValueProperty = null; 93 try { 94 String attrName = attrQName.getLocalPart(); 95 if(attrName.equals(NAME_PROP)) { 97 attrValueProperty = createNameProperty(); 99 } else { 100 attrValueProperty = super.createAttributeProperty(attrQName); 101 } 102 103 } catch(Exception ex) { 104 mLogger.log(Level.SEVERE, "failed to create property sheet for "+ getWSDLComponent(), ex); 105 ErrorManager.getDefault().notify(ex); 106 } 107 return attrValueProperty; 108 } 109 110 111 @Override 112 protected List <Node.Property> createAlwaysPresentAttributeProperty() throws Exception { 113 ArrayList <Node.Property> alwaysPresentAttrProperties = new ArrayList <Node.Property>(); 114 alwaysPresentAttrProperties.add(createNameProperty()); 115 116 return alwaysPresentAttrProperties; 117 } 118 119 120 private Node.Property createNameProperty() throws NoSuchMethodException { 121 Node.Property attrValueProperty; 122 attrValueProperty = new BaseAttributeProperty(mPropertyAdapter, 123 String .class, NAME_PROP); 124 attrValueProperty.setName(NbBundle.getMessage(BindingOperationOutputNode.class, "PROP_NAME_DISPLAYNAME")); 125 attrValueProperty.setShortDescription("Name of the wsdl binding operation output."); 126 127 128 return attrValueProperty; 129 } 130 131 132 133 public class BindingOperationOutputPropertyAdapter extends PropertyAdapter implements NamedPropertyAdapter { 134 135 public BindingOperationOutputPropertyAdapter() { 136 super(getWSDLComponent()); 137 } 138 139 public void setName(String name) { 140 getWSDLComponent().getModel().startTransaction(); 141 ((BindingOutput) getWSDLComponent()).setName(name); 142 getWSDLComponent().getModel().endTransaction(); 143 } 144 145 public String getName() { 146 if(mWSDLConstruct.getName() == null) { 147 return ""; 148 } 149 150 return mWSDLConstruct.getName(); 151 } 152 153 } 154 155 public static final class BindingOperationOutputNewTypesFactory implements NewTypesFactory{ 156 157 public NewType[] getNewTypes(WSDLComponent def) { 158 ArrayList <NewType> list = new ArrayList <NewType>(); 159 if (def.getDocumentation() == null) { 160 list.add(new DocumentationNewType(def)); 161 } 162 163 list.addAll(Arrays.asList(new ExtensibilityElementNewTypesFactory(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT).getNewTypes(def))); 164 return list.toArray(new NewType[]{}); 165 } 166 } 167 168 @Override 169 public String getTypeDisplayName() { 170 return NbBundle.getMessage(BindingOperationOutputNode.class, "LBL_BindingOutputNode_TypeDisplayName"); 171 } 172 } 173 174 | Popular Tags |