📄 contikimotetypedialog.java
字号:
} for (Class presetMoteInterface : moteTypeToConfigure.getMoteInterfaces()) { // Try to find mote interface in current list boolean foundAndSelectedMoteInterface = false; for (Component moteInterfaceCheckBox : myDialog.moteInterfacePanel .getComponents()) { Class moteInterfaceClass = (Class) ((JCheckBox) moteInterfaceCheckBox) .getClientProperty("class"); if (presetMoteInterface == moteInterfaceClass) { ((JCheckBox) moteInterfaceCheckBox).setSelected(true); foundAndSelectedMoteInterface = true; break; } } // Warn if not found if (!foundAndSelectedMoteInterface) { logger.warn("Mote interface was not found in current environment: " + presetMoteInterface); } } } // Set position and focus of dialog myDialog.pack(); myDialog.setLocationRelativeTo(parentContainer); myDialog.textDescription.requestFocus(); myDialog.textDescription.select(0, myDialog.textDescription.getText() .length()); Rectangle maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); if (maxSize != null && (myDialog.getSize().getWidth() > maxSize.getWidth() || myDialog.getSize().getHeight() > maxSize.getHeight())) { Dimension newSize = new Dimension(); newSize.height = Math.min((int) maxSize.getHeight(), (int) myDialog.getSize().getHeight()); newSize.width = Math.min((int) maxSize.getWidth(), (int) myDialog.getSize().getWidth()); logger.info("Resizing dialog: " + myDialog.getSize() + " -> " + newSize); myDialog.setSize(newSize); } myDialog.setVisible(true); if (myDialog.myMoteType != null) { // Library was compiled and loaded return true; } return false; } private ContikiMoteTypeDialog(Dialog dialog) { super(dialog, "Create Mote Type", ModalityType.APPLICATION_MODAL); setupDialog(); } private ContikiMoteTypeDialog(Window window) { super(window, "Create Mote Type", ModalityType.APPLICATION_MODAL); setupDialog(); } private ContikiMoteTypeDialog(Frame frame) { super(frame, "Create Mote Type", ModalityType.APPLICATION_MODAL); setupDialog(); } private void setupDialog() { myDialog = this; JLabel label; JPanel mainPane = new JPanel(); mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); JPanel smallPane; JTextField textField; JButton button; // BOTTOM BUTTON PART JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); button = new JButton("Cancel"); button.setActionCommand("cancel"); button.addActionListener(myEventHandler); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(button); buttonPane.add(Box.createHorizontalGlue()); button = new JButton("Clean"); button.setActionCommand("clean"); button.addActionListener(myEventHandler); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(button); button = new JButton("Compile"); button.setActionCommand("testsettings"); button.addActionListener(myEventHandler); testButton = button; this.getRootPane().setDefaultButton(button); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(button); button = new JButton("Create"); button.setEnabled(libraryCreatedOK); button.setActionCommand("create"); button.addActionListener(myEventHandler); createButton = button; buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(button); // MAIN PART // Identifier smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Identifier"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setText(""); textField.getDocument().addDocumentListener(myEventHandler); textID = textField; label.setLabelFor(textField); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Output filenames smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Output files"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setText(ContikiMoteType.tempOutputDirectory.getPath() + File.separatorChar + textID.getText() + ContikiMoteType.mapSuffix + ", " + ContikiMoteType.tempOutputDirectory.getPath() + File.separatorChar + textID.getText() + ContikiMoteType.librarySuffix + ", " + ContikiMoteType.tempOutputDirectory.getPath() + File.separatorChar + textID.getText() + ContikiMoteType.dependSuffix); textField.setEnabled(false); textOutputFiles = textField; label.setLabelFor(textField); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Description smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Description"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setBackground(Color.GREEN); textField.setText("[enter description here]"); textField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { if (myDialog.isVisible()) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { updateVisualFields(); } }); } } public void removeUpdate(DocumentEvent e) { if (myDialog.isVisible()) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { updateVisualFields(); } }); } } public void changedUpdate(DocumentEvent e) { if (myDialog.isVisible()) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { updateVisualFields(); } }); } } }); textDescription = textField; label.setLabelFor(textField); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Contiki dir smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Contiki 2.x OS path"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setText(GUI.getExternalToolsSetting("PATH_CONTIKI")); textField.getDocument().addDocumentListener(myEventHandler); textField.setEnabled(false); /* Disabled: Almost never used */ textContikiDir = textField; label.setLabelFor(textField); button = new JButton("Browse"); button.setActionCommand("browsecontiki"); button.setEnabled(false); /* Disabled: Almost never used */ button.addActionListener(myEventHandler); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); smallPane.add(button); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // COOJA core platform dir smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Core platform path"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setText(textContikiDir.getText() + GUI.getExternalToolsSetting("PATH_COOJA_CORE_RELATIVE")); textField.setEditable(false); textField.setEnabled(false); /* Disabled: Almost never used */ textCoreDir = textField; label.setLabelFor(textField); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // COOJA project directory smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Contiki code search paths"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); textField = new JTextField(); textField.setText(""); textField.setEditable(false); textProjectDirs = textField; label.setLabelFor(textField); button = new JButton("Manage"); button.setActionCommand("manageprojectdirs"); button.addActionListener(myEventHandler); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(textField); smallPane.add(button); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Include symbols selection smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("System symbols"); label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT)); symbolsCheckBox = new JCheckBox("Include"); symbolsCheckBox.setSelected(false); symbolsCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pathsWereUpdated(); } }); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(symbolsCheckBox); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Separator mainPane.add(new JSeparator()); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Rescan button smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Scan after entering above information"); rescanButton = new JButton("Scan now"); rescanButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Thread(new Runnable() { public void run() { rescanDirectories(); } }).start(); } }); smallPane.add(label); smallPane.add(Box.createHorizontalStrut(10)); smallPane.add(Box.createHorizontalGlue()); smallPane.add(rescanButton); mainPane.add(smallPane); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Separator mainPane.add(new JSeparator()); mainPane.add(Box.createRigidArea(new Dimension(0, 5))); // Communication stack smallPane = new JPanel(); smallPane.setAlignmentX(Component.LEFT_ALIGNMENT); smallPane.setLayout(new BoxLayout(smallPane, BoxLayout.X_AXIS)); label = new JLabel("Communication stack"); commStackComboBox = new JComboBox(CommunicationStack.values()); commStackComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createButton.setEnabled(libraryCreatedOK = false); } }); commStackComboBox.setSelectedIndex(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -