Exemplo n.º 1
0
  private void updateSelection() {
    /*
     * This cell should be selected if the selection mode of the table
     * is cell-based, and if the row and column that this cell represents
     * is selected.
     *
     * If the selection mode is not cell-based, then the listener in the
     * TableRow class might pick up the need to set an entire row to be
     * selected.
     */
    if (isEmpty()) return;

    final boolean isSelected = isSelected();
    if (!isInCellSelectionMode()) {
      if (isSelected) {
        updateSelected(false);
      }
      return;
    }

    final TableView<S> tableView = getTableView();
    if (getIndex() == -1 || tableView == null) return;

    TableSelectionModel<S> sm = tableView.getSelectionModel();
    if (sm == null) return;

    boolean isSelectedNow = sm.isSelected(getIndex(), getTableColumn());
    if (isSelected == isSelectedNow) return;

    updateSelected(isSelectedNow);
  }