ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ide VAJAntToolGUI.java
Date Tue, 05 Feb 2002 21:38:25 GMT
sbailliez    02/02/05 13:38:25

  Modified:    src/main/org/apache/tools/ant DefaultLogger.java
               src/main/org/apache/tools/ant/taskdefs/optional/ide
                        VAJAntToolGUI.java
  Log:
  Use refactored elapsed time formatting in DateUtils.
  
  Revision  Changes    Path
  1.32      +4 -32     jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java
  
  Index: DefaultLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/DefaultLogger.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- DefaultLogger.java	31 Jan 2002 23:56:26 -0000	1.31
  +++ DefaultLogger.java	5 Feb 2002 21:38:25 -0000	1.32
  @@ -59,6 +59,7 @@
   import java.text.MessageFormat;
   
   import org.apache.tools.ant.util.StringUtils;
  +import org.apache.tools.ant.util.DateUtils;
   
   /**
    *  Writes build event to a PrintStream. Currently, it
  @@ -66,28 +67,6 @@
    *  any messages that get logged.
    */
   public class DefaultLogger implements BuildLogger {
  -    private final static MessageFormat MINUTE_SECONDS =
  -        new MessageFormat("Total time: {0}{1}.");
  -
  -    private final static double[] LIMITS = {0, 1, 2};
  -
  -    private final static String[] MINUTES_PART =
  -        {"", "1 minute, ", "{0,number} minutes, "};
  -
  -    private final static String[] SECONDS_PART =
  -        {"no seconds", "1 second", "{1,number} seconds"};
  -
  -    private final static ChoiceFormat MINUTES_FORMAT =
  -        new ChoiceFormat(LIMITS, MINUTES_PART);
  -
  -    private final static ChoiceFormat SECONDS_FORMAT =
  -        new ChoiceFormat(LIMITS, SECONDS_PART);
  -
  -    static {
  -        MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
  -        MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
  -    }
  -
       private static int LEFT_COLUMN_SIZE = 12;
   
       protected PrintStream out;
  @@ -181,6 +160,7 @@
               }
           }
           message.append(StringUtils.LINE_SEP);
  +        message.append("Total time: ");
           message.append(formatTime(System.currentTimeMillis() - startTime));
   
           String msg = message.toString();
  @@ -236,16 +216,8 @@
           }
       }
   
  -    protected static String formatTime(long millis) {
  -        long seconds = millis / 1000;
  -        long minutes = seconds / 60;
  -
  -        Object[] args = {
  -            new Long(minutes),
  -            new Long(seconds % 60)
  -        };
  -
  -        return MINUTE_SECONDS.format(args);
  +    protected static String formatTime(final long millis) {
  +        return DateUtils.formatElapsedTime(millis);
       }
   
       protected void printMessage(final String message,
  
  
  
  1.10      +3 -19     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
  
  Index: VAJAntToolGUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- VAJAntToolGUI.java	31 Jan 2002 09:24:16 -0000	1.9
  +++ VAJAntToolGUI.java	5 Feb 2002 21:38:25 -0000	1.10
  @@ -86,7 +86,6 @@
   import java.awt.event.TextEvent;
   import java.awt.event.WindowEvent;
   
  -
   import java.beans.PropertyChangeListener;
   
   import org.apache.tools.ant.BuildException;
  @@ -94,6 +93,7 @@
   import org.apache.tools.ant.BuildEvent;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.util.StringUtils;
  +import org.apache.tools.ant.util.DateUtils;
   
   /**
    * This is a simple grafical user interface to provide the information needed
  @@ -214,7 +214,7 @@
                   logException( error );
               }
   
  -            getMessageTextArea().append(lineSeparator + "Total time: " + formatTime(System.currentTimeMillis()
- startTime));
  +            getMessageTextArea().append(lineSeparator + "Total time: " + DateUtils.formatElapsedTime(System.currentTimeMillis()
- startTime));
           }
   
   
  @@ -543,23 +543,7 @@
               getBuildButton().setEnabled(true);
           }
       }
  -    /**
  -     * Copied from DefaultLogger to provide the same time-format.
  -     */
  -    public static String formatTime(long millis) {
  -        long seconds = millis / 1000;
  -        long minutes = seconds / 60;
  -        if (minutes > 0) {
  -            return Long.toString(minutes) + " minute"
  -                + (minutes == 1 ? " " : "s ")
  -                + Long.toString(seconds%60) + " second"
  -                + (seconds%60 > 1 ? "s" : "");
  -        }
  -        else {
  -            return Long.toString(seconds) + " second"
  -                + (seconds%60 > 1 ? "s" : "");
  -        }
  -    }
  +
       /**
        * Return the AboutCommandPanel property value.
        * @return java.awt.Panel
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message