using updated messagelist

This commit is contained in:
fros4943 2008-12-03 15:18:47 +00:00
parent 1117ce1be8
commit 430333b515
3 changed files with 24 additions and 26 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspMoteType.java,v 1.19 2008/11/04 17:37:09 fros4943 Exp $ * $Id: MspMoteType.java,v 1.20 2008/12/03 15:19:03 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -45,6 +45,7 @@ import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.*; import se.sics.cooja.*;
import se.sics.cooja.dialogs.MessageList; import se.sics.cooja.dialogs.MessageList;
import se.sics.cooja.dialogs.MessageList.MessageContainer;
@ClassDescription("Msp Mote Type") @ClassDescription("Msp Mote Type")
public abstract class MspMoteType implements MoteType { public abstract class MspMoteType implements MoteType {
@ -239,14 +240,13 @@ public abstract class MspMoteType implements MoteType {
newException = (MoteTypeCreationException) newException.initCause(e); newException = (MoteTypeCreationException) newException.initCause(e);
newException.setCompilationOutput(compilationOutput); newException.setCompilationOutput(compilationOutput);
/* Print last compilation errors */ /* Print last 5 compilation errors */
try { Thread.sleep(500); } catch (InterruptedException ignore) { } MessageContainer[] messages = compilationOutput.getMessages();
ListModel tmp = compilationOutput.getModel(); for (int i=messages.length-5; i < messages.length; i++) {
for (int i=tmp.getSize()-5; i < tmp.getSize(); i++) {
if (i < 0) { if (i < 0) {
continue; continue;
} }
logger.fatal(">> " + tmp.getElementAt(i)); logger.fatal(">> " + messages[i]);
} }
logger.fatal("Compilation error: " + e.getMessage()); logger.fatal("Compilation error: " + e.getMessage());

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiMoteTypeDialog.java,v 1.49 2008/11/03 18:32:22 fros4943 Exp $ * $Id: ContikiMoteTypeDialog.java,v 1.50 2008/12/03 15:18:47 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
@ -49,6 +49,7 @@ import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.contikimote.ContikiMoteType.CommunicationStack; import se.sics.cooja.contikimote.ContikiMoteType.CommunicationStack;
import se.sics.cooja.dialogs.MessageList; import se.sics.cooja.dialogs.MessageList;
import se.sics.cooja.dialogs.ProjectDirectoriesDialog; import se.sics.cooja.dialogs.ProjectDirectoriesDialog;
import se.sics.cooja.dialogs.MessageList.MessageContainer;
/** /**
* A dialog for configuring Contiki mote types and compiling Contiki mote type * A dialog for configuring Contiki mote types and compiling Contiki mote type
@ -1053,10 +1054,10 @@ public class ContikiMoteTypeDialog extends JDialog {
consoleOutputMenuItem.setEnabled(true); consoleOutputMenuItem.setEnabled(true);
consoleOutputMenuItem.addActionListener(new ActionListener() { consoleOutputMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int nrRows = taskOutput.getModel().getSize(); MessageContainer[] messages = taskOutput.getMessages();
System.out.println("\nCOMPILATION OUTPUT:\n"); System.out.println("\nCOMPILATION OUTPUT:\n");
for (int n=0; n < nrRows; n++) { for (MessageContainer msg: messages) {
System.out.println(taskOutput.getModel().getElementAt(n)); System.out.println(msg);
} }
System.out.println(); System.out.println();
} }
@ -1070,9 +1071,9 @@ public class ContikiMoteTypeDialog extends JDialog {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String output = ""; String output = "";
int nrRows = taskOutput.getModel().getSize(); MessageContainer[] messages = taskOutput.getMessages();
for (int n=0; n < nrRows; n++) { for (MessageContainer msg: messages) {
output += taskOutput.getModel().getElementAt(n) + "\n"; output += msg + "\n";
} }
StringSelection stringSelection = new StringSelection(output); StringSelection stringSelection = new StringSelection(output);

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ScriptRunner.java,v 1.7 2008/11/05 18:17:45 fros4943 Exp $ * $Id: ScriptRunner.java,v 1.8 2008/12/03 15:21:02 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -45,7 +45,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.StringReader; import java.io.StringReader;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -435,9 +434,7 @@ public class ScriptRunner extends VisPlugin {
try { try {
final Process externalCoojaProcess; final Process externalCoojaProcess;
MessageList testOutput = new MessageList(); final MessageList testOutput = new MessageList();
final PrintStream normal = testOutput.getInputStream(MessageList.NORMAL);
final PrintStream error = testOutput.getInputStream(MessageList.ERROR);
JPanel progressPanel = new JPanel(new BorderLayout()); JPanel progressPanel = new JPanel(new BorderLayout());
final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null); final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null);
@ -482,8 +479,8 @@ public class ScriptRunner extends VisPlugin {
String readLine; String readLine;
try { try {
while ((readLine = input.readLine()) != null) { while ((readLine = input.readLine()) != null) {
if (normal != null) { if (testOutput != null) {
normal.println(readLine); testOutput.addMessage(readLine, MessageList.NORMAL);
} }
} }
@ -491,9 +488,9 @@ public class ScriptRunner extends VisPlugin {
logger.warn("Error while reading from process"); logger.warn("Error while reading from process");
} }
normal.println(""); testOutput.addMessage("", MessageList.NORMAL);
normal.println(""); testOutput.addMessage("", MessageList.NORMAL);
normal.println(""); testOutput.addMessage("", MessageList.NORMAL);
/* Parse log file for success info */ /* Parse log file for success info */
try { try {
@ -506,7 +503,7 @@ public class ScriptRunner extends VisPlugin {
if (line == null) { if (line == null) {
line = ""; line = "";
} }
normal.println(line); testOutput.addMessage("", MessageList.NORMAL);
if (line.contains("TEST OK")) { if (line.contains("TEST OK")) {
testSucceeded = true; testSucceeded = true;
break; break;
@ -537,8 +534,8 @@ public class ScriptRunner extends VisPlugin {
String readLine; String readLine;
try { try {
while ((readLine = err.readLine()) != null) { while ((readLine = err.readLine()) != null) {
if (error != null) { if (testOutput != null) {
error.println(readLine); testOutput.addMessage(readLine, MessageList.ERROR);
} }
} }
} catch (IOException e) { } catch (IOException e) {