From 83113cb68c3cf294068c67a9d0d56c4642887038 Mon Sep 17 00:00:00 2001 From: metasim Date: Fri, 9 Feb 2001 13:14:03 +0000 Subject: [PATCH] Applied Chris Wilhelm's change to provide a clear log button, and not to clear the log by default. Also added date to the start and end build messages. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268618 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/gui/modules/console/BuildConsole.java | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java b/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java index 6b7353541..30c926a9b 100644 --- a/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java +++ b/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java @@ -64,6 +64,7 @@ import java.awt.FlowLayout; import java.awt.Dimension; import java.awt.Color; import java.util.EventObject; +import java.util.Date; /** * Logging console display. @@ -78,6 +79,8 @@ public class BuildConsole extends AntModule { private JComboBox _logLevel = null; /** Display styles. */ private ConsoleStyleContext _styles = null; + /** ClearLog Button. */ + private JButton _clearLog = null; /** * Default ctor. @@ -112,11 +115,33 @@ public class BuildConsole extends AntModule { _logLevel.setSelectedItem(LogLevelEnum.INFO); controls.add(_logLevel); + // Padding. + controls.add(Box.createHorizontalStrut(10)); + _clearLog = new JButton( + context.getResources().getString( + getClass(), "clearLog")); + _clearLog.addActionListener(new ActionHandler()); + controls.add(_clearLog); + add(BorderLayout.NORTH, controls); } + /** + * Clear the contents of the console. + * + */ + private void clearDisplay() { + Document doc = _text.getDocument(); + try { + doc.remove(0, doc.getLength()); + } + catch(Exception ex) { + // Intentionally ignored. + } + } + /** Class for handling project events. */ private class Handler implements BusMember { private final Filter _filter = new Filter(); @@ -131,20 +156,6 @@ public class BuildConsole extends AntModule { return _filter; } - /** - * Clear the contents of the console. - * - */ - private void clearDisplay() { - Document doc = _text.getDocument(); - try { - doc.remove(0, doc.getLength()); - } - catch(Exception ex) { - // Intentionally ignored. - } - } - /** * Called when an event is to be posed to the member. * @@ -154,7 +165,6 @@ public class BuildConsole extends AntModule { */ public boolean eventPosted(EventObject event) { if(event instanceof ProjectSelectedEvent) { - clearDisplay(); return true; } @@ -164,9 +174,10 @@ public class BuildConsole extends AntModule { switch(buildEvent.getType().getValue()) { case BuildEventType.BUILD_STARTED_VAL: - clearDisplay(); + case BuildEventType.BUILD_FINISHED_VAL: - text = buildEvent.getType().toString(); + text = buildEvent.getType().toString() + + " (" + new Date().toString() + ")"; style = _styles.getHeadingStyle(); break; case BuildEventType.TARGET_STARTED_VAL: @@ -205,6 +216,14 @@ public class BuildConsole extends AntModule { return true; } } + + /** Handles press of the ClearLog button. */ + private class ActionHandler implements java.awt.event.ActionListener { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (e.getSource() == _clearLog) clearDisplay(); + } + } + /** Class providing filtering for project events. */ private static class Filter implements BusFilter { /**