alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans, Community Edition. The Initial
 * Developer of the Original Code is Sun Microsystems, Inc. Portions
 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
 */


package org.netbeans.api.nodes2looks;

import org.netbeans.spi.looks.Look;
import org.netbeans.spi.looks.LookSelector;
import org.openide.nodes.Node;

/**
 * Interoperability of nodes and looks.
 */
public final class Nodes {
    private static final Look NODE_LOOK = new NodeProxyLook( "NodeProxyLook" );

    private Nodes() {}

    /** Creates a new node representing an object using a look.
     * @see org.netbeans.spi.looks.Selectors#defaultTypes
     * @param representedObject the object which the node will represent
     */
    public static Node node( Object representedObject ) {
        return node (representedObject, null, null );
    }

    /** Creates new LookNode.
     * @see Look#attachTo(Object)
     * @param representedObject The object which the node will represent.
     * @param look Explicit look which will be set on the node.
     */
    public static Node node (Object representedObject, Look look ) {
        return node ( representedObject, look, null );
    }

    /** Creates new LookNode.
     * @see Look#attachTo(Object)
     * @param representedObject The object which the node will represent.
     * @param look Explicit look which will be set on the node. If null
     *        first look from the lookSelector which accepts the represented
     *        object will be used for this node. 
     * @param lookSelector LookSelector for this node.
     */
    public static Node node (Object representedObject, Look look, LookSelector lookSelector ) {
        return node ( representedObject, look, lookSelector, null );
    }

    /** Creates new LookNode.
     * @see Look#attachTo(Object)
     * @param representedObject The object which the node will represent.
     * @param look Explicit look which will be set on the node. If null
     *        first look from the lookSelector which accepts the represented
     *        object will be used for this node. 
     * @param lookSelector LookSelector for this node.
     * @param handle Node.Handle which will take care of the persistence.
     */
    public static Node node(Object representedObject, Look look, LookSelector lookSelector, Node.Handle handle ) {
        return new LookNode(
            representedObject,
            look,
            lookSelector,
            handle
        );
    }

    /** Look that works with {@link Node}. If the represented object
     * is Node the look takes its name, actions, properties, etc.
     * Very useful for bridging to already written nodes.
     * 

* To create this look from an XML layer type: *

     * <file name="NameOfYourLook.instance" >
     *   <attr name="instanceClass" stringvalue="org.netbeans.spi.looks.Look" />
     *   <attr name="instanceCreate" methodvalue="org.netbeans.api.nodes2looks.Nodes.nodeLook" />
     * </file>
     * 
* @return Look for bridging functionality of existing nodes */ public static final Look nodeLook() { return NODE_LOOK; } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.