@Override public void initialize(URL location, ResourceBundle resources) { BooleanBinding noSelection = fileListView.getSelectionModel().selectedItemProperty().isNull(); removeFileButton.disableProperty().bind(noSelection); moveItemUpButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(0))); // we can't just map the val because we need an ObservableNumberValue IntegerBinding lastIndexBinding = Bindings.createIntegerBinding(() -> fileListView.getItems().size() - 1, Val.wrap(fileListView.itemsProperty()).flatMap(LiveList::sizeOf)); moveItemDownButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(lastIndexBinding))); fileListView.setCellFactory(DesignerUtil.simpleListCellFactory(File::getName, File::getAbsolutePath)); selectFilesButton.setOnAction(e -> onSelectFileClicked()); removeFileButton.setOnAction(e -> onRemoveFileClicked()); moveItemUpButton.setOnAction(e -> moveUp()); moveItemDownButton.setOnAction(e -> moveDown()); }
fieldFileBtn.disableProperty().bind( enableConnectionUrl.selectedProperty() ); buttonConnect.disableProperty().bind(createBooleanBinding( () -> ((fieldHost.textProperty().isEmpty().get() || fieldPort.textProperty().isEmpty().get())
okey.disableProperty().bind(Bindings.createBooleanBinding( () -> IS_INVALID_MAIL.test(email.getText()), email.textProperty()
@Override public void initialize(URL location, ResourceBundle resources) { commitButton.setOnAction(e -> { commitHandler.ifPresent(Runnable::run); getStage().close(); this.free(); }); commitButton.disableProperty().bind(validationSupport.invalidProperty()); Platform.runLater(() -> { typeId.bind(typeChoiceBox.getSelectionModel().selectedItemProperty()); typeChoiceBox.setConverter(DesignerUtil.stringConverter(PropertyTypeId::getStringId, PropertyTypeId::lookupMnemonic)); typeChoiceBox.getItems().addAll(PropertyTypeId.typeIdsToConstants().values()); FXCollections.sort(typeChoiceBox.getItems()); }); Platform.runLater(this::registerBasicValidators); typeIdProperty().values() .filter(Objects::nonNull) .subscribe(this::registerTypeDependentValidators); }
button.disableProperty().bind(validation.invalidProperty());
btnProceed.disableProperty().bind(hasErrors);
@FXML private Button button1; @FXML private Button button2; @FXML private Button button3; ... @FXML private ToggleButton on; @FXML private void initialize() { BooleanBinding disable = on.selectedProperty().not(); button1.disableProperty().bind(disable); button2.disableProperty().bind(disable); button3.disableProperty().bind(disable); ... }
TableColumn<Person, Person> actionsColumn = new TableColumn<>("Actions"); actionsColumn.setCellValueFactory(cellData -> new SimpleObjectProperty<>(cellData.getValue())); actionsColumn.setCellFactory(tc -> new TableCell<Person, Person>() { // ... Button b3 = new Button(...) ; HBox buttons = new HBox(5, b1, b2, b3); // ... { b3.disableProperty().bind(itemProperty().isNotEqualTo(personWithLatestDate)); } @Override protected void updateItem(Person person, boolean empty) { super.updateItem(person, empty); setGraphic(empty ? null : buttons); } });
@FXML private Button aButton; private final BooleanProperty disableProperty = new ReadOnlyBooleanWrapper(); public init() { disableProperty.bind(-- Your observable list here--.isEmpty()); aButton.disableProperty().bindBidirectional(disableProperty);
/** * {@inheritDoc} */ @Override public void handle(ActionEvent e) { button.disableProperty().set(true); // build button task task = new ButtonActionTask(button, e); // waiting.visibleProperty().bind(task.runningProperty()); taskProgress.progressProperty().bind(task.progressProperty()); for(ChangeListener<Worker.State> l: listeners) { task.stateProperty().addListener(l); } CompletableFuture.runAsync(task, Executors.newSingleThreadExecutor()).whenComplete(this::taskCompleted); }
private void bindMoveAllButtonsToDataModel() { moveToTargetAll.disableProperty().bind( Bindings.isEmpty(getSourceListView().getItems())); moveToSourceAll.disableProperty().bind( Bindings.isEmpty(getTargetListView().getItems())); }
private void bindMoveButtonsToSelectionModel() { moveToTarget.disableProperty().bind( Bindings.isEmpty(getSourceListView().getSelectionModel() .getSelectedItems())); moveToSource.disableProperty().bind( Bindings.isEmpty(getTargetListView().getSelectionModel() .getSelectedItems())); }
@Override protected void setupDialogControls() { // setup SportType list liSportTypes.setCellFactory(list -> new SportTypeListCell()); updateSportTypeList(); // start SportType edit dialog on double clicks in list liSportTypes.setOnMouseClicked(event -> { if (event.getClickCount() > 1) { onEditSportType(null); } }); // Edit and Delete buttons must be disabled when there is no selection in list final BooleanBinding selected = Bindings.isNull(liSportTypes.getSelectionModel().selectedItemProperty()); btEdit.disableProperty().bind(selected); btDelete.disableProperty().bind(selected); }
/** * Setup of the binding between the view model and the UI controls. */ private void setupBinding() { tfName.textProperty().bindBidirectional(sportTypeViewModel.name); cbRecordDistance.selectedProperty().bindBidirectional(sportTypeViewModel.recordDistance); cbSpeedMode.valueProperty().bindBidirectional(sportTypeViewModel.speedMode); cpColor.valueProperty().bindBidirectional(sportTypeViewModel.color); // the record distance mode can only be changed, when no exercises exists for // this sport type => disable checkbox, when such exercises were found Optional<Exercise> oExercise = document.getExerciseList().stream() .filter(exercise -> exercise.getSportType().getId() == sportTypeViewModel.id) .findFirst(); cbRecordDistance.setDisable(oExercise.isPresent()); // speed mode can only be configured when distance is being recorded cbSpeedMode.disableProperty().bind(cbRecordDistance.selectedProperty().not()); // Edit and Delete buttons must be disabled when there is no selection in the appropriate list final BooleanBinding sportSubtypeSelected = Bindings.isNull( liSportSubtypes.getSelectionModel().selectedItemProperty()); btSportSubtypeEdit.disableProperty().bind(sportSubtypeSelected); btSportSubtypeDelete.disableProperty().bind(sportSubtypeSelected); final BooleanBinding equipmentSelected = Bindings.isNull( liEquipments.getSelectionModel().selectedItemProperty()); btEquipmentEdit.disableProperty().bind(equipmentSelected); btEquipmentDelete.disableProperty().bind(equipmentSelected); }
@Override // This method is called by the FXMLLoader when initialization is complete public void initialize(URL fxmlFileLocation, ResourceBundle resources) { assert name != null : "fx:id=\"name\" was not injected: check your FXML file 'Provider.fxml'."; assert start != null : "fx:id=\"start\" was not injected: check your FXML file 'Provider.fxml'."; assert status != null : "fx:id=\"status\" was not injected: check your FXML file 'Provider.fxml'."; assert stop != null : "fx:id=\"stop\" was not injected: check your FXML file 'Provider.fxml'."; name.setText(dataProviderInfo.getName()); status.setText(dataProviderInfo.getStatus()); start.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dataProvider.startMonitoringDataProvider(dataProviderInfo.getName()); context.createConfigurationForm().delayedRefresh(); } }); start.disableProperty().bind(status.textProperty().isEqualTo("STARTED")); stop.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { dataProvider.stopMonitoringDataProvider(dataProviderInfo.getName()); context.createConfigurationForm().delayedRefresh(); } }); stop.disableProperty().bind(status.textProperty().isEqualTo("STOPPED")); }
private VBox createMenuBodyMainMenu() { Button btnContinue = createActionButton("CONTINUE", this::fireContinue); Button btnNew = createActionButton("NEW GAME", this::fireNewGame); Button btnLoad = createContentButton("LOAD GAME", this::createContentLoad); Button btnLogout = createActionButton("LOGOUT", this::fireLogout); Button btnExit = createActionButton("EXIT", this::fireExit); btnContinue.disableProperty().bind(listener.hasSavesProperty().not()); return new VBox(10, btnContinue, btnNew, btnLoad, btnLogout, btnExit); }
public void openPage(String location) { final URL url; try { url = URLVerifier.verifyURL(location); } catch (MalformedURLException ex) { Logger.getLogger(BrowserFXController.class.getName()).log(Level.SEVERE, null, ex); return; } URLHandler urlHandler = URLHandlersRegistry.getHandler(url); if (urlHandler == null) { return; } Platform.runLater(() -> { URLHandler.Result handleResult = urlHandler.handle(url); if (handleResult.contentDescriptor != ContentDescriptor.NoContent.instance()) { BrowserTab browserTab = TabFactory.newTab(this, locale, handleResult.contentDescriptor); browserTab.getNavigationContext().goTo(url); selectionTab.getSelectedItem().contentProperty().bind(browserTab.contentProperty()); browserMap.put(selectionTab.getSelectedIndex(), browserTab); // if(!urlField.isFocused()){ urlField.textProperty().bind(browserTab.locationProperty()); // } stopButton.disableProperty().set(!browserTab.isStoppable()); selectionTab.getSelectedItem().textProperty().bind(browserTab.titleProperty()); } }); }
public ModificationScriptEditor(StorableScript storableScript, Scene scene, GseContext context) { this.storableScript = storableScript; this.context = context; codeEditor = new GroovyCodeEditor(scene); Text saveGlyph = Glyph.createAwesomeFont('\uf0c7').size("1.3em"); saveButton = new Button("", saveGlyph); saveButton.getStyleClass().add("gse-toolbar-button"); saveButton.disableProperty().bind(saved); saveButton.setOnAction(event -> save()); codeEditorWithProgressIndicator = new StackPane(codeEditor, new Group(progressIndicator)); codeEditor.codeProperty().addListener((observable, oldValue, newValue) -> saved.set(false)); splitPane = new SplitPane(codeEditorWithProgressIndicator); toolBar = new ToolBar(saveButton); splitPane.setOrientation(Orientation.VERTICAL); splitPane.setDividerPosition(0, 0.8); setTop(toolBar); setCenter(splitPane); // listen to modifications storableScript.addListener(this); }
@Override @SuppressWarnings("unchecked") public Node createValueVisualisation() { ComboBox<E> comboBox = new ComboBox<>(); comboBox.setEditable(false); comboBox.getItems().addAll(possibleEnumConstants); comboBox.valueProperty().bindBidirectional(observableAttributeValue); comboBox.setConverter(stringConverter); Button deleteButton = new Button(); uniformDesign.addDangerIcon(deleteButton, FontAwesome.Glyph.TIMES); deleteButton.setOnAction(event -> observableAttributeValue.set(null)); deleteButton.disableProperty().bind(observableAttributeValue.isNull());//.or(Bindings.createBooleanBinding(()-> isReadOnlyVisualisation))); HBox hbox = new HBox(3); hbox.getChildren().addAll(comboBox,deleteButton); hbox.disableProperty().bind(readOnly); return hbox; } }
/** * Constructor * * @param control The control belonging to the skin */ public ContainerEngineToolsPanelSkin(ContainerEngineToolsPanel control) { super(control); // map the tool scripts to a tool button this.toolButtons = new MappedList<>(control.getEngineToolScripts(), tool -> { final Button toolButton = new Button(tool.getScriptName()); toolButton.getStyleClass().addAll("toolButton"); toolButton.setStyle("-fx-background-image: url('" + tool.getIcon() + "');"); toolButton.disableProperty().bind(getControl().lockToolsProperty()); toolButton.setOnMouseClicked(event -> { getControl().setLockTools(true); final ContainerDTO container = getControl().getContainer(); // TODO: find a better way to get the engine ID getControl().getEngineToolsManager().runTool(container.getEngine().toLowerCase(), container.getName(), tool.getId(), () -> getControl().setLockTools(false), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error")) .withException(e) .build(); errorDialog.showAndWait(); })); }); return toolButton; }); }