1 19 20 package org.netbeans.spi.palette; 21 22 import java.awt.Image ; 23 import java.net.MalformedURLException ; 24 import java.net.URL ; 25 import org.openide.nodes.AbstractNode; 26 import org.openide.nodes.Children; 27 import org.openide.nodes.Node; 28 import org.openide.util.Utilities; 29 30 31 35 class DummyPalette { 36 37 private static final int CATEGORY_COUNT = 9; 38 private static final int ITEM_COUNT = 9; 39 40 41 private DummyPalette() { 42 } 43 44 public static Node createPaletteRoot() { 45 Children categories = new Children.Array(); 46 categories.add( createCategories() ); 47 return new RootNode( categories ); 48 } 49 50 private static Node[] createCategories() { 51 Node[] categories = new Node[ CATEGORY_COUNT ]; 52 53 for( int i=0; i<categories.length; i++ ) { 54 Children items = new Children.Array(); 55 items.add( createItems() ); 56 categories[i] = new CategoryNode( items, i ); 57 } 58 return categories; 59 } 60 61 private static Node[] createItems() { 62 Node[] items = new Node[ ITEM_COUNT ]; 63 64 for( int i=0; i<items.length; i++ ) { 65 items[i] = new ItemNode( i ); 66 } 67 return items; 68 } 69 70 private static class RootNode extends AbstractNode { 71 public RootNode( Children children ) { 72 super( children ); 73 setName( "DummyPalette" ); 74 } 75 } 76 77 private static class CategoryNode extends AbstractNode { 78 public CategoryNode( Children children, int index ) { 79 super( children ); 80 setName( "Category_" + index ); 81 setDisplayName( "CategoryName_" + index ); 82 setShortDescription( "Short category description " + index ); 83 } 84 85 public Image getIcon(int type) { 86 87 Image icon = null; 88 try { 89 URL url = new URL ("nbres:/javax/swing/beaninfo/images/JTabbedPaneColor16.gif"); 90 icon = java.awt.Toolkit.getDefaultToolkit().getImage(url); 91 } catch( MalformedURLException murlE ) { 92 } 93 return icon; 94 } 95 } 96 97 private static class ItemNode extends AbstractNode { 98 99 public ItemNode( int index ) { 100 super( Children.LEAF ); 101 setName( "Item_" + index ); 102 setDisplayName( "ItemName_" + index ); 103 setShortDescription( "Short item description " + index ); 104 } 105 106 public Image getIcon(int type) { 107 108 Image icon = null; 109 try { 110 URL url = new URL ("nbres:/javax/swing/beaninfo/images/JTabbedPaneColor16.gif"); 111 icon = java.awt.Toolkit.getDefaultToolkit().getImage(url); 112 } catch( MalformedURLException murlE ) { 113 } 114 return icon; 115 } 116 } 117 } 118 | Popular Tags |