Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r171 - trunk: . src/ise/antelope/app src/ise/antelope/common src/ise/antelope/launcher src/ise/antelope/plugin src/ise/antelope/tasks src/ise/antelope/tasks/util/math

antelope
Discussion topic

Back to topic list

svn commit: r171 - trunk: . src/ise/antelope/app src/ise/antelope/common src/ise/antelope/launcher src/ise/antelope/plugin src/ise/antelope/tasks src/ise/antelope/tasks/util/math

Author danson
Full name Dale Anson
Date 2010-08-29 18:55:59 PDT
Message Author: danson
Date: 2010-08-29 18:55:58-0700
New Revision: 171

Modified:
   trunk/build-app.xml
   trunk/build-plugin.xml
   trunk/src/ise/antelo​pe/app/Antelope.java​
   trunk/src/ise/antelo​pe/common/AntLogger.​java
   trunk/src/ise/antelo​pe/common/AntProgres​sListener.java
   trunk/src/ise/antelo​pe/common/AntelopePa​nel.java
   trunk/src/ise/antelo​pe/common/CommonHelp​er.java
   trunk/src/ise/antelo​pe/common/CommonHelp​erWrapper.java
   trunk/src/ise/antelo​pe/common/version.tx​t
   trunk/src/ise/antelo​pe/launcher/CommonHe​lper.java
   trunk/src/ise/antelo​pe/plugin/AntelopePl​uginPanel.java
   trunk/src/ise/antelo​pe/plugin/AntelopeSh​ell.java
   trunk/src/ise/antelo​pe/plugin/ConsolePlu​ginHandler.java
   trunk/src/ise/antelo​pe/tasks/Op.java
   trunk/src/ise/antelo​pe/tasks/util/math/O​p.java

Log:
general clean up, etc.

Modified: trunk/build-app.xml
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/buil​d-app.xml?view=diff​&pathrev=171&​r1=170&r2=171
====================​====================​====================​==================
--- trunk/build-app.xml (original)
+++ trunk/build-app.xml 2010-08-29 18:55:58-0700
@@ -88,8 +88,8 @@
                nowarn="${nowarn}"
                destdir="${classes.dir}"
                srcdir="${src.dir}"
- source="1.5"
- target="1.5">
+ source="1.6"
+ target="1.6">
 
             <classpath refid="classpathref" />
             <exclude name="testcases/**/*"/>

Modified: trunk/build-plugin.xml
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/buil​d-plugin.xml?view=di​ff&pathrev=171​&r1=170&r2=171​
====================​====================​====================​==================
--- trunk/build-plugin.xml (original)
+++ trunk/build-plugin.xml 2010-08-29 18:55:58-0700
@@ -58,7 +58,8 @@
    ====================​====================​====================​============= -->
     <target name="dist"
             description="Compiles, jars, puts the jar in the jEdit jars directory."
- depends="init, compile, docs-xalan, prep_files, copy_resources">
+ depends="init, compile, prep_files, copy_resources">
+ <!-- depends="init, compile, docs-xalan, prep_files, copy_resources"> -->
       <!-- make the jar file. jEdit standards require just the name of the
         plugin, e.g. Antelope.jar. put it in $prep.dir -->
         <tstamp/>
@@ -155,8 +156,8 @@
                 nowarn="on"
                 destdir="${classes.dir}"
                 srcdir="${src.dir}"
- source="1.5"
- target="1.5">
+ source="1.6"
+ target="1.6">
             <classpath refid="classpathref" />
             <exclude name="testcases/**/*"/>
             <exclude name="**/app/**/*"/>
@@ -215,6 +216,12 @@
               includes="userguide.xml"
               extension=".html"
               style="${docbook-wrapper}"/>
+ <replace dir="${doc.dir}/manual" encoding="ISO-8859-1">
+ <replacefilter token="@buildnum@" value="${build.num}"/>
+ <replacefilter token="@tstamp@" value="${TODAY}" />
+ <replacefilter token="@style@"
+ value="&lt;STYLE TYPE=&quot;text/​css&quot;&gt​; &lt;!-- @import url(./style.css); --&gt; &lt;/STYLE&gt;" />
+ </replace>
     </target>
 
 

Modified: trunk/src/ise/antelo​pe/app/Antelope.java​
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/app/Ant​elope.java?view=diff​&pathrev=171​&r1=170&r2=171
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/app/Antelope.java​ (original)
+++ trunk/src/ise/antelo​pe/app/Antelope.java​ 2010-08-29 18:55:58-0700
@@ -64,7 +64,7 @@
 import ise.antelope.app.jedit.*;
 import ise.antelope.common.*;
 import ise.library.*;
-import ise.library.swingwor​ker.SwingWorker;
+import javax.swing.SwingWorker;
 
 /**
  * Main entry point for Antelope application.

Modified: trunk/src/ise/antelo​pe/common/AntLogger.​java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​AntLogger.java?view=​diff&pathrev=171​&r1=170&r2=1​71
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/common/AntLogger.​java (original)
+++ trunk/src/ise/antelo​pe/common/AntLogger.​java 2010-08-29 18:55:58-0700
@@ -56,7 +56,6 @@
 import java.io.PrintStream;
 import java.io.File;
 
-
 import java.util.logging.Logger;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
@@ -115,542 +114,520 @@
  */
 public class AntLogger implements org.apache.tools.ant​.BuildLogger {
 
- // some spaces for nice indenting
- private String targetIndent = " ";
- private String taskIndent = targetIndent + targetIndent;
- private String msgIndent = taskIndent + targetIndent;
-
- /**
- * Storage for real System.out.
- */
- private PrintStream systemOut;
-
- /**
- * Storage for real System.err.
- */
- private PrintStream systemErr;
-
- /**
- * Storage for user defined output.
- */
- private PrintStream out = null;
-
- /**
- * Storage for user defined output.
- */
- private PrintStream err = null;
-
- /**
- * Should output be echoed to System.out and System.err? Default is false.
- */
- private boolean echo = false;
-
- /**
- * Lowest level of message to write out
- */
- protected int msgOutputLevel = Project.MSG_INFO;
-
- /**
- * Time of the start of the build
- */
- private long startTime = System.currentTimeMillis();
-
- /**
- * Convenience for local system line separator
- */
- protected final static String lSep = System.getProperty( "line.separator" );
-
- /**
- * Whether or not to show build events, default is true.
- */
- public boolean SHOW_BUILD_EVENTS = true;
-
- /**
- * Whether or not to show target events, default is false.
- */
- public boolean SHOW_TARGET_EVENTS = false;
-
- /**
- * Whether or not to show task events, default is false.
- */
- public boolean SHOW_TASK_EVENTS = false;
-
- /**
- * Whether or not to show log messages, default is true.
- */
- public boolean SHOW_LOG_MSGS = true;
-
- /**
- * Namespace for logger
- */
- public static String NAMESPACE = "ise.antelope.common​.AntLogger";
-
- /**
- * java.util.logging.Logger for namespace
- */
- private Logger logger = Logger.getLogger( NAMESPACE );
-
- /**
- * AntFileHandler is a handler that can be "turned on" by setting properties.
- */
- private AntFileHandler fileHandler = null;
-
- /**
- * LogRecords can have parameters, the namespace is added as the only parameter.
- */
- private Object[] parameters = new String[]{NAMESPACE};
-
- /**
- * Boolean to tell if this logger is open for business.
- */
- private boolean open = false;
-
-
- /**
- * Default constructor.
- */
- public AntLogger() {
- this( NAMESPACE );
- }
-
- /**
- * Constructor.
- * @param namespace namespace for java.util.logging.Logger
- */
- public AntLogger( String namespace ) {
- NAMESPACE = namespace;
- initLogger();
- ///open();
- }
-
-
- /**
- * Opens this logger for logging. Intercepts standard in and out.
- */
- public void open() {
- if ( !open ) {
- systemOut = System.out;
- systemErr = System.err;
- PrintStream ps_out = createPrintStream();
- PrintStream ps_err = createPrintStream();
- System.setOut( ps_out );
- System.setErr( ps_err );
- open = true;
- }
- }
-
-
- /**
- * Closes this logger. As logger replaces System.out and System.err with custom
- * print streams, calling this method resets System.out and System.err to their
- * original values.
- */
- public void close() {
- if ( !open )
- return ;
- try {
- System.out.flush();
- System.err.flush();
- System.setOut( systemOut );
- System.setErr( systemErr );
- if ( fileHandler != null ) {
- fileHandler.close();
- }
- }
- catch ( Exception ignored ) {} // NOPMD
- open = false;
- }
-
-
- /**
- * Sets the highest level of message this logger should respond to. Only
- * messages with a message level lower than or equal to the given level should
- * be written to the log. <P>
- *
- * Constants for the message levels are in the Ant Project class. The order of
- * the levels, from least to most verbose, is <code>MSG_ERR​</code>, <code>MSG_WARN​</code>
- * , <code>MSG_INFO​</code>, <code>MSG_VERB​OSE</code>, <code>MSG_DEBU​G</code>.
- * <P>
- *
- * The default message level for DefaultLogger is Project.MSG_INFO.
- *
- * @param level the logging level for the logger.
- */
- public void setMessageOutputLevel( int level ) {
- this.msgOutputLevel = level;
- }
-
-
- /**
- * <strong>Does nothing!</strong>
- *
- * @param outputStream ignored
- */
- public void setOutputPrintStream( PrintStream outputStream ) {}
-
-
- /**
- * <strong>Does nothing!</strong>
- *
- * @param errorStream ignored
- */
- public void setErrorPrintStream( PrintStream errorStream ) {}
-
-
- /**
- * <strong>Does nothing!</strong​><br>
- * Not used, emacs mode is always on.
- *
- * @param b ignored
- */
- public void setEmacsMode( boolean b ) { }
-
-
- /**
- * Responds to a build being started by getting our properties set and remembering the current time.
- *
- * @param event Ignored.
- */
- public void buildStarted( BuildEvent event ) {
- handleProperties( event );
- open();
- log( " " );
- // note: ConsolePluginHandler uses this message to show the Console plugin,
- // so if you change this message, be sure to update the ConsolePluginHandler
- log( Level.CONFIG, "===== BUILD STARTED =====" + lSep );
- startTime = System.currentTimeMillis();
- }
-
-
- /**
- * Prints whether the build succeeded or failed, any errors the occured during
- * the build, and how long the build took.
- *
- * @param event An event with any relevant extra information. Must not be
- * <code>null</code>.
- */
- public void buildFinished( BuildEvent event ) {
- //handleProperties(event);
- //if ( SHOW_BUILD_EVENTS ) {
- Throwable error = event.getException();
- StringBuffer message = new StringBuffer();
-
- if ( error == null ) {
- message.append( lSep );
- message.append( "BUILD SUCCESSFUL" );
- log( Level.WARNING, message.toString() );
- }
- else {
- message.append( lSep );
- message.append( "BUILD FAILED" );
- message.append( lSep );
-
- if ( Project.MSG_VERBOSE <= msgOutputLevel ||
- !( error instanceof BuildException ) ) {
- message.append( StringUtils.getStackTrace( error ) );
- }
- else {
- if ( error instanceof BuildException ) {
- message.append( error.toString() ).append( lSep );
+ // some spaces for nice indenting
+ private String targetIndent = " ";
+ private String taskIndent = targetIndent + targetIndent;
+ private String msgIndent = taskIndent + targetIndent;
+
+ /**
+ * Storage for real System.out.
+ */
+ private PrintStream systemOut;
+
+ /**
+ * Storage for real System.err.
+ */
+ private PrintStream systemErr;
+
+ /**
+ * Storage for user defined output.
+ */
+ private PrintStream out = null;
+
+ /**
+ * Storage for user defined output.
+ */
+ private PrintStream err = null;
+
+ /**
+ * Should output be echoed to System.out and System.err? Default is false.
+ */
+ private boolean echo = false;
+
+ /**
+ * Lowest level of message to write out
+ */
+ protected int msgOutputLevel = Project.MSG_INFO;
+
+ /**
+ * Time of the start of the build
+ */
+ private long startTime = System.currentTimeMillis();
+
+ /**
+ * Convenience for local system line separator
+ */
+ protected static final String lSep = System.getProperty("​line.separator");
+
+ /**
+ * Whether or not to show build events, default is true.
+ */
+ public boolean SHOW_BUILD_EVENTS = true;
+
+ /**
+ * Whether or not to show target events, default is false.
+ */
+ public boolean SHOW_TARGET_EVENTS = false;
+
+ /**
+ * Whether or not to show task events, default is false.
+ */
+ public boolean SHOW_TASK_EVENTS = false;
+
+ /**
+ * Whether or not to show log messages, default is true.
+ */
+ public boolean SHOW_LOG_MSGS = true;
+
+ /**
+ * Namespace for logger
+ */
+ public static String NAMESPACE = "ise.antelope.common​.AntLogger";
+
+ /**
+ * java.util.logging.Logger for namespace
+ */
+ private Logger logger = Logger.getLogger(NAMESPACE);
+
+ /**
+ * AntFileHandler is a handler that can be "turned on" by setting properties.
+ */
+ private AntFileHandler fileHandler = null;
+
+ /**
+ * LogRecords can have parameters, the namespace is added as the only parameter.
+ */
+ private Object[] parameters = new String[]{NAMESPACE} ;
+
+ /**
+ * Boolean to tell if this logger is open for business.
+ */
+ private boolean open = false;
+
+ /**
+ * Default constructor.
+ */
+ public AntLogger() {
+ this(NAMESPACE);
+ }
+
+ /**
+ * Constructor.
+ * @param namespace namespace for java.util.logging.Logger
+ */
+ public AntLogger(String namespace) {
+ NAMESPACE = namespace;
+ Log.log(this, "AntLogger constructor");
+ initLogger();
+ ///open();
+ }
+
+ /**
+ * Opens this logger for logging. Intercepts standard in and out.
+ */
+ public void open() {
+ if (! open) {
+ systemOut = System.out;
+ systemErr = System.err;
+ PrintStream ps_out = createPrintStream();
+ PrintStream ps_err = createPrintStream();
+ System.setOut(ps_out);
+ System.setErr(ps_err);
+ open = true;
+ }
+ }
+
+ /**
+ * Closes this logger. As logger replaces System.out and System.err with custom
+ * print streams, calling this method resets System.out and System.err to their
+ * original values.
+ */
+ public void close() {
+ if (! open) {
+ return ;
+ }
+ try {
+ System.out.flush();
+ System.err.flush();
+ System.setOut(systemOut);
+ System.setErr(systemErr);
+ if (fileHandler != null) {
+ fileHandler.close();
+ }
+ } catch (Exception ignored) { } // NOPMD
+ open = false;
+ }
+
+ /**
+ * Sets the highest level of message this logger should respond to. Only
+ * messages with a message level lower than or equal to the given level should
+ * be written to the log. <P>
+ *
+ * Constants for the message levels are in the Ant Project class. The order of
+ * the levels, from least to most verbose, is <code>MSG_ERR​</code>, <code>MSG_WARN​</code>
+ * , <code>MSG_INFO​</code>, <code>MSG_VERB​OSE</code>, <code>MSG_DEBU​G</code>.
+ * <P>
+ *
+ * The default message level for DefaultLogger is Project.MSG_INFO.
+ *
+ * @param level the logging level for the logger.
+ */
+ public void setMessageOutputLevel(int level) {
+ this.msgOutputLevel = level;
+ }
+
+ /**
+ * <strong>Does nothing!</strong>
+ *
+ * @param outputStream ignored
+ */
+ public void setOutputPrintStream​(PrintStream outputStream) { }
+
+ /**
+ * <strong>Does nothing!</strong>
+ *
+ * @param errorStream ignored
+ */
+ public void setErrorPrintStream(PrintStream errorStream) { }
+
+ /**
+ * <strong>Does nothing!</strong​><br>
+ * Not used, emacs mode is always on.
+ *
+ * @param b ignored
+ */
+ public void setEmacsMode(boolean b) { }
+
+ /**
+ * Responds to a build being started by getting our properties set and remembering the current time.
+ *
+ * @param event Ignored.
+ */
+ public void buildStarted(BuildEvent event) {
+ handleProperties(event);
+ open();
+ log(" ");
+ // note: ConsolePluginHandler uses this message to show the Console plugin,
+ // so if you change this message, be sure to update the ConsolePluginHandler
+ log(Level.CONFIG, "===== BUILD STARTED =====" + lSep);
+ startTime = System.currentTimeMillis();
+ }
+
+ /**
+ * Prints whether the build succeeded or failed, any errors the occured during
+ * the build, and how long the build took.
+ *
+ * @param event An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ */
+ public void buildFinished(BuildEvent event) {
+ //handleProperties(event);
+ //if ( SHOW_BUILD_EVENTS ) {
+ Throwable error = event.getException();
+ StringBuffer message = new StringBuffer();
+
+ if (error == null) {
+ message.append(lSep);
+ message.append("BUILD SUCCESSFUL");
+ log(Level.WARNING, message.toString());
+ } else {
+ message.append(lSep);
+ message.append("BUILD FAILED");
+ message.append(lSep);
+
+ if (Project.MSG_VERBOSE <= msgOutputLevel || ! (error instanceof BuildException)) {
+ message.append(Strin​gUtils.getStackTrace​(error));
+ } else {
+ if (error instanceof BuildException) {
+ message.append(error​.toString()).append(​lSep);
+ } else {
+ message.append(error​.getMessage()).appen​d(lSep);
+ }
+ }
+ log(Level.SEVERE, message.toString());
+ }
+ message = new StringBuffer();
+ //message.append( "Total time: " );
+ //message.append( formatTime( System.currentTimeMillis() - startTime ) );
+ message.append(lSep);
+ // note: ConsolePluginHandler uses this message to set focus back to the buffer,
+ // so if you change this message, be sure to update the ConsolePluginHandler
+ message.append("===== BUILD FINISHED =====").append(lSep);
+ //message.append( new java.util.Date().toS​tring()).append(lSep​);
+
+ String msg = message.toString();
+ log(Level.CONFIG, msg);
+ //}
+ close();
+ }
+
+ /**
+ * Logs a message to say that the target has started if this logger allows
+ * SHOW_TARGET_EVENT messages.
+ *
+ * @param event An event with any relevant extra information. Must not be
+ * <code>null</code>.
+ */
+ public void targetStarted(BuildEvent event) {
+ handleProperties(event);
+ if (SHOW_TARGET_EVENTS) {
+ String msg = targetIndent + "<" + event.getTarget().getName() + "> ";
+ log(Level.CONFIG, msg);
+ }
+ messageLogged(event);
+ }
+
+ /**
+ * Logs the target name.
+ *
+ * @param event Ignored.
+ */
+ public void targetFinished(BuildEvent event) {
+ if (SHOW_TARGET_EVENTS) {
+ String msg = targetIndent + "</" + event.getTarget().getName() + "> ";
+ log(Level.CONFIG, msg);
+ }
+ messageLogged(event);
+ }
+
+ /**
+ * Logs a message to say that the task has started if this logger allows
+ * SHOW_TASK_EVENT messages.
+ *
+ * @param event Ignored.
+ */
+ public void taskStarted(BuildEvent event) {
+ if (SHOW_TASK_EVENTS) {
+ String msg = taskIndent + "<" + event.getTask().getTaskName() + "> ";
+ log(Level.CONFIG, msg);
+ }
+ messageLogged(event);
+ }
+
+ /**
+ * Logs task name.
+ *
+ * @param event Ignored.
+ */
+ public void taskFinished(BuildEvent event) {
+ if (SHOW_TASK_EVENTS) {
+ String msg = taskIndent + "</" + event.getTask().getTaskName() + "> ";
+ log(Level.CONFIG, msg);
+ }
+ messageLogged(event);
+ }
+
+ /**
+ * Logs a message, if the priority is suitable and SHOW_LOG_MESSAGES.
+ *
+ * @param event A BuildEvent containing message information. Must not be
+ * <code>null</code> .
+ */
+ public void messageLogged(BuildEvent event) {
+ String msg = event.getMessage();
+ if (msg == null || msg.length() == 0) {
+ msg = "" ;
+ }
+ if (SHOW_LOG_MSGS) {
+ int priority = event.getPriority();
+ // Filter out messages based on priority
+ if (priority <= msgOutputLevel) {
+ StringBuffer message = new StringBuffer();
+ message.append(msgIndent);
+ message.append(msg);
+ log(message.toString());
+ }
+ }
+ }
+
+ /**
+ * Convenience method to format a specified length of time.
+ *
+ * @param millis Length of time to format, in milliseonds.
+ * @return the time as a formatted string.
+ * @see DateUtils#formatElap​sedTime(long)
+ */
+ protected static String formatTime(final long millis) {
+ return DateUtils.formatElap​sedTime(millis);
+ }
+
+ /**
+ * Logs build output to a java.util.logging.Logger.
+ *
+ * @param message Message being logged. <code>null</code> messages are not
+ * logged, however, zero-length strings are.
+ * @param level the log level
+ */
+ protected void log(Level level, String message) {
+ if (message == null) {
+ message = "" ;
+ }
+
+ Log.log(this, message);
+
+ // log the message
+ LogRecord record = new LogRecord(level, message);
+ record.setParameters​(parameters);
+ logger.log(record);
+
+ // write the message to the original System.out if desired
+ if (echo) {
+ ///systemOut.println( message );
+ }
+ }
+
+ /**
+ * Logs build output to a java.util.logging.Logger.
+ *
+ * @param message Message to log. <code>null</code> messages are not logged,
+ * however, zero-length strings are.
+ */
+ protected void log(String message) {
+ log(Level.INFO, message);
+ }
+
+ /**
+ * If set to true, output from this logger will be echoed to the original
+ * System.out and System.err print streams. The default setting is false.
+ *
+ * @param echo The new echo value
+ */
+ public void setEcho(boolean echo) {
+ this.echo = echo;
+ }
+
+ /**
+ * Gets the echo state, set setEcho.
+ *
+ * @return The echo value
+ */
+ public boolean getEcho() {
+ return echo;
+ }
+
+ /**
+ * Initializes the logger. This will install a ConsoleHandler by default.
+ */
+ private void initLogger() {
+ logger = Logger.getLogger(NAMESPACE);
+ logger.setUseParentH​andlers(false);
+ removeAllLogHandlers();
+ logger.setLevel(Level.ALL);
+
+ // default log handler is a ConsoleHandler
+ ConsoleHandler console = new ConsoleHandler();
+ console.setLevel(Level.ALL);
+ console.setFormatter(new PlainFormatter());
+ logger.addHandler(console);
+ Log.log(this, "initLogger complete");
+ }
+
+ /**
+ * Removes all log handlers from the logger for our namespace.
+ */
+ public void removeAllLogHandlers() {
+ if (logger == null) {
+ return ;
+ }
+ synchronized (logger) {
+ Handler[] handlers = logger.getHandlers();
+ for (int i = 0; i < handlers.length; i++) {
+ logger.removeHandler(handlers[ i]);
             }
- else {
- message.append( error.getMessage() ).append( lSep );
+ }
+ }
+
+ /**
+ * The simplest formatter possible.
+ */
+ public class PlainFormatter extends Formatter {
+ /**
+ * Format the given log record and return the formatted string.
+ *
+ * @param record the log record to be formatted.
+ * @return the formatted log record
+ */
+ public String format(LogRecord record) {
+ return record.getMessage() + lSep;
+ }
+ }
+
+ /**
+ * Calls internal methods based on the settings of certain properties
+ * in the Project. Properties can be<br>
+ * <ul>
+ * <li>antlogger.echo, value is true/false, mimics <code>setEcho​</code>.
+ * <li>antlogger.namespace, value is a string, mimics <code>setNames​paceForLogger</co​de>.
+ * <li>antlogger.file, value is a String per FileLogger 'pattern' API.
+ * <li>antlogger.​file.append, value is true/false, append to the log file or overwrite.
+ * </ul>
+ *
+ * @param event The build event from the buildStarted method.
+ */
+ private void handleProperties(BuildEvent event) {
+ // handle echo
+ Object o = event.getProject().g​etProperty("antlogge​r.echo");
+ if (o == null) {
+ o = System.getProperty("​antlogger.echo");
+ }
+ if (o != null) {
+ setEcho(Project.toBo​olean(o.toString()))​;
+ }
+
+ // set up the file handler
+ o = event.getProject().g​etProperty("antlogge​r.file");
+ if (o == null) {
+ o = System.getProperty("​antlogger.file");
+ }
+ if (o != null) {
+ if (fileHandler == null) {
+ String filename = o.toString();
+ o = event.getProject().g​etProperty("antlogge​r.file.append");
+ if (o == null) {
+ o = System.getProperty("​antlogger.file.appen​d");
+ }
+ boolean append = false;
+ if (o != null) {
+ append = Project.toBoolean(o.​toString());
+ }
+ try {
+ fileHandler = new AntFileHandler(new File(filename), append);
+ fileHandler.setLevel​(Level.ALL);
+ fileHandler.setFormatter(new PlainFormatter());
+ logger.addHandler(fileHandler);
+ } catch (Exception ignored) { // NOPMD
+ // silently ignore any error -- the alternative is to bail out
+ // of the build.
+ }
             }
- }
- log( Level.SEVERE, message.toString() );
- }
- message = new StringBuffer();
- //message.append( "Total time: " );
- //message.append( formatTime( System.currentTimeMillis() - startTime ) );
- message.append( lSep );
- // note: ConsolePluginHandler uses this message to set focus back to the buffer,
- // so if you change this message, be sure to update the ConsolePluginHandler
- message.append( "===== BUILD FINISHED =====" ).append( lSep );
- //message.append( new java.util.Date().toS​tring()).append(lSep​);
-
- String msg = message.toString();
- log( Level.CONFIG, msg );
- //}
- close();
- }
-
-
- /**
- * Logs a message to say that the target has started if this logger allows
- * SHOW_TARGET_EVENT messages.
- *
- * @param event An event with any relevant extra information. Must not be
- * <code>null</code>.
- */
- public void targetStarted( BuildEvent event ) {
- handleProperties( event );
- if ( SHOW_TARGET_EVENTS ) {
- String msg = targetIndent + "<" + event.getTarget().getName() + "> ";
- log( Level.CONFIG, msg );
- }
- messageLogged( event );
- }
-
-
- /**
- * Logs the target name.
- *
- * @param event Ignored.
- */
- public void targetFinished( BuildEvent event ) {
- if ( SHOW_TARGET_EVENTS ) {
- String msg = targetIndent + "</" + event.getTarget().getName() + "> ";
- log( Level.CONFIG, msg );
- }
- messageLogged( event );
- }
-
-
- /**
- * Logs a message to say that the task has started if this logger allows
- * SHOW_TASK_EVENT messages.
- *
- * @param event Ignored.
- */
- public void taskStarted( BuildEvent event ) {
- if ( SHOW_TASK_EVENTS ) {
- String msg = taskIndent + "<" + event.getTask().getTaskName() + "> ";
- log( Level.CONFIG, msg );
- }
- messageLogged( event );
- }
-
-
- /**
- * Logs task name.
- *
- * @param event Ignored.
- */
- public void taskFinished( BuildEvent event ) {
- if ( SHOW_TASK_EVENTS ) {
- String msg = taskIndent + "</" + event.getTask().getTaskName() + "> ";
- log( Level.CONFIG, msg );
- }
- messageLogged( event );
- }
-
-
- /**
- * Logs a message, if the priority is suitable and SHOW_LOG_MESSAGES.
- *
- * @param event A BuildEvent containing message information. Must not be
- * <code>null</code> .
- */
- public void messageLogged( BuildEvent event ) {
- String msg = event.getMessage();
- if ( msg == null || msg.length() == 0 ) {
- msg = "" ;
- }
- if ( SHOW_LOG_MSGS ) {
- int priority = event.getPriority();
- // Filter out messages based on priority
- if ( priority <= msgOutputLevel ) {
- StringBuffer message = new StringBuffer();
- message.append( msgIndent );
- message.append( msg );
- log( message.toString() );
- }
- }
- }
-
-
- /**
- * Convenience method to format a specified length of time.
- *
- * @param millis Length of time to format, in milliseonds.
- * @return the time as a formatted string.
- * @see DateUtils#formatElap​sedTime(long)
- */
- protected static String formatTime( final long millis ) {
- return DateUtils.formatElapsedTime( millis );
- }
-
-
- /**
- * Logs build output to a java.util.logging.Logger.
- *
- * @param message Message being logged. <code>null</code> messages are not
- * logged, however, zero-length strings are.
- * @param level the log level
- */
- protected void log( Level level, String message ) {
- if ( message == null ) {
- message = "" ;
- }
-
- Log.log(this, message);
-
- // log the message
- LogRecord record = new LogRecord( level, message );
- record.setParameters​(parameters);
- logger.log( record );
-
- // write the message to the original System.out if desired
- if ( echo ) {
- ///systemOut.println( message );
- }
- }
-
-
- /**
- * Logs build output to a java.util.logging.Logger.
- *
- * @param message Message to log. <code>null</code> messages are not logged,
- * however, zero-length strings are.
- */
- protected void log( String message ) {
- log( Level.INFO, message );
- }
-
-
- /**
- * If set to true, output from this logger will be echoed to the original
- * System.out and System.err print streams. The default setting is false.
- *
- * @param echo The new echo value
- */
- public void setEcho( boolean echo ) {
- this.echo = echo;
- }
-
-
- /**
- * Gets the echo state, set setEcho.
- *
- * @return The echo value
- */
- public boolean getEcho() {
- return echo;
- }
-
-
- /**
- * Initializes the logger. This will install a ConsoleHandler by default.
- */
- private void initLogger() {
- logger = Logger.getLogger( NAMESPACE );
- logger.setUseParentHandlers( false );
- removeAllLogHandlers();
- logger.setLevel( Level.ALL );
-
- // default log handler is a ConsoleHandler
- ConsoleHandler console = new ConsoleHandler();
- console.setLevel( Level.ALL );
- console.setFormatter( new PlainFormatter() );
- logger.addHandler( console );
- }
-
- /**
- * Removes all log handlers from the logger for our namespace.
- */
- public void removeAllLogHandlers() {
- if ( logger == null ) {
- return ;
- }
- synchronized ( logger ) {
- Handler[] handlers = logger.getHandlers();
- for ( int i = 0; i < handlers.length; i++ ) {
- logger.removeHandler( handlers[ i ] );
- }
- }
- }
-
- /**
- * The simplest formatter possible.
- */
- public class PlainFormatter extends Formatter {
- /**
- * Format the given log record and return the formatted string.
- *
- * @param record the log record to be formatted.
- * @return the formatted log record
- */
- public String format( LogRecord record ) {
- return record.getMessage() + lSep;
- }
- }
-
- /**
- * Calls internal methods based on the settings of certain properties
- * in the Project. Properties can be<br>
- * <ul>
- * <li>antlogger.echo, value is true/false, mimics <code>setEcho​</code>.
- * <li>antlogger.namespace, value is a string, mimics <code>setNames​paceForLogger</co​de>.
- * <li>antlogger.file, value is a String per FileLogger 'pattern' API.
- * <li>antlogger.​file.append, value is true/false, append to the log file or overwrite.
- * </ul>
- *
- * @param event The build event from the buildStarted method.
- */
- private void handleProperties( BuildEvent event ) {
- // handle echo
- Object o = event.getProject().getProperty( "antlogger.echo" );
- if ( o == null )
- o = System.getProperty( "antlogger.echo" );
- if ( o != null ) {
- setEcho( Project.toBoolean( o.toString() ) );
- }
-
- // set up the file handler
- o = event.getProject().getProperty( "antlogger.file" );
- if ( o == null )
- o = System.getProperty( "antlogger.file" );
- if ( o != null ) {
- if ( fileHandler == null ) {
- String filename = o.toString();
- o = event.getProject().getProperty( "antlogger.file.append" );
- if ( o == null )
- o = System.getProperty( "antlogger.file.append" );
- boolean append = false;
- if ( o != null ) {
- append = Project.toBoolean( o.toString() );
+ } else {
+ if (fileHandler != null) {
+ logger.removeHandler​(fileHandler);
             }
- try {
- fileHandler = new AntFileHandler( new File( filename ), append );
- fileHandler.setLevel( Level.ALL );
- fileHandler.setFormatter( new PlainFormatter() );
- logger.addHandler( fileHandler );
+ }
+ }
+
+ /**
+ * Creates a special print stream for this logger. Everything written to this
+ * stream is sent to the <code>log</code> method for logging.
+ *
+ * @return a print stream
+ */
+ private PrintStream createPrintStream() {
+ PrintStream ps = new PrintStream( new java.io.OutputStream() {
+ public void write(int b) {
+ byte[] bytes = { (byte) b} ;
+ write(bytes, 0, 1);
             }
- catch ( Exception ignored ) { // NOPMD
- // silently ignore any error -- the alternative is to bail out
- // of the build.
+
+ public void write(byte[] bytes, int offset, int length) {
+ String s = new String(bytes, offset, length);
+ log(s);
             }
- }
- }
- else {
- if ( fileHandler != null ) {
- logger.removeHandler( fileHandler );
- }
- }
- }
-
- /**
- * Creates a special print stream for this logger. Everything written to this
- * stream is sent to the <code>log</code> method for logging.
- *
- * @return a print stream
- */
- private PrintStream createPrintStream() {
- PrintStream ps = new PrintStream(
- new java.io.OutputStream() {
- public void write( int b ) {
- byte[] bytes = {( byte ) b};
- write( bytes, 0, 1 );
- }
-
- public void write( byte[] bytes, int offset, int length ) {
- String s = new String(bytes, offset, length);
- log(s);
- }
- }
- );
- return ps;
- }
+ }
+ );
+ return ps;
+ }
 
 }
 

Modified: trunk/src/ise/antelo​pe/common/AntProgres​sListener.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​AntProgressListener.​java?view=diff&p​athrev=171&r1=17​0&r2=171
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/common/AntProgres​sListener.java (original)
+++ trunk/src/ise/antelo​pe/common/AntProgres​sListener.java 2010-08-29 18:55:58-0700
@@ -86,9 +86,9 @@
  */
 public class AntProgressListener extends JProgressBar implements BuildListener {
 
- private int total; // total number of tasks that will be executed by the target
- private Color errorColor = Color.red; // build failed
- private Color defaultColor = new Color( 0, 153, 51 ); // a nice green for build succeeded
+ private int total; // total number of tasks that will be executed by the target
+ private Color errorColor = Color.red; // build failed
+ private Color defaultColor = new Color(0, 153, 51); // a nice green for build succeeded
 
     private HashMap project_cache = new HashMap();
 
@@ -96,19 +96,23 @@
      * Default constructor sets up the progress bar values.
      */
     public AntProgressListener() {
- setStringPainted( true );
+ setStringPainted(true);
     }
 
     /**
      * Resets the progress bar to 0 and to default color.
      * @param be not used
      */
- public void buildStarted( BuildEvent be ) {
- setStringPainted( true );
- setValue( 0 );
- setString( null );
+ public void buildStarted(BuildEvent be) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ setStringPainted(true);
+ setValue(0);
+ setString(null);
+ setForeground(defaultColor);
+ }
+ } );
         total = 0;
- setForeground( defaultColor );
     }
 
     /**
@@ -116,17 +120,20 @@
      * failure or success.
      * @param be not used
      */
- public void buildFinished( BuildEvent be ) {
- if ( be.getException() != null ) {
+ public void buildFinished(BuildEvent be) {
+ if (be.getException() != null) {
             be.getException().pr​intStackTrace();
- setForeground( errorColor );
- setString( "Failed" );
- }
- else {
- setString( "Complete" );
- }
- setIndeterminate( false );
- setValue( getMaximum() );
+ setForeground(errorColor);
+ setString("Failed");
+ } else {
+ setString("Complete");
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ setIndeterminate(false);
+ setValue(getMaximum());
+ }
+ } );
     }
 
     /**
@@ -137,44 +144,50 @@
      * null.
      * @param target_list a list of target names to execute, must not be null.
      */
- public void setExecutingTarget( Project project, ArrayList target_list ) {
+ public void setExecutingTarget(Project project, ArrayList target_list) {
         // XXX this needs more work...
- if ( project == null )
- throw new IllegalArgumentException( "project is null" );
- if ( target_list == null )
- throw new IllegalArgumentException( "target list is null" );
+ if (project == null) {
+ throw new IllegalArgumentExcep​tion("project is null");
+ }
+ if (target_list == null) {
+ throw new IllegalArgumentExcep​tion("target list is null");
+ }
         Hashtable targets = project.getTargets();
         Iterator it = target_list.iterator();
- while ( it.hasNext() ) {
- String target_name = ( String ) it.next();
- Target target = ( Target ) targets.get( target_name );
- total += countTasks( target );
+ while (it.hasNext()) {
+ String target_name = (String) it.next();
+ Target target = (Target) targets.get(target_name);
+ total += countTasks(target);
         }
 
- if ( total == 1 ) {
- setIndeterminate( true );
+ if (total == 1) {
+ setIndeterminate(true);
         }
- setMaximum( total );
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ setMaximum(total);
+ }
+ } );
     }
 
     /**
      * Show the name of the currently executing target in the status.
      */
- public void targetStarted( BuildEvent be ) {
- setString( be.getTarget().getName() );
+ public void targetStarted(BuildEvent be) {
+ setString(be.getTarg​et().getName());
     }
 
     /**
      * no-op
      */
- public void targetFinished( BuildEvent be ) {
+ public void targetFinished(BuildEvent be) {
         // does nothing
     }
 
     /**
      * no-op
      */
- public void taskStarted( BuildEvent be ) {
+ public void taskStarted(BuildEvent be) {
         // does nothing
         /*
         try {
@@ -250,15 +263,19 @@
      * Sets progress bar to maximum value.
      * @param be not used
      */
- public void taskFinished( BuildEvent be ) {
- setValue( getValue() + 1 );
+ public void taskFinished(BuildEvent be) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ setValue(getValue() + 1);
+ }
+ } );
         total += 1;
     }
 
     /**
      * no-op
      */
- public void messageLogged( BuildEvent be ) {
+ public void messageLogged(BuildEvent be) {
         // does nothing
     }
 
@@ -271,10 +288,11 @@
      * @param target the target to count tasks in
      * @return the number of tasks performed by this target
      */
- public int countTasks( Target target ) {
- if ( target == null )
+ public int countTasks(Target target) {
+ if (target == null) {
             return 0;
- int cnt = doCountTasks( target );
+ }
+ int cnt = doCountTasks(target);
         return cnt;
     }
 
@@ -286,9 +304,9 @@
      * @param target the target to count tasks in
      * @return the number of tasks performed by this target
      */
- private int doCountTasks( Target target ) {
- int dependency_count = doCountDependencies( target );
- int task_count = doTasks( target );
+ private int doCountTasks(Target target) {
+ int dependency_count = doCountDependencies(target);
+ int task_count = doTasks(target);
         return dependency_count + task_count;
     }
 
@@ -300,23 +318,23 @@
      * @param target the target to count dependency tasks for
      * @return the number of tasks performed dependency targets for this target
      */
- private int doCountDependencies( Target target ) {
- if ( target == null )
+ private int doCountDependencies(Target target) {
+ if (target == null) {
             return 0;
+ }
         int task_count = 0;
         Enumeration dependencies = target.getDependencies();
- while ( dependencies.hasMoreElements() ) {
+ while (dependencies.hasMor​eElements()) {
             Object depend = dependencies.nextElement();
             Project project = target.getProject();
             Hashtable targets = project.getTargets();
- Target t = ( Target ) targets.get( depend.toString() );
- int cnt = doCountTasks( t );
- task_count += cnt ;
+ Target t = (Target) targets.get(depend.toString());
+ int cnt = doCountTasks(t);
+ task_count += cnt;
         }
         return task_count;
     }
 
-
     /**
      * Counts the number of tasks performed by the given target. If this target calls
      * other targets (either via &lt;ant&gt; or &lt;antcall&gt; tasks), the returned
@@ -324,86 +342,90 @@
      * @param target the target to count tasks in
      * @return the number of tasks performed by this target
      */
- private int doTasks( Target target ) {
- if ( target == null )
+ private int doTasks(Target target) {
+ if (target == null) {
             return 0;
+ }
 
         int task_count = 0;
         Task[] tasks = target.getTasks();
- for ( int i = 0; i < tasks.length; i++ ) {
- Task task = tasks[ i ];
+ for (int i = 0; i < tasks.length; i++) {
+ Task task = tasks[i];
             String task_name = task.getTaskName();
             Hashtable attrs = null;
             RuntimeConfigurable rc = task.getRuntimeConfi​gurableWrapper();
             try {
- if ( AntUtils.getAntVersion() >= 1.60 ) {
- attrs = ( Hashtable ) PrivilegedAccessor.getValue( rc, "getAttributeMap" );
- }
- else {
- attrs = makeMap( ( AttributeList ) PrivilegedAccessor.getValue( rc, "getAttributes" ) );
+ if (AntUtils.getAntVersion() >= 1.60) {
+ attrs = (Hashtable) PrivilegedAccessor.getValue(rc, "getAttributeMap");
+ } else {
+ attrs = makeMap((AttributeList) PrivilegedAccessor.getValue(rc, "getAttributes"));
                 }
- }
- catch ( Exception e ) { // NOPMD
+ } catch (Exception e) { // NOPMD
                 // ignored
             }
- if ( task instanceof TaskContainer ) {
- if ( attrs == null )
+ if (task instanceof TaskContainer) {
+ if (attrs == null) {
                     continue;
+ }
                 task_count += attrs.size();
- }
- else if ( task_name.equals( "antcall" ) || task_name.equals( "call" ) ) {
+ } else if (task_name.equals("antcall") || task_name.equals("call")) {
                 // count the tasks in the target specified by an 'antcall' task
- if ( attrs == null )
+ if (attrs == null) {
                     continue;
+ }
                 Iterator it = attrs.keySet().iterator();
- while ( it.hasNext() ) {
- String name = ( String ) it.next();
- String value = ( String ) attrs.get( name );
- if ( name.equals( "target" ) ) {
+ while (it.hasNext()) {
+ String name = (String) it.next();
+ String value = (String) attrs.get(name);
+ if (name.equals("target")) {
                         Hashtable targets = target.getProject().​getTargets();
- Target subtarget = ( Target ) targets.get( value );
- task_count += doCountTasks( subtarget );
+ Target subtarget = (Target) targets.get(value);
+ task_count += doCountTasks(subtarget);
                     }
                 }
- }
- else if ( task_name.equals( "ant" ) ) {
+ } else if (task_name.equals("ant")) {
                 // count the tasks in the target specified by an 'ant' task. This target will
                 // be in another build file, so need to grab the build file name
                 // and directory and load a project from it.
- if ( attrs == null )
+ if (attrs == null) {
                     continue;
+ }
                 String antfile = "build.xml";
                 String dir = "";
                 String subtarget = "";
                 Iterator it = attrs.keySet().iterator();
- while ( it.hasNext() ) {
- String name = ( String ) it.next();
- String value = ( String ) attrs.get( name );
- if ( name.equals( "antfile" ) )
+ while (it.hasNext()) {
+ String name = (String) it.next();
+ String v

View complete message

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r171 - trunk: . src/ise/antelope/app src/ise/antelope/common src/ise/antelope/launcher src/ise/antelope/plugin src/ise/antelope/tasks src/ise/antelope/tasks/util/math danson Dale Anson 2010-08-29 18:55:59 PDT
Messages per page: