1 19 20 package org.netbeans.modules.refactoring.api; 21 22 import org.openide.util.Lookup; 23 import org.openide.util.Lookup.Result; 24 import org.openide.util.Lookup.Template; 25 import org.openide.util.lookup.AbstractLookup; 26 import org.openide.util.lookup.InstanceContent; 27 28 34 public final class Context extends Lookup { 35 36 private InstanceContent instanceContent; 37 private AbstractLookup delegate; 38 39 Context(InstanceContent instanceContent) { 40 super(); 41 delegate = new AbstractLookup(instanceContent); 42 this.instanceContent = instanceContent; 43 } 44 45 51 public void add(Object value) { 52 Object old = lookup(value.getClass()); 53 if (old!=null) { 54 instanceContent.remove(old); 55 } 56 instanceContent.add(value); 57 } 58 59 public <T> T lookup(Class <T> clazz) { 60 return delegate.lookup(clazz); 61 } 62 63 public <T> Result<T> lookup(Template<T> template) { 64 return delegate.lookup(template); 65 } 66 } 67 | Popular Tags |