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.BindingInput; 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 BindingOperationInputNode extends WSDLExtensibilityElementNode { 59 60 private BindingInput mWSDLConstruct; 61 62 private BindingOperationPropertyAdapter mPropertyAdapter = null; 63 64 private static Image ICON = Utilities.loadImage 65 ("org/netbeans/modules/xml/wsdl/ui/view/resources/bindinginput.png"); 66 67 public BindingOperationInputNode(BindingInput wsdlConstruct) { 68 super(new GenericWSDLComponentChildren(wsdlConstruct), wsdlConstruct, new BindingOperationInputNewTypesFactory()); 69 mWSDLConstruct = wsdlConstruct; 70 71 72 this.mPropertyAdapter = new BindingOperationPropertyAdapter(); 73 super.setNamedPropertyAdapter(this.mPropertyAdapter); 74 } 75 76 @Override 77 public String getNameInLayer() { 78 return WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT; 79 } 80 81 @Override 82 public Image getIcon(int type) { 83 return ICON; 84 } 85 86 @Override 87 public Image getOpenedIcon(int type) { 88 return ICON; 89 } 90 91 @Override 92 protected Node.Property createAttributeProperty(QName attrQName) { 93 Node.Property attrValueProperty = null; 94 try { 95 String attrName = attrQName.getLocalPart(); 96 if(attrName.equals(NAME_PROP)) { 98 attrValueProperty = createNameProperty(); 100 101 102 } else { 103 attrValueProperty = super.createAttributeProperty(attrQName); 104 } 105 106 } catch(Exception ex) { 107 mLogger.log(Level.SEVERE, "failed to create property sheet for "+ getWSDLComponent(), ex); 108 ErrorManager.getDefault().notify(ex); 109 } 110 return attrValueProperty; 111 } 112 113 114 @Override 115 protected List <Node.Property> createAlwaysPresentAttributeProperty() throws Exception { 116 ArrayList <Node.Property> alwaysPresentAttrProperties = new ArrayList <Node.Property>(); 117 alwaysPresentAttrProperties.add(createNameProperty()); 118 119 return alwaysPresentAttrProperties; 120 } 121 122 123 private Node.Property createNameProperty() throws NoSuchMethodException { 124 Node.Property attrValueProperty; 125 attrValueProperty = new BaseAttributeProperty(mPropertyAdapter, 126 String .class, NAME_PROP); 127 attrValueProperty.setName(NbBundle.getMessage(BindingOperationInputNode.class, "PROP_NAME_DISPLAYNAME")); 128 attrValueProperty.setShortDescription(NbBundle.getMessage(BindingOperationInputNode.class, "BINDINGOPERATIONINPUT_NAME_DESCRIPTION")); 129 130 131 return attrValueProperty; 132 } 133 134 135 136 public class BindingOperationPropertyAdapter extends PropertyAdapter implements NamedPropertyAdapter { 137 138 public BindingOperationPropertyAdapter() { 139 super(getWSDLComponent()); 140 } 141 142 public void setName(String name) { 143 getWSDLComponent().getModel().startTransaction(); 144 ((BindingInput) getWSDLComponent()).setName(name); 145 getWSDLComponent().getModel().endTransaction(); 146 } 147 148 public String getName() { 149 if(mWSDLConstruct.getName() == null) { 150 return ""; 151 } 152 153 return mWSDLConstruct.getName(); 154 } 155 156 } 157 158 public static final class BindingOperationInputNewTypesFactory implements NewTypesFactory{ 159 160 public NewType[] getNewTypes(WSDLComponent def) { 161 ArrayList <NewType> list = new ArrayList <NewType>(); 162 if (def.getDocumentation() == null) { 163 list.add(new DocumentationNewType(def)); 164 } 165 166 list.addAll(Arrays.asList(new ExtensibilityElementNewTypesFactory(WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT).getNewTypes(def))); 167 return list.toArray(new NewType[]{}); 168 } 169 } 170 171 @Override 172 public String getTypeDisplayName() { 173 return NbBundle.getMessage(BindingOperationInputNode.class, "LBL_BindingInputNode_TypeDisplayName"); 174 } 175 } 176 | Popular Tags |