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();
  }
Пример #2
0
  /**
   * Create the active column, which holds the activity state and also creates a callback to the
   * string property behind it.
   */
  private void setUpActiveColumn(TableView<FilterInput> tableView) {
    // Set up active column
    final TableColumn<FilterInput, Boolean> activeColumn = new TableColumn<>("Active");
    activeColumn.setMinWidth(50);
    activeColumn.setPrefWidth(50);
    tableView.getColumns().add(activeColumn);
    activeColumn.setSortable(false);

    activeColumn.setCellFactory(
        CheckBoxTableCell.forTableColumn(
            (Callback<Integer, ObservableValue<Boolean>>)
                param -> {
                  final FilterInput input = tableView.getItems().get(param);
                  input
                      .getActiveProperty()
                      .addListener(
                          l -> {
                            notifyUpdateCommand(input);
                          });
                  return input.getActiveProperty();
                }));
  }
 @Override
 public void initialize(URL location, ResourceBundle resources) {
   // cellvaluefactory
   checkedColumn.setCellValueFactory(new PropertyValueFactory<>("checked"));
   columnNameColumn.setCellValueFactory(new PropertyValueFactory<>("columnName"));
   jdbcTypeColumn.setCellValueFactory(new PropertyValueFactory<>("jdbcType"));
   propertyNameColumn.setCellValueFactory(new PropertyValueFactory<>("propertyName"));
   typeHandlerColumn.setCellValueFactory(new PropertyValueFactory<>("typeHandler"));
   // Cell Factory that customize how the cell should render
   checkedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(checkedColumn));
   javaTypeColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   // handle commit event to save the user input data
   javaTypeColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setJavaType(event.getNewValue());
       });
   propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   propertyNameColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setPropertyName(event.getNewValue());
       });
   typeHandlerColumn.setCellFactory(TextFieldTableCell.forTableColumn());
   typeHandlerColumn.setOnEditCommit(
       event -> {
         event
             .getTableView()
             .getItems()
             .get(event.getTablePosition().getRow())
             .setTypeHandle(event.getNewValue());
       });
 }