1 19 20 package org.openide.explorer; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Component ; 24 import java.awt.DefaultKeyboardFocusManager ; 25 import java.awt.KeyboardFocusManager ; 26 import java.awt.event.ActionEvent ; 27 import java.beans.FeatureDescriptor ; 28 import java.util.*; 29 import javax.swing.AbstractAction ; 30 import javax.swing.ActionMap ; 31 import javax.swing.JTextField ; 32 33 import junit.framework.*; 34 35 import org.netbeans.junit.*; 36 import org.openide.cookies.*; 37 import org.openide.nodes.*; 38 import org.openide.util.*; 39 import org.openide.util.lookup.AbstractLookup; 40 import org.openide.util.lookup.InstanceContent; 41 42 49 public class ExplorerUtilCreateLookupTest extends org.openide.windows.TopComponentGetLookupTest { 50 public ExplorerUtilCreateLookupTest(String testName) { 51 super(testName); 52 } 53 54 public static void main(String [] args) { 55 junit.textui.TestRunner.run(suite()); 56 } 57 58 public static Test suite() { 59 return new NbTestSuite(ExplorerUtilCreateLookupTest.class); 60 } 61 62 63 protected boolean runInEQ () { 64 return true; 65 } 66 67 69 protected void setUp () { 70 class ExTC extends org.openide.windows.TopComponent 71 implements java.beans.PropertyChangeListener { 72 ExplorerManager em = new ExplorerManager (); 73 { 74 addPropertyChangeListener (this); 75 em.setRootContext (new AbstractNode (new Children.Array ())); 76 } 77 78 public void propertyChange (java.beans.PropertyChangeEvent ev) { 79 if ("activatedNodes".equals (ev.getPropertyName())) { 80 try { 81 Node[] arr = getActivatedNodes (); 82 Children.Array ch = (Children.Array)em.getRootContext ().getChildren (); 83 for (int i = 0; i < arr.length; i++) { 84 if (arr[i].getParentNode() != em.getRootContext()) { 85 assertTrue ("If this fails we are in troubles", ch.add (new Node[] { arr[i] })); 86 } 87 } 88 em.setSelectedNodes (getActivatedNodes ()); 89 } catch (java.beans.PropertyVetoException ex) { 90 ex.printStackTrace(); 91 fail (ex.getMessage()); 92 } 93 } 94 } 95 } 96 ExTC e = new ExTC (); 97 98 top = e; 99 lookup = ExplorerUtils.createLookup (e.em, e.getActionMap ()); 100 } 101 102 } 103 | Popular Tags |