1 19 20 package org.netbeans.modules.looks; 21 22 import java.util.Collections ; 23 import org.netbeans.spi.looks.Look; 24 import org.netbeans.spi.looks.LookSelector; 25 import org.netbeans.spi.looks.Selectors; 26 import org.openide.util.Lookup; 27 28 32 public final class ChildrenSelectorProvider extends org.netbeans.spi.looks.ProxyLook { 33 34 private Look look; 35 private LookSelector lookSelector; 36 37 38 public ChildrenSelectorProvider( String name, Look look, LookSelector lookSelector) { 39 super ( name, Selectors.singleton (look)); 40 this.look = look; 41 this.lookSelector = lookSelector; 42 } 43 44 public String getDisplayName() { 45 return look.getDisplayName(); 46 } 47 48 49 51 public java.util.Collection getLookupItems( Object representedObject, Lookup oldEnv ) { 52 java.util.Collection res = super.getLookupItems(representedObject, oldEnv ); 53 if ( res == null ) { 54 return Collections.singleton( new Item() ); 55 } 56 java.util.ArrayList r = new java.util.ArrayList (res.size () + 1); 57 r.add (new Item ()); 58 r.addAll (res); 59 return r; 60 } 61 62 private final class Item extends org.openide.util.Lookup.Item { 63 64 public String getDisplayName() { 65 return getId (); 66 } 67 68 public String getId() { 69 return getType ().getName (); 70 } 71 72 public Object getInstance() { 73 return ChildrenSelectorProvider.this.lookSelector; 74 } 75 76 public Class getType() { 77 return LookSelector.class; 78 } 79 80 public boolean equals (Object o) { 81 if (o instanceof Item) { 82 Item i = (Item)o; 83 return getInstance () == i.getInstance (); 84 } 85 return false; 86 } 87 } 88 } 89 | Popular Tags |