1 19 package org.netbeans.mdr.test; 20 21 import org.openide.util.*; 22 import org.netbeans.mdr.NBMDRManagerImpl; 23 import org.netbeans.lib.jmi.xmi.*; 24 import org.netbeans.lib.jmi.mapping.JMIMapperImpl; 25 26 import java.util.*; 27 28 33 public class MDRTestLookup extends Lookup { 34 35 private ArrayList instances = null; 36 37 38 public MDRTestLookup() { 39 } 40 41 public Object lookup(Class cls) { 42 if (instances == null) { 43 instances = new ArrayList(); 44 instances.add(new NBMDRManagerImpl()); 45 instances.add(new XMISaxReaderImpl()); 46 instances.add(new JMIMapperImpl()); 47 instances.add(new XMIWriterImpl()); 48 } 49 for (Iterator it = instances.iterator(); it.hasNext();) { 50 Object instance = it.next(); 51 if (cls.isAssignableFrom(instance.getClass())) { 52 return instance; 53 } 54 } 55 return null; 56 } 57 58 public Lookup.Result lookup(Lookup.Template template) { 59 return new Result(lookup(template.getType())); 60 } 61 62 private static class Result extends Lookup.Result { 63 private final ArrayList result = new ArrayList(); 64 65 public Result(Object o) { 66 if (o != null) result.add(o); 67 } 68 69 74 public void addLookupListener(LookupListener l) { 75 } 77 78 81 public java.util.Collection allInstances() { 82 return result; 83 } 84 85 88 public void removeLookupListener(LookupListener l) { 89 } 91 } 92 } 93 | Popular Tags |