private void initProgressBinding() { DoubleExpression tmp = constantOf(0); for (Command command : registeredCommands) { final ReadOnlyDoubleProperty progressProperty = command.progressProperty(); /** * When the progress of a command is "undefined", the progress property has a value of -1. * But in our use case we like to have a value of 0 in this case. * Therefore we create a custom binding here. */ final DoubleBinding normalizedProgress = Bindings .createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(), progressProperty); tmp = tmp.add(normalizedProgress); } int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size(); progress.bind(Bindings.divide(tmp, divisor)); }
@FXML private void initialize() { // Replace constants in instructions label instructionsLabel.setText(instructionsLabel.getText() .replace("${version}", TLD_VERSION) .replace("${exe_path}", OPERATING_SYSTEM.getExampleExecutablePath()) .replace("${dll_name}", DLL_NAME)); // Selected file depends on the path in the text field // Not bound the "traditional" way as that caused duplicate calls to createPathFromText fileTextField.setOnKeyReleased(ke -> selectedFile.setValue(createPathFromText(fileTextField.getText()))); // Only able to change file path when not currently patching fileTextField.disableProperty().bind(working); // File status depends on selected file fileStatusBinding = Bindings.createObjectBinding(this::calculateHashes, selectedFile); fileStatusProperty.bind(fileStatusBinding); // File status label responds to selected file status fileStatusLabel.textProperty().bind(Bindings.createStringBinding( () -> fileStatusProperty.getValue().getDisplayName(), fileStatusProperty)); fileStatusLabel.textFillProperty().bind(Bindings.createObjectBinding( () -> fileStatusProperty.getValue().getDisplayColor(), fileStatusProperty)); // File select button should be focused (runLater -> when Scene graph is established) Platform.runLater(() -> fileSelectButton.requestFocus()); // Patch button should only be enabled if file is valid and not currently patching patchButton.disableProperty().bind( Bindings.createBooleanBinding(() -> !fileStatusProperty.getValue().isValid(), fileStatusProperty) .or(working)); patchButton.textProperty().bind(Bindings.createStringBinding( () -> fileStatusProperty.getValue().getButtonText(), fileStatusProperty)); }
private void defineTableButtons() { Button addButton = new Button("Add", addIconView); addButton.setOnAction(actionEvent -> new NewJWKView(primaryStage, rootPane, jwkSetData).initialize()); Button removeButton = new Button("Remove", removeIconView); removeButton.setOnAction(actionEvent -> onRemove(tableView)); removeButton.disableProperty().bind(Bindings.isEmpty(tableView.getSelectionModel().getSelectedItems())); Button importButton = new Button("Import", importIconView); importButton.setOnAction(actionEvent -> onImport()); buttonRow = new HBox(30); // Buttons buttonRow.setPadding(new Insets(10, 10, 10, 10)); buttonRow.getChildren().addAll(addButton, removeButton, importButton); }
private void defineTableButtons() { Button cancelButton = new Button("Cancel"); cancelButton.setOnAction(actionEvent -> new JWKView(primaryStage, rootPane, jwkSetData).initialize()); Button importPublicButton = new Button("Import public"); importPublicButton.setOnAction(actionEvent -> importPublicKey()); importPublicButton.disableProperty().bind(Bindings.createBooleanBinding(this::isImportPublicButtonDisabled, tableView.getSelectionModel().getSelectedItems())); Button importButton = new Button("Import"); importButton.setOnAction(actionEvent -> importKey()); importButton.disableProperty().bind(Bindings.isEmpty(tableView.getSelectionModel().getSelectedItems())); buttonRow = new HBox(30); // Buttons buttonRow.setPadding(new Insets(10, 10, 10, 10)); buttonRow.getChildren().addAll(cancelButton, importPublicButton, importButton); }
public void bind(TestdataLinkMappingPresenter presenter) { this.presenter = presenter; saveMaxEntities = presenter.getSaveMaxEntities(); entityProperty.unbind(); entityProperty.setValue(0); entityProperty.bind(super.progressProperty()); this.presenter.getProgressBarPercentInformation().textProperty().bind( Bindings.createStringBinding(() -> { int process = (int) (entityProperty.getValue() * 100.0d); if (process <= 0) { process = 0; } else { ++process; } return process + "%"; // NOI18N }, entityProperty)); this.presenter.progressPropertyFromEntityDream().unbind(); this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty()); }
public HighlightCell(StringProperty textToHighlight) { super(); this.backgroundProperty().bind(Bindings.when(Bindings.and(Bindings.isNotNull(textToHighlight), Bindings.equal(itemProperty(), textToHighlight))) .then(HIGHLIGHT_BACKGROUND) .otherwise(Background.EMPTY)); }
/** * Invokes {@link DateControl#bind(DateControl, boolean)} and adds some more * bindings between this control and the given control. * * @param otherControl the control that will be bound to this control * @param bindDate if true will also bind the date property */ public final void bind(DayViewBase otherControl, boolean bindDate) { super.bind(otherControl, bindDate); Bindings.bindBidirectional( otherControl.earlyLateHoursStrategyProperty(), earlyLateHoursStrategy); Bindings.bindBidirectional(otherControl.hoursLayoutStrategyProperty(), hoursLayoutStrategyProperty()); Bindings.bindBidirectional(otherControl.hourHeightProperty(), hourHeightProperty()); Bindings.bindBidirectional(otherControl.hourHeightCompressedProperty(), hourHeightCompressedProperty()); Bindings.bindBidirectional(otherControl.visibleHoursProperty(), visibleHoursProperty()); Bindings.bindBidirectional(otherControl.enableCurrentTimeMarkerProperty(), enableCurrentTimeMarkerProperty()); Bindings.bindBidirectional(otherControl.trimTimeBoundsProperty(), trimTimeBoundsProperty()); }
public final void unbind(DayViewBase otherControl) { super.unbind(otherControl); Bindings.unbindBidirectional( otherControl.earlyLateHoursStrategyProperty(), earlyLateHoursStrategy); Bindings.unbindBidirectional(otherControl.hoursLayoutStrategyProperty(), hoursLayoutStrategyProperty()); Bindings.unbindBidirectional(otherControl.hourHeightProperty(), hourHeightProperty()); Bindings.unbindBidirectional( otherControl.hourHeightCompressedProperty(), hourHeightCompressedProperty()); Bindings.unbindBidirectional(otherControl.visibleHoursProperty(), visibleHoursProperty()); Bindings.unbindBidirectional(otherControl.enableCurrentTimeMarkerProperty(), enableCurrentTimeMarkerProperty()); Bindings.unbindBidirectional(otherControl.trimTimeBoundsProperty(), trimTimeBoundsProperty()); }
public void bind(TestdataExerciseTermPresenter presenter) { this.presenter = presenter; saveMaxEntities = presenter.getSaveMaxEntities(); entityProperty.unbind(); entityProperty.setValue(0); entityProperty.bind(super.progressProperty()); this.presenter.getProgressBarPercentInformation().textProperty().bind( Bindings.createStringBinding(() -> { int process = (int) (entityProperty.getValue() * 100.0d); if (process <= 0) { process = 0; } else { ++process; } return process + "%"; // NOI18N }, entityProperty)); this.presenter.progressPropertyFromEntityDream().unbind(); this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty()); }
@Override public void initialize(URL location, ResourceBundle resources) { this.title = resources.getString(R.Translate.ITEM_TYPE_WEAPON_MELE); this.imageChooserTitle = resources.getString(R.Translate.ITEM_IMAGE_CHOOSE_DIALOG); txtName.textProperty().bindBidirectional(model.name); txtDescription.textProperty().bindBidirectional(model.description); cmbWeaponType.setItems(FXCollections.observableArrayList(MeleWeaponType.values())); cmbWeaponType.valueProperty().bindBidirectional(model.weaponType); cmbWeaponType.converterProperty().setValue(StringConvertors.forMeleWeaponType(translator)); cmbWeaponClass.setItems(FXCollections.observableArrayList(MeleWeaponClass.values())); cmbWeaponClass.valueProperty().bindBidirectional(model.weaponClass); cmbWeaponClass.converterProperty() .setValue(StringConvertors.forMeleWeaponClass(translator)); FormUtils.initTextFormater(txtStrength, model.strength); FormUtils.initTextFormater(txtRampancy, model.rampancy); FormUtils.initTextFormater(txtDefenceNumber, model.defence); FormUtils.initTextFormater(txtWeight, model.weight); lblPrice.textProperty().bind(model.price.text); imageView.imageProperty().bindBidirectional(model.image); btnFinish.disableProperty().bind(Bindings.or(model.name.isEmpty(), model.imageRaw.isNull())); }
/** * Vytvoří novou abstrakní nákupní položku */ public ShopEntry(ItemBase itemBase) { ammount.minValueProperty().bind(Bindings .when(inShoppingCart) .then(1) .otherwise(0)); imageRaw.addListener((observable, oldValue, newValue) -> { final ByteArrayInputStream inputStream = new ByteArrayInputStream(newValue); image.set(new Image(inputStream)); }); this.itemBase = itemBase; this.id.bind(itemBase.idProperty()); this.name.bind(itemBase.nameProperty()); this.description.bind(itemBase.descriptionProperty()); this.price = itemBase.getPrice(); this.weight.bind(itemBase.weightProperty()); this.author.bind(itemBase.authorProperty()); this.downloaded.bindBidirectional(itemBase.downloadedProperty()); this.uploaded.bindBidirectional(itemBase.uploadedProperty()); this.imageRaw.bind(itemBase.imageProperty()); }
public CSSTheme() { css.bind(Bindings.createStringBinding(() -> String.format( ".root { %n " + "-fx-base: %s;%n " + "-fx-background: %s;%n " + "-fx-accent: %s;%n " + "-fx-default-button: %s;%n " + "-fx-focus-color: %s;%n " + "-fx-faint-focus-color: %s;%n}", ColorEncoder.encodeColor((Color) base.get()), ColorEncoder.encodeColor((Color) background.get()), ColorEncoder.encodeColor((Color) accent.get()), ColorEncoder.encodeColor((Color) defaultButton.get()), ColorEncoder.encodeColor((Color) focusColor.get()), ColorEncoder.encodeColor((Color) faintFocusColor.get())), base, background, accent, defaultButton, focusColor, faintFocusColor)); }
private ContextMenu createContextMenu() { MenuItem insertRow = new MenuItem("Insert Row"); MenuItem columnResize = new MenuItem("Resize columns"); MenuItem deleteRow = new MenuItem("Delete Row"); MenuItem comment = new MenuItem("Comment ..."); insertRow.setAccelerator(new KeyCodeCombination(KeyCode.INSERT)); insertRow.setOnAction(event -> insertRow()); deleteRow.setAccelerator(new KeyCodeCombination(KeyCode.DELETE)); deleteRow.setOnAction(event -> deleteRow()); MenuItem addNewColumn = new MenuItem("New Column..."); addNewColumn.setOnAction(event -> addNewColumn()); comment.setOnAction(event -> addRowComment(event)); comment.setAccelerator(KeyCodeCombination.keyCombination("Ctrl+k")); insertRow.disableProperty().bind(Bindings.not(tableView.editableProperty())); deleteRow.disableProperty().bind(Bindings.not(tableView.editableProperty())); addNewColumn.disableProperty().bind(Bindings.not(tableView.editableProperty())); columnResize.setAccelerator(KeyCodeCombination.keyCombination("Ctrl+R")); columnResize.setOnAction(event -> resizeColumns()); return new ContextMenu(insertRow, deleteRow, addNewColumn, comment, columnResize); }
private void initRightClick() { fileTable.setRowFactory(param -> { final TableRow<File> row = new TableRow<>(); final ContextMenu rowMenu = new ContextMenu(); MenuItem addNewFile = new MenuItem("Add File"); addNewFile.setOnAction(event -> addCvFile()); MenuItem removeFile = new MenuItem("Remove file"); removeFile.setOnAction(event -> removeCvFile()); rowMenu.getItems().addAll(removeFile, addNewFile); row.contextMenuProperty() .bind(Bindings .when(Bindings.isNotNull(row.itemProperty())) .then(rowMenu) .otherwise((ContextMenu) null)); return row; }); }
private void initRightClick() { millingTable.setRowFactory(param -> { final TableRow<Filed> row = new TableRow<>(); final ContextMenu rowMenu = new ContextMenu(); MenuItem showExtracted = new MenuItem("Show extracted"); showExtracted.setOnAction(event -> showExtracted()); MenuItem showParsed = new MenuItem("Show parsed"); showParsed.setOnAction(event -> showParsed()); row.setOnMouseClicked(event -> { if (event.getClickCount() == 2 && (!row.isEmpty())) { screensManager.showParsedFileData(row.getItem()); } }); rowMenu.getItems().addAll(showParsed, showExtracted); row.contextMenuProperty() .bind(Bindings .when(Bindings.isNotNull(row.itemProperty())) .then(rowMenu) .otherwise((ContextMenu) null)); return row; }); }
public FilterableTreeItem(T value) { super(value); this.sourceList = FXCollections.observableArrayList(); this.filteredList = new FilteredList<>(this.sourceList); this.filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> { return child -> { // Set the predicate of child items to force filtering if (child instanceof FilterableTreeItem) { FilterableTreeItem<T> filterableChild = (FilterableTreeItem<T>) child; filterableChild.setPredicate(this.predicate.get()); } // If there is no predicate, keep this tree item if (this.predicate.get() == null) return true; // If there are children, keep this tree item if (child.getChildren().size() > 0) return true; // Otherwise ask the TreeItemPredicate return this.predicate.get().test(this, child.getValue()); }; }, this.predicate)); setHiddenFieldChildren(this.filteredList); }
private Node createAddItemPane() { HBox box = new HBox(6); TextField firstname = new TextField(); firstname.setPromptText("Enter first name ..."); TextField lastname = new TextField(); lastname.setPromptText("Enter last name ..."); Button addBtn = new Button("Add new actor to \"Folder 1\""); addBtn.setOnAction(event -> { FilterableTreeItem<Actor> treeItem = new FilterableTreeItem<>(new Actor(firstname.getText(), lastname.getText())); folder1.getInternalChildren().add(treeItem); }); addBtn.disableProperty().bind(Bindings.isEmpty(lastname.textProperty())); box.getChildren().addAll(firstname, lastname, addBtn); TitledPane pane = new TitledPane("Add new element", box); pane.setCollapsible(false); return pane; }
private Node createFilteredTree() { FilterableTreeItem<Actor> root = getTreeModel(); root.predicateProperty().bind(Bindings.createObjectBinding(() -> { if (filterField.getText() == null || filterField.getText().isEmpty()) return null; return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText())); }, filterField.textProperty())); TreeView<Actor> treeView = new TreeView<>(root); treeView.setShowRoot(false); TitledPane pane = new TitledPane("Filtered TreeView", treeView); pane.setCollapsible(false); pane.setMaxHeight(Double.MAX_VALUE); return pane; }
@Override public void initialize(final URL location, final ResourceBundle resources) { try { Hygene.getInstance().getPrimaryStage().setMinHeight(650.0); Hygene.getInstance().getPrimaryStage().setMinWidth(920.0); } catch (final UIInitialisationException e) { LOGGER.error("Hygene instance not initialised.", e); } mainBorderPane.getLeft().visibleProperty().bind(graphStore.getGfaFileProperty().isNotNull()); mainBorderPane.getRight().visibleProperty().bind(graphStore.getGfaFileProperty().isNotNull()); leftPane.visibleProperty().bind(toggleLeftPane.selectedProperty() .and(graphStore.getGfaFileProperty().isNotNull())); leftPane.managedProperty().bind(toggleLeftPane.selectedProperty() .and(graphStore.getGfaFileProperty().isNotNull())); toggleLeftPane.textProperty().bind(Bindings.when(toggleLeftPane.selectedProperty()) .then("<") .otherwise(">")); rightPane.visibleProperty().bind(toggleRightPane.selectedProperty() .and(graphStore.getGfaFileProperty().isNotNull())); rightPane.managedProperty().bind(toggleRightPane.selectedProperty() .and(graphStore.getGfaFileProperty().isNotNull())); toggleRightPane.textProperty().bind(Bindings.when(toggleRightPane.selectedProperty()) .then(">") .otherwise("<")); graphVisualizer.getSelectedSegmentProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { toggleLeftPane.setSelected(true); nodeProperties.setExpanded(true); } }); }
private Node createButtonBar() { ButtonBarX buttonBar = new ButtonBarX(); okButton = FXUIUtils.createButton("ok", "Create " + type.fileType().toLowerCase() + " file", false, "OK"); okButton.setOnAction(e -> onOK()); okButton.disableProperty().bind(Bindings.isEmpty(name.textProperty())); Button cancelButton = FXUIUtils.createButton("cancel", "Cancel the " + type.fileType().toLowerCase() + " file creation", true, "Cancel"); cancelButton.setOnAction(e -> dispose()); buttonBar.getButtons().addAll(okButton, cancelButton); return buttonBar; }
private void init() { // name name.bind(Bindings.when(file.isNull()) .then(Bindings.createStringBinding(() -> "new" + order.get(), order)) .otherwise(toStringBinding(map(file, f -> f.getName())))); // graphics tab.setGraphic(icon); icon.setStyleClass("tab-icon"); icon.setIcon(FontAwesomeIcon.SAVE); // Hold the object in cache to avoid gc StringBinding state = CacheUtil.cache(this, "state", () -> Bindings.when(Bindings.equal(toObjectBinding(currentTabEntity()), this)) .then(Bindings.when(manager.modifiedProperty()) .then("selected-modified") .otherwise("selected")) .otherwise(Bindings.when(manager.modifiedProperty()) .then("modified") .otherwise(""))); state.addListener((ob, o, n) -> { uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(o), false)); uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(n), true)); }); // recent file.addListener((ob, o, n) -> todoAll( () -> ifThat(n != null).todo(() -> recentSupport.setLastFile(n)), () -> ifThat(o == null && n != null).todo(() -> releaseName()) )); }
private void initUndoRedo() { undoButton.disableProperty().bind( Bindings.not(editor.undoAvailableProperty())); redoButton.disableProperty().bind( Bindings.not(editor.redoAvailableProperty())); undoButton.setOnAction(editorAction(editor::undo)); redoButton.setOnAction(editorAction(editor::redo)); }
@Test public void testBinding() { SimpleLongProperty lp = new SimpleLongProperty(); lp.setValue(4711); keepBinding = Bindings.createLongBinding(() -> callMe(lp.get()), lp); lp.addListener((obs, oldValue, newValue) -> callMe(newValue)); lp.setValue(1); assertEquals(2, calledEffect); assertEquals(2, keepBinding.get()); }
/** * Binds the list cell to change background when you can place the cell * * @param box */ private void setBackgroundBinding () { BooleanProperty canPlace = getProfilable().getCost().canPlace(); backgroundProperty().bind(Bindings.when(canPlace) .then(PLACEABLE_BACKGROUND) .otherwise(UNPLACEABLE_BACKGROUND)); }
public static ObservableBooleanValue notEmpty(ObservableValue<String> source) { return Bindings.createBooleanBinding(() -> { final String s = source.getValue(); return s != null && !s.trim().isEmpty(); }, source); }
/** * Creates a command with a condition about the executability by using the 'executableObservable' parameter. Pass a * <code>true</code> to the #inBackground parameter to run the {@link Command} in a background thread. * * <b>IF YOU USE THE BACKGROUND THREAD: </b> don't forget to return to the UI-thread by using * {@link Platform#runLater(Runnable)}, otherwise you get an Exception. * * @param actionSupplier * a function that returns a new Action which should be executed * @param executableObservable * which defines whether the {@link Command} can execute * @param inBackground * defines whether the execution {@link #execute()} is performed in a background thread or not */ public DelegateCommand(final Supplier<Action> actionSupplier, ObservableValue<Boolean> executableObservable, boolean inBackground) { this.actionSupplier = actionSupplier; this.inBackground = inBackground; if (executableObservable != null) { executable.bind(Bindings.createBooleanBinding(() -> { final boolean isRunning = runningProperty().get(); final boolean isExecutable = executableObservable.getValue(); return !isRunning && isExecutable; }, runningProperty(), executableObservable)); } }
@Override public void updateItem(T item, boolean empty){ if(empty){ }else{ ca.setContent(item); setText(ca.getAdaptedContent().toString()); backgroundProperty().bind(Bindings.when(this.visibleProperty()) .then(new Background(new BackgroundFill(Color.valueOf(ca.getColor()), new CornerRadii(2d), Insets.EMPTY))) .otherwise(new Background(new BackgroundFill(Color.TRANSPARENT, new CornerRadii(2d), Insets.EMPTY)))); setPrefHeight(this.getFont().getSize() * Constants.TODO_TICKET_CELL_HEIGHT); } }
@Override public void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (empty) { setText(null); setGraphic(null); } else { Image out = IDH.getImagesMap().get(item.toString()); if(out != null){ im.setImage(out); im.setSmooth(true); im.setPreserveRatio(true); setGraphic(im); this.setOnMouseClicked(evt ->{ SELECTED = VIEWER_PANEL.getSelectionModel().getSelectedIndex(); setInfoViewData(CDH.getData().get(item.toString().split(":")[0])); }); setPrefHeight(155); setPrefWidth(VIEWER_PANEL.getPrefWidth() - 5); backgroundProperty().bind(Bindings.when(this.selectedProperty()) .then(new Background(new BackgroundFill(Color.valueOf("#1E90FF"), new CornerRadii(2d), Insets.EMPTY))) .otherwise(new Background(new BackgroundFill(Color.valueOf("#FFFFFF"), new CornerRadii(2d), Insets.EMPTY)))); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); } } }
public void bind(TestdataLinkPresenter presenter) { this.presenter = presenter; saveMaxEntities = presenter.getSaveMaxEntities(); timePeriod = presenter.getTimePeriod(); String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE); int year = Integer.parseInt(startTime.substring(6)) - timePeriod; startTime = startTime.substring(0, 6) + year; final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE); convertedTimePeriod = now - convertedStartTime; entityProperty.unbind(); entityProperty.setValue(0); entityProperty.bind(super.progressProperty()); this.presenter.getProgressBarPercentInformation().textProperty().bind( Bindings.createStringBinding(() -> { int process = (int) (entityProperty.getValue() * 100.0d); if (process <= 0) { process = 0; } else { ++process; } return process + "%"; // NOI18N }, entityProperty)); this.presenter.progressPropertyFromEntityDream().unbind(); this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty()); }
void setRootLayout(BorderPane rootLayout) { this.rootLayout = rootLayout; brightness.valueProperty().addListener((observable, oldValue, newValue) -> { Double value = (Double) newValue; value = value * 2.55; StringExpression styleString = Bindings.format("-fx-base:rgb(%1$.0f , %1$.0f, %1$.0f)", value); this.rootLayout.styleProperty().bind(styleString); }); brightness.setMin(0); brightness.setMax(100); brightness.setValue(30.8); }
/********************************************* * * * CONTEXT MENU FACTORY * * * *********************************************/ private TableRow<ObservableGanttTask> tableRowFactory(TableView<ObservableGanttTask> table) { final TableRow<ObservableGanttTask> row = new TableRow<>(); row.contextMenuProperty().bind( Bindings.when(Bindings.isNull(row.itemProperty())) .then((ContextMenu)null) .otherwise(Bindings.when(row.indexProperty().isEqualTo(0)) .then(makeFirstTaskContextMenu()) .otherwise(makeRegularTaskContextMenu(row)))); return row; }
private HBox connexionStatusInformation( ) { final HBox container = new HBox( ); container.setAlignment( Pos.CENTER ); container.setSpacing( 10 ); final ProgressIndicator indicator = new ProgressIndicator( ); indicator.setPrefSize( 20, 20 ); indicator.visibleProperty( ).bind( _model.loadingProperty( ) ); final Label connectionInformation = new Label( ); connectionInformation.setTextAlignment( TextAlignment.CENTER ); connectionInformation.setWrapText( true ); connectionInformation.textProperty( ).bind( _model.loadingInformationProperty( ) ); connectionInformation.visibleProperty( ).bind( _model.loadingInformationProperty( ).isEmpty( ).not( ) ); connectionInformation.textFillProperty( ).bind( Bindings.<Paint>createObjectBinding( ( ) -> { if ( _model.loadingProperty( ).get( ) ) return Paint.valueOf( "black" ); return _model.isLoadingFailure( ) ? Paint.valueOf( "red" ) : Paint.valueOf( "green" ); }, _model.loadingFailureProperty( ), _model.loadingProperty( ) ) ); connectionInformation.minHeightProperty( ).bind( createIntegerBinding( ( ) -> { if ( _model.loadingInformationProperty( ).isEmpty( ).get( ) ) { return 0; } else { return 50; } }, _model.loadingInformationProperty( ) ) ); connectionInformation.maxHeightProperty( ).bind( connectionInformation.minHeightProperty( ) ); container.getChildren( ).addAll( indicator, connectionInformation ); return container; }
public void initialize() { // get URL of the video file URL url = VideoPlayerController.class.getResource("sts117.mp4"); // create a Media object for the specified URL Media media = new Media(url.toExternalForm()); // create a MediaPlayer to control Media playback mediaPlayer = new MediaPlayer(media); // specify which MediaPlayer to display in the MediaView mediaView.setMediaPlayer(mediaPlayer); // set handler to be called when the video completes playing mediaPlayer.setOnEndOfMedia(() -> { playing = false; playPauseButton.setText("Play"); }); // set handler that displays an ExceptionDialog if an error occurs mediaPlayer.setOnError(() -> { ExceptionDialog dialog = new ExceptionDialog(mediaPlayer.getError()); dialog.showAndWait(); }); // bind the MediaView's width/height to the scene's width/height DoubleProperty width = mediaView.fitWidthProperty(); DoubleProperty height = mediaView.fitHeightProperty(); width.bind(Bindings.selectDouble( mediaView.sceneProperty(), "width")); height.bind(Bindings.selectDouble( mediaView.sceneProperty(), "height")); }
public void bind(TestdataExercisePresenter presenter) { this.presenter = presenter; saveMaxEntities = presenter.getSaveMaxEntities(); timePeriod = presenter.getTimePeriod(); String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE); int year = Integer.parseInt(startTime.substring(6)) - timePeriod; startTime = startTime.substring(0, 6) + year; final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE); convertedTimePeriod = now - convertedStartTime; entityProperty.unbind(); entityProperty.setValue(0); entityProperty.bind(super.progressProperty()); this.presenter.getProgressBarPercentInformation().textProperty().bind( Bindings.createStringBinding(() -> { int process = (int) (entityProperty.getValue() * 100.0d); if (process <= 0) { process = 0; } else { ++process; } return process + "%"; // NOI18N }, entityProperty)); this.presenter.progressPropertyFromEntityDream().unbind(); this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty()); }
/** * A text label that you can double click to edit. */ public EditableLabel() { setMaxWidth(USE_PREF_SIZE); Label label = new Label(); label.textProperty().bind(text); label.visibleProperty().bind(Bindings.not(editing)); getChildren().add(label); TextField editField = new AutoSizedTextField(); editField.visibleProperty().bind(editing); editField.textProperty().bindBidirectional(text); getChildren().add(editField); setOnMouseClicked(mouseEvent -> { if (mouseEvent.getClickCount() == 2) { editing.set(true); } }); editField.setOnAction(__ae -> editing.set(false)); editField.focusedProperty().addListener((__, wasFocused, isFocused) -> { if (!isFocused) { editing.set(false); } }); editing.addListener((__, wasEditing, isEditing) -> { if (isEditing) { editField.requestFocus(); } }); }
public void bind(TestdataTopicPresenter presenter) { this.presenter = presenter; saveMaxEntities = presenter.getSaveMaxEntities(); timePeriod = presenter.getTimePeriod(); String startTime = DateConverter.getDefault().convertLongToDateTime(now, DateConverter.PATTERN__DATE); int year = Integer.parseInt(startTime.substring(6)) - timePeriod; startTime = startTime.substring(0, 6) + year; final long convertedStartTime = DateConverter.getDefault().convertDateTimeToLong(startTime, DateConverter.PATTERN__DATE); convertedTimePeriod = now - convertedStartTime; entityProperty.unbind(); entityProperty.setValue(0); entityProperty.bind(super.progressProperty()); this.presenter.getProgressBarPercentInformation().textProperty().bind( Bindings.createStringBinding(() -> { int process = (int) (entityProperty.getValue() * 100.0d); if (process <= 0) { process = 0; } else { ++process; } return process + "%"; // NOI18N }, entityProperty)); this.presenter.progressPropertyFromEntityDream().unbind(); this.presenter.progressPropertyFromEntityDream().bind(super.progressProperty()); }
@FXML private void initialize() { root.backgroundProperty().bind( Bindings.createObjectBinding( () -> createSolidColorBackground(getColor()), dataProperty(), trueColor, falseColor)); exportProperties(trueColor, falseColor); }
@Override protected DateControl createControl() { CalendarSource calendarSource = new CalendarSource(); calendarSource.getCalendars().add(new HelloCalendar()); allDayView = new AllDayView(); allDayView.prefWidthProperty().bind(Bindings.multiply(150, allDayView.numberOfDaysProperty())); allDayView.setMaxWidth(Double.MAX_VALUE); allDayView.getCalendarSources().add(calendarSource); return allDayView; }