KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > nodes2looks > Nodes


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.api.nodes2looks;
21
22 import org.netbeans.spi.looks.Look;
23 import org.netbeans.spi.looks.LookSelector;
24 import org.openide.nodes.Node;
25
26 /**
27  * Interoperability of nodes and looks.
28  */

29 public final class Nodes {
30     private static final Look NODE_LOOK = new NodeProxyLook( "NodeProxyLook" );
31
32     private Nodes() {}
33
34     /** Creates a new node representing an object using a look.
35      * @see org.netbeans.spi.looks.Selectors#defaultTypes
36      * @param representedObject the object which the node will represent
37      */

38     public static Node node( Object JavaDoc representedObject ) {
39         return node (representedObject, null, null );
40     }
41
42     /** Creates new LookNode.
43      * @see Look#attachTo(Object)
44      * @param representedObject The object which the node will represent.
45      * @param look Explicit look which will be set on the node.
46      */

47     public static Node node (Object JavaDoc representedObject, Look look ) {
48         return node ( representedObject, look, null );
49     }
50
51     /** Creates new LookNode.
52      * @see Look#attachTo(Object)
53      * @param representedObject The object which the node will represent.
54      * @param look Explicit look which will be set on the node. If null
55      * first look from the lookSelector which accepts the represented
56      * object will be used for this node.
57      * @param lookSelector LookSelector for this node.
58      */

59     public static Node node (Object JavaDoc representedObject, Look look, LookSelector lookSelector ) {
60         return node ( representedObject, look, lookSelector, null );
61     }
62
63     /** Creates new LookNode.
64      * @see Look#attachTo(Object)
65      * @param representedObject The object which the node will represent.
66      * @param look Explicit look which will be set on the node. If null
67      * first look from the lookSelector which accepts the represented
68      * object will be used for this node.
69      * @param lookSelector LookSelector for this node.
70      * @param handle Node.Handle which will take care of the persistence.
71      */

72     public static Node node(Object JavaDoc representedObject, Look look, LookSelector lookSelector, Node.Handle handle ) {
73         return new LookNode(
74             representedObject,
75             look,
76             lookSelector,
77             handle
78         );
79     }
80
81     /** Look that works with {@link Node}. If the represented object
82      * is <code>Node</code> the look takes its name, actions, properties, etc.
83      * Very useful for bridging to already written nodes.
84      * <P>
85      * To create this look from an XML layer type:
86      * <pre>
87      * &lt;file name="NameOfYourLook.instance" &gt;
88      * &lt;attr name="instanceClass" stringvalue="org.netbeans.spi.looks.Look" /&gt;
89      * &lt;attr name="instanceCreate" methodvalue="org.netbeans.api.nodes2looks.Nodes.nodeLook" /&gt;
90      * &lt;/file&gt;
91      * </pre>
92      * @return Look for bridging functionality of existing nodes
93      */

94     public static final Look nodeLook() {
95         return NODE_LOOK;
96     }
97
98
99 }
100
Popular Tags