⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contikimotetypedialog.java

📁 Contiki is an open source, highly portable, multi-tasking operating system for memory-constrained n
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    return true;  }  /**   * Scans a directory for sourcefiles which defines a Contiki process.   *    * @param rootDirectory   *          Top directory to search in   * @return Process definitions found under rootDirectory, {sourcefile,   *         processname}   */  public static Vector<String[]> scanForProcesses(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> processes = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_PROCESSES")          + " '" + rootDirectory.getPath().replace(File.separatorChar, '/')          + "'/*.[ch]";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_PROCESSES"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          processes.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();//      BufferedReader err = new BufferedReader(new InputStreamReader(p//          .getErrorStream()));//      if (err.ready())//        logger.warn("Error occured during scan:");//      while ((line = err.readLine()) != null) {//        logger.warn(line);//      }//      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    }    return processes;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * Contiki sensor.   *    * @param rootDirectory   *          Top directory to search in   * @return Sensor definitions found under rootDirectory, {sourcefile,   *         sensorname}   */  public static Vector<String[]> scanForSensors(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> sensors = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_SENSORS") + " '"          + rootDirectory.getPath().replace(File.separatorChar, '/') + "'";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_SENSORS"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          sensors.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();      BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      if (err.ready())        logger.warn("Error occured during scan:");      while ((line = err.readLine()) != null) {        logger.warn(line);      }      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    }    return sensors;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * COOJA core interface.   *    * @param rootDirectory   *          Top directory to search in   * @return Core interface definitions found under rootDirectory, {sourcefile,   *         interfacename}   */  public static Vector<String[]> scanForInterfaces(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> interfaces = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_INTERFACES")          + " '" + rootDirectory.getPath().replace(File.separatorChar, '/')          + "'";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_INTERFACES"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          interfaces.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();      BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      if (err.ready())        logger.warn("Error occured during scan:");      while ((line = err.readLine()) != null) {        logger.warn(line);      }      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for interfaces: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for interfaces: " + err);      err.printStackTrace();    }    return interfaces;  }  /**   * Scans given file for an autostart expression and returns all process names   * found.   *    * @param sourceFile   *          Source file to scan   * @return Autostart process names or null   * @throws FileNotFoundException   *           Given file not found   * @throws IOException   *           IO Exception   */  public static Vector<String> parseAutostartProcesses(File sourceFile)      throws FileNotFoundException, IOException {    // Open file for reading    BufferedReader sourceFileReader = new BufferedReader(new FileReader(        sourceFile));    // Find which processes were set to autostart    String line;    String autostartExpression = "^AUTOSTART_PROCESSES([^$]*)$";    Pattern pattern = Pattern.compile(autostartExpression);    Vector<String> foundProcesses = new Vector<String>();    while ((line = sourceFileReader.readLine()) != null) {      Matcher matcher = pattern.matcher(line);      if (matcher.find()) {        // Parse autostart processes        String[] allProcesses = matcher.group(1).split(",");        for (String autostartProcess : allProcesses) {          foundProcesses.add(autostartProcess.replaceAll("[&; \\(\\)]", ""));        }      }    }    return foundProcesses;  }  private boolean autoSelectDependencyProcesses(String processName,      String sourceFilename, boolean confirmSelection) {    // Locate source file    File sourceFile = new File(textCoreDir.getText(), sourceFilename);    boolean foundFile = sourceFile.exists();    if (!foundFile)      for (File projectDir : myGUI.getProjectDirs()) {        sourceFile = new File(projectDir, sourceFilename);        if (foundFile = sourceFile.exists())          break;      }    if (!foundFile)      for (File projectDir : moteTypeProjectDirs) {        sourceFile = new File(projectDir, sourceFilename);        if (foundFile = sourceFile.exists())          break;      }    if (!foundFile) {      // Die quietly      return false;    }    Vector<String> autostartProcesses = null;    try {      autostartProcesses = parseAutostartProcesses(sourceFile);    } catch (Exception e) {      return false;    }    if (autostartProcesses == null || autostartProcesses.isEmpty()) {      // Die quietly      return true;    }    for (String autostartProcess : autostartProcesses) {      // Does this process already exist?      boolean processAlreadySelected = false;      for (Component checkBox : processPanel.getComponents()) {        JCheckBox checkBox2 = (JCheckBox) checkBox;        String existingProcess = checkBox2.getText();        boolean selected = checkBox2.isSelected();        if (existingProcess.equals(autostartProcess) && selected) {          processAlreadySelected = true;        }      }      if (!processAlreadySelected) {        boolean processShouldBeSelected = false;        if (confirmSelection) {          // Let user choose whether to add process          Object[] options = { "Add", "Cancel" };          String question = "The process " + processName              + " depends on the following process: " + autostartProcess              + "\nDo you want to select this as well?";          String title = "Select dependency process?";          int answer = JOptionPane.showOptionDialog(myDialog, question, title,              JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null,              options, options[0]);          if (answer == JOptionPane.YES_OPTION) {            processShouldBeSelected = true;          }        } else {          // Add process          processShouldBeSelected = true;        }        if (processShouldBeSelected) {          // Get checkbox to select          JCheckBox processToSelectCheckBox = null;          for (Component checkBox : processPanel.getComponents()) {            JCheckBox checkBox2 = (JCheckBox) checkBox;            if (checkBox2.getText().equals(autostartProcess)) {              processToSelectCheckBox = checkBox2;              break;            }          }          if (processToSelectCheckBox == null) {            // Create new check box            processToSelectCheckBox = new JCheckBox(autostartProcess, true);            processToSelectCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);            processToSelectCheckBox.setActionCommand("process_clicked: "                + autostartProcess);            processToSelectCheckBox.addActionListener(myEventHandler);            processPanel.add(processToSelectCheckBox);          }          processToSelectCheckBox.setSelected(true);          processPanel.invalidate();          processPanel.revalidate();        }      }    }    return true;  }  private void pathsWereUpdated() {    updateVisualFields();    // Remove all prevously scanned entries    coreInterfacePanel.removeAll();    moteInterfacePanel.removeAll();    processPanel.removeAll();    sensorPanel.removeAll();    coreInterfacePanel.revalidate();    coreInterfacePanel.repaint();    moteInterfacePanel.revalidate();    moteInterfacePanel.repaint();    processPanel.revalidate();    processPanel.repaint();    sensorPanel.revalidate();    sensorPanel.repaint();    createButton.setEnabled(libraryCreatedOK = false);    settingsOK = false;    testButton.setEnabled(settingsOK);  }  private void updateVisualFields() {    settingsOK = true;    // Check for non-unique identifier    textID.setBackground(Color.WHITE);    textID.setToolTipText(null);    for (MoteType otherType : allOtherTypes) {      if (

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -