示例#1
0
  @NotNull
  private JButton createSaveImageButton() {
    JButton saveImageButton = UiUtils.createSaveImageButton();
    saveImageButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String fileName = FileLog.getDate() + "_gauges.png";

            UiUtils.saveImageWithPrompt(fileName, content, gauges);
          }
        });
    return saveImageButton;
  }
示例#2
0
  private void findAndApplyPorts() {
    List<String> ports = findAllAvailablePorts();
    if (!currentlyDisplayedPorts.equals(ports) || isFirstTimeApplyingPorts) {
      FileLog.MAIN.logLine("Available ports " + ports);
      isFirstTimeApplyingPorts = false;
      connectPanel.setVisible(!ports.isEmpty());
      noPortsMessage.setVisible(ports.isEmpty());
      //        panel.add(comboSpeeds); // todo: finish speed selector UI component
      //            horizontalLine.setVisible(!ports.isEmpty());

      addPortSelection(ports);
      currentlyDisplayedPorts = ports;
      UiUtils.trueLayout(connectPanel);
      frame.pack();
    }
  }
示例#3
0
  public void chooseSerialPort() {

    leftPanel = new JPanel(new VerticalFlowLayout());
    leftPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10),
            BorderFactory.createLineBorder(Color.darkGray)));

    connectPanel.add(comboPorts);
    final JComboBox<String> comboSpeeds = createSpeedCombo();
    connectPanel.add(comboSpeeds);

    final JButton connect = new JButton("Connect");
    connectPanel.add(connect);
    connect.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            disposeFrameAndProceed();
            PortHolder.BAUD_RATE = Integer.parseInt((String) comboSpeeds.getSelectedItem());
            new Launcher(comboPorts.getSelectedItem().toString());
          }
        });

    leftPanel.add(connectPanel);
    leftPanel.add(noPortsMessage);
    installMessage(
        noPortsMessage,
        "Check you cables. Check your drivers. Do you want to start simulator maybe?");
    leftPanel.add(new URLLabel(VCP_DRIVER_TEXT, VCP_DRIVER_URI));
    leftPanel.add(new HorizontalLine());

    findAndApplyPorts();

    final JButton buttonLogViewer = new JButton();
    buttonLogViewer.setText("Start " + LinkManager.LOG_VIEWER);
    buttonLogViewer.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            disposeFrameAndProceed();
            new Launcher(LinkManager.LOG_VIEWER);
          }
        });

    leftPanel.add(buttonLogViewer);
    leftPanel.add(new HorizontalLine());

    leftPanel.add(SimulatorHelper.createSimulatorComponent(this));

    if (ProcessStatusWindow.isWindows()) {
      leftPanel.add(new HorizontalLine());
      leftPanel.add(
          new FirmwareFlasher(FirmwareFlasher.IMAGE_DEBUG_FILE, "Program Firmware/Debug")
              .getButton());
      leftPanel.add(new HorizontalLine());
      leftPanel.add(
          new FirmwareFlasher(FirmwareFlasher.IMAGE_RELEASE_FILE, "Program Firmware/Release")
              .getButton());
      leftPanel.add(new HorizontalLine());
      leftPanel.add(new EraseChip().getButton());
    }

    JPanel rightPanel = new JPanel(new VerticalFlowLayout());

    ImageIcon logoIcon = UiUtils.loadIcon(LOGO);
    if (logoIcon != null) {
      JLabel logo = new JLabel(logoIcon);
      logo.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
      URLLabel.addUrlAction(logo, URLLabel.createUri(URI));
      logo.setCursor(new Cursor(Cursor.HAND_CURSOR));
      rightPanel.add(logo);
    }
    rightPanel.add(new URLLabel(LINK_TEXT, URI));

    JPanel content = new JPanel(new BorderLayout());
    content.add(leftPanel, BorderLayout.WEST);
    content.add(rightPanel, BorderLayout.EAST);
    frame.add(content);
    frame.pack();
    frame.setVisible(true);
    UiUtils.centerWindow(frame);
  }
示例#4
0
 public static void setAppIcon(JFrame frame) {
   ImageIcon icon = UiUtils.loadIcon(APPICON);
   if (icon != null) frame.setIconImage(icon.getImage());
 }