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
* 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;
@ -45,6 +45,7 @@ import org.apache.log4j.Logger;
import org.jdom.Element;
import se.sics.cooja.*;
import se.sics.cooja.dialogs.MessageList;
import se.sics.cooja.dialogs.MessageList.MessageContainer;
@ClassDescription("Msp Mote Type")
public abstract class MspMoteType implements MoteType {
@ -239,14 +240,13 @@ public abstract class MspMoteType implements MoteType {
newException = (MoteTypeCreationException) newException.initCause(e);
newException.setCompilationOutput(compilationOutput);
/* Print last compilation errors */
try { Thread.sleep(500); } catch (InterruptedException ignore) { }
ListModel tmp = compilationOutput.getModel();
for (int i=tmp.getSize()-5; i < tmp.getSize(); i++) {
/* Print last 5 compilation errors */
MessageContainer[] messages = compilationOutput.getMessages();
for (int i=messages.length-5; i < messages.length; i++) {
if (i < 0) {
continue;
}
logger.fatal(">> " + tmp.getElementAt(i));
logger.fatal(">> " + messages[i]);
}
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
* 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;
@ -49,6 +49,7 @@ import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.contikimote.ContikiMoteType.CommunicationStack;
import se.sics.cooja.dialogs.MessageList;
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
@ -1053,10 +1054,10 @@ public class ContikiMoteTypeDialog extends JDialog {
consoleOutputMenuItem.setEnabled(true);
consoleOutputMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int nrRows = taskOutput.getModel().getSize();
MessageContainer[] messages = taskOutput.getMessages();
System.out.println("\nCOMPILATION OUTPUT:\n");
for (int n=0; n < nrRows; n++) {
System.out.println(taskOutput.getModel().getElementAt(n));
for (MessageContainer msg: messages) {
System.out.println(msg);
}
System.out.println();
}
@ -1070,9 +1071,9 @@ public class ContikiMoteTypeDialog extends JDialog {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String output = "";
int nrRows = taskOutput.getModel().getSize();
for (int n=0; n < nrRows; n++) {
output += taskOutput.getModel().getElementAt(n) + "\n";
MessageContainer[] messages = taskOutput.getMessages();
for (MessageContainer msg: messages) {
output += msg + "\n";
}
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
* 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;
@ -45,7 +45,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.StringReader;
import java.util.*;
import java.util.regex.Matcher;
@ -435,9 +434,7 @@ public class ScriptRunner extends VisPlugin {
try {
final Process externalCoojaProcess;
MessageList testOutput = new MessageList();
final PrintStream normal = testOutput.getInputStream(MessageList.NORMAL);
final PrintStream error = testOutput.getInputStream(MessageList.ERROR);
final MessageList testOutput = new MessageList();
JPanel progressPanel = new JPanel(new BorderLayout());
final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null);
@ -482,8 +479,8 @@ public class ScriptRunner extends VisPlugin {
String readLine;
try {
while ((readLine = input.readLine()) != null) {
if (normal != null) {
normal.println(readLine);
if (testOutput != null) {
testOutput.addMessage(readLine, MessageList.NORMAL);
}
}
@ -491,9 +488,9 @@ public class ScriptRunner extends VisPlugin {
logger.warn("Error while reading from process");
}
normal.println("");
normal.println("");
normal.println("");
testOutput.addMessage("", MessageList.NORMAL);
testOutput.addMessage("", MessageList.NORMAL);
testOutput.addMessage("", MessageList.NORMAL);
/* Parse log file for success info */
try {
@ -506,7 +503,7 @@ public class ScriptRunner extends VisPlugin {
if (line == null) {
line = "";
}
normal.println(line);
testOutput.addMessage("", MessageList.NORMAL);
if (line.contains("TEST OK")) {
testSucceeded = true;
break;
@ -537,8 +534,8 @@ public class ScriptRunner extends VisPlugin {
String readLine;
try {
while ((readLine = err.readLine()) != null) {
if (error != null) {
error.println(readLine);
if (testOutput != null) {
testOutput.addMessage(readLine, MessageList.ERROR);
}
}
} catch (IOException e) {