1 19 20 package org.netbeans.modules.tasklist.suggestions; 21 22 import org.netbeans.modules.tasklist.providers.SuggestionProvider; 23 import org.openide.util.Lookup; 24 import org.openide.util.lookup.AbstractLookup; 25 import org.openide.util.lookup.InstanceContent; 26 import junit.framework.Assert; 27 28 34 public final class TrackingProvider extends SuggestionProvider { 35 36 public static void installSuggestionProviders() { 37 InstanceContent content = new InstanceContent(); 38 content.add(new TrackingProvider()); 39 content.add(new Lookup.Provider() { 40 public Lookup getLookup() { 41 return Lookup.getDefault(); 42 } 43 }); 44 AbstractLookup testLookup = new AbstractLookup(content); 45 SuggestionProviders.lookup = testLookup; 46 } 47 48 public String getType() { 49 return "test"; 50 } 51 52 static final int PREPARED = 1; 53 static final int RUN = 10; 54 static final int STOPPED = 30; 55 static final int FINISHED = 50; 56 57 private int state = FINISHED; 58 59 public void notifyFinish() { 60 if (state != STOPPED && state != PREPARED) Assert.fail("Unexpected state: " + state); 61 state = FINISHED; 62 } 63 64 public void notifyPrepare() { 65 if (state != FINISHED) Assert.fail("Unexpected state: " + state); 66 state = PREPARED; 67 } 68 69 public void notifyRun() { 70 if (state != PREPARED && state != STOPPED) Assert.fail("Unexpected state: " + state); 71 state = RUN; 72 } 73 74 public void notifyStop() { 75 if (state != RUN) Assert.fail("Unexpected state: " + state); 76 state = STOPPED; 77 } 78 } 79 | Popular Tags |