public static <S, C> ListBinding<C> selectList(ObservableValue<S> source, Function<S, ObservableList<C>> getList) { return new ListBinding<C>() { { bind(source); } @Override protected ObservableList<C> computeValue() { S sourceValue = source.getValue(); if (sourceValue != null) { return getList.apply(sourceValue); } else { return FXCollections.emptyObservableList(); } } }; }
private void initializeColumnsTable() { columnsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); newColumnHeaderField.setMaxWidth(headerColumn.getPrefWidth()); newColumnGroupField.setMaxWidth(capturingGroupColumn.getPrefWidth()); ListBinding<ColumnDefinition> columnDefinitions = UIUtils.selectList(columnizersPane.selectedItemProperty(), Columnizer::getColumnDefinitions); visibleColumn.setCellFactory( CheckBoxTableCell.forTableColumn(index -> columnDefinitions.get(index).visibleProperty())); visibleColumn.setCellValueFactory(data -> data.getValue().headerLabelProperty()); headerColumn.setCellFactory(TextFieldTableCell.forTableColumn()); headerColumn.setCellValueFactory(data -> data.getValue().headerLabelProperty()); capturingGroupColumn.setCellFactory(TextFieldTableCell.forTableColumn()); capturingGroupColumn.setCellValueFactory(data -> data.getValue().capturingGroupNameProperty()); descriptionColumn.setCellFactory(TextFieldTableCell.forTableColumn()); descriptionColumn.setCellValueFactory(data -> data.getValue().descriptionProperty()); columnsTable.itemsProperty().bind(columnDefinitions); initializeDeleteButtons(); }
public ListBinding<TestRunModel> runsProperty() { return new ListBinding<TestRunModel>() { { super.bind(selectedBatchProperty()); } @Override protected ObservableList<TestRunModel> computeValue() { TestBatchModel selectedBatch = selectedBatchProperty().get(); if (selectedBatch == null) { return FXCollections.emptyObservableList(); } return selectedBatchProperty().get().testRunsProperty(); } }; }
public ListBinding<WeightedPolicyModel> weightedPoliciesProperty() { return new ListBinding<WeightedPolicyModel>() { { super.bind(selectedPolicyProperty()); } @Override protected ObservableList<WeightedPolicyModel> computeValue() { CompositePolicyModel selectedPolicy = selectedPolicyProperty().get(); if (selectedPolicy == null) { return FXCollections.emptyObservableList(); } return selectedPolicy.weightedPoliciesProperty(); } }; }
public ListBinding<PolicyModel> newWeightedPolicy_policiesProperty() { return new ListBinding<PolicyModel>() { { super.bind(allPoliciesProperty()); super.bind(selectedPolicyProperty()); } @Override protected ObservableList<PolicyModel> computeValue() { ObservableList<PolicyModel> policies = allPoliciesProperty().get(); if (policies == null) return null; CompositePolicyModel selected = selectedPolicyProperty().get(); if (selected == null) return policies; // Add allowed policies ObservableList<PolicyModel> filtered = FXCollections.observableArrayList(); for (PolicyModel policyModel : policies) { if (selected.getPolicy().canHaveAsTestSortingPolicy(policyModel.getPolicy())) { filtered.add(policyModel); } } return filtered; } }; }
private void initializeRulesPane() { ObservableObjectValue<Colorizer> selectedColorizer = colorizersPane.selectedItemProperty(); selectedColorizerPane.disableProperty().bind(Bindings.isNull(selectedColorizer)); ListBinding<StyleRule> selectedColorizerRules = UIUtils.selectList(selectedColorizer, Colorizer::getRules); rulesPane.setItemFactory(StyleRule::new); rulesPane.setItemDuplicator(StyleRule::new); rulesPane.getList().itemsProperty().bind(selectedColorizerRules); }
private void initializePatternsPane() { ReadOnlyObjectProperty<Columnizer> selectedColumnizer = columnizersPane.selectedItemProperty(); selectedColumnizerPane.disableProperty().bind(selectedColumnizer.isNull()); ListBinding<Pattern> patterns = UIUtils.selectList(selectedColumnizer, Columnizer::getPatterns); Predicate<String> isValidRegex = regex -> createPattern(regex) != null; patternsPane.setItemFactory(ColumnizersController::createPattern); patternsPane.setItemDuplicator(p -> p); // not updated anyway patternsPane.setNewItemValidator(isValidRegex); patternsPane.getList().setConverter(ColumnizersController::createPattern, Pattern::pattern, isValidRegex); patternsPane.getList().itemsProperty().bind(patterns); initializeColumnsTable(); }
public ListBinding<LOSPickingPosition> getMatchingPicks(ObservableValue<TreatOrderPosition> posProperty) { return new ListBinding<LOSPickingPosition>() { { bind(posProperty); } @Override protected ObservableList<LOSPickingPosition> computeValue() { TreatOrderPosition pos = posProperty.getValue(); if (pos == null) return FXCollections.emptyObservableList(); String posNumber = pos.getNumber(); return pickingPositions.filtered(p -> Strings.equals(p.getCustomerOrderPosition().getNumber(), posNumber)); } }; }
public ListBinding<LOSPickingPosition> getPicklistPositions(ObservableValue<LOSPickingOrder> pickValue) { return new ListBinding<LOSPickingPosition>() { { bind(pickValue); } @Override protected ObservableList<LOSPickingPosition> computeValue() { LOSPickingOrder pick = pickValue.getValue(); if (pick == null) return FXCollections.emptyObservableList(); String posNumber = pick.getNumber(); return pickingPositions.filtered(p -> Strings.equals(p.getPickingOrderNumber(), posNumber)); } }; }
@Override protected void initializePresenter() { tilesMapping = new MappedObservableList<>(tileService.getTiles(StackingStatus.SHOWN, StackingStatus.HIDDEN), this::createTile); tileContainerElements = new ListBinding<Node>() { ObservableIntegerValue maxShownTiles = tileService.maxShownTilesProperty(); { bind(tilesMapping, maxShownTiles); } @Override protected ObservableList<Node> computeValue() { List<Node> elements = new ArrayList<>(); int maxShown = maxShownTiles.get(); if (maxShown > 0 && elements.size() > 0) { elements.add(view.shownTilesLabel); } int i = 0; for (Tile tile : tilesMapping) { if (i == maxShown) { elements.add(view.hiddenTileLabel); } elements.add(tile); i++; } return FXCollections.observableList(elements); } }; Bindings.bindContent(view.tilesContainer.getChildren(), tileContainerElements); bindManagementTile(); }
public ListBinding<T> wrappedListProperty() { return wrappedListBinding; }