private void displayMetrics(Node node) { ObservableList<MetricResult> metrics = evaluateAllMetrics(node); metricResultsListView.setItems(metrics); notifyMetricsAvailable(metrics.stream() .map(MetricResult::getValue) .filter(result -> !result.isNaN()) .count()); }
/** Gets the index of the currently focused item. */ private int getFocusIdx() { if (!autoCompletePopup.isShowing()) { return -1; } List<ObservableSet<PseudoClass>> collect = autoCompletePopup.getItems() .stream() .map(this::getStyleableNode) .filter(Objects::nonNull) .map(Node::getPseudoClassStates) .collect(Collectors.toList()); for (int i = 0; i < collect.size(); i++) { if (collect.get(i).contains(PseudoClass.getPseudoClass("focused"))) { return i; } } return -1; }
/** * Creates a new GridPane, with proper column layout, and adds the editor items * in order * * @param properties the properties which should be rendered */ PropertyLayout(ObservableList<PropertyEditor.Item> properties){ this.index = new AtomicInteger(0); this.items = new HashSet<>(); getColumnConstraints().add(0, new ColumnConstraints(MIN_LABEL_WIDTH, USE_COMPUTED_SIZE, USE_PREF_SIZE, Priority.NEVER, HPos.LEFT, true)); getColumnConstraints().add(1, new ColumnConstraints(MIN_EDITOR_WIDTH, USE_COMPUTED_SIZE, Double.MAX_VALUE, Priority.ALWAYS, HPos.LEFT, true)); getStyleClass().add("properties-layout"); properties.stream().forEachOrdered( i -> addItem(i) ); }
strings.stream() .filter(elem -> elem.equalsIgnoreCase(value)) .forEach(elem -> duplicate.set(true));
/** * Given a toggle group whose toggles all have user data of type T, * maps the selected toggle property to a Var<T> */ @SuppressWarnings("unchecked") public static <T> Var<T> mapToggleGroupToUserData(ToggleGroup toggleGroup) { return Var.fromVal(toggleGroup.selectedToggleProperty(), toggleGroup::selectToggle) .mapBidirectional( item -> (T) item.getUserData(), t -> toggleGroup.getToggles() .stream() .filter(toggle -> toggle.getUserData().equals(t)) .findFirst() .orElseThrow(() -> new IllegalStateException("Unknown toggle " + t)) ); }
Node currentNode = pathToNode.next(); current = current.getChildren().stream() .filter(item -> item.getValue() == currentNode) .findAny()
change.getValueAdded().stream() .filter(HasExpandedProperty.class::isInstance) .map(d -> (DocumentProperty & HasExpandedProperty) d)
private void registerBasicValidators() { Validator<String> noWhitespaceName = Validator.createRegexValidator("Name cannot contain whitespace", "\\S*+", Severity.ERROR); Validator<String> emptyName = Validator.createEmptyValidator("Name required"); Validator<String> uniqueName = (c, val) -> { long sameNameDescriptors = backingDescriptorList.getOrElse(FXCollections.emptyObservableList()) .stream() .map(PropertyDescriptorSpec::getName) .filter(getName()::equals) .count(); return new ValidationResult().addErrorIf(c, "The name must be unique", sameNameDescriptors > 1); }; validationSupport.registerValidator(nameField, Validator.combine(noWhitespaceName, emptyName, uniqueName)); Validator<String> noWhitespaceDescription = Validator.createRegexValidator("Message cannot be whitespace", "(\\s*+\\S.*)?", Severity.ERROR); Validator<String> emptyDescription = Validator.createEmptyValidator("Message required"); validationSupport.registerValidator(descriptionField, Validator.combine(noWhitespaceDescription, emptyDescription)); }
xpath, ruleBuilder.getRuleProperties())); xpathResultListView.setItems(results.stream().map(parent::wrapNode).collect(Collectors.toCollection(LiveArrayList::new))); parent.highlightXPathResults(results); violationsTitledPane.setTitle("Matched nodes (" + results.size() + ")");
builder.usesMultifile(usesMultifile.getValue()); ruleProperties.getValue().stream().map(PropertyDescriptorSpec::build).forEach(builder::defineProperty); examples.getValue().forEach(builder::addExample);
@Override public void saveStateTo(Map<String, String> data) { data.put("levelCombo.levels", getItems().stream().collect(Collectors.joining(","))); data.put("levelCombo.selected", ofNullable(getValue()).orElse("")); }
@Override public void restoreStateFrom(Map<String, String> data) { field.setText(Optional.ofNullable(data.get("size")).orElse(EMPTY)); group.getToggles().stream().map(t -> { return (SizeUnitRadio) t; }).forEach(s -> s.restoreStateFrom(data)); }
@Override public void saveStateTo(Map<String, String> data) { data.put("size", defaultString(field.getText())); group.getToggles().stream().map(t -> { return (SizeUnitRadio) t; }).forEach(s -> s.saveStateTo(data)); }
@EventListener public void onSetPageRanges(SetPageRangesRequest event) { getItems().stream().forEach(i -> i.pageSelection.set(event.range)); }
@Override public void apply(MergeParametersBuilder builder, Consumer<String> onError) { try { table().getItems().stream().filter(s -> !Objects.equals("0", trim(s.pageSelection.get()))) .map(i -> new PdfMergeInput(i.descriptor().toPdfFileSource(), i.toPageRangeSet())) .forEach(builder::addInput); if (!builder.hasInput()) { onError.accept(DefaultI18nContext.getInstance().i18n("No PDF document has been selected")); } } catch (ConversionException e) { LOG.error(e.getMessage()); onError.accept(e.getMessage()); } } }
@Override public void apply(RotateParametersBuilder builder, Consumer<String> onError) { try { table().getItems().stream().filter(s -> !Objects.equals("0", trim(s.pageSelection.get()))) .forEach(i -> builder.addInput(i.descriptor().toPdfFileSource(), i.toPageRangeSet())); if (!builder.hasInput()) { onError.accept(DefaultI18nContext.getInstance().i18n("No PDF document has been selected")); } } catch (ConversionException e) { LOG.error(e.getMessage()); onError.accept(e.getMessage()); } } }
@Override public void apply(ExtractParametersBuilder builder, Consumer<String> onError) { try { table().getItems().stream().forEach(i -> builder.addSource(i.descriptor().toPdfFileSource())); if (!builder.hasInput()) { onError.accept(DefaultI18nContext.getInstance().i18n("No PDF document has been selected")); } } catch (ConversionException e) { LOG.error(e.getMessage()); onError.accept(e.getMessage()); } } }
private void copySelectedToClipboard() { ClipboardContent content = new ClipboardContent(); writeContent(getSelectionModel().getSelectedItems().stream().map(item -> { return item.descriptor().getFile().getAbsolutePath() + ", " + item.descriptor().getFile().length() + ", " + item.descriptor().pages().getValue(); }).collect(Collectors.toList())).to(content); Clipboard.getSystemClipboard().setContent(content); }
SplitOptionsPane() { this.field.setOnEnterValidation(true); this.field.setEnableInvalidStyle(true); this.field.setPromptText(DefaultI18nContext.getInstance().i18n("Set the size to split at")); this.field.setValidator(Validators.positiveInteger()); this.field.setErrorMessage(DefaultI18nContext.getInstance().i18n("Size must be a number")); this.field.setId("sizeField"); getStyleClass().addAll(Style.CONTAINER.css()); getStyleClass().addAll(Style.HCONTAINER.css()); getChildren().addAll(new Label(DefaultI18nContext.getInstance().i18n("Split at this size:")), this.field); Arrays.stream(SizeUnit.values()).map(SizeUnitRadio::new).forEach(r -> { r.setToggleGroup(group); getChildren().add(r); }); group.getToggles().stream().findFirst().ifPresent(t -> t.setSelected(true)); }
private void removeValue(R value) { boolean removedLastDuplicate = filterValuesDupeCounter.remove(value) == 0; if (removedLastDuplicate) { // Remove the FilterValue associated with the value Optional<FilterValue<T,R>> existingFilterValue = getFilterValues().stream() .filter(fv -> Objects.equals(fv.getValue(), value)).findAny(); if (existingFilterValue.isPresent()) getFilterValues().remove(existingFilterValue.get()); } } private void addVisibleItem(ObservableValue<R> cellValue) {