1 19 20 package org.netbeans.api.nodes2looks; 21 22 import java.net.URL ; 23 import org.openide.nodes.Node; 24 import org.netbeans.spi.looks.Look; 25 import org.netbeans.spi.looks.LookSelector; 26 import org.openide.filesystems.FileSystem; 27 import org.openide.filesystems.XMLFileSystem; 28 import org.xml.sax.SAXException ; 29 30 31 35 public class TestUtil { 36 37 38 private TestUtil() { 39 } 40 41 public static Object getRepresentedObject( Node node ) { 42 43 if ( node instanceof LookNode ) { 44 return ((LookNode)node).getRepresentedObject(); 45 } 46 else { 47 return null; 48 } 49 50 65 66 } 67 68 70 public static void setLook( Node node, Look look ) { 71 72 if ( node instanceof LookNode ) { 73 LookNode lookNode = (LookNode)node; 74 lookNode.setLook( look ); 75 } 76 else { 77 throw new IllegalArgumentException ( node + "does not support look switching (is not LookNode)" ); 78 } 79 80 } 81 82 84 public static Look getLook( Node node ) { 85 86 if ( node instanceof LookNode ) { 87 LookNode lookNode = (LookNode)node; 88 return lookNode.getLook(); 89 } 90 else { 91 throw new IllegalArgumentException ( node + "does not support look switching (is not LookNode)" ); 92 } 93 94 } 95 96 98 public static LookSelector getLookSelector( Node node ) { 99 100 if ( node instanceof LookNode ) { 101 LookNode lookNode = (LookNode)node; 102 return lookNode.getLookSelector(); 103 } 104 else { 105 throw new IllegalArgumentException ( node + "does not support look switching (is not LookNode)" ); 106 } 107 108 } 109 110 111 113 public static void setUpRegistryToDefault() { 114 115 URL url = org.netbeans.modules.looks.Accessor.class.getResource ("mf-layer.xml"); 116 117 try { 118 FileSystem defaultFs = new XMLFileSystem( url ); 119 org.netbeans.modules.looks.RegistryBridge.setDefault( defaultFs.getRoot() ); 120 } 121 catch ( SAXException e ) { 122 IllegalStateException ex = new IllegalStateException ( "Cant initialize defaut filesystem" ); 123 ex.initCause( e ); 124 throw ex; 125 } 126 } 127 } 128 | Popular Tags |