private Tab createAndAttachTab(Path path) { BorderPane pane = new BorderPane(); MplEditor editor = MplEditor.create(path, pane, eventBus, appMemento, this); ReadOnlyBooleanProperty modifiedProperty = editor.modifiedProperty(); StringExpression titleText = Bindings.createStringBinding(() -> { return modifiedProperty.get() ? "*" : ""; }, modifiedProperty).concat(path.getFileName()); Tab tab = new Tab(); tab.textProperty().bind(titleText); tab.setContent(pane); tab.setUserData(new MplEditorData(path, editor)); tab.setOnCloseRequest(e -> { if (warnAboutUnsavedResources(Arrays.asList(tab))) e.consume(); }); editorTabPane.getTabs().add(tab); tab.setOnClosed(e -> { editors.remove(path); tabs.remove(path); }); editors.put(path, editor); tabs.put(path, tab); return tab; }
private void initializeLabels() { filePathLabel.textProperty().bind(stringProperty(photo, "filePath")); StringExpression fileSize = Bindings.format("%.2f MB", numberProperty(photo, "fileSize").divide(1024*1014)); fileSizeLabel.textProperty().bind(fileSize); stateLabel.textProperty().bind(objectProperty(photo, STATE_PROPERTY).asString("State: %s")); try { FileHandler fileHandler = photoFlow.fileHandler(photo.getProjectId().get()); String metadata = fileHandler.loadPhotoMetadata(photo); metadataLabel.setText("Metadata/Exif:\n" + metadata); metadataLabel.setVisible(!metadata.isEmpty()); } catch (FileHandlerException e) { EventHandler.spawnError("Could not load any metadata from your photo :-("); throw new RuntimeException(e); } }
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); }
public static StringExpression forRaceAndProfessionConverter(Translator translator, Hero hero) { Race race = hero.getRace(); Profession profession = hero.getProfession(); if (race == null || profession == null) { return Bindings.concat(); } String translatedRace = translator.getRaceList().get(hero.getRace().ordinal()); String translatedProfession = translator.getProfessionList() .get(hero.getProfession().ordinal()); return Bindings.concat(translatedRace, " ", translatedProfession); }
public StatusDisplay(StringExpression statusProperty) { Text statusText = new Text(); statusText.textProperty().bind(statusProperty); HBox.setMargin(statusText, new Insets(1, 6, 3, 6)); setEffect(new DropShadow()); getStyleClass().add("status-background"); getChildren().add(statusText); setVisible(false); statusText.textProperty().addListener((observableValue, oldValue, newValue) -> setVisible(newValue != null && !newValue.equals("")) ); }
@Test public void testStringExpression(){ final StringExpression actual = Bindings.concat("hello", "world"); assertThat(actual).hasValue("helloworld"); assertThat(actual).hasSameValue(actual); }
public StringExpression getTitle() { StringBinding fileName = ChainedBindingFunctions.from(editedFile).mapToString(File::getName); StringBinding titleText = Bindings.when(editedFile.isNotNull()).then(fileName).otherwise("Untitled"); StringBinding dirtyFlag = Bindings.when(dirty).then("*").otherwise(""); return Bindings.concat(TITLE_BASE, titleText, dirtyFlag); }
public static Tooltip createNumberedTooltip(final StringProperty label, final DoubleProperty value) { final StringExpression text = label.concat(": ").concat(value.asString("%.0f")); final Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(text); return tooltip; }
default Text newText(StringExpression textBinding) { Text text = newText(textBinding.get()); text.textProperty().bind(textBinding); return text; }
public StatusDisplay(StringExpression statusProperty) { Label statusText = new Label(); statusText.setTextOverrun(OverrunStyle.ELLIPSIS); statusText.textProperty().bind(statusProperty); getStyleClass().add("status-background"); setVisible(true); //statusText.textProperty().addListener((observableValue, oldValue, newValue) -> //setVisible(newValue != null && !newValue.equals("")) //); getChildren().addAll(statusText, progressHolder); }
@Test public void testStringExpression(){ final StringExpression actual = Bindings.createStringBinding(() -> null); assertThat(actual).hasNullValue(); }
@Test public void testStringExpression(){ final StringExpression actual = Bindings.createStringBinding(() -> "test"); assertThat(actual).hasNotNullValue(); }
/** * The string binding that represents the text to be shown in the Actor Cell. * * @param actor * the {@link Actor} bind to * @return the string binding */ private StringExpression getTextBinding(Actor actor) { return Bindings.concat(actor.getElementInfo().nameProperty()).concat(" (") .concat(checkIntervalProperty).concat(")"); }