KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 /**
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 BindingOperationInputNode extends WSDLExtensibilityElementNode {
59     
60     private BindingInput mWSDLConstruct;
61     
62     private BindingOperationPropertyAdapter mPropertyAdapter = null;
63     
64     private static Image JavaDoc 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 JavaDoc
77     public String JavaDoc getNameInLayer() {
78         return WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_INPUT;
79     }
80     
81     @Override JavaDoc
82     public Image JavaDoc getIcon(int type) {
83         return ICON;
84     }
85     
86     @Override JavaDoc
87     public Image JavaDoc getOpenedIcon(int type) {
88         return ICON;
89     }
90     
91     @Override JavaDoc
92     protected Node.Property createAttributeProperty(QName JavaDoc attrQName) {
93         Node.Property attrValueProperty = null;
94         try {
95             String JavaDoc attrName = attrQName.getLocalPart();
96             //name
97
if(attrName.equals(NAME_PROP)) {
98                 //name
99
attrValueProperty = createNameProperty();
100                 
101                 
102             } else {
103                 attrValueProperty = super.createAttributeProperty(attrQName);
104             }
105             
106         } catch(Exception JavaDoc 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 JavaDoc
115     protected List JavaDoc<Node.Property> createAlwaysPresentAttributeProperty() throws Exception JavaDoc {
116         ArrayList JavaDoc<Node.Property> alwaysPresentAttrProperties = new ArrayList JavaDoc<Node.Property>();
117         alwaysPresentAttrProperties.add(createNameProperty());
118         
119         return alwaysPresentAttrProperties;
120     }
121     
122     
123     private Node.Property createNameProperty() throws NoSuchMethodException JavaDoc {
124         Node.Property attrValueProperty;
125         attrValueProperty = new BaseAttributeProperty(mPropertyAdapter,
126                 String JavaDoc.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 JavaDoc name) {
143             getWSDLComponent().getModel().startTransaction();
144             ((BindingInput) getWSDLComponent()).setName(name);
145                 getWSDLComponent().getModel().endTransaction();
146         }
147         
148         public String JavaDoc 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 JavaDoc<NewType> list = new ArrayList JavaDoc<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 JavaDoc
172     public String JavaDoc getTypeDisplayName() {
173         return NbBundle.getMessage(BindingOperationInputNode.class, "LBL_BindingInputNode_TypeDisplayName");
174     }
175 }
176
Popular Tags