Package se.sics.cooja.dialogs

Examples of se.sics.cooja.dialogs.MessageList$MessageContainer


      /* Compile Contiki (may consist of several commands) */
      if (getCompileCommands() == null) {
        throw new MoteTypeCreationException("No compile commands specified");
      }
      final MessageList compilationOutput = new MessageList();
      String[] arr = getCompileCommands().split("\n");
      for (String cmd: arr) {
        if (cmd.trim().isEmpty()) {
          continue;
        }

        try {
          CompileContiki.compile(
              cmd,
              envOneDimension,
              null /* Do not observe output firmware file */,
              getContikiSourceFile().getParentFile(),
              null,
              null,
              compilationOutput,
              true
          );
        } catch (Exception e) {
          MoteTypeCreationException newException =
            new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* Print last 10 compilation errors to console */
          MessageContainer[] messages = compilationOutput.getMessages();
          for (int i=messages.length-10; i < messages.length; i++) {
            if (i < 0) {
              continue;
            }
            logger.fatal(">> " + messages[i]);
View Full Code Here


      return;
    }

    try {
      final Process externalCoojaProcess;
      final MessageList testOutput = new MessageList();

      JPanel progressPanel = new JPanel(new BorderLayout());
      final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null);
      progressDialog.setTitle("Running test...");

      String command[] = {
          "java",
          "-jar",
          "../dist/cooja.jar",
          "-nogui",
          "-test=" + testName
      };
      externalCoojaProcess = Runtime.getRuntime().exec(command, null, testDir);
      final BufferedReader input = new BufferedReader(new InputStreamReader(externalCoojaProcess.getInputStream()));
      final BufferedReader err = new BufferedReader(new InputStreamReader(externalCoojaProcess.getErrorStream()));

      final JButton button = new JButton("Abort test");
      button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          externalCoojaProcess.destroy();
          if (progressDialog.isDisplayable()) {
            progressDialog.dispose();
          }
        }
      });

      progressPanel.add(BorderLayout.CENTER, new JScrollPane(testOutput));
      progressPanel.add(BorderLayout.SOUTH, button);
      progressPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
      progressPanel.setVisible(true);

      progressDialog.getContentPane().add(progressPanel);
      progressDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

      progressDialog.getRootPane().setDefaultButton(button);
      progressDialog.setSize(500, 300);
      progressDialog.setLocationRelativeTo(ScriptRunner.this.pluginGUI);
      progressDialog.setVisible(true);

      Thread readInput = new Thread(new Runnable() {
        public void run() {
          String readLine;
          try {
            while ((readLine = input.readLine()) != null) {
              if (testOutput != null) {
                testOutput.addMessage(readLine, MessageList.NORMAL);
              }
            }

          } catch (IOException e) {
            logger.warn("Error while reading from process");
          }

          testOutput.addMessage("", MessageList.NORMAL);
          testOutput.addMessage("", MessageList.NORMAL);
          testOutput.addMessage("", MessageList.NORMAL);

          /* Parse log file for success info */
          try {
            BufferedReader in = new BufferedReader(new InputStreamReader(
                new FileInputStream(logFile)));
            boolean testSucceeded = false;

            while (in.ready()) {
              String line = in.readLine();
              if (line == null) {
                line = "";
              }
              testOutput.addMessage(line, MessageList.NORMAL);
              if (line.contains("TEST OK")) {
                testSucceeded = true;
               break;
              }
            }
            if (testSucceeded) {
              progressDialog.setTitle("Test run completed. Test succeeded!");
              button.setText("Test OK");
            } else {
              progressDialog.setTitle("Test run completed. Test failed!");
              button.setText("Test failed");
            }
          } catch (FileNotFoundException e) {
            logger.fatal("File not found: " + e);
            progressDialog.setTitle("Test run completed. Test failed! (no logfile)");
            button.setText("Test failed");
          } catch (IOException e) {
            logger.fatal("IO error: " + e);
            progressDialog.setTitle("Test run completed. Test failed! (IO exception)");
            button.setText("Test failed");
          }

        }
      }, "read input stream thread");

      Thread readError = new Thread(new Runnable() {
        public void run() {
          String readLine;
          try {
            while ((readLine = err.readLine()) != null) {
              if (testOutput != null) {
                testOutput.addMessage(readLine, MessageList.ERROR);
              }
            }
          } catch (IOException e) {
            logger.warn("Error while reading from process");
          }
View Full Code Here

      boolean success = simulation.setConfigXML(arguments, false);
    } catch (Exception e) {
      logger.fatal("Error when configuring simulation: " + e);
      if (DEBUG_OUTPUT) {
        if (e instanceof MoteTypeCreationException) {
          MessageList compilationOutput = ((MoteTypeCreationException) e).getCompilationOutput();
          if (compilationOutput != null) {
            logger.info("Compilation output:");
            for(int i = 0; i < compilationOutput.getModel().getSize(); i++) {
              logger.info(compilationOutput.getModel().getElementAt(i));
            }
          }
          StackTraceElement[] stackTrace = e.getStackTrace();
          if (stackTrace != null) {
            logger.info("Stack trace:");
View Full Code Here

          return true;
        } else {
          return false;
        }
      } else {
        MessageList compilationOutput = new MessageList();
        try {
          compiler.compileFirmware(getContikiSourceFile(), null, null, compilationOutput,
              true);

        } catch (Exception e) {
          MoteTypeCreationException newException = new MoteTypeCreationException(
              "Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* 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(">> " + messages[i]);
View Full Code Here

              compileProcess.waitFor();
            } catch (Exception e) {
              if (compilationOutput != null) {
                compilationOutput.addMessage(e.getMessage(), MessageList.ERROR);
              }
              syncException.setCompilationOutput(new MessageList());
              syncException.fillInStackTrace();
              return;
            }

            /* Check return value */
            if (compileProcess.exitValue() != 0) {
              if (compilationOutput != null) {
                compilationOutput.addMessage("Process returned error code " + compileProcess.exitValue(), MessageList.ERROR);
              }
              if (failAction != null) {
                failAction.actionPerformed(null);
              }
              syncException.setCompilationOutput(new MessageList());
              syncException.fillInStackTrace();
              return;
            }

            if (firmware == null) {
              return;
            }

            if (!ELFFile.exists()) {
              if (compilationOutput != null) {
                compilationOutput.addMessage("Can't locate output file " + ELFFile, MessageList.ERROR);
              }
              if (failAction != null) {
                failAction.actionPerformed(null);
              }
              syncException.setCompilationOutput(new MessageList());
              syncException.fillInStackTrace();
              return;
            }

            if (compilationOutput != null) {
View Full Code Here

      } else {
        logger.fatal("Unknown parent container type: " + parentContainer);
        return false;
      }

      final MessageList taskOutput = new MessageList();

      // BOTTOM BUTTON PART
      Box buttonBox = Box.createHorizontalBox();
      buttonBox.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
View Full Code Here

  public abstract boolean canLoadFirmware(File file);

  protected String[] compilationEnvironment = null; /* Default environment: inherit from current process */
  public void compileContiki()
  throws Exception {
    final MessageList taskOutput = new MessageList();

    if (contikiFirmware.exists()) {
      contikiFirmware.delete();
    }

    /* Handle multiple compilation commands one by one */
    final ArrayList<String> commands = new ArrayList<String>();
    String[] arr = getCompileCommands().split("\n");
    for (String cmd: arr) {
      if (cmd.trim().isEmpty()) {
        continue;
      }

      commands.add(cmd);
    }
    if (commands.isEmpty()) {
      throw new Exception("No compile commands specified");
    }

    setDialogState(DialogState.IS_COMPILING);
    createNewCompilationTab(taskOutput);

    /* Add abort compilation menu item */
    final JMenuItem abortMenuItem = new JMenuItem("Abort compilation");
    abortMenuItem.setEnabled(true);
    abortMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        abortAnyCompilation();
      }
    });
    taskOutput.addPopupMenuItem(abortMenuItem, true);

    /* Called when last command has finished (success only) */
    final Action compilationSuccessAction = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        abortMenuItem.setEnabled(false);
View Full Code Here

    /* Not visualized: Compile Contiki immediately */
    if (getIdentifier() == null) {
      throw new MoteTypeCreationException("No identifier");
    }

    final MessageList compilationOutput = new MessageList();

    if (getCompileCommands() != null) {
      /* Handle multiple compilation commands one by one */
      String[] arr = getCompileCommands().split("\n");
      for (String cmd: arr) {
        if (cmd.trim().isEmpty()) {
          continue;
        }

        try {
          CompileContiki.compile(
              cmd,
              null,
              null /* Do not observe output firmware file */,
              getContikiSourceFile().getParentFile(),
              null,
              null,
              compilationOutput,
              true
          );
        } catch (Exception e) {
          MoteTypeCreationException newException =
            new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* Print last 10 compilation errors to console */
          MessageContainer[] messages = compilationOutput.getMessages();
          for (int i=messages.length-10; i < messages.length; i++) {
            if (i < 0) {
              continue;
            }
            logger.fatal(">> " + messages[i]);
View Full Code Here

    /* Not visualized: Compile Contiki immediately */
    if (getIdentifier() == null) {
      throw new MoteTypeCreationException("No identifier");
    }

    final MessageList compilationOutput = new MessageList();

    if (getCompileCommands() != null) {
      /* Handle multiple compilation commands one by one */
      String[] arr = getCompileCommands().split("\n");
      for (String cmd: arr) {
        if (cmd.trim().isEmpty()) {
          continue;
        }

        try {
          CompileContiki.compile(
              cmd,
              null,
              null /* Do not observe output firmware file */,
              getContikiSourceFile().getParentFile(),
              null,
              null,
              compilationOutput,
              true
          );
        } catch (Exception e) {
          MoteTypeCreationException newException =
            new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* Print last 10 compilation errors to console */
          MessageContainer[] messages = compilationOutput.getMessages();
          for (int i=messages.length-10; i < messages.length; i++) {
            if (i < 0) {
              continue;
            }
            logger.fatal(">> " + messages[i]);
View Full Code Here

    /* Not visualized: Compile Contiki immediately */
    if (getIdentifier() == null) {
      throw new MoteTypeCreationException("No identifier");
    }

    final MessageList compilationOutput = new MessageList();

    if (getCompileCommands() != null) {
      /* Handle multiple compilation commands one by one */
      String[] arr = getCompileCommands().split("\n");
      for (String cmd: arr) {
        if (cmd.trim().isEmpty()) {
          continue;
        }

        try {
          CompileContiki.compile(
              cmd,
              null,
              null /* Do not observe output firmware file */,
              getContikiSourceFile().getParentFile(),
              null,
              null,
              compilationOutput,
              true
          );
        } catch (Exception e) {
          MoteTypeCreationException newException =
            new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* Print last 10 compilation errors to console */
          MessageContainer[] messages = compilationOutput.getMessages();
          for (int i=messages.length-10; i < messages.length; i++) {
            if (i < 0) {
              continue;
            }
            logger.fatal(">> " + messages[i]);
View Full Code Here

TOP

Related Classes of se.sics.cooja.dialogs.MessageList$MessageContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.