コード例 #1
0
  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
 public List<InteractionClassFDD> getInteractions() {
   return interactions
       .stream()
       .filter(a -> a.isOn())
       .map(a -> a.interaction)
       .collect(Collectors.toList());
 }
コード例 #3
0
    @Override
    protected Registration follow(ObservableList<ItemT> srcList) {
      for (int i = 0; i < srcList.size(); i++) {
        add(i, srcList.get(i));
      }

      return srcList.addListener(
          new CollectionAdapter<ItemT>() {
            @Override
            public void onItemAdded(CollectionItemEvent<? extends ItemT> event) {
              add(event.getIndex(), event.getNewItem());
            }

            @Override
            public void onItemRemoved(CollectionItemEvent<? extends ItemT> event) {
              remove(event.getIndex());
            }
          });
    }
コード例 #4
0
 public static <ItemT> ObservableList<ItemT> toObservable(List<ItemT> l) {
   ObservableList<ItemT> result = new ObservableArrayList<>();
   result.addAll(l);
   return result;
 }