/**
   * Sets up the entire TableView with all its functionalities.
   *
   * @return The created TableView.
   */
  private TableView<FilterInput> setUpTableView() {
    // Set up table view
    final TableView<FilterInput> tableView = new TableView<>();
    tableView.setEditable(true);
    tableView.setMinWidth(522);
    tableView.setMinHeight(280);

    // Set up columns
    setUpFilterColumn(tableView);
    setUpTypeColumn(tableView);
    setUpOriginColumn(tableView);
    setUpColorColumn(tableView);
    setUpPriorityColumn(tableView);
    setUpLegalityColumn(tableView);
    setUpActiveColumn(tableView);

    // Insert data from database into table
    tableView.setItems(data);

    // Set select/deselect on mouse click
    tableView.setRowFactory(
        tableViewLambda -> {
          final TableRow<FilterInput> row = new TableRow<>();
          row.addEventFilter(
              MouseEvent.MOUSE_PRESSED,
              event -> {
                final int index = row.getIndex();
                if (index >= 0
                    && index < tableView.getItems().size()
                    && tableView.getSelectionModel().isSelected(index)) {
                  tableView.getSelectionModel().clearSelection();
                  event.consume();
                }
              });
          return row;
        });

    return tableView;
  }
Example #2
0
  /** Displays a human readable summary of the preferences chosen by the user on the main form */
  private void ShowPreferencesSummary() {
    Utilities.LogDebug("GpsMainActivity.ShowPreferencesSummary");
    try {
      TextView txtLoggingTo = (TextView) findViewById(R.id.txtLoggingTo);
      TextView txtFrequency = (TextView) findViewById(R.id.txtFrequency);
      TextView txtDistance = (TextView) findViewById(R.id.txtDistance);
      TextView txtAutoEmail = (TextView) findViewById(R.id.txtAutoEmail);

      if (!AppSettings.shouldLogToKml() && !AppSettings.shouldLogToGpx()) {
        txtLoggingTo.setText(R.string.summary_loggingto_screen);

      } else if (AppSettings.shouldLogToGpx() && AppSettings.shouldLogToKml()) {
        txtLoggingTo.setText(R.string.summary_loggingto_both);
      } else {
        txtLoggingTo.setText((AppSettings.shouldLogToGpx() ? "GPX" : "KML"));
      }

      if (AppSettings.getMinimumSeconds() > 0) {
        String descriptiveTime =
            Utilities.GetDescriptiveTimeString(
                AppSettings.getMinimumSeconds(), getApplicationContext());

        txtFrequency.setText(descriptiveTime);
      } else {
        txtFrequency.setText(R.string.summary_freq_max);
      }

      if (AppSettings.getMinimumDistanceInMeters() > 0) {
        if (AppSettings.shouldUseImperial()) {
          int minimumDistanceInFeet =
              Utilities.MetersToFeet(AppSettings.getMinimumDistanceInMeters());
          txtDistance.setText(
              ((minimumDistanceInFeet == 1)
                  ? getString(R.string.foot)
                  : String.valueOf(minimumDistanceInFeet) + getString(R.string.feet)));
        } else {
          txtDistance.setText(
              ((AppSettings.getMinimumDistanceInMeters() == 1)
                  ? getString(R.string.meter)
                  : String.valueOf(AppSettings.getMinimumDistanceInMeters())
                      + getString(R.string.meters)));
        }
      } else {
        txtDistance.setText(R.string.summary_dist_regardless);
      }

      if (AppSettings.isAutoEmailEnabled()) {
        String autoEmailResx;

        if (AppSettings.getAutoEmailDelay() == 0) {
          autoEmailResx = "autoemail_frequency_whenistop";
        } else {

          autoEmailResx =
              "autoemail_frequency_"
                  + String.valueOf(AppSettings.getAutoEmailDelay()).replace(".", "");
        }

        String autoEmailDesc =
            getString(getResources().getIdentifier(autoEmailResx, "string", getPackageName()));

        txtAutoEmail.setText(autoEmailDesc);
      } else {
        TableRow trAutoEmail = (TableRow) findViewById(R.id.trAutoEmail);
        trAutoEmail.setVisibility(View.INVISIBLE);
      }

      onFileName(Session.getCurrentFileName());
    } catch (Exception ex) {
      Utilities.LogError("ShowPreferencesSummary", ex);
    }
  }