private void initRegisteredCommandsListener() { this.registeredCommands.addListener((ListChangeListener<Command>) c -> { while (c.next()) { if (registeredCommands.isEmpty()) { executable.unbind(); running.unbind(); progress.unbind(); } else { BooleanBinding executableBinding = constantOf(true); BooleanBinding runningBinding = constantOf(false); for (Command registeredCommand : registeredCommands) { ReadOnlyBooleanProperty currentExecutable = registeredCommand.executableProperty(); ReadOnlyBooleanProperty currentRunning = registeredCommand.runningProperty(); executableBinding = executableBinding.and(currentExecutable); runningBinding = runningBinding.or(currentRunning); } executable.bind(executableBinding); running.bind(runningBinding); initProgressBinding(); } } }); }
public static BooleanBinding toBooleanBinding(final ObservableValue<Boolean> ov) { if (ov == null) { throw new NullPointerException("Operand cannot be null."); } return new BooleanBinding() { { super.bind(ov); } @Override public void dispose() { super.unbind(ov); } @Override protected boolean computeValue() { return ov.getValue() != Boolean.FALSE; } @Override public ObservableList<?> getDependencies() { return FXCollections.singletonObservableList(ov); } }; }
@Override public void initialize(URL url, ResourceBundle rb) { rack.getItems().addAll(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8)); rack.getSelectionModel().select(0); slot.getItems().addAll(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8)); slot.getSelectionModel().select(0); session.bind(host.textProperty(), "connect.host"); BooleanBinding disabled = bindings.connectedProperty().or(bindings.progressProperty()); connect.disableProperty().bind(disabled.or(host.textProperty().isEmpty())); host.disableProperty().bind(disabled); rack.disableProperty().bind(disabled); slot.disableProperty().bind(disabled); watchdog.disableProperty().bind(disabled); disconnect.disableProperty().bind(bindings.connectedProperty().not().or(bindings.progressProperty())); bindings.connectedProperty().addListener((l, a, con) -> update(con)); pingService.setOnPingFailed(this::pingFailed); watchdog.selectedProperty().bindBidirectional(bindings.pingWatchdogProperty()); session.bind(watchdog.selectedProperty(), "ping.watchdog"); reset(); }
@Override @FXThread protected @NotNull ObservableBooleanValue buildAdditionalDisableCondition() { final VirtualResourceTree<C> resourceTree = getResourceTree(); final MultipleSelectionModel<TreeItem<VirtualResourceElement<?>>> selectionModel = resourceTree.getSelectionModel(); final ReadOnlyObjectProperty<TreeItem<VirtualResourceElement<?>>> selectedItemProperty = selectionModel.selectedItemProperty(); final Class<C> type = getObjectsType(); final BooleanBinding typeCondition = new BooleanBinding() { @Override protected boolean computeValue() { final TreeItem<VirtualResourceElement<?>> treeItem = selectedItemProperty.get(); return treeItem == null || !type.isInstance(treeItem.getValue().getObject()); } @Override public Boolean getValue() { return computeValue(); } }; return Bindings.or(selectedItemProperty.isNull(), typeCondition); }
private void initializeProperties() { imagesFoundProperty = new SimpleBooleanProperty(Boolean.FALSE); nameBinding = tfName.textProperty().isEmpty(); selectedBinding = cbMap.getSelectionModel().selectedIndexProperty().isEqualTo(-1); disableBinding = new BooleanBinding() { { super.bind(imagesFoundProperty, nameBinding, selectedBinding); } @Override protected boolean computeValue() { if (imagesFoundProperty.not().getValue()) { return true; } return nameBinding.getValue() || selectedBinding.getValue(); } }; bCreate.disableProperty().bind(disableBinding); }
@Override public void initialize(URL location, ResourceBundle resources) { UIUtils.makeClearable(searchTextField); BooleanBinding disableMatchBrowsing = Bindings.createBooleanBinding(matchRows::isEmpty, matchRows); nextButton.disableProperty().bind(disableMatchBrowsing); previousButton.disableProperty().bind(disableMatchBrowsing); // TODO regex mode feature regexCheckBox.setDisable(true); search.textProperty().bind(searchTextField.textProperty()); search.matchCaseProperty().bind(matchCaseCheckBox.selectedProperty()); search.regexModeProperty().bind(regexCheckBox.selectedProperty()); Binding<Integer> matchRowsCount = Bindings.createObjectBinding(matchRows::size, matchRows); Binding<Integer> currentMatchRowIndexOneBased = Bindings.createObjectBinding(() -> { return currentMatchRowIndex.get() == null ? 0 : currentMatchRowIndex.get() + 1; }, currentMatchRowIndex); matchNavigationLabel.currentCountProperty().bind(currentMatchRowIndexOneBased); matchNavigationLabel.totalCountProperty().bind(matchRowsCount); matchNavigationLabel.visibleProperty().bind(currentMatchRowIndex.isNotNull()); }
private void configuraBindings() { // esse binding só e false quando os campos da tela estão preenchidos BooleanBinding camposPreenchidos = txtConsc.textProperty().isEmpty().or(txtDesc.textProperty().isEmpty()) .or(dpVencimento.valueProperty().isNull()); // indica se há algo selecionado na tabela BooleanBinding algoSelecionado = tblContas.getSelectionModel().selectedItemProperty().isNull(); // alguns botões só são habilitados se algo foi selecionado na tabela btnApagar.disableProperty().bind(algoSelecionado); btnAtualizar.disableProperty().bind(algoSelecionado); btnLimpart.disableProperty().bind(algoSelecionado); // o botão salvar só é habilitado se as informações foram preenchidas e não tem nada na tela btnSalvar.disableProperty().bind(algoSelecionado.not().or(camposPreenchidos)); // quando algo é selecionado na tabela, preenchemos os campos de entrada com os valores para o // usuário editar tblContas.getSelectionModel().selectedItemProperty().addListener((b, o, n) -> { if (n != null) { LocalDate data = null; data = n.getDataVencimento().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); txtConsc.setText(n.getConcessionaria()); txtDesc.setText(n.getDescricao()); dpVencimento.setValue(data); } }); }
private void updateHost() { Dialog<String> dialog = new Dialog<String>("Host", null); TextField hostField = new TextField(TicTacToe.getHost()); dialog.setContent(hostField); Button okButton = new Button("OK"); okButton.setOnAction(e -> { dialog.setResult(hostField.getText()); dialog.hide(); }); BooleanBinding urlBinding = Bindings.createBooleanBinding( () -> isUrlValid(hostField.getText()), hostField.textProperty()); okButton.disableProperty().bind(urlBinding.not()); Button cancelButton = new Button("CANCEL"); cancelButton.setOnAction(e -> dialog.hide()); dialog.getButtons().addAll(okButton,cancelButton); dialog.showAndWait().ifPresent( url -> TicTacToe.setHost(url)); }
@FXML private void initialize() { setupWindowCloseRequestListener(); fileExplorer.addEventHandler(ResourceEvent.openResourceEvent(), e -> openResources(e.getResourceItems())); setRootDir( getFurthestExistingSubDir(FileSystemView.getFileSystemView().getDefaultDirectory(), "mpl")); ObservableList<ResourceItem> items = fileExplorer.getSelectedItems(); BooleanBinding disable = Bindings.createBooleanBinding(() -> items.size() != 1, items); newFileMenuItem.disableProperty().bind(disable); newDirectoryMenuItem.disableProperty().bind(disable); renameResourceMenuItem.disableProperty().bind(disable); contextNewFileMenuItem.disableProperty().bind(disable); contextNewDirectoryMenuItem.disableProperty().bind(disable); contextRenameResourceMenuItem.disableProperty().bind(disable); }
/** * Constructor */ public ViewCustomer() { // Create left part: Products Label productsLabel = new Label("Products"); HBox buyGroup = new HBox(buyButton, quantityInput); VBox productsBox = new VBox(productsLabel, productsTableView, buyGroup); this.quantityInput.setPromptText("Quantity..."); // Create right part: Orders Label ordersLAbel = new Label("Orders"); VBox ordersBox = new VBox(ordersLAbel, ordersTableView); // Setting up splitpane with product and orders section SplitPane contentPane = new SplitPane(productsBox, ordersBox); contentPane.prefHeightProperty().bind(this.heightProperty()); this.setMinHeight(300); // Add Splitpane to View this.getChildren().add(contentPane); // Activate add button only when all required input fields are filled BooleanBinding booleanBinding = quantityInput .textProperty() .isEqualTo(""); buyButton.disableProperty().bind(booleanBinding); }
private BooleanBinding getHasMissingConnectionSettingsBinding() { BooleanBinding hasMissingPassword = youTrackPassword.isEmpty(); BooleanBinding hasMissingOAuthSettings = hasMissingPassword .or(youTrackOAuth2ServiceId.isEmpty()) .or(youTrackOAuth2ServiceSecret.isEmpty()) .or(youTrackHubUrl.isEmpty()); BooleanBinding hasMissingPermanentToken = youTrackPermanentToken.isEmpty(); return youTrackUrl.isEmpty() .or(youTrackVersion.isNull()) .or(youTrackAuthenticationMethod.isNull()) .or(youTrackUsername.isEmpty()) .or(requiresPassword.and(hasMissingPassword)) .or(requiresOAuthSettings.and(hasMissingOAuthSettings)) .or(requiresPermanentToken.and(hasMissingPermanentToken)); }
@Override public void initialize(URL url, ResourceBundle rb) { _activeProfile = getActiveProfile().orElse(null); if (_activeProfile != null) { SettingsService settings = (SettingsService) ServiceLocator.getService(SettingsService.class); settings.putSetting(Constants.SETTING_ACTIVE_PROFILE, _activeProfile.getProfileName()); for (Category c : _activeProfile.getCategories()) { MainTabPane.getTabs().add(new CategoryTabController(c)); } } _tabSelection = MainTabPane.getSelectionModel(); _tabSelection.selectFirst(); BooleanBinding enableButtonsBinding = ((CategoryTabController)_tabSelection.selectedItemProperty().get()) .selectedScriptNodeProperty().isNull() .or(((CategoryTabController)_tabSelection.selectedItemProperty().get()) .selectedScriptNodeIsLeafProperty().not()); //Only enable the Replace button if we actually have a sound selected. ReplaceButton.disableProperty().bind(enableButtonsBinding); RevertButton.disableProperty().bind(enableButtonsBinding); }
public void initialise(final Button buttonUnseen, final Button buttonKnown, final Button buttonUnknown, final SessionModel sessionModel, final ObjectBinding<WordState> wordStateProperty, final Runnable nextWordSelector) { this.sessionModel = sessionModel; this.nextWordSelector = nextWordSelector; SimpleBooleanProperty editableProperty = sessionModel.editableProperty(); BooleanBinding resettableProperty = editableProperty.and(notEqual(WordState.UNSEEN, wordStateProperty)); buttonUnseen.visibleProperty().bind(resettableProperty); buttonKnown.visibleProperty().bind(editableProperty); buttonUnknown.visibleProperty().bind(editableProperty); buttonUnseen.setOnAction(e -> processResponse(WordState.UNSEEN, false)); buttonKnown.setOnAction(e -> processResponse(WordState.KNOWN, true)); buttonUnknown.setOnAction(e -> processResponse(WordState.UNKNOWN, true)); }
public RfxContentBottomToolbarButton createCancelButton(UserInterfaceContainer userInterfaceContainer, RfxFormView formView) { @SuppressWarnings("rawtypes") GraphicalUserinterfaceController userInterfaceController = userInterfaceContainer .get(GraphicalUserinterfaceController.class); ViewContainer viewContainer = userInterfaceController .getViewContainer(); LanguageProvider languageProvider = userInterfaceContainer .get(LanguageProvider.class); CancelItem cancelItem = new CancelItem(languageProvider, viewContainer, formView); RfxContentBottomToolbarButton cancelButton = new RfxContentBottomToolbarButton(cancelItem); RfxWindow window=userInterfaceContainer.get(RfxWindow.class); BooleanBinding extraWideBinding = window.getExtraWideBinding(); cancelButton.visibleProperty().bind(extraWideBinding); return cancelButton; }
public RfxAppTitleBar(UserInterfaceContainer userInterfaceContainer) { RfxWindow rfxWindow=userInterfaceContainer.get(RfxWindow.class); BooleanBinding windowExtraHighBinding = rfxWindow.getExtraHighBinding(); setMinHeight(BAR_HEIGHT); visibleProperty().bind(windowExtraHighBinding); NumberBinding heightBinding = Bindings.when(windowExtraHighBinding).then(BAR_HEIGHT) .otherwise(0); minHeightProperty().bind(heightBinding); maxHeightProperty().bind(heightBinding); String title = getTitle(userInterfaceContainer); Label titleLabel = new Label(title); String style = new RfxStyleProperties() .setTextFill(MaterialColorSetCssName.PRIMARY.FOREGROUND1()) .setAlignment(Pos.CENTER_LEFT).setFont(MaterialFont.getTitle()) .setPadding(0, 0, 0, 16).toString(); titleLabel.setStyle(style); getChildren().add(titleLabel); }
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); root_.add(new Label("Role Type"), 0, 0); root_.add(roleType_.getNode(), 1, 0); root_.add(new Label("Role Value"), 0, 1); root_.add(roleValue_.getNode(), 1, 1); FxUtils.preventColCollapse(root_, 0); GridPane.setHgrow(roleValue_.getNode(), Priority.ALWAYS); //TODO (artf231870) are there restrictions on concepts that can be roles? allValid_ = new BooleanBinding() { { super.bind(roleType_.isValid(), roleValue_.isValid()); } @Override protected boolean computeValue() { return roleType_.isValid().get() && roleValue_.isValid().get(); } }; }
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); root_.add(new Label("New Role Type"), 0, 0); root_.add(newRoleType_.getNode(), 1, 0); root_.add(new Label("New Role Value"), 0, 1); root_.add(newRoleValue_.getNode(), 1, 1); FxUtils.preventColCollapse(root_, 0); GridPane.setHgrow(newRoleValue_.getNode(), Priority.ALWAYS); //TODO (artf231870) are there restrictions on concepts that can be roles? allValid_ = new BooleanBinding() { { super.bind(newRoleType_.isValid(), newRoleValue_.isValid()); } @Override protected boolean computeValue() { return newRoleType_.isValid().get() && newRoleValue_.isValid().get(); } }; }
@Override public void init(ObservableList<SimpleDisplayConcept> conceptList) { super.init(conceptList); root_.add(new Label("To refset"), 0, 0); root_.add(toRefset_.getNode(), 1, 0); rvs_.setup(root_, 1); allValid_ = new BooleanBinding() { { bind(toRefset_.isValid(), rvs_.isValid()); } @Override protected boolean computeValue() { return toRefset_.isValid().get() && rvs_.isValid().get(); } }; GridPane.setHgrow(toRefset_.getNode(), Priority.ALWAYS); FxUtils.preventColCollapse(root_, 0); }
/** * {@inheritDoc} */ @Override protected void initView() { // final FlowPane fp = FlowPaneBuilder.create() // .children(new ImageView(MTImages.MT_TITLE.get())) // .build(); // fp.setAlignment(Pos.CENTER); this.topPane = new FlowPane(Orientation.VERTICAL); this.topPane.setPrefHeight(100); node().setTop(this.topPane); node().setCenter(buildGameConfigPanel()); // getRootNode().setBottom(buildStartGamePanel()); // Ui binding final BooleanBinding bb1 = Bindings.or(this.addition.selectedProperty(), this.subtraction.selectedProperty()); final BooleanBinding bb2 = Bindings.or(this.multiplication.selectedProperty(), this.division.selectedProperty()); final BooleanBinding bb = Bindings.or(bb1, bb2); this.playButton.disableProperty().bind(bb.and(this.lengthGroup.selectedToggleProperty().isNotNull()).not()); }
@Override public void initialize(URL url, ResourceBundle r) { BooleanBinding textNotEmpty = field.textProperty().isEqualTo("").not(); BooleanBinding labelActive = textNotEmpty.or(field.focusedProperty()); BooleanBinding fieldActive = textNotEmpty.and(field.focusedProperty()); labelActive.addListener(new LabelFadeIn()); fieldActive.addListener(new FieldActiveStyler()); label.setVisible(false); label.visibleProperty().bind(labelActive); label.textProperty().bind(field.promptTextProperty()); label.setLabelFor(field); // make sure that any click within this control will give focus to the input field field.getParent().setOnMouseClicked((e) -> { field.requestFocus(); }); }
private void initCopyCutPaste() { val selectionEmpty = new BooleanBinding() { { bind(editor.selectionProperty()); } @Override protected boolean computeValue() { return editor.getSelection().getLength() == 0; } }; cutButton.disableProperty().bind(selectionEmpty); copyButton.disableProperty().bind(selectionEmpty); cutButton.setOnAction(editorAction(editor::cut)); copyButton.setOnAction(editorAction(editor::copy)); pasteButton.setOnAction(editorAction(editor::paste)); }
private BooleanBinding constantOf(boolean defaultValue) { return new BooleanBinding() { @Override protected boolean computeValue() { return defaultValue; } }; }
@SuppressWarnings("rawtypes") public static void disableIfNotSelected(SelectionModel selectionModel, Node... nodes) { BooleanBinding selected = selectionModel.selectedItemProperty().isNull(); for (Node node : nodes) { node.disableProperty().bind(selected); } }
private BooleanBinding nameAlreadyExists() { BooleanBinding binding = bindFalse(); for (String name : service.getCollectionNames()) { binding = binding.or(nameField.textProperty().isEqualTo(name)); } return binding; }
@Test public void shouldCreateBindingInformingIfNoFeatureIsSelected() throws Exception { ObservableList<ViewableFeature> features = someFeatures( notSelected(Feature.CEDD), notSelected(Feature.TAMURA) ); BooleanBinding binding = utils.noFeatureIsSelectedIn(features); assertThat(valueOf(binding), is(true)); selectFirstItemOf(features); assertThat(valueOf(binding), is(false)); }
public Issue(final Predicate<T> presentPredicate, final T subject, final Observable... observables) { presentProperty = new BooleanBinding() { { // Bind to the provided observables (which may influence the "present" stringBinder super.bind(observables); } @Override protected boolean computeValue() { return presentPredicate.test(subject); } }; }
private void initMenu() { Menu fileMenu = new Menu(EditorConfig.MENU_FILE); MenuItem openFile = new MenuItem(EditorConfig.MENU_FILE_OPEN); FontAwesomeIconView openView = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN); openFile.setGraphic(openView); MenuItem saveFile = new MenuItem(EditorConfig.MENU_FILE_SAVE); FontAwesomeIconView saveView = new FontAwesomeIconView(FontAwesomeIcon.SAVE); saveFile.setGraphic(saveView); fileMenu.getItems().addAll(openFile, saveFile); Menu toolMenu = new Menu(EditorConfig.MENU_TOOL); MenuItem randomName = new MenuItem(EditorConfig.MENU_TOOL_RANDOM); BooleanBinding when = new When(Bindings.createBooleanBinding(() -> torrentProperty.getValue() == null, torrentProperty)).then(true).otherwise(false); randomName.disableProperty().bind(when); saveFile.disableProperty().bind(when); centerBtn.visibleProperty().bind(when); fileTree.visibleProperty().bind(when.not()); toolMenu.getItems().add(randomName); menuBar.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null))); menuBar.getMenus().addAll(fileMenu, toolMenu); openFile.setOnAction(event -> openFile()); saveFile.setOnAction((event) -> saveFile()); randomName.setOnAction(event -> randomNameAll(itemRoot)); }
/** * Returns a self updating binding to check if the definition is invalid * @param alreadyDefinedVariables check against this list if variable name is already present * @return binding that always represents the return value of * {@link IoVariableDefinitionPane#isDefinitionInvalid(List)}. */ public BooleanBinding createDefinitionInvalidBinding( List<SpecIoVariable> alreadyDefinedVariables) { return Bindings.createBooleanBinding(() -> isDefinitionInvalid(alreadyDefinedVariables), nameTextField.textProperty(), typeTextField.textProperty()); }
@FXML public void initialize() { // 기본경로 처리 txtCheckoutLocation.textProperty().set(getBaseDir()); txtCheckoutLocation.disabledProperty().addListener((oba, old, newv) -> btnBrowse.setDisable(newv)); // btnFinish 활성화/비활성화 처리를 담당한다. BooleanBinding empty1 = txtProjectName.textProperty().isEmpty(); BooleanBinding empty2 = txtCheckoutLocation.textProperty().isEmpty(); btnFinishDisableBinding = empty1.or(empty2); btnFinishDisableBinding.addListener((oba, old, newv) -> btnFinish.setDisable(newv)); txtProjectName.textProperty().bind(fileName); /* * checkout이 정상적으로 처리완료되거나 cancel버튼을 클릭한경우 행위를 기술한다. * * 디폴트값은 stage를 닫는다. */ onCloseAction.set(defaultCloseAction); advanceOption.addListener(new ChangeListener<SVNAdvanceOption>() { @Override public void changed(ObservableValue<? extends SVNAdvanceOption> observable, SVNAdvanceOption oldValue, SVNAdvanceOption newValue) { if (newValue != null) { txtRevision.setText(String.valueOf(newValue.getRevision())); } } }); }
private void configureButtonsActivation() { BooleanBinding noItemSelected = list.getSelectionModel().selectedItemProperty().isNull(); IntegerExpression selectedItemIndex = list.getSelectionModel().selectedIndexProperty(); BooleanBinding selectedItemIsUsed = selectedItemIndex.isEqualTo(itemInUseIndex); BooleanBinding selectedItemIsFirst = list.getSelectionModel().selectedIndexProperty().isEqualTo(0); IntegerExpression lastIndex = Bindings.createIntegerBinding(() -> list.getItems().size() - 1, list.itemsProperty()); BooleanBinding selectedItemIsLast = list.getSelectionModel().selectedIndexProperty().isEqualTo(lastIndex); addButton.disableProperty().bind(isNewItemTextValid().not()); duplicateButton.disableProperty().bind(noItemSelected); removeButton.disableProperty().bind(noItemSelected.or(selectedItemIsUsed)); moveUpButton.disableProperty().bind(noItemSelected.or(selectedItemIsFirst)); moveDownButton.disableProperty().bind(noItemSelected.or(selectedItemIsLast)); }
private Binding<Tooltip> createTooltipBinding() { Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(description); BooleanBinding descriptionIsNull = description.isNull(); Callable<Tooltip> tooltipCallable = () -> { if (descriptionIsNull.get()) { // no tooltip when no description return null; } return tooltip; }; return Bindings.createObjectBinding(tooltipCallable, descriptionIsNull); }
private void initializeDeleteButtons() { BooleanBinding noColumnDefSelected = UIUtils.noItemIsSelected(columnsTable); BooleanBinding firstColumnDefSelected = UIUtils.firstItemIsSelected(columnsTable); BooleanBinding lastColumnDefSelected = UIUtils.lastItemIsSelected(columnsTable); removeColumnButton.disableProperty().bind(noColumnDefSelected); moveColumnUpButton.disableProperty().bind(noColumnDefSelected.or(firstColumnDefSelected)); moveColumnDownButton.disableProperty().bind(noColumnDefSelected.or(lastColumnDefSelected)); }
private BooleanBinding bindForValidity(boolean withConfirmation, TextField electionOfficer1Password, TextField electionOfficer2Password, Label errorMessage, Node confirmButton) { BooleanBinding passwordsValid = Bindings.createBooleanBinding( () -> withConfirmation ? arePasswordsEqualAndValid(electionOfficer1Password.textProperty(), electionOfficer2Password.textProperty()) : isPasswordValid(electionOfficer1Password.getText()), electionOfficer1Password.textProperty(), electionOfficer2Password.textProperty()); passwordsValid.addListener((observable, werePasswordsValid, arePasswordsValid) -> { confirmButton.setDisable(!arePasswordsValid); errorMessage.setVisible(!arePasswordsValid && withConfirmation); }); return passwordsValid; }
private void initializeBindings() { encryptButton.setDisable(true); BooleanBinding plainTextsEmpty = Bindings.createBooleanBinding(plainTexts::isEmpty, plainTexts); plainTextsEmpty.addListener( (observable, oldValue, isPlainTextListEmpty) -> encryptButton.setDisable(isPlainTextListEmpty) ); decryptButton.setDisable(true); cipherTexts.addListener((ListChangeListener<AuthenticatedBallot>) c -> decryptButton.setDisable(c.getList().isEmpty())); }
public VFlow(FxEditor ed) { this.editor = ed; clip = new Rectangle(); selectionHighlight = new Path(); FX.style(selectionHighlight, FxEditor.HIGHLIGHT); selectionHighlight.setManaged(false); selectionHighlight.setStroke(null); selectionHighlight.setFill(Color.rgb(255, 255, 0, 0.25)); caretPath = new Path(); FX.style(caretPath, FxEditor.CARET); caretPath.setManaged(false); caretPath.setStroke(Color.BLACK); caretAnimation = new Timeline(); caretAnimation.setCycleCount(Animation.INDEFINITE); getChildren().addAll(selectionHighlight, caretPath); setClip(clip); caretPath.visibleProperty().bind(new BooleanBinding() { { bind(caretVisible, editor.displayCaret, editor.focusedProperty(), editor.disabledProperty(), suppressBlink); } protected boolean computeValue() { return (isCaretVisible() || suppressBlink.get()) && editor.isDisplayCaret() && editor.isFocused() && (!editor.isDisabled()); } }); }
private void setEventStreamers(GroupEntity rect) { BooleanBinding animationRunning = rect.getRedoAnimation().statusProperty().isEqualTo(Animation.Status.RUNNING); EventStream<UndoChange<CustomBoundingBox>> xChanges = makeEventStream(rect.getRect().xProperty(), xRect -> new CustomBoundingBox(xRect.doubleValue(), rect.getRect().getY(), rect.getRect().getWidth(), rect.getRect().getHeight(), rect.getRotate())); EventStream<UndoChange<CustomBoundingBox>> yChanges = makeEventStream(rect.getRect().yProperty(), yRect -> new CustomBoundingBox(rect.getRect().getX(), yRect.doubleValue(), rect.getRect().getWidth(), rect.getRect().getHeight(), rect.getRotate())); EventStream<UndoChange<CustomBoundingBox>> widthChanges = makeEventStream(rect.getRect().widthProperty(), wRect -> new CustomBoundingBox(rect.getRect().getX(), rect.getRect().getY(), wRect.doubleValue(), rect.getRect().getHeight(), rect.getRotate())); EventStream<UndoChange<CustomBoundingBox>> heightChanges = makeEventStream(rect.getRect().heightProperty(), hRect -> new CustomBoundingBox(rect.getRect().getX(), rect.getRect().getY(), rect.getRect().getWidth(), hRect.doubleValue(), rect.getRotate())); EventStream<UndoChange<CustomBoundingBox>> rotationChanges = makeEventStream(rect.rotateProperty(), rRect -> new CustomBoundingBox(rect.getRect().getX(), rect.getRect().getY(), rect.getRect().getWidth(), rect.getRect().getHeight(), rRect.doubleValue())); EventStream<UndoChange<CustomBoundingBox>> boundsChanges = EventStreams .merge(xChanges, yChanges, widthChanges, heightChanges, rotationChanges).reducible(UndoChange::merge) .suspendWhen(animationRunning); rect.undoManager = UndoManagerFactory.unlimitedHistoryUndoManager(boundsChanges, UndoChange::invert, c -> { rect.getRedoAnimation().getKeyFrames() .setAll(new KeyFrame(GroupEntity.getRedoAnimationTime(), new KeyValue(rect.getRect().xProperty(), c.getNewValue().getMinX()), new KeyValue(rect.getRect().yProperty(), c.getNewValue().getMinY()), new KeyValue(rect.getRect().widthProperty(), c.getNewValue().getWidth()), new KeyValue(rect.getRect().heightProperty(), c.getNewValue().getHeight()), new KeyValue(rect.rotateProperty(), c.getNewValue().getRotation()) )); rect.getRedoAnimation().play(); }, (c1, c2) -> Optional.of(c1.merge(c2))); }