metasim 01/02/09 05:14:04
Modified: src/antidote/org/apache/tools/ant/gui/modules/console
BuildConsole.java
Log:
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.
Revision Changes Path
1.5 +37 -18
jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java
Index: BuildConsole.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/console/BuildConsole.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BuildConsole.java 2001/01/08 19:43:50 1.4
+++ BuildConsole.java 2001/02/09 13:14:03 1.5
@@ -64,11 +64,12 @@
import java.awt.Dimension;
import java.awt.Color;
import java.util.EventObject;
+import java.util.Date;
/**
* Logging console display.
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author Simeon Fitch
*/
public class BuildConsole extends AntModule {
@@ -78,6 +79,8 @@
private JComboBox _logLevel = null;
/** Display styles. */
private ConsoleStyleContext _styles = null;
+ /** ClearLog Button. */
+ private JButton _clearLog = null;
/**
* Default ctor.
@@ -112,11 +115,33 @@
_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();
@@ -132,20 +157,6 @@
}
/**
- * 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.
*
* @param event Event to post.
@@ -154,7 +165,6 @@
*/
public boolean eventPosted(EventObject event) {
if(event instanceof ProjectSelectedEvent) {
- clearDisplay();
return true;
}
@@ -164,9 +174,10 @@
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 @@
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 {
/**