KickJava   Java API By Example, From Geeks To Geeks.

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


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.BindingFault;
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 BindingOperationFaultNode extends WSDLExtensibilityElementNode {
59     
60     private BindingFault mWSDLConstruct;
61     
62     private BindingOperationFaultPropertyAdapter mPropertyAdapter = null;
63     
64     private static Image JavaDoc ICON = Utilities.loadImage
65             ("org/netbeans/modules/xml/wsdl/ui/view/resources/bindingfault.png");
66     
67     public BindingOperationFaultNode(BindingFault wsdlConstruct) {
68         super(new GenericWSDLComponentChildren(wsdlConstruct), wsdlConstruct, new BindingOperationFaultNewTypesFactory());
69         mWSDLConstruct = wsdlConstruct;
70         
71         
72         this.mPropertyAdapter = new BindingOperationFaultPropertyAdapter();
73         super.setNamedPropertyAdapter(this.mPropertyAdapter);
74     }
75     
76     @Override JavaDoc
77     public String JavaDoc getNameInLayer() {
78         return WSDLExtensibilityElements.ELEMENT_BINDING_OPERATION_FAULT;
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)) { //NOT I18N
98
//name
99
attrValueProperty = createNameProperty();
100                 
101             } else {
102                 attrValueProperty = super.createAttributeProperty(attrQName);
103             }
104             
105         } catch(Exception JavaDoc ex) {
106             mLogger.log(Level.SEVERE, "failed to create property sheet for "+ getWSDLComponent(), ex);
107             ErrorManager.getDefault().notify(ex);
108         }
109         return attrValueProperty;
110     }
111     
112     @Override JavaDoc
113     protected List JavaDoc<Node.Property> createAlwaysPresentAttributeProperty() throws Exception JavaDoc {
114         ArrayList JavaDoc<Node.Property> alwaysPresentAttrProperties = new ArrayList JavaDoc<Node.Property>();
115         alwaysPresentAttrProperties.add(createNameProperty());
116         
117         return alwaysPresentAttrProperties;
118     }
119     
120     
121     private Node.Property createNameProperty() throws NoSuchMethodException JavaDoc {
122         Node.Property attrValueProperty;
123         attrValueProperty = new BaseAttributeProperty(mPropertyAdapter,
124                 String JavaDoc.class, NAME_PROP);
125         attrValueProperty.setName(NbBundle.getMessage(BindingOperationFaultNode.class, "PROP_NAME_DISPLAYNAME"));
126         attrValueProperty.setShortDescription(NbBundle.getMessage(BindingOperationFaultNode.class, "BINDINGOPERATIONFAULT_NAME_DESCRIPTION"));
127         
128         return attrValueProperty;
129     }
130     
131     
132     
133     
134     
135     public class BindingOperationFaultPropertyAdapter extends PropertyAdapter implements NamedPropertyAdapter {
136         
137         public BindingOperationFaultPropertyAdapter() {
138             super(getWSDLComponent());
139         }
140         
141         public void setName(String JavaDoc name) {
142             getWSDLComponent().getModel().startTransaction();
143             ((BindingFault) getWSDLComponent()).setName(name);
144                 getWSDLComponent().getModel().endTransaction();
145         }
146         
147         public String JavaDoc getName() {
148             if(mWSDLConstruct.getName() == null) {
149                 return "";
150             }
151             
152             return mWSDLConstruct.getName();
153         }
154         
155         
156     }
157     
158     public static final class BindingOperationFaultNewTypesFactory 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_FAULT).getNewTypes(def)));
167             return list.toArray(new NewType[]{});
168         }
169     }
170
171     @Override JavaDoc
172     public String JavaDoc getTypeDisplayName() {
173         return NbBundle.getMessage(BindingOperationFaultNode.class, "LBL_BindingFaultNode_TypeDisplayName");
174     }
175 }
176
177
178
Popular Tags