From 681b40c3c13216a3afcda632fea2d6e0d940e191 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Thu, 26 Jan 2012 16:03:41 +0100 Subject: [PATCH] public clean method, and broke out add log messages method --- .../se/sics/cooja/plugins/LogListener.java | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java index 592ec880b..f0dc111ca 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/LogListener.java +++ b/tools/cooja/java/se/sics/cooja/plugins/LogListener.java @@ -437,21 +437,7 @@ public class LogListener extends VisPlugin { updateTitle(); } public void newLogOutput(LogOutputEvent ev) { - /* Display new log output */ - if (!hasHours && ev.getTime() > TIME_HOUR) { - hasHours = true; - repaintTimeColumn(); - } - LogData data = new LogData(ev); - logUpdateAggregator.add(data); - if (appendToFile) { - appendToFile(appendStreamFile, - data.getTime() + "\t" + - data.getID() + "\t" + - data.ev.getMessage() + "\n" - ); - - } + registerNewLogOutput(ev); } public void removedLogOutput(LogOutputEvent ev) { } @@ -500,6 +486,28 @@ public class LogListener extends VisPlugin { setLocation(0, gui.getDesktopPane().getHeight() - 300); } + public void registerNewLogOutput(Mote mote, long time, String msg) { + LogOutputEvent ev = new LogOutputEvent(mote, time, msg); + registerNewLogOutput(ev); + } + + private void registerNewLogOutput(LogOutputEvent ev) { + /* Display new log output */ + if (!hasHours && ev.getTime() > TIME_HOUR) { + hasHours = true; + repaintTimeColumn(); + } + LogData data = new LogData(ev); + logUpdateAggregator.add(data); + if (appendToFile) { + appendToFile(appendStreamFile, + data.getTime() + "\t" + + data.getID() + "\t" + + data.ev.getMessage() + "\n" + ); + } + } + private void repaintTimeColumn() { logTable.getColumnModel().getColumn(COLUMN_TIME).setHeaderValue( logTable.getModel().getColumnName(COLUMN_TIME)); @@ -872,14 +880,18 @@ public class LogListener extends VisPlugin { private static final long serialVersionUID = -2115620313183440224L; public void actionPerformed(ActionEvent e) { - int size = logs.size(); - if (size > 0) { - logs.clear(); - model.fireTableRowsDeleted(0, size - 1); - } + clear(); } }; + public void clear() { + int size = logs.size(); + if (size > 0) { + logs.clear(); + model.fireTableRowsDeleted(0, size - 1); + } + } + private Action copyAction = new AbstractAction("Selected") { private static final long serialVersionUID = -8433490108577001803L;