|
What this is
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. 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 java.net.URL; import org.openide.nodes.Node; import org.netbeans.spi.looks.Look; import org.netbeans.spi.looks.LookSelector; import org.openide.filesystems.FileSystem; import org.openide.filesystems.XMLFileSystem; import org.xml.sax.SAXException; /** Usefull utility methods for Tests * * @author phrebejk */ public class TestUtil { /** Creates a new instance of TestUtil */ private TestUtil() { } public static Object getRepresentedObject( Node node ) { if ( node instanceof LookNode ) { return ((LookNode)node).getRepresentedObject(); } else { return null; } /* Lookup lookup = node.getLookup(); if ( lookup == null ) { return null; } Look.NodeSubstitute subst = (Look.NodeSubstitute)lookup.lookup( Look.NodeSubstitute.class ); if ( subst == null ) { return null; } return subst.getRepresentedObject(); */ } /** [PENDING] This should be rewritten to LD, LS switcher later */ public static void setLook( Node node, Look look ) { if ( node instanceof LookNode ) { LookNode lookNode = (LookNode)node; lookNode.setLook( look ); } else { throw new IllegalArgumentException( node + "does not support look switching (is not LookNode)" ); } } /** [PENDING] This should be rewritten to LD, LS switcher later */ public static Look getLook( Node node ) { if ( node instanceof LookNode ) { LookNode lookNode = (LookNode)node; return lookNode.getLook(); } else { throw new IllegalArgumentException( node + "does not support look switching (is not LookNode)" ); } } /** [PENDING] This should be rewritten to LD, LS switcher later */ public static LookSelector getLookSelector( Node node ) { if ( node instanceof LookNode ) { LookNode lookNode = (LookNode)node; return lookNode.getLookSelector(); } else { throw new IllegalArgumentException( node + "does not support look switching (is not LookNode)" ); } } /** Sets up the registry to use the default XML layer of Looks */ public static void setUpRegistryToDefault() { URL url = org.netbeans.modules.looks.Accessor.class.getResource ("mf-layer.xml"); try { FileSystem defaultFs = new XMLFileSystem( url ); org.netbeans.modules.looks.RegistryBridge.setDefault( defaultFs.getRoot() ); } catch ( SAXException e ) { IllegalStateException ex = new IllegalStateException( "Cant initialize defaut filesystem" ); ex.initCause( e ); throw ex; } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.