KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > treeeditor > OperationParameterNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor;
22
23 import java.awt.Image JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.logging.Level JavaDoc;
27
28 import javax.swing.Action JavaDoc;
29 import javax.xml.namespace.QName JavaDoc;
30 import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory;
31
32 //import org.netbeans.modules.xml.refactoring.actions.FindUsagesAction;
33
//import org.netbeans.modules.xml.refactoring.actions.RefactorAction;
34
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 /**
59  *
60  *@author skini
61  *
62  */

63 public abstract class OperationParameterNode extends WSDLNamedElementNode implements ComponentListener {
64     
65     protected OperationParameter mWSDLConstruct;
66     
67     protected Image JavaDoc 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.get(FindUsagesAction.class),
84
(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 JavaDoc
100     public Image JavaDoc getIcon(int type) {
101         return ICON;
102     }
103     
104     @Override JavaDoc
105     public Image JavaDoc getOpenedIcon(int type) {
106         return ICON;
107     }
108     
109     @Override JavaDoc
110     public Action JavaDoc[] getActions(boolean context) {
111         return ACTIONS;
112     }
113     
114     
115     public Object JavaDoc getWSDLConstruct() {
116         return mWSDLConstruct;
117     }
118     
119     @Override JavaDoc
120     protected Node.Property createAttributeProperty(QName JavaDoc attrQName) {
121         Node.Property attrValueProperty = null;
122         try {
123             String JavaDoc attrName = attrQName.getLocalPart();
124             //name
125
if(attrName.equals(NAME_PROP)) { //NOT I18N
126
//name
127
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 JavaDoc 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 JavaDoc
144     protected List JavaDoc<Node.Property> createAlwaysPresentAttributeProperty() throws Exception JavaDoc {
145         ArrayList JavaDoc<Node.Property> alwaysPresentAttrProperties = new ArrayList JavaDoc<Node.Property>();
146         alwaysPresentAttrProperties.add(createNameProperty());
147         alwaysPresentAttrProperties.add(createMessageProperty());
148         return alwaysPresentAttrProperties;
149     }
150     
151     
152     private Node.Property createNameProperty() throws NoSuchMethodException JavaDoc {
153         Node.Property attrValueProperty;
154         attrValueProperty = new BaseAttributeProperty(mPropertyAdapter, String JavaDoc.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 JavaDoc {
164         Node.Property attrValueProperty;
165         attrValueProperty = new MessageAttributeProperty(mPropertyAdapter, mWSDLConstruct, String JavaDoc.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 JavaDoc MESSAGE_PROP = "message";//NOI18N
175

176     @Override JavaDoc
177     public String JavaDoc getHtmlDisplayName() {
178         String JavaDoc htmlDisplayName = super.getHtmlDisplayName();
179         NamedComponentReference<Message> message = mWSDLConstruct.getMessage();
180         
181         String JavaDoc decoration = null;
182         if (message != null && message.get() != null) {
183             String JavaDoc 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             //decoration = NbBundle.getMessage(OperationParameterNode.class, "LBL_MessageNotSet");
190
return htmlDisplayName;
191         }
192         return htmlDisplayName + " <font color='#999999'>"+decoration+"</font>";
193     }
194 }
195
Popular Tags