1 19 20 21 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor; 22 23 import java.awt.Image ; 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import java.util.logging.Level ; 27 28 import javax.swing.Action ; 29 import javax.xml.namespace.QName ; 30 import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory; 31 32 import org.netbeans.modules.xml.wsdl.model.Message; 35 import org.netbeans.modules.xml.wsdl.model.OperationParameter; 36 import org.netbeans.modules.xml.wsdl.ui.actions.CommonAddExtensibilityAttributeAction; 37 import org.netbeans.modules.xml.wsdl.ui.actions.RemoveAttributesAction; 38 import org.netbeans.modules.xml.wsdl.ui.api.property.MessageAttributeProperty; 39 import org.netbeans.modules.xml.wsdl.ui.netbeans.module.Utility; 40 import org.netbeans.modules.xml.wsdl.ui.view.property.BaseAttributeProperty; 41 import org.netbeans.modules.xml.wsdl.ui.view.property.OperationInputOutputFaultPropertyAdapter; 42 import org.netbeans.modules.xml.xam.ComponentListener; 43 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 44 import org.netbeans.modules.xml.xam.ui.actions.GoToAction; 45 import org.openide.ErrorManager; 46 import org.openide.actions.CopyAction; 47 import org.openide.actions.CutAction; 48 import org.openide.actions.DeleteAction; 49 import org.openide.actions.NewAction; 50 import org.openide.actions.PasteAction; 51 import org.openide.actions.PropertiesAction; 52 import org.openide.nodes.Node; 53 import org.openide.util.NbBundle; 54 import org.openide.util.actions.SystemAction; 55 56 57 58 63 public abstract class OperationParameterNode extends WSDLNamedElementNode implements ComponentListener { 64 65 protected OperationParameter mWSDLConstruct; 66 67 protected Image ICON; 68 69 private OperationInputOutputFaultPropertyAdapter mPropertyAdapter; 70 71 private static final SystemAction[] ACTIONS = new SystemAction[]{ 72 SystemAction.get(CutAction.class), 73 SystemAction.get(CopyAction.class), 74 SystemAction.get(PasteAction.class), 75 null, 76 SystemAction.get(NewAction.class), 77 SystemAction.get(DeleteAction.class), 78 null, 79 SystemAction.get(CommonAddExtensibilityAttributeAction.class), 80 SystemAction.get(RemoveAttributesAction.class), 81 null, 82 SystemAction.get(GoToAction.class), 83 (SystemAction)RefactoringActionsFactory.whereUsedAction(), 85 null, 86 (SystemAction)RefactoringActionsFactory.editorSubmenuAction(), 87 null, 88 SystemAction.get(PropertiesAction.class) 89 }; 90 91 public OperationParameterNode(OperationParameter wsdlConstruct) { 92 super(new GenericWSDLComponentChildren(wsdlConstruct), wsdlConstruct); 93 mWSDLConstruct = wsdlConstruct; 94 this.mPropertyAdapter = new OperationInputOutputFaultPropertyAdapter(wsdlConstruct); 95 super.setNamedPropertyAdapter(this.mPropertyAdapter); 96 } 97 98 99 @Override  100 public Image getIcon(int type) { 101 return ICON; 102 } 103 104 @Override  105 public Image getOpenedIcon(int type) { 106 return ICON; 107 } 108 109 @Override  110 public Action [] getActions(boolean context) { 111 return ACTIONS; 112 } 113 114 115 public Object getWSDLConstruct() { 116 return mWSDLConstruct; 117 } 118 119 @Override  120 protected Node.Property createAttributeProperty(QName attrQName) { 121 Node.Property attrValueProperty = null; 122 try { 123 String attrName = attrQName.getLocalPart(); 124 if(attrName.equals(NAME_PROP)) { attrValueProperty = createNameProperty(); 128 129 } else if(attrName.equals(MESSAGE_PROP)) { 130 attrValueProperty = createMessageProperty(); 131 } else { 132 attrValueProperty = super.createAttributeProperty(attrQName); 133 } 134 135 } catch(Exception ex) { 136 mLogger.log(Level.SEVERE, "failed to create property sheet for "+ getWSDLComponent(), ex); 137 ErrorManager.getDefault().notify(ex); 138 } 139 return attrValueProperty; 140 } 141 142 143 @Override  144 protected List <Node.Property> createAlwaysPresentAttributeProperty() throws Exception { 145 ArrayList <Node.Property> alwaysPresentAttrProperties = new ArrayList <Node.Property>(); 146 alwaysPresentAttrProperties.add(createNameProperty()); 147 alwaysPresentAttrProperties.add(createMessageProperty()); 148 return alwaysPresentAttrProperties; 149 } 150 151 152 private Node.Property createNameProperty() throws NoSuchMethodException { 153 Node.Property attrValueProperty; 154 attrValueProperty = new BaseAttributeProperty(mPropertyAdapter, String .class, NAME_PROP); 155 156 157 attrValueProperty.setName(NbBundle.getMessage(OperationParameterNode.class, "PROP_NAME_DISPLAYNAME")); 158 attrValueProperty.setShortDescription(NbBundle.getMessage(OperationParameterNode.class, "OPERATION_PARAMETER_NAME_DESC")); 159 160 return attrValueProperty; 161 } 162 163 private Node.Property createMessageProperty() throws NoSuchMethodException { 164 Node.Property attrValueProperty; 165 attrValueProperty = new MessageAttributeProperty(mPropertyAdapter, mWSDLConstruct, String .class, "getMessage", "setMessage"); 166 167 attrValueProperty.setName(NbBundle.getMessage(OperationParameterNode.class, "PROP_MESSAGE_DISPLAYNAME")); 168 attrValueProperty.setShortDescription(NbBundle.getMessage(OperationParameterNode.class, "OPERATIONPARAMETER_MESSAGE_DESC")); 169 170 return attrValueProperty; 171 } 172 173 174 private static final String MESSAGE_PROP = "message"; 176 @Override  177 public String getHtmlDisplayName() { 178 String htmlDisplayName = super.getHtmlDisplayName(); 179 NamedComponentReference<Message> message = mWSDLConstruct.getMessage(); 180 181 String decoration = null; 182 if (message != null && message.get() != null) { 183 String tns = message.get().getModel().getDefinitions().getTargetNamespace(); 184 decoration = NbBundle.getMessage(OperationParameterNode.class, "LBL_Message", 185 Utility.getNameAndDropPrefixIfInCurrentModel(tns, message.get().getName(), mWSDLConstruct.getModel())); 186 } 187 188 if (decoration == null) { 189 return htmlDisplayName; 191 } 192 return htmlDisplayName + " <font color='#999999'>"+decoration+"</font>"; 193 } 194 } 195 | Popular Tags |