/** Updates the enabled state of the buttons */
  private void updateButtonEnabledState() {
    boolean wpSelected = selectedWp >= 0;
    btnActivate.setEnabled(wpSelected && readOnlyRoute);
    btnDelete.setEnabled(wpSelected && !readOnlyRoute);
    btnZoomToWp.setEnabled(wpSelected && chartPanel != null);
    btnZoomToRoute.setEnabled(chartPanel != null);

    boolean allRowsLocked = checkLockedRows();
    arrivalPicker.setEnabled(!readOnlyRoute && !allRowsLocked);
    arrivalSpinner.setEnabled(!readOnlyRoute && !allRowsLocked);
  }
  private void initComboBoxes() {

    HashMap<String, ArrayList<Object>> map;

    // make sure the connection is open
    DBConnection.close(); // close old connection
    DBConnection.open(); // open new connection
    sql.setConnection(DBConnection.getConnection()); // set connection
    sql.createStatement(DBConnection.getConnection()); // create statement

    // Opened or Closed Dates
    cboxOpenCloseDB.removeAllItems();
    cboxOpenCloseDB.addItem(DATES_STILL_OPENED);
    cboxOpenCloseDB.addItem(DATES_CLOSED);
    cboxOpenCloseDB.addItem(DATES_OPENED);
    cboxOpenCloseDB.addItem(DATES_ALL);
    datePickerFrom.setEnabled(false);
    datePickerTo.setEnabled(false);
    Date date = new Date();
    datePickerTo.setDate(date);

    // App combobox
    map = sql.getDistinctColumnValues(DB_TABLE_NAME, COL_APP);
    cboxApp.removeAllItems();
    cboxApp.addItem(ALL);
    for (int i = 0; i < map.get(COL_APP).size(); i++) {
      cboxApp.addItem(map.get(COL_APP).get(i).toString());
    }

    // Programmer combobox
    map = sql.getDistinctColumnValues(DB_TABLE_NAME, COL_PROGRAMMER);
    cboxProgrammer.removeAllItems();
    cboxProgrammer.addItem(ALL);
    for (int i = 0; i < map.get(COL_PROGRAMMER).size(); i++) {
      cboxProgrammer.addItem(map.get(COL_PROGRAMMER).get(i).toString());
    }
  }
  /**
   * Configures the given date picker and associated time spinner
   *
   * @param picker the date picker
   * @param spinner the time spinner
   */
  private void initDatePicker(JXDatePicker picker, JSpinner spinner) {
    picker.setFormats(new SimpleDateFormat("E dd/MM/yyyy"));
    picker.addPropertyChangeListener("date", this);

    DateEditor editor = new JSpinner.DateEditor(spinner, "HH:mm");
    DateFormatter formatter = (DateFormatter) editor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);
    formatter.setOverwriteMode(true);
    formatter.setCommitsOnValidEdit(true);
    spinner.setEditor(editor);
    spinner.addChangeListener(new SpinnerChangeListener());

    // Set the enabled state
    picker.setEnabled(!readOnlyRoute);
    spinner.setEnabled(!readOnlyRoute);
  }
Example #4
0
 @Override
 public void setEnabled(boolean enabled) {
   datePicker.setEnabled(enabled);
 }