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

📄 contikimotetypedialog.java

📁 Contiki是一个开源
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    commStackComboBox.setEnabled(false);    commStackComboBox.setToolTipText("Disabled since Nov 2008, awaiting new Contiki communication protocol build interface");    smallPane.add(label);    smallPane.add(Box.createHorizontalStrut(10));    smallPane.add(Box.createHorizontalGlue());    smallPane.add(commStackComboBox);    mainPane.add(smallPane);    mainPane.add(Box.createRigidArea(new Dimension(0, 5)));    // Processes    smallPane = new JPanel();    smallPane.setAlignmentX(Component.LEFT_ALIGNMENT);    smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS));    label = new JLabel("Processes");    label.setAlignmentX(Component.LEFT_ALIGNMENT);    label.setAlignmentY(Component.TOP_ALIGNMENT);    label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));    JPanel processHolder = new JPanel(new BorderLayout());    processHolder.setAlignmentX(Component.LEFT_ALIGNMENT);    processHolder.setAlignmentY(Component.TOP_ALIGNMENT);    button = new JButton("Add process name");    button.setActionCommand("addprocess");    button.addActionListener(myEventHandler);    processHolder.add(BorderLayout.SOUTH, button);    processPanel = new JPanel();    processPanel.setLayout(new BoxLayout(processPanel, BoxLayout.Y_AXIS));    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));    tempPane = new JScrollPane(sensorPanel);    tempPane.setPreferredSize(new Dimension(300, 200));    sensorHolder.add(BorderLayout.WEST, tempPane);    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));    tempPane = new JScrollPane(coreInterfacePanel);    tempPane.setPreferredSize(new Dimension(300, 200));    interfaceHolder.add(BorderLayout.WEST, tempPane);    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, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);    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);    final MessageList taskOutput;    progressDialog.setLocationRelativeTo(myDialog);    JProgressBar progressBar = new JProgressBar(0, 100);    progressBar.setValue(0);    progressBar.setStringPainted(true);    progressBar.setIndeterminate(true);    taskOutput = new MessageList();    final Thread compilationThreadCopy = Thread.currentThread();    final JButton button = new JButton("Abort compilation");    button.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        if (compilationThreadCopy != null && compilationThreadCopy.isAlive()) {          compilationThreadCopy.interrupt();        }        if (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() {

⌨️ 快捷键说明

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