KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > beanbrowser > Wrapper


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.beanbrowser;
21
22 import org.openide.nodes.AbstractNode;
23 import org.openide.nodes.FilterNode;
24 import org.openide.nodes.FilterNode.Children;
25 import org.openide.nodes.Node;
26 import org.openide.util.HelpCtx;
27
28 /** The basic class--a wrapper for a node. */
29 public class Wrapper extends FilterNode {
30
31     private Wrapper(Node orig) {
32         super(orig, new WrapperKids(orig));
33     }
34
35     /** Create a wrapper node from an original.
36      * Specially prevents recursion (creating a wrapper of a wrapper).
37      */

38     public static Node make(Node orig) {
39         if (orig instanceof Wrapper) {
40             // FQN to avoid interpretation as FilterNode.Children:
41
org.openide.nodes.Children kids = new Children.Array();
42             kids.add(new Node[] { orig.cloneNode() });
43             AbstractNode toret = new AbstractNode(kids) {
44                 public HelpCtx getHelpCtx() {
45                     return new HelpCtx("org.netbeans.modules.apisupport.beanbrowser");
46                 }
47             };
48             toret.setName("Already a wrapper node...");
49             toret.setIconBaseWithExtension("org/netbeans/modules/apisupport/beanbrowser/BeanBrowserIcon.gif");
50             return toret;
51         } else {
52             return new Wrapper(orig);
53         }
54     }
55     
56     public Node cloneNode() {
57         return new Wrapper(getOriginal());
58     }
59     
60     /*
61     // Override to include special node-exploration action.
62     public SystemAction[] getActions () {
63         SystemAction[] orig = super.getActions ();
64         if (orig == null) orig = new SystemAction[0];
65         boolean includeSep = orig.length > 0 && orig[0] != null;
66         SystemAction[] nue = new SystemAction[orig.length + (includeSep ? 2 : 1)];
67         nue[0] = SystemAction.get (NodeExploreAction.class);
68         if (includeSep) nue[1] = null;
69         for (int i = 0; i < orig.length; i++)
70             nue[i + (includeSep ? 2 : 1)] = orig[i];
71         return nue;
72     }
73      
74     // For access by NodeExploreAction:
75     public Node getOriginal () {
76         return super.getOriginal ();
77     }
78      */

79     
80 }
81
Popular Tags