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

📄 contikimotetypedialog.java

📁 传感器网络操作系统contiki。 被广泛应用于环境检测、结构健康监测等等。包括路由协议
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    JScrollPane tempPane = new JScrollPane(processPanel);    tempPane.setPreferredSize(new Dimension(300, 200));    processHolder.add(BorderLayout.WEST, tempPane);    label.setLabelFor(processPanel);    smallPane.add(label);    smallPane.add(Box.createHorizontalStrut(10));    smallPane.add(Box.createHorizontalGlue());    smallPane.add(processHolder);    mainPane.add(smallPane);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Mote interfaces    smallPane = new JPanel();    smallPane.setAlignmentX(Component.LEFT_ALIGNMENT);    smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS));    label = new JLabel("Mote Interfaces");    label.setAlignmentX(Component.LEFT_ALIGNMENT);    label.setAlignmentY(Component.TOP_ALIGNMENT);    label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));    JPanel moteInterfaceHolder = new JPanel(new BorderLayout());    moteInterfaceHolder.setAlignmentX(Component.LEFT_ALIGNMENT);    moteInterfaceHolder.setAlignmentY(Component.TOP_ALIGNMENT);    moteInterfacePanel = new JPanel();    moteInterfacePanel.setLayout(new BoxLayout(moteInterfacePanel,        BoxLayout.Y_AXIS));    tempPane = new JScrollPane(moteInterfacePanel);    tempPane.setPreferredSize(new Dimension(300, 200));    moteInterfaceHolder.add(BorderLayout.WEST, tempPane);    label.setLabelFor(moteInterfacePanel);    smallPane.add(label);    smallPane.add(Box.createHorizontalStrut(10));    smallPane.add(Box.createHorizontalGlue());    smallPane.add(moteInterfaceHolder);    mainPane.add(smallPane);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Separator with show advanced checkbox    JCheckBox showAdvancedCheckBox = new JCheckBox("Show advanced settings");    showAdvancedCheckBox.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        if (((JCheckBox) e.getSource()).isSelected()) {          if (entireCoreInterfacePane != null) {            entireCoreInterfacePane.setVisible(true);          }          if (entireSensorPane != null) {            entireSensorPane.setVisible(true);          }        } else {          if (entireCoreInterfacePane != null) {            entireCoreInterfacePane.setVisible(false);          }          if (entireSensorPane != null) {            entireSensorPane.setVisible(false);          }        }      }    });    mainPane.add(new JSeparator());    mainPane.add(showAdvancedCheckBox);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Core sensors    smallPane = new JPanel();    smallPane.setAlignmentX(Component.LEFT_ALIGNMENT);    smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS));    label = new JLabel("Sensors");    label.setAlignmentX(Component.LEFT_ALIGNMENT);    label.setAlignmentY(Component.TOP_ALIGNMENT);    label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));    JPanel sensorHolder = new JPanel(new BorderLayout());    sensorHolder.setAlignmentX(Component.LEFT_ALIGNMENT);    sensorHolder.setAlignmentY(Component.TOP_ALIGNMENT);    // button = new JButton(GUI.lang.getString("motetype_scansens"));    // button.setActionCommand("scansensors");    // button.addActionListener(myEventHandler);    // sensorHolder.add(BorderLayout.NORTH, button);    button = new JButton("Add sensor name");    button.setActionCommand("addsensor");    button.addActionListener(myEventHandler);    sensorHolder.add(BorderLayout.SOUTH, button);    sensorPanel = new JPanel();    sensorPanel.setLayout(new BoxLayout(sensorPanel, BoxLayout.Y_AXIS));    JScrollPane tempPane2 = new JScrollPane(sensorPanel);    tempPane2.setPreferredSize(new Dimension(300, 200));    sensorHolder.add(BorderLayout.WEST, tempPane2);    label.setLabelFor(sensorPanel);    smallPane.add(label);    smallPane.add(Box.createHorizontalStrut(10));    smallPane.add(Box.createHorizontalGlue());    smallPane.add(sensorHolder);    mainPane.add(smallPane);    entireSensorPane = smallPane;    entireSensorPane.setVisible(false);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Core interfaces    smallPane = new JPanel();    smallPane.setAlignmentX(Component.LEFT_ALIGNMENT);    smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS));    label = new JLabel("Core Interfaces");    label.setAlignmentX(Component.LEFT_ALIGNMENT);    label.setAlignmentY(Component.TOP_ALIGNMENT);    label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));    JPanel interfaceHolder = new JPanel(new BorderLayout());    interfaceHolder.setAlignmentX(Component.LEFT_ALIGNMENT);    interfaceHolder.setAlignmentY(Component.TOP_ALIGNMENT);    button = new JButton("Add interface name");    button.setActionCommand("addinterface");    button.addActionListener(myEventHandler);    interfaceHolder.add(BorderLayout.SOUTH, button);    coreInterfacePanel = new JPanel();    coreInterfacePanel.setLayout(new BoxLayout(coreInterfacePanel,        BoxLayout.Y_AXIS));    JScrollPane tempPane3 = new JScrollPane(coreInterfacePanel);    tempPane3.setPreferredSize(new Dimension(300, 200));    interfaceHolder.add(BorderLayout.WEST, tempPane3);    label.setLabelFor(coreInterfacePanel);    smallPane.add(label);    smallPane.add(Box.createHorizontalStrut(10));    smallPane.add(Box.createHorizontalGlue());    smallPane.add(interfaceHolder);    mainPane.add(smallPane);    entireCoreInterfacePane = smallPane;    entireCoreInterfacePane.setVisible(false);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Add everything!    mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));    Container contentPane = getContentPane();    JScrollPane mainScrollPane = new JScrollPane(mainPane);    // mainScrollPane.setPreferredSize(new Dimension(    // mainPane.getPreferredSize().width + 50, 500));    contentPane.add(mainScrollPane, BorderLayout.CENTER);    contentPane.add(buttonPane, BorderLayout.SOUTH);    addWindowListener(new WindowListener() {      public void windowDeactivated(WindowEvent e) {      }      public void windowIconified(WindowEvent e) {      }      public void windowDeiconified(WindowEvent e) {      }      public void windowOpened(WindowEvent e) {      }      public void windowClosed(WindowEvent e) {      }      public void windowActivated(WindowEvent e) {      }      public void windowClosing(WindowEvent e) {        myMoteType = null;        dispose();      }    });  }  /**   * Checks which core interfaces are needed by the currently selected mote   * interfaces, and selects only them.   */  private void recheckInterfaceDependencies() {    // Unselect all core interfaces    for (Component checkBox : coreInterfacePanel.getComponents()) {      ((JCheckBox) checkBox).setSelected(false);    }    // Loop through all mote interfaces    for (Component checkBox : moteInterfacePanel.getComponents()) {      JCheckBox moteIntfCheckBox = (JCheckBox) checkBox;      // If the mote interface is selected, select needed core interfaces      if (moteIntfCheckBox.isSelected()) {        String[] neededCoreInterfaces = null;        // Get needed core interfaces (if any)        try {          Class moteInterfaceClass = (Class) moteIntfCheckBox              .getClientProperty("class");          if (ContikiMoteInterface.class.isAssignableFrom(moteInterfaceClass)) {            Method m = moteInterfaceClass.getDeclaredMethod(                "getCoreInterfaceDependencies", (Class[]) null);            neededCoreInterfaces = (String[]) m.invoke(null, (Object[]) null);          }        } catch (NoSuchMethodException e) {          logger.warn("Can't read core interface dependencies of "              + moteIntfCheckBox.getText() + ", assuming no core dependencies");        } catch (InvocationTargetException e) {          logger.warn("Can't read core interface dependencies of "              + moteIntfCheckBox.getText() + ": " + e);        } catch (IllegalAccessException e) {          logger.warn("Can't read core interface dependencies of "              + moteIntfCheckBox.getText() + ": " + e);        }        // If needed core interfaces found, select them        if (neededCoreInterfaces != null) {          // Loop through all needed core interfaces          for (String neededCoreInterface : neededCoreInterfaces) {            int coreInterfacePosition = -1;            // Check that the core interface actually exists            for (int j = 0; j < coreInterfacePanel.getComponentCount(); j++) {              JCheckBox coreCheckBox = (JCheckBox) coreInterfacePanel                  .getComponent(j);              if (coreCheckBox.getText().equals(neededCoreInterface)) {                coreInterfacePosition = j;                coreCheckBox.setSelected(true);                break;              }            }            // Was the core interface found?            if (coreInterfacePosition < 0) {              logger.warn("Warning! " + moteIntfCheckBox.getText()                  + " needs non-existing core interface " + neededCoreInterface                  + " (rescan?)");            }          }        }      }    }  }  /**   * Tries to compile library using current settings.   */  public void doTestSettings() {    libraryCreatedOK = false;    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);    // 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()) {

⌨️ 快捷键说明

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