Skip to content

Commit

Permalink
feat: Drop LabelHelper#text(Property)
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Nov 8, 2024
1 parent ce0b16a commit 1bf5231
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 55 deletions.
23 changes: 4 additions & 19 deletions src/main/java/viewtify/ui/helper/LabelHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

import java.io.InputStream;

import javafx.beans.property.Property;
import org.controlsfx.glyphfont.Glyph;
import org.controlsfx.glyphfont.INamedCharacter;

import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
Expand All @@ -23,10 +25,6 @@
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

import org.controlsfx.glyphfont.Glyph;
import org.controlsfx.glyphfont.INamedCharacter;

import kiss.Disposable;
import kiss.I;
import kiss.Variable;
Expand Down Expand Up @@ -56,7 +54,7 @@ default String text() {
* @return Chainable API.
*/
default Self text(Object text) {
return text(Variable.of(text).fix());
return text(Variable.of(text));
}

/**
Expand All @@ -79,19 +77,6 @@ default Self text(Variable text) {
return (Self) this;
}

/**
* Set text.
*
* @param text A text {@link Variable} to set.
* @return Chainable API.
*/
default Self text(Property text) {
FXUtils.disposeAssociation(ui(), Disposable.class);

property(Type.Text).bindBidirectional(text);
return (Self) this;
}

/**
* Set text.
*
Expand Down
36 changes: 0 additions & 36 deletions src/test/java/viewtify/ui/helper/LabelHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,42 +100,6 @@ void textVariableDiscadedByText(LabelHelper ui) {
assert ui.text().equals("NEW");
}

@ParameterizedTest
@ArgumentsSource(Providers.LabelHelpers.class)
void textVariableDiscadedByProperty(LabelHelper ui) {
Variable text = Variable.of("TEST");
ui.text(text);
assert ui.text().equals("TEST");

// sync from model
text.set("UPDATE");
assert ui.text().equals("UPDATE");

// update by text model
ui.text(new SimpleStringProperty("NEW"));
assert ui.text().equals("NEW");

// old model was discarded
text.set("FROM OLD");
assert ui.text().equals("NEW");
}

@ParameterizedTest
@ArgumentsSource(Providers.LabelHelpers.class)
void textProperty(LabelHelper ui) {
SimpleStringProperty text = new SimpleStringProperty("TEST");
ui.text(text);
assert ui.text().equals("TEST");

// sync from model
text.set("UPDATE");
assert ui.text().equals("UPDATE");

// sync from ui
ui.text("FROM UI");
assert text.get().equals("FROM UI");
}

@ParameterizedTest
@ArgumentsSource(Providers.LabelHelpers.class)
void textNode(LabelHelper<?> ui) {
Expand Down

0 comments on commit 1bf5231

Please sign in to comment.