KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Created on May 24, 2005
22  *
23  * To change the template for this generated file go to
24  * Window - Preferences - Java - Code Generation - Code and Comments
25  */

26 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor;
27
28 import java.awt.Image JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Arrays JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.logging.Level JavaDoc;
33
34 import javax.xml.namespace.QName JavaDoc;
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 /**
53  * @author radval
54  *
55  * To change the template for this generated type comment go to
56  * Window - Preferences - Java - Code Generation - Code and Comments
57  */

58 public class BindingOperationOutputNode extends WSDLExtensibilityElementNode {
59     
60     private BindingOutput mWSDLConstruct;
61     
62     private BindingOperationOutputPropertyAdapter mPropertyAdapter = null;
63     
64     private static Image JavaDoc 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 JavaDoc
76     public String JavaDoc getNameInLayer() {
77         return WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_OUTPUT;
78     }
79     
80     @Override JavaDoc
81     public Image JavaDoc getIcon(int type) {
82         return ICON;
83     }
84     
85     @Override JavaDoc
86     public Image JavaDoc getOpenedIcon(int type) {
87         return ICON;
88     }
89     
90     @Override JavaDoc
91     protected Node.Property createAttributeProperty(QName JavaDoc attrQName) {
92         Node.Property attrValueProperty = null;
93         try {
94             String JavaDoc attrName = attrQName.getLocalPart();
95             //name
96
if(attrName.equals(NAME_PROP)) {
97                 //name
98
attrValueProperty = createNameProperty();
99             } else {
100                 attrValueProperty = super.createAttributeProperty(attrQName);
101             }
102             
103         } catch(Exception JavaDoc 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 JavaDoc
112     protected List JavaDoc<Node.Property> createAlwaysPresentAttributeProperty() throws Exception JavaDoc {
113         ArrayList JavaDoc<Node.Property> alwaysPresentAttrProperties = new ArrayList JavaDoc<Node.Property>();
114         alwaysPresentAttrProperties.add(createNameProperty());
115         
116         return alwaysPresentAttrProperties;
117     }
118     
119     
120     private Node.Property createNameProperty() throws NoSuchMethodException JavaDoc {
121         Node.Property attrValueProperty;
122         attrValueProperty = new BaseAttributeProperty(mPropertyAdapter,
123                 String JavaDoc.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 JavaDoc name) {
140             getWSDLComponent().getModel().startTransaction();
141             ((BindingOutput) getWSDLComponent()).setName(name);
142                 getWSDLComponent().getModel().endTransaction();
143         }
144         
145         public String JavaDoc 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 JavaDoc<NewType> list = new ArrayList JavaDoc<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 JavaDoc
169     public String JavaDoc getTypeDisplayName() {
170         return NbBundle.getMessage(BindingOperationOutputNode.class, "LBL_BindingOutputNode_TypeDisplayName");
171     }
172 }
173
174
Popular Tags