KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > jsf > navigation > vwmodel > LinkNode


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 package org.netbeans.modules.web.jsf.navigation.vwmodel;
20
21 import org.netbeans.modules.web.jsf.navigation.vwmodel.PageSelector;
22 import org.netbeans.modules.web.jsf.navigation.vwmodel.Link;
23 import org.netbeans.modules.web.jsf.navigation.*;
24 import java.awt.datatransfer.Transferable JavaDoc;
25 import java.util.List JavaDoc;
26 import org.openide.ErrorManager;
27 import org.openide.nodes.Children;
28 import org.openide.loaders.DataObject;
29 import org.openide.nodes.AbstractNode;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.PropertySupport;
32 import org.openide.nodes.Sheet;
33 import org.openide.nodes.PropertySupport.Reflection;
34 import org.openide.nodes.Sheet.Set;
35 import org.openide.util.NbBundle;
36
37 /**
38  * A node which represents the navigation case
39  *
40  * @author Tor Norbye
41  */

42 public class LinkNode extends AbstractNode {
43     private Link link;
44     private DataObject dobj;
45     private NavigationModel document;
46
47     public LinkNode(DataObject dobj, NavigationModel document, Link link) {
48         super(Children.LEAF);
49         this.document = document;
50         this.link = link;
51         this.dobj = dobj;
52     }
53
54     /*
55     protected SystemAction[] createActions() {
56         return new SystemAction[] {
57             SystemAction.get(PropertiesAction.class)
58         };
59     }
60     */

61
62     protected Sheet createSheet() {
63         Sheet s = Sheet.createDefault();
64         Set ss = s.get("general"); // NOI18N
65
if (ss == null) {
66             ss = new Sheet.Set();
67             ss.setName("general"); // NOI18N
68
ss.setDisplayName(NbBundle.getMessage(LinkNode.class, "General")); // NOI18N
69
ss.setShortDescription(NbBundle.getMessage(LinkNode.class, "GeneralHint")); // NOI18N
70
s.put(ss);
71         }
72         Set gs = ss;
73
74         try {
75             PropertySupport.Reflection p;
76
77             p = new Reflection(link, String JavaDoc.class, "getFromOutcome", "setFromOutcome"); // NOI18N
78
p.setName("fromOutcome"); // NOI18N
79
p.setDisplayName(NbBundle.getMessage(LinkNode.class, "Outcome")); // NOI18N
80
p.setShortDescription(NbBundle.getMessage(LinkNode.class, "OutcomeHint")); // NOI18N
81
ss.put(p);
82
83             p = new Reflection(link, String JavaDoc.class, "getFromView", "setFromView"); // NOI18N
84
p.setName("fromView"); // NOI18N
85
p.setDisplayName(NbBundle.getMessage(LinkNode.class, "FromView")); // NOI18N
86
p.setShortDescription(NbBundle.getMessage(LinkNode.class, "FromViewHint")); // NOI18N
87
p.setValue(PageSelector.PROPERTY_NAVDOC, document);
88             p.setPropertyEditorClass(PageSelector.class);
89             ss.put(p);
90
91             p = new Reflection(link, String JavaDoc.class, "getToView", "setToView"); // NOI18N
92
p.setName("toView"); // NOI18N
93
p.setDisplayName(NbBundle.getMessage(LinkNode.class, "ToView")); // NOI18N
94
p.setShortDescription(NbBundle.getMessage(LinkNode.class, "ToViewHint")); // NOI18N
95
p.setValue(PageSelector.PROPERTY_NAVDOC, document);
96             p.setPropertyEditorClass(PageSelector.class);
97             ss.put(p);
98
99         } catch (NoSuchMethodException JavaDoc nsme) {
100             ErrorManager.getDefault().notify(nsme);
101         }
102
103         return s;
104     }
105
106 // /**
107
// * Set the data object this component is associated with (if any). When set, this node will
108
// * return the cookies of the data object as well. Therefore, as an example, if you select an
109
// * image component in a web form, the
110
// */
111
// public void setDataObject(DataObject dobj) {
112
// this.dobj = dobj;
113
// }
114

115     /**
116      * Get a cookie. Call super first, but if null, also check the associated data object.
117      */

118     public Node.Cookie getCookie(Class JavaDoc cl) {
119         Node.Cookie c = super.getCookie(cl);
120         if (c != null) {
121             return c;
122         }
123         if (dobj != null) {
124             return dobj.getCookie(cl);
125         }
126         return null;
127     }
128
129     public boolean canRename() {
130         return false;
131     }
132
133     public boolean canDestroy() {
134         // No point since it gets recreated after every edit
135
return false;
136     }
137
138     /**
139      * Can this node be copied?
140      *
141      * @return <code>true</code>
142      */

143     public boolean canCopy() {
144         return false;
145     }
146
147     /**
148      * Can this node be cut?
149      *
150      * @return <code>false</code>
151      */

152     public boolean canCut() {
153         // No point since it gets recreated after every edit
154
return false;
155     }
156
157     /** Don't allow pastes */
158     protected void createPasteTypes(Transferable JavaDoc t, List JavaDoc s) {
159     }
160
161     /*
162     public Image getIcon(int type) {
163         // set icon base lazily. The icon should only be needed by nodes
164         // displayed in for example the nonvisual gutter
165         if (iconbase != null) {
166             setIconBase(iconbase);
167             iconbase = null;
168         }
169         return super.getIcon(type);
170     }
171     */

172
173     public final String JavaDoc getDisplayName() {
174         return link.getNavcase().getFromOutcome();
175     }
176     
177 }
178
Popular Tags