Discover custom ViewModels and validate Computed bindings in shared hosts
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
package fixture.components;
|
||||
|
||||
@jakarta.inject.Singleton
|
||||
@de.neitzel.fx.view.ViewModelClass(BadgeViewModel.class)
|
||||
public class BadgeCard extends javafx.scene.layout.VBox {
|
||||
static {
|
||||
System.setProperty("fixture.badgecard.initialized", "yes");
|
||||
}
|
||||
|
||||
private final javafx.beans.property.ObjectProperty<Object> model =
|
||||
new javafx.beans.property.SimpleObjectProperty<>();
|
||||
|
||||
public javafx.beans.property.ObjectProperty<Object> modelProperty() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public String caption() {
|
||||
throw new AssertionError("Metadata must not invoke Component method");
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package fixture.components;
|
||||
|
||||
public class BadgeViewModel extends de.neitzel.fx.view.ViewModel {
|
||||
public BadgeViewModel(fixture.model.Address model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
public javafx.beans.property.StringProperty badgeProperty() {
|
||||
throw new AssertionError("Metadata must not invoke accessor");
|
||||
}
|
||||
}
|
||||
+12
@@ -3,6 +3,18 @@ package fixture.components;
|
||||
@jakarta.inject.Singleton
|
||||
@de.neitzel.fx.view.ViewModelClass(PersonViewModel.class)
|
||||
public class PersonController implements de.neitzel.fx.view.HasViewModel {
|
||||
static {
|
||||
System.setProperty("fixture.controller.initialized", "yes");
|
||||
}
|
||||
|
||||
public Integer invalidComputed() {
|
||||
throw new AssertionError("Validation must not invoke methods");
|
||||
}
|
||||
|
||||
public Object uncertainComputed() {
|
||||
return "Uncertain";
|
||||
}
|
||||
|
||||
public final Greeting greeting;
|
||||
public de.neitzel.fx.view.ViewModel received;
|
||||
|
||||
|
||||
+15
@@ -1,6 +1,21 @@
|
||||
package fixture.components;
|
||||
|
||||
public class PersonViewModel extends de.neitzel.fx.view.ViewModel {
|
||||
static {
|
||||
System.setProperty("fixture.viewmodel.initialized", "yes");
|
||||
}
|
||||
|
||||
private final javafx.beans.property.StringProperty badge =
|
||||
new javafx.beans.property.SimpleStringProperty("Custom badge");
|
||||
|
||||
public javafx.beans.property.StringProperty badgeProperty() {
|
||||
return badge;
|
||||
}
|
||||
|
||||
public javafx.beans.property.IntegerProperty nameProperty() {
|
||||
throw new AssertionError("Model name must win");
|
||||
}
|
||||
|
||||
public PersonViewModel(Object model) {
|
||||
super(model);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package fixture.components;
|
||||
|
||||
@jakarta.inject.Singleton
|
||||
@de.neitzel.fx.view.ViewModelClass(ReplacementViewModel.class)
|
||||
public class ReplacementController {
|
||||
public String caption() {
|
||||
return "Replacement computed";
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package fixture.components;
|
||||
|
||||
public class ReplacementViewModel {
|
||||
static {
|
||||
System.setProperty("fixture.replacement.initialized", "yes");
|
||||
}
|
||||
|
||||
private final javafx.beans.property.StringProperty badge =
|
||||
new javafx.beans.property.SimpleStringProperty("Replacement badge");
|
||||
|
||||
public ReplacementViewModel(fixture.model.Person model) {}
|
||||
|
||||
public javafx.beans.property.StringProperty badgeProperty() {
|
||||
return badge;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<?neitzel-model fixture.model.Address?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="javafx.scene.layout.VBox"><fx:define><de.neitzel.fx.view.BindingList><de.neitzel.fx.view.DirectBinding control="badge" property="text" path="badge" direction="view"/><de.neitzel.fx.view.ComputedBinding control="caption" property="text" method="#caption"/></de.neitzel.fx.view.BindingList></fx:define><Label fx:id="badge"/><Label fx:id="caption"/></fx:root>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?neitzel-model fixture.model.Person?>
|
||||
<?import javafx.scene.layout.VBox?><?import javafx.scene.control.TextField?><?import javafx.scene.control.Label?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1" fx:controller="fixture.components.PersonController">
|
||||
<fx:define><de.neitzel.fx.view.BindingList>
|
||||
<de.neitzel.fx.view.DirectBinding control="badge" property="text" path="badge" direction="both"/>
|
||||
<de.neitzel.fx.view.ComputedBinding control="computed" property="text" method="#greeting"/>
|
||||
</de.neitzel.fx.view.BindingList></fx:define>
|
||||
<TextField fx:id="badge"/><Label fx:id="computed"/>
|
||||
</VBox>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?neitzel-model fixture.model.Person?>
|
||||
<?import javafx.scene.layout.VBox?><?import javafx.scene.control.TextField?><?import javafx.scene.control.Label?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1" fx:controller="fixture.components.ReplacementController">
|
||||
<fx:define><de.neitzel.fx.view.BindingList>
|
||||
<de.neitzel.fx.view.DirectBinding control="badge" property="text" path="badge" direction="both"/>
|
||||
<de.neitzel.fx.view.ComputedBinding control="computed" property="text" method="#caption"/>
|
||||
</de.neitzel.fx.view.BindingList></fx:define>
|
||||
<TextField fx:id="badge"/><Label fx:id="computed"/>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user