public void setFddObjectModel(FddObjectModel fddObjectModel) {
    logger.entry();
    if (fddObjectModel != null) {
      fddObjectModel
          .getInteractionClasses()
          .values()
          .stream()
          .forEach(
              (value) -> {
                interactions.add(new InteractionState(value));
              });
      InteractionTableView.setItems(interactions);
      interactions.forEach(
          (interaction) -> {
            interaction
                .onProperty()
                .addListener(
                    (observable, oldValue, newValue) -> {
                      if (!newValue) {
                        cb.setSelected(false);
                      } else if (interactions.stream().allMatch(a -> a.isOn())) {
                        cb.setSelected(true);
                      }
                    });
          });
      InteractionTableColumn.setCellValueFactory(new PropertyValueFactory<>("interactionName"));
      CheckTableColumn.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<InteractionState, Boolean>, ObservableValue<Boolean>>() {
            @Override
            public ObservableValue<Boolean> call(
                TableColumn.CellDataFeatures<InteractionState, Boolean> param) {
              return param.getValue().onProperty();
            }
          });

      CheckTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(CheckTableColumn));
      cb.setUserData(CheckTableColumn);
      cb.setOnAction(
          (ActionEvent event) -> {
            CheckBox cb1 = (CheckBox) event.getSource();
            TableColumn tc = (TableColumn) cb1.getUserData();
            InteractionTableView.getItems()
                .stream()
                .forEach(
                    (item) -> {
                      item.setOn(cb1.isSelected());
                    });
          });
      CheckTableColumn.setGraphic(cb);
    }
    logger.exit();
  }
Ejemplo n.º 2
0
  /**
   * 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;
  }
Ejemplo n.º 3
0
 void fillTracks(List<Track> tracks) {
   ObservableList<Track> items = FXCollections.observableArrayList(tracks);
   tracksView.setItems(items);
 }