From 8060e85e5ef86ea0199d251e941ba0b414124953 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 29 Mar 2012 21:36:39 +0200 Subject: [PATCH] [patch by Przemek Lubanski]: IDEA-25975 Time in ant build end should be displayed in minutes when it is too big for seconds --- .../config/execution/AntBuildMessageView.java | 29 +++++++++++++++---- .../src/messages/AntBundle.properties | 16 +++++----- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java index 6fb39be0dcf1..ebe8fe62245b 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntBuildMessageView.java @@ -815,24 +815,41 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O int warnings = getWarningCount(); final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime()); - long buildTimeInSeconds = buildTimeInMilliseconds / 1000; + String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000); if (isAborted) { - return AntBundle.message("build.finished.status.ant.build.aborted", buildTimeInSeconds, theDateAsString); + return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString); } else if (errors == 0 && warnings == 0) { - return AntBundle.message("build.finished.status.ant.build.completed.successfully", buildTimeInSeconds, theDateAsString); + return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString); } else if (errors == 0) { - return AntBundle - .message("build.finished.status.ant.build.completed.with.warnings", warnings, buildTimeInSeconds, theDateAsString); + return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString); } else { return AntBundle - .message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, buildTimeInSeconds, theDateAsString); + .message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString); } } + private String formatBuildTime(long seconds) { + if (seconds == 0) return "0s"; + + StringBuilder sb = new StringBuilder(); + if (seconds >= 3600) { + sb.append(seconds / 3600).append("h "); + seconds %= 3600; + } + if (seconds >= 60 || sb.length() > 0) { + sb.append(seconds / 60).append("m "); + seconds %= 60; + } + if (seconds > 0 || sb.length() > 0) { + sb.append(seconds).append("s"); + } + return sb.toString(); + } + public boolean isOutputPaused() { return myIsOutputPaused; } diff --git a/resources-en/src/messages/AntBundle.properties b/resources-en/src/messages/AntBundle.properties index ea8219b88e44..1350693c18f3 100644 --- a/resources-en/src/messages/AntBundle.properties +++ b/resources-en/src/messages/AntBundle.properties @@ -27,17 +27,17 @@ starting.ant.build.dialog.title=Starting Ant Build ant.process.is.active.terminate.confirmation.text=Ant Process is active. Terminate Ant process? close.ant.build.messages.dialog.title=Close Ant Build Messages cannot.start.build.name.error.message=Cannot start {0} -#0 - execution time (seconds), 1 - finish date (as string) -build.finished.status.ant.build.aborted=Ant build aborted in {0}s at {1} -#0 - execution time (seconds), 1 - finish date (as string) -build.finished.status.ant.build.completed.successfully=Ant build completed successfully in {0}s at {1} -#0 - warnings count 1 - execution time (in seconds) 2 - finish date (as string) +#0 - formatted execution time as string (i.e. 2h 35m 29s), 1 - finish date (as string) +build.finished.status.ant.build.aborted=Ant build aborted in {0} at {1} +#0 - formatted execution time as string (i.e. 2h 35m 29s), 1 - finish date (as string) +build.finished.status.ant.build.completed.successfully=Ant build completed successfully in {0} at {1} +#0 - warnings count, 1 - formatted execution time as string (i.e. 2h 35m 29s), 2 - finish date (as string) build.finished.status.ant.build.completed.with.warnings=Ant build completed with \ - {0, choice, 1#one warning|2#{0} warnings} in {1}s at {2} -#0 - errors count, 1 - warnings count 2 - execution time (in seconds) 3 - finish date (as string) + {0, choice, 1#one warning|2#{0} warnings} in {1} at {2} +#0 - errors count, 1 - warnings count, 2 - formatted execution time as string (i.e. 2h 35m 29s), 3 - finish date (as string) build.finished.status.ant.build.completed.with.errors.warnings=Ant build completed with \ {0, choice, 1#one error|2#{0} errors} {1, choice, 1#one warning|2#{0} warnings} \ - in {2}s at {3} + in {2} at {3} project.jdk.not.specified.error.message=Project JDK not specified jdk.with.name.not.configured.error.message=JDK ({0}) needed to run this ANT target is not configured. Please update your settings in the Project | Libraries menu. jdk.with.name.bad.configured.error.message=JDK ({0}) needed to run this ANT target is incorrectly configured. Please update your settings in the Project | Libraries menu.