Validate preview sessions against real classpath and module-path fixtures
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
package fixture.components;
|
||||
|
||||
@jakarta.inject.Singleton
|
||||
public class Card extends javafx.scene.layout.VBox implements de.neitzel.fx.view.HasViewModel {
|
||||
public final Greeting greeting;
|
||||
private final javafx.beans.property.ObjectProperty<Object> model =
|
||||
new javafx.beans.property.SimpleObjectProperty<>();
|
||||
@javafx.fxml.FXML private javafx.scene.control.Label captionLabel;
|
||||
@javafx.fxml.FXML private javafx.scene.control.TextField street;
|
||||
public de.neitzel.fx.view.ViewModel received;
|
||||
public boolean injected;
|
||||
|
||||
public Card(Greeting greeting) {
|
||||
this.greeting = greeting;
|
||||
}
|
||||
|
||||
@javafx.fxml.FXML
|
||||
public void initialize() {
|
||||
injected = true;
|
||||
captionLabel.setText(greeting.prefix);
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return captionLabel.getText();
|
||||
}
|
||||
|
||||
public void setCaption(String value) {
|
||||
if (!injected) throw new IllegalStateException("Caption applied before injection");
|
||||
captionLabel.setText(value);
|
||||
}
|
||||
|
||||
public javafx.beans.property.ObjectProperty<Object> modelProperty() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public Object getModel() {
|
||||
return model.get();
|
||||
}
|
||||
|
||||
public void setModel(Object value) {
|
||||
model.set(value);
|
||||
}
|
||||
|
||||
public void setViewModel(de.neitzel.fx.view.ViewModel vm) {
|
||||
received = vm;
|
||||
}
|
||||
|
||||
public javafx.scene.control.TextField street() {
|
||||
return street;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package fixture.components;
|
||||
|
||||
@jakarta.inject.Singleton
|
||||
public class Greeting implements AutoCloseable {
|
||||
public final String identity = java.util.UUID.randomUUID().toString();
|
||||
public String prefix = "sample";
|
||||
public int closes;
|
||||
|
||||
public void close() {
|
||||
closes++;
|
||||
}
|
||||
|
||||
public String text() {
|
||||
return prefix + "-" + identity;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package fixture.components;
|
||||
|
||||
@jakarta.inject.Singleton
|
||||
@de.neitzel.fx.view.ViewModelClass(PersonViewModel.class)
|
||||
public class PersonController implements de.neitzel.fx.view.HasViewModel {
|
||||
public final Greeting greeting;
|
||||
public de.neitzel.fx.view.ViewModel received;
|
||||
|
||||
public PersonController(Greeting greeting) {
|
||||
this.greeting = greeting;
|
||||
System.setProperty("fixture.controllers", "constructed");
|
||||
}
|
||||
|
||||
public void setViewModel(de.neitzel.fx.view.ViewModel vm) {
|
||||
received = vm;
|
||||
}
|
||||
|
||||
public String greeting() {
|
||||
if (received == null) throw new IllegalStateException("No ViewModel before bindings");
|
||||
return greeting.text();
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package fixture.components;
|
||||
|
||||
public class PersonViewModel extends de.neitzel.fx.view.ViewModel {
|
||||
public PersonViewModel(Object model) {
|
||||
super(model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package fixture.model;
|
||||
|
||||
public class Address {
|
||||
private String street = "First Street";
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package fixture.model;
|
||||
|
||||
public class Person {
|
||||
private String name = "Ada";
|
||||
private Address home = new Address();
|
||||
|
||||
public Person() {
|
||||
System.setProperty(
|
||||
"fixture.models",
|
||||
Integer.toString(Integer.parseInt(System.getProperty("fixture.models", "0")) + 1));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Address getHome() {
|
||||
return home;
|
||||
}
|
||||
|
||||
public void setHome(Address home) {
|
||||
this.home = home;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
module fixture.app {
|
||||
requires fx;
|
||||
requires injection;
|
||||
requires jakarta.inject;
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
exports fixture.model to
|
||||
fixture.preview,
|
||||
fixture.checks;
|
||||
exports fixture.components to
|
||||
fixture.preview,
|
||||
fixture.checks;
|
||||
|
||||
opens fixture.components;
|
||||
opens fixture.model to
|
||||
fx;
|
||||
}
|
||||
Reference in New Issue
Block a user