Examples of MessageList


Examples of se.sics.cooja.dialogs.MessageList

    JPanel progressPanel = new JPanel(new BorderLayout());
    final JDialog progressDialog = new JDialog(myDialog, (String) null);
    JProgressBar progressBar;
    JButton button;
    final MessageList taskOutput;
    progressDialog.setLocationRelativeTo(myDialog);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    progressBar.setIndeterminate(true);

    taskOutput = new MessageList();

    final Thread compilationThreadCopy = compilationThread;
    button = new JButton("Close/Abort");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (compilationThreadCopy != null && compilationThreadCopy.isAlive()) {
          compilationThreadCopy.interrupt();
        }
        if (progressDialog != null && progressDialog.isDisplayable()) {
          progressDialog.dispose();
        }
      }
    });

    final JPopupMenu popup = new JPopupMenu();
    JMenuItem headerMenuItem = new JMenuItem("Compilation output:");
    headerMenuItem.setEnabled(false);
    popup.add(headerMenuItem);
    popup.add(new JSeparator());

    JMenuItem consoleOutputMenuItem = new JMenuItem("Output to console");
    consoleOutputMenuItem.setEnabled(true);
    consoleOutputMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        int nrRows = taskOutput.getModel().getSize();
        System.out.println("\nCOMPILATION OUTPUT:\n");
        for (int n=0; n < nrRows; n++) {
          System.out.println(taskOutput.getModel().getElementAt(n));
        }
        System.out.println();
      }
    });
    popup.add(consoleOutputMenuItem);

    JMenuItem clipboardMenuItem = new JMenuItem("Copy to clipboard");
    clipboardMenuItem.setEnabled(true);
    clipboardMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        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";
        }

        StringSelection stringSelection = new StringSelection(output);
        clipboard.setContents(stringSelection, null);

        logger.info("Output copied to clipboard");
      }
    });
    popup.add(clipboardMenuItem);

    taskOutput.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) {
          popup.show(taskOutput, e.getX(), e.getY());
        }
      }
    });

    progressPanel.add(BorderLayout.CENTER, new JScrollPane(taskOutput));
    progressPanel.add(BorderLayout.NORTH, progressBar);
    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.pack();

    progressDialog.getRootPane().setDefaultButton(button);
    progressDialog.setVisible(true);

    // Create temp output directory if not already exists
    if (!ContikiMoteType.tempOutputDirectory.exists()) {
      ContikiMoteType.tempOutputDirectory.mkdir();
    }

    // Parse selected sensors
    Vector<String> sensors = new Vector<String>();
    for (Component checkBox : sensorPanel.getComponents()) {
      if (((JCheckBox) checkBox).isSelected()) {
        sensors.add(((JCheckBox) checkBox).getText());
      }
    }

    // Parse selected core interfaces
    Vector<String> coreInterfaces = new Vector<String>();
    for (Component checkBox : coreInterfacePanel.getComponents()) {
      if (((JCheckBox) checkBox).isSelected()) {
        coreInterfaces.add(((JCheckBox) checkBox).getText());
      }
    }

    // Parse selected user processes
    Vector<String> userProcesses = new Vector<String>();
    for (Component checkBox : processPanel.getComponents()) {
      if (((JCheckBox) checkBox).isSelected()) {
        userProcesses.add(((JCheckBox) checkBox).getText());
      }
    }

    // Generate main contiki source file
    String filename = null;
    try {
      filename = generateSourceFile(textID.getText(), sensors, coreInterfaces,
          userProcesses);
    } catch (Exception e) {
      libraryCreatedOK = false;
      progressBar.setBackground(Color.ORANGE);
      progressBar.setString(e.getMessage());
      progressBar.setIndeterminate(false);
      progressBar.setValue(0);
      createButton.setEnabled(libraryCreatedOK);
      return;
    }

    // Test compile shared library
    progressBar.setString("..compiling..");
    final File contikiDir = new File(textContikiDir.getText());
    final String identifier = textID.getText();
    File libFile = new File(ContikiMoteType.tempOutputDirectory,
        identifier + ContikiMoteType.librarySuffix);
    File mapFile = new File(ContikiMoteType.tempOutputDirectory,
        identifier + ContikiMoteType.mapSuffix);
    File depFile = new File(ContikiMoteType.tempOutputDirectory,
        identifier + ContikiMoteType.dependSuffix);

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

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

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

    compilationThread = new Thread(new Runnable() {
      public void run() {
        // Add all project directories
        compilationFiles = (Vector<File>) myGUI
            .getProjectDirs().clone();


        if (moteTypeProjectDirs == null || moteTypeProjectDirs.isEmpty()) {
          compilationFiles.add(new File(textCoreDir.getText(), "testapps"));
        } else {
          compilationFiles.addAll(moteTypeProjectDirs);
        }

        // Add source files from project configs
        String[] projectSourceFiles = newMoteTypeConfig.getStringArrayValue(
            ContikiMoteType.class, "C_SOURCES");
        for (String projectSourceFile : projectSourceFiles) {
          if (!projectSourceFile.equals("")) {
            File file = new File(projectSourceFile);
            if (file.getParent() != null) {
              // Find which project directory added this file
              File projectDir = newMoteTypeConfig.getUserProjectDefining(
                  ContikiMoteType.class, "C_SOURCES", projectSourceFile);
              if (projectDir != null) {
                // We found a project directory; add it to path
                compilationFiles.add(new File(projectDir.getPath(), file
                    .getParent()));
              }
            }
            compilationFiles.add(new File(file.getName()));
          }
        }

        // Add selected process source files
        for (Component checkBox : processPanel.getComponents()) {
          if (((JCheckBox) checkBox).isSelected()) {
            String fileName = ((JCheckBox) checkBox).getToolTipText();
            if (fileName != null) {
              compilationFiles.add(new File(fileName));
            }
          }
        }

        compilationSucceded = ContikiMoteTypeDialog.compileLibrary(identifier,
            contikiDir, compilationFiles, symbolsCheckBox.isSelected(),
            (ContikiMoteType.CommunicationStack) commStackComboBox.getSelectedItem(),
            taskOutput.getInputStream(MessageList.NORMAL),
            taskOutput.getInputStream(MessageList.ERROR));
      }
    }, "compilation thread");
    compilationThread.start();

    while (compilationThread.isAlive()) {

Examples of se.sics.cooja.dialogs.MessageList

   * @throws MoteTypeCreationException
   *           If Java class compilation error occurs
   */
  private static void compileSourceFile(String className)
      throws MoteTypeCreationException {
    MessageList compilationOutput = new MessageList();
    OutputStream compilationStandardStream = compilationOutput
        .getInputStream(MessageList.NORMAL);
    OutputStream compilationErrorStream = compilationOutput
        .getInputStream(MessageList.ERROR);

    File classFile = new File("se/sics/cooja/corecomm/" + className + ".class");

    try {

Examples of se.sics.cooja.dialogs.MessageList

    JPanel progressPanel = new JPanel(new BorderLayout());
    final JDialog progressDialog = new JDialog(myDialog, (String) null);
    JProgressBar progressBar;
    JButton button;
    final MessageList taskOutput;
    progressDialog.setLocationRelativeTo(myDialog);

    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);
    progressBar.setStringPainted(true);
    progressBar.setIndeterminate(true);

    taskOutput = new MessageList();

    button = new JButton("Close/Abort");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (compilationThread != null && compilationThread.isAlive()) {
          compilationThread.interrupt();
        }
        if (progressDialog != null && progressDialog.isDisplayable())
          progressDialog.dispose();
      }
    });

    progressPanel.add(BorderLayout.CENTER, new JScrollPane(taskOutput));
    progressPanel.add(BorderLayout.NORTH, progressBar);
    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.pack();

    progressDialog.getRootPane().setDefaultButton(button);
    progressDialog.setVisible(true);

    // Generate main mantis source file
    try {
      // Remove old file is existing
      if (srcFile.exists()) {
        srcFile.delete();
      }
     
      if (srcFile.exists()) {
        throw new Exception("could not remove old source file");
      }
     
      generateSourceFile(srcFile);
     
      if (!srcFile.exists()) {
        throw new Exception("source file not created");
      }
    } catch (Exception e) {
      libraryCreatedOK = false;
      progressBar.setBackground(Color.ORANGE);
      if (e.getMessage() != null)
        progressBar.setString("source file generation failed: " + e.getMessage());
      else
        progressBar.setString("source file generation failed");
        
      progressBar.setIndeterminate(false);
      progressBar.setValue(0);
      createButton.setEnabled(libraryCreatedOK);
      return;
    }
   
    // Test compile shared library
    progressBar.setString("..compiling..");

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

    compilationThread = new Thread(new Runnable() {
      public void run() {
        compilationSucceded =
          MantisMoteTypeDialog.compileLibrary(
              libFile,
              objFile,
              srcFile,
              workingDir,
              taskOutput.getInputStream(MessageList.NORMAL),
              taskOutput.getInputStream(MessageList.ERROR));
      }
    }, "compilation thread");
    compilationThread.start();

    while (compilationThread.isAlive()) {

Examples of se.sics.cooja.dialogs.MessageList

      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:");
TOP
Copyright © 2018 www.massapi.com. 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.