コード例 #1
0
ファイル: StartupFrame.java プロジェクト: rusefi/rusefi
  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);
  }
コード例 #2
0
ファイル: StartupFrame.java プロジェクト: rusefi/rusefi
 public static void setAppIcon(JFrame frame) {
   ImageIcon icon = UiUtils.loadIcon(APPICON);
   if (icon != null) frame.setIconImage(icon.getImage());
 }