1 19 20 package org.netbeans.modules.apisupport.project; 21 22 import java.io.File ; 23 import org.apache.tools.ant.module.spi.AntEvent; 24 import org.apache.tools.ant.module.spi.AntLogger; 25 import org.apache.tools.ant.module.spi.AntSession; 26 import org.openide.util.Lookup; 27 28 33 public class TestAntLogger extends AntLogger { 34 boolean bEnabled; 35 36 37 public void setEnabled(boolean bEnabled) { 38 this.bEnabled = true; 39 } 40 public void messageLogged(AntEvent event) { 41 if (bEnabled) { 42 System.out.println(event.getMessage()); 43 } 44 } 45 46 public boolean interestedInSession(AntSession session) { 47 return bEnabled; 48 } 49 50 public boolean interestedInScript(File script, AntSession session) { 51 return bEnabled; 52 } 53 54 public boolean interestedInAllScripts(AntSession session) { 55 return bEnabled; 56 } 57 58 public void targetStarted(AntEvent event) { 59 System.out.println("target started:" + event.getTargetName()); 60 } 61 62 public String [] interestedInTasks(AntSession session) { 63 return (bEnabled) ? ALL_TASKS : new String [0]; 64 } 65 66 public String [] interestedInTargets(AntSession session) { 67 return (bEnabled) ? ALL_TARGETS : new String [0]; 68 } 69 70 public int[] interestedInLogLevels(AntSession session) { 71 return (bEnabled) ? 72 new int[]{AntEvent.LOG_INFO,AntEvent.LOG_WARN,AntEvent.LOG_ERR}: 73 new int[0]; 74 } 75 76 static TestAntLogger getDefault() { 77 return (TestAntLogger) Lookup.getDefault().lookupItem( 78 new Lookup.Template(AntLogger.class, 79 "org.netbeans.modules.apisupport.project.TestAntLogger", 80 null)).getInstance(); 81 } 82 83 } 84 | Popular Tags |