Exemple #1
0
  public void afterPropertiesSet() throws Exception {
    // Attempt to retrieve settings persisted locally (if exist).
    try {
      tanitaLocalSettings = settingsHelper.retrieveSettings();
    } catch (CouldNotRetrieveSettingsException e) {
    }

    log.info("Setting bioimpedance-locale to {}", getLocale().getDisplayLanguage());

    tanitaResourceBundle = ResourceBundle.getBundle("bioimpedance-instrument", getLocale());
    appWindow = new JFrame(tanitaResourceBundle.getString("Title.Tanita"));
    saveDataBtn.setToolTipText(tanitaResourceBundle.getString("ToolTip.Save_and_return"));
    saveDataBtn.setText(tanitaResourceBundle.getString("Save"));
  }
Exemple #2
0
  /** Reestablish a lost connection. */
  protected void reestablishConnection() {

    String[] options = {
      tanitaResourceBundle.getString("OK"),
      tanitaResourceBundle.getString("Cancel"),
      tanitaResourceBundle.getString("Settings")
    };

    // Loop until connection is reestablished.
    int selectedOption;
    while (serialPort == null || !serialPort.isCTS()) {

      selectedOption =
          JOptionPane.showOptionDialog(
              appWindow,
              tanitaResourceBundle.getString("Err.No_communication"),
              tanitaResourceBundle.getString("Title.Communication_problem"),
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.ERROR_MESSAGE,
              null,
              options,
              tanitaResourceBundle.getString("OK"));

      // OK option selected.
      if (selectedOption == 0) {

        // Try to reestablish connection.
        setupSerialPort();

        // Cancel option selected.
      } else if (selectedOption == 1) {

        exitUI();
        break;

        // Configuration option selected.
      } else if (selectedOption == 2) {

        // List all serial port in a drop down list, so a new one can be
        // selected.
        refreshSerialPortList();
        String selectedPort =
            (String)
                JOptionPane.showInputDialog(
                    appWindow,
                    tanitaResourceBundle.getString("Instruction.Choose_port"),
                    tanitaResourceBundle.getString("Title.Settings"),
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    availablePortNames.toArray(),
                    getTanitaCommPort());

        if (selectedPort != null) {
          setTanitaCommPort(selectedPort);

          try {
            settingsHelper.saveSettings(tanitaLocalSettings);
          } catch (CouldNotSaveSettingsException e) {
            log.error("Local settings could not be persisted.", e);
          }

          setupSerialPort();
        } else {
          exitUI();
        }
      }
    }
  }