KickJava   Java API By Example, From Geeks To Geeks.

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


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 Jun 7, 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.beans.PropertyChangeEvent JavaDoc;
30 import java.util.logging.Level JavaDoc;
31
32 import javax.swing.Action JavaDoc;
33 import org.netbeans.modules.refactoring.api.ui.RefactoringActionsFactory;
34
35 //import org.netbeans.modules.xml.refactoring.actions.FindUsagesAction;
36
//import org.netbeans.modules.xml.refactoring.actions.RefactorAction;
37
import org.netbeans.modules.xml.wsdl.model.Documentation;
38 import org.netbeans.modules.xml.wsdl.ui.api.property.PropertyAdapter;
39 import org.netbeans.modules.xml.wsdl.ui.commands.CommonAttributePropertyAdapter;
40 import org.netbeans.modules.xml.wsdl.ui.view.property.BaseAttributeProperty;
41 import org.netbeans.modules.xml.xam.ui.actions.GoToAction;
42 import org.openide.actions.CopyAction;
43 import org.openide.actions.CutAction;
44 import org.openide.actions.DeleteAction;
45 import org.openide.actions.PasteAction;
46 import org.openide.actions.PropertiesAction;
47 import org.openide.nodes.Children;
48 import org.openide.nodes.Node;
49 import org.openide.nodes.Sheet;
50 import org.openide.util.NbBundle;
51 import org.openide.util.Utilities;
52 import org.openide.util.actions.SystemAction;
53
54
55
56 /**
57  * @author radval
58  *
59  * To change the template for this generated type comment go to
60  * Window - Preferences - Java - Code Generation - Code and Comments
61  */

62 public class DocumentationNode extends WSDLElementNode {
63
64     protected Documentation mWSDLConstruct;
65     
66     Image JavaDoc ICON =Utilities.loadImage
67          ("org/netbeans/modules/xml/wsdl/ui/view/resources/documentation.png");
68     
69     private DocumentationPropertyAdapter 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(DeleteAction.class),
77         null,
78         SystemAction.get(GoToAction.class),
79         //SystemAction.get(FindUsagesAction.class),
80
(SystemAction)RefactoringActionsFactory.whereUsedAction(),
81         null,
82         (SystemAction)RefactoringActionsFactory.editorSubmenuAction(),
83         null,
84         SystemAction.get(PropertiesAction.class),
85     };
86
87     public DocumentationNode(Documentation wsdlConstruct) {
88         super(Children.LEAF, wsdlConstruct);
89         mWSDLConstruct = wsdlConstruct;
90         this.setDisplayName(NbBundle.getMessage(TypesNode.class, "DOCUMENTATION_NODE_NAME"));
91         
92         this.mPropertyAdapter = new DocumentationPropertyAdapter();
93     }
94     
95     
96     @Override JavaDoc
97     public Image JavaDoc getIcon(int type) {
98         return ICON;
99     }
100
101     @Override JavaDoc
102     public Image JavaDoc getOpenedIcon(int type) {
103         return ICON;
104     }
105
106     public Object JavaDoc getWSDLConstruct() {
107         return mWSDLConstruct;
108     }
109
110     @Override JavaDoc
111     public Action JavaDoc[] getActions(boolean context) {
112         return ACTIONS;
113     }
114     
115     @Override JavaDoc
116     protected void refreshAttributesSheetSet() {
117         Sheet.Set ss = createPropertiesSheetSet();
118         try {
119             //value
120
Node.Property nameProperty = new BaseAttributeProperty(mPropertyAdapter, String JavaDoc.class, CommonAttributePropertyAdapter.VALUE);
121             
122             
123             nameProperty.setName(NbBundle.getMessage(DocumentationNode.class, "DOC_NODE_Documentation_text"));
124             nameProperty.setShortDescription(NbBundle.getMessage(DocumentationNode.class, "DOC_NODE_Documentation_text"));
125             ss.put(nameProperty);
126             
127             
128         } catch(Exception JavaDoc ex) {
129             mLogger.log(Level.SEVERE, "failed to create property sheet for "+ mWSDLConstruct, ex);
130         }
131     }
132     
133     public void nodeValueChanged(PropertyChangeEvent JavaDoc evt) {
134 // fire a propertysets change so that property sheet
135
//can be refreshed
136
this.firePropertySetsChange(new Node.PropertySet[] {}, this.getPropertySets());
137     }
138     
139     public class DocumentationPropertyAdapter extends PropertyAdapter {
140         
141         public DocumentationPropertyAdapter() {
142             super(mWSDLConstruct);
143         }
144         
145         public void setValue(String JavaDoc value) {
146             mWSDLConstruct.getModel().startTransaction();
147             mWSDLConstruct.setTextContent(value);
148                 mWSDLConstruct.getModel().endTransaction();
149          }
150          
151          public String JavaDoc getValue() {
152              if(mWSDLConstruct.getTextContent() == null) {
153                  return "";
154              }
155              
156              return mWSDLConstruct.getTextContent();
157          }
158          
159     }
160
161     @Override JavaDoc
162     public String JavaDoc getTypeDisplayName() {
163         return NbBundle.getMessage(DocumentationNode.class, "LBL_DocumentationNode_TypeDisplayName");
164     }
165 }
166
167
Popular Tags