Author HTML and typed suggestion bindings in the IntelliJ designer
This commit is contained in:
@@ -85,7 +85,7 @@ Open **Bindings → DataGrid / Docking** in `FolderTab.fxml` to select the grid
|
|||||||
|
|
||||||
In `ArchiveWindow.fxml`, select a layout branch to split it or an outer side area to move it. **Add area with group** creates a destination in an unused area. The **Beispielarchiv** example opens a document and its details in the declared destinations. Both the embedded image and the interactive window use this layout. To repeat both acceptance scenarios, add `--grid-docking ../NeitzelLib/fx-example/src/main/resources/de/neitzel/fx/example/docking/workspace/ReferenceWorkspace.fxml` to the Archiver host check.
|
In `ArchiveWindow.fxml`, select a layout branch to split it or an outer side area to move it. **Add area with group** creates a destination in an unused area. The **Beispielarchiv** example opens a document and its details in the declared destinations. Both the embedded image and the interactive window use this layout. To repeat both acceptance scenarios, add `--grid-docking ../NeitzelLib/fx-example/src/main/resources/de/neitzel/fx/example/docking/workspace/ReferenceWorkspace.fxml` to the Archiver host check.
|
||||||
|
|
||||||
Add `--saved-document` to the Archiver launcher or host check to open the designer-profile view `SavedDocument.fxml`. Under **Form controls**, select **HtmlViewer #article** to edit the media button labels and tooltips. Select **AutoCompleteTextField #fixed** and edit **suggestions**, one tag per line. **Build and Refresh** discovers **HTML · Rechnung** and **HTML · Lieferschein**. **Form preview** shows the rendered HTML at the selected dimensions. In **Interactive preview**, use **Dokument wechseln**, edit **HTML-Quelle**, or type **Re** and **Li** into **Dokument-Tags** before and after switching. The example controller forwards HTML to the viewer and binds the contents of the dynamic tag list.
|
Add `--saved-document` to the Archiver launcher or host check to open the designer-profile view `SavedDocument.fxml`. Under **Form controls**, select **HtmlViewer #article** to edit the media button labels and tooltips. Select **AutoCompleteTextField #fixed** and edit **suggestions**, one tag per line. **Build and Refresh** discovers **HTML · Rechnung** and **HTML · Lieferschein**. **Form preview** shows the rendered HTML at the selected dimensions. In **Interactive preview**, use **Dokument wechseln**, edit **HTML-Quelle**, or type **Re** and **Li** into **Dokument-Tags** before and after switching. The form binds `article.html` to `html` and `dynamic.suggestionsSource` to `tags`, both toward the view. To create either binding, open **Bindings → Discover targets**, select **view** and the model path, select the compatible control property, then choose **Use selected target → Apply binding**. **Form controls → Bind property** opens the declaration for an existing target.
|
||||||
|
|
||||||
For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots.
|
For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots.
|
||||||
|
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
|||||||
values -> {
|
values -> {
|
||||||
bindings.setExpanded(true);
|
bindings.setExpanded(true);
|
||||||
directBindingTab.getTabPane().getSelectionModel().select(directBindingTab);
|
directBindingTab.getTabPane().getSelectionModel().select(directBindingTab);
|
||||||
bindingEditor.newBinding(values);
|
bindingEditor.editProperty(values);
|
||||||
});
|
});
|
||||||
var formPane = new TitledPane("Form controls", formEditor);
|
var formPane = new TitledPane("Form controls", formEditor);
|
||||||
formPane.setExpanded(false);
|
formPane.setExpanded(false);
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ final class FormDocument {
|
|||||||
record Edit(String source, List<Replacement> changes, String selectId) {}
|
record Edit(String source, List<Replacement> changes, String selectId) {}
|
||||||
|
|
||||||
record Field(String name, String type, String fallback, boolean editable) {
|
record Field(String name, String type, String fallback, boolean editable) {
|
||||||
|
boolean bindable() {
|
||||||
|
return type.equals("ObservableList<String>")
|
||||||
|
|| editable
|
||||||
|
&& !name.equals("dismissText")
|
||||||
|
&& Set.of("Integer", "String", "Boolean", "Number", "CSS", "Insets").contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -335,8 +342,12 @@ final class FormDocument {
|
|||||||
field(fields, "initialValue", "Constructor integer", "0");
|
field(fields, "initialValue", "Constructor integer", "0");
|
||||||
field(fields, "number", "Integer", "initialValue");
|
field(fields, "number", "Integer", "initialValue");
|
||||||
}
|
}
|
||||||
if (item.type().equals("AutoCompleteTextField"))
|
if (item.type().equals("AutoCompleteTextField")) {
|
||||||
field(fields, "suggestions", "String list", "");
|
field(fields, "suggestions", "String list", "");
|
||||||
|
fields.put(
|
||||||
|
"suggestionsSource",
|
||||||
|
new Field("suggestionsSource", "ObservableList<String>", "fixed suggestions", false));
|
||||||
|
}
|
||||||
if (item.type().equals("TagChip")) {
|
if (item.type().equals("TagChip")) {
|
||||||
field(fields, "removable", "Boolean", "false");
|
field(fields, "removable", "Boolean", "false");
|
||||||
field(fields, "onRemove", "Event handler", "");
|
field(fields, "onRemove", "Event handler", "");
|
||||||
@@ -351,6 +362,7 @@ final class FormDocument {
|
|||||||
if (Set.of("Label", "Button", "CheckBox", "TextArea").contains(item.type()))
|
if (Set.of("Label", "Button", "CheckBox", "TextArea").contains(item.type()))
|
||||||
field(fields, "wrapText", "Boolean", "false");
|
field(fields, "wrapText", "Boolean", "false");
|
||||||
if (item.type().equals("HtmlViewer")) {
|
if (item.type().equals("HtmlViewer")) {
|
||||||
|
field(fields, "html", "String", "");
|
||||||
field(fields, "mediaButtonVisible", "Boolean", "true");
|
field(fields, "mediaButtonVisible", "Boolean", "true");
|
||||||
field(fields, "mediaLoadText", "String", "Load external media");
|
field(fields, "mediaLoadText", "String", "Load external media");
|
||||||
field(fields, "mediaReloadText", "String", "Reload external media");
|
field(fields, "mediaReloadText", "String", "Reload external media");
|
||||||
|
|||||||
@@ -103,11 +103,7 @@ final class FormEditor extends VBox {
|
|||||||
message.setText("Select a control with an fx:id and a property.");
|
message.setText("Select a control with an fx:id and a property.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!property.editable()
|
if (!property.bindable()) {
|
||||||
|| !(java.util.Set.of(
|
|
||||||
"Integer", "String", "Boolean", "Number", "CSS", "Insets")
|
|
||||||
.contains(property.type()))
|
|
||||||
|| property.name().equals("dismissText")) {
|
|
||||||
message.setText(
|
message.setText(
|
||||||
"This setting has no writable JavaFX property for DirectBinding.");
|
"This setting has no writable JavaFX property for DirectBinding.");
|
||||||
return;
|
return;
|
||||||
@@ -185,7 +181,9 @@ final class FormEditor extends VBox {
|
|||||||
+ " · default "
|
+ " · default "
|
||||||
+ (f.fallback().isEmpty() ? "(empty)" : f.fallback())
|
+ (f.fallback().isEmpty() ? "(empty)" : f.fallback())
|
||||||
+ " · "
|
+ " · "
|
||||||
+ (f.editable() ? "editable" : "read only"));
|
+ (f.type().equals("ObservableList<String>")
|
||||||
|
? "bind to a model list"
|
||||||
|
: f.editable() ? "editable" : "read only"));
|
||||||
value.setEditable(f.editable());
|
value.setEditable(f.editable());
|
||||||
value.setText(form.value(item, f));
|
value.setText(form.value(item, f));
|
||||||
}
|
}
|
||||||
|
|||||||
+44
-4
@@ -27,7 +27,32 @@ public final class BindingDiscovery {
|
|||||||
private final Map<String, Class<?>> paths = new TreeMap<>();
|
private final Map<String, Class<?>> paths = new TreeMap<>();
|
||||||
private final List<Attribute> attributes = new ArrayList<>();
|
private final List<Attribute> attributes = new ArrayList<>();
|
||||||
|
|
||||||
private record TargetType(Class<?> type, boolean writable) {}
|
private final Map<String, Class<?>> listElements = new HashMap<>();
|
||||||
|
|
||||||
|
private record TargetType(Class<?> type, boolean writable, Class<?> listElement) {}
|
||||||
|
|
||||||
|
// Invariant element signatures for explicit JavaFX list properties. Keep raw, wildcard
|
||||||
|
// and unresolvable generic declarations in the existing unverified collection path.
|
||||||
|
private static Class<?> listElement(Method method) {
|
||||||
|
if (!(method.getGenericReturnType() instanceof ParameterizedType p)
|
||||||
|
|| p.getActualTypeArguments().length != 1) return null;
|
||||||
|
Type value = p.getActualTypeArguments()[0];
|
||||||
|
if (p.getRawType() == javafx.beans.property.ListProperty.class
|
||||||
|
|| p.getRawType() == javafx.beans.property.ReadOnlyListProperty.class)
|
||||||
|
return value instanceof Class<?> element ? element : null;
|
||||||
|
if ((p.getRawType() == javafx.beans.property.ObjectProperty.class
|
||||||
|
|| p.getRawType() == javafx.beans.property.ReadOnlyObjectProperty.class)
|
||||||
|
&& value instanceof ParameterizedType list
|
||||||
|
&& list.getRawType() == javafx.collections.ObservableList.class
|
||||||
|
&& list.getActualTypeArguments()[0] instanceof Class<?> element) return element;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean knownListPair(String path, TargetType target, String direction) {
|
||||||
|
return direction.equals("view")
|
||||||
|
&& listElements.containsKey(path)
|
||||||
|
&& target.listElement() != null;
|
||||||
|
}
|
||||||
|
|
||||||
private final Set<String> actionHandlers = new HashSet<>();
|
private final Set<String> actionHandlers = new HashSet<>();
|
||||||
private final Map<String, Class<?>> controlTypes = new HashMap<>();
|
private final Map<String, Class<?>> controlTypes = new HashMap<>();
|
||||||
@@ -344,9 +369,10 @@ public final class BindingDiscovery {
|
|||||||
value = load(componentModel);
|
value = load(componentModel);
|
||||||
constrained = true;
|
constrained = true;
|
||||||
}
|
}
|
||||||
targetTypes.put(
|
var target =
|
||||||
id + "." + property,
|
new TargetType(
|
||||||
new TargetType(value, Property.class.isAssignableFrom(m.getReturnType())));
|
value, Property.class.isAssignableFrom(m.getReturnType()), listElement(m));
|
||||||
|
targetTypes.put(id + "." + property, target);
|
||||||
String status, reason;
|
String status, reason;
|
||||||
if (!Property.class.isAssignableFrom(m.getReturnType())) {
|
if (!Property.class.isAssignableFrom(m.getReturnType())) {
|
||||||
status = "INCOMPATIBLE";
|
status = "INCOMPATIBLE";
|
||||||
@@ -361,6 +387,13 @@ public final class BindingDiscovery {
|
|||||||
status = "UNRESOLVED";
|
status = "UNRESOLVED";
|
||||||
reason =
|
reason =
|
||||||
"Declared types are insufficient; rebuild with specific signatures/Model metadata.";
|
"Declared types are insufficient; rebuild with specific signatures/Model metadata.";
|
||||||
|
} else if (knownListPair(selected, target, direction)) {
|
||||||
|
boolean matches = listElements.get(selected) == target.listElement();
|
||||||
|
status = matches ? "COMPATIBLE" : "INCOMPATIBLE";
|
||||||
|
reason =
|
||||||
|
matches
|
||||||
|
? "Matching observable list element type: " + target.listElement().getName()
|
||||||
|
: "Observable list element types differ.";
|
||||||
} else if (Collection.class.isAssignableFrom(source)
|
} else if (Collection.class.isAssignableFrom(source)
|
||||||
|| Collection.class.isAssignableFrom(value)
|
|| Collection.class.isAssignableFrom(value)
|
||||||
|| Map.class.isAssignableFrom(source)
|
|| Map.class.isAssignableFrom(source)
|
||||||
@@ -518,6 +551,8 @@ public final class BindingDiscovery {
|
|||||||
|| m.isSynthetic()) continue;
|
|| m.isSynthetic()) continue;
|
||||||
String name = m.getName().substring(0, m.getName().length() - 8);
|
String name = m.getName().substring(0, m.getName().length() - 8);
|
||||||
if (name.isEmpty() || paths.containsKey(name)) continue;
|
if (name.isEmpty() || paths.containsKey(name)) continue;
|
||||||
|
Class<?> element = listElement(m);
|
||||||
|
if (element != null) listElements.put(name, element);
|
||||||
Class<?> value = propertyType(m.getGenericReturnType(), Map.of());
|
Class<?> value = propertyType(m.getGenericReturnType(), Map.of());
|
||||||
Class<?> getter = valueType(vm, name);
|
Class<?> getter = valueType(vm, name);
|
||||||
if (value == Number.class && getter != null && Number.class.isAssignableFrom(box(getter)))
|
if (value == Number.class && getter != null && Number.class.isAssignableFrom(box(getter)))
|
||||||
@@ -703,6 +738,11 @@ public final class BindingDiscovery {
|
|||||||
severity = c.status().equals("UNVERIFIED") ? "WARNING" : "ERROR";
|
severity = c.status().equals("UNVERIFIED") ? "WARNING" : "ERROR";
|
||||||
message = converter + ": " + c.reason();
|
message = converter + ": " + c.reason();
|
||||||
}
|
}
|
||||||
|
} else if (knownListPair(path, target, direction)) {
|
||||||
|
if (listElements.get(path) != target.listElement()) {
|
||||||
|
severity = "ERROR";
|
||||||
|
message = "Observable list element types differ.";
|
||||||
|
}
|
||||||
} else if (target.type() == null
|
} else if (target.type() == null
|
||||||
|| source == Object.class
|
|| source == Object.class
|
||||||
|| target.type() == Object.class
|
|| target.type() == Object.class
|
||||||
|
|||||||
+32
@@ -49,6 +49,14 @@ class ViewModelComputedTest {
|
|||||||
throw new AssertionError("reserved invoked");
|
throw new AssertionError("reserved invoked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyListProperty<String> tagsProperty() {
|
||||||
|
throw new AssertionError("property invoked");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectProperty<javafx.collections.ObservableList<Integer>> numbersProperty() {
|
||||||
|
throw new AssertionError("property invoked");
|
||||||
|
}
|
||||||
|
|
||||||
public ReadOnlyStringProperty readOnlyProperty() {
|
public ReadOnlyStringProperty readOnlyProperty() {
|
||||||
throw new AssertionError("readonly invoked");
|
throw new AssertionError("readonly invoked");
|
||||||
}
|
}
|
||||||
@@ -237,6 +245,30 @@ class ViewModelComputedTest {
|
|||||||
assertNull(System.getProperty(key));
|
assertNull(System.getProperty(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void listTargetsCheckTheDeclaredElementTypeForDiscoveryAndValidation() throws Exception {
|
||||||
|
for (String path : List.of("tags", "numbers")) {
|
||||||
|
String document =
|
||||||
|
xml(
|
||||||
|
Controller.class,
|
||||||
|
direct(path).replace("property='text'", "property='suggestionsSource'"))
|
||||||
|
.replace(
|
||||||
|
"javafx.scene.control.TextField", "de.neitzel.fx.control.AutoCompleteTextField")
|
||||||
|
.replace("<TextField", "<AutoCompleteTextField")
|
||||||
|
.replace("</TextField>", "</AutoCompleteTextField>");
|
||||||
|
var result = BindingDiscovery.inspect(document, path, "view", getClass().getClassLoader());
|
||||||
|
var target =
|
||||||
|
result.targets().stream()
|
||||||
|
.filter(t -> t.property().equals("suggestionsSource"))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow();
|
||||||
|
boolean matching = path.equals("tags");
|
||||||
|
assertEquals(matching ? "COMPATIBLE" : "INCOMPATIBLE", target.status());
|
||||||
|
assertEquals(
|
||||||
|
!matching, result.problems().stream().anyMatch(p -> p.severity().equals("ERROR")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void replacementDoesNotInheritModelAttributesOrDottedTraversal() throws Exception {
|
void replacementDoesNotInheritModelAttributesOrDottedTraversal() throws Exception {
|
||||||
var result = inspect(xml(ReplacementController.class, direct("home.name")));
|
var result = inspect(xml(ReplacementController.class, direct("home.name")));
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"status": "verified-local-development-snapshot",
|
"status": "verified-local-development-snapshot",
|
||||||
"sourceRepository": "ssh://git@gitea.neitzel.de:2222/konrad/NeitzelLib.git",
|
"sourceRepository": "ssh://git@gitea.neitzel.de:2222/konrad/NeitzelLib.git",
|
||||||
"sourceRevision": "514cc7fb8ec85824aa4f62adecd52585fe8a9093",
|
"sourceRevision": "e4f1fd3c96f79f22da8998f5a03d05363e30b1e2",
|
||||||
"minimumReleasedVersion": null,
|
"minimumReleasedVersion": null,
|
||||||
"requiredCapability": "managed-views-and-command-bindings",
|
"requiredCapability": "managed-views-command-bindings-and-document-inputs",
|
||||||
"javaVersion": "25",
|
"javaVersion": "25",
|
||||||
"javafxVersion": "27.0.1",
|
"javafxVersion": "27.0.1",
|
||||||
"testResults": {
|
"testResults": {
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"skipped": 0
|
"skipped": 0
|
||||||
},
|
},
|
||||||
"fx": {
|
"fx": {
|
||||||
"tests": 405,
|
"tests": 408,
|
||||||
"failures": 0,
|
"failures": 0,
|
||||||
"errors": 0,
|
"errors": 0,
|
||||||
"skipped": 12
|
"skipped": 12
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
"version": "1.0.6-SNAPSHOT",
|
"version": "1.0.6-SNAPSHOT",
|
||||||
"extension": "jar",
|
"extension": "jar",
|
||||||
"repositoryPath": "de/neitzel/lib/fx/1.0.6-SNAPSHOT/fx-1.0.6-SNAPSHOT.jar",
|
"repositoryPath": "de/neitzel/lib/fx/1.0.6-SNAPSHOT/fx-1.0.6-SNAPSHOT.jar",
|
||||||
"sha256": "e2d5795d1c6e79d2ac47ef7944a14a8d4b847e78473012f3c63370ba7a04618f"
|
"sha256": "6c1b95e963073ccca21bf2214ce33b9baf2fccae506b97e8215ef0130282b192"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generatedViewModelSupport": "stored-property-access-and-declarative-service-registry",
|
"generatedViewModelSupport": "stored-property-access-and-declarative-service-registry",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# NeitzelLib development runtime
|
# NeitzelLib development runtime
|
||||||
|
|
||||||
The IntelliJ Archiver preview uses `de.neitzel.lib:fx:1.0.6-SNAPSHOT` on JDK 25 and JavaFX 27.0.1. The target uses managed Views, CommandBindings and the direct `ViewLoader.loadComponent` entry point for fx:root previews. The host uses JavaFX 26. Source revision, build timestamp, test totals and the nine installed POM/JAR checksums are in the [active manifest](neitzellib-baseline.json).
|
The IntelliJ Archiver preview uses `de.neitzel.lib:fx:1.0.6-SNAPSHOT` on JDK 25 and JavaFX 27.0.1. The target uses managed Views, CommandBindings and the direct `ViewLoader.loadComponent` entry point for fx:root previews. The Archiver document example uses the one-way HTML and observable suggestion-source inputs. The host uses JavaFX 26. Source revision, build timestamp, test totals and the nine installed POM/JAR checksums are in the [active manifest](neitzellib-baseline.json).
|
||||||
|
|
||||||
## Rebuild and verify
|
## Rebuild and verify
|
||||||
|
|
||||||
|
|||||||
@@ -94,12 +94,43 @@ public final class SavedDocumentTargetProbe {
|
|||||||
popup(dynamic, "Re", List.of("Rechnung", "Reise"));
|
popup(dynamic, "Re", List.of("Rechnung", "Reise"));
|
||||||
fx(
|
fx(
|
||||||
() -> {
|
() -> {
|
||||||
|
var tags = tagSource();
|
||||||
|
dynamic.setText("R");
|
||||||
|
tags.add("Register");
|
||||||
|
var choices =
|
||||||
|
Window.getWindows().stream()
|
||||||
|
.filter(w -> w instanceof Popup && w.isShowing())
|
||||||
|
.map(w -> (ListView<?>) w.getScene().lookup(".list-view"))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow();
|
||||||
|
require(
|
||||||
|
choices.getItems().equals(List.of("Rechnung", "Reise", "Register")),
|
||||||
|
"addition in open popup");
|
||||||
|
tags.remove("Reise");
|
||||||
|
require(
|
||||||
|
choices.getItems().equals(List.of("Rechnung", "Register")),
|
||||||
|
"removal in open popup");
|
||||||
|
dynamic.fireEvent(
|
||||||
|
new KeyEvent(
|
||||||
|
KeyEvent.KEY_PRESSED, "", "", KeyCode.DOWN, false, false, false, false));
|
||||||
|
dynamic.fireEvent(
|
||||||
|
new KeyEvent(
|
||||||
|
KeyEvent.KEY_PRESSED, "", "", KeyCode.ENTER, false, false, false, false));
|
||||||
|
require(
|
||||||
|
dynamic.getText().equals("Rechnung")
|
||||||
|
&& tags.equals(List.of("Rechnung", "Register")),
|
||||||
|
"pick leaves catalogue intact");
|
||||||
|
dynamic.setText("Re");
|
||||||
((Button) root.lookup("#next")).fire();
|
((Button) root.lookup("#next")).fire();
|
||||||
|
require(
|
||||||
|
Window.getWindows().stream().noneMatch(w -> w instanceof Popup && w.isShowing()),
|
||||||
|
"old matches dismissed on replacement");
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
body("Lieferschein LS-018");
|
body("Lieferschein LS-018");
|
||||||
require(
|
require(
|
||||||
fx(() -> suggestions(dynamic).equals(List.of("Lieferung", "Lieferschein"))),
|
fx(() -> tagSource().equals(List.of("Lieferung", "Lieferschein"))),
|
||||||
"replacement removes old document tags");
|
"replacement removes old document tags");
|
||||||
popup(dynamic, "Li", List.of("Lieferung", "Lieferschein"));
|
popup(dynamic, "Li", List.of("Lieferung", "Lieferschein"));
|
||||||
popup(fixed, "Pr", List.of("Prüfung", "Privat"));
|
popup(fixed, "Pr", List.of("Prüfung", "Privat"));
|
||||||
@@ -157,8 +188,9 @@ public final class SavedDocumentTargetProbe {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<?> suggestions(TextField field) throws Exception {
|
@SuppressWarnings("unchecked")
|
||||||
return (List<?>) field.getClass().getMethod("getSuggestions").invoke(field);
|
private List<String> tagSource() throws Exception {
|
||||||
|
return (List<String>) dynamic.getClass().getMethod("getSuggestionsSource").invoke(dynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void popup(TextField field, String prefix, List<String> expected) throws Exception {
|
private void popup(TextField field, String prefix, List<String> expected) throws Exception {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import static qualification.WorkflowProbe.*;
|
|||||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
|
import de.neitzel.fxdesigner.protocol.BindingMetadata.Target;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import javafx.embed.swing.SwingFXUtils;
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@@ -48,20 +49,43 @@ public final class SavedDocumentWorkflowProbe extends FormWorkflowProbe {
|
|||||||
.getText()
|
.getText()
|
||||||
.contains("no writable JavaFX property")))
|
.contains("no writable JavaFX property")))
|
||||||
throw new AssertionError("Static collection was offered as a direct binding target");
|
throw new AssertionError("Static collection was offered as a direct binding target");
|
||||||
var current = source();
|
if (source().contains("property=\"suggestionsSource\"")
|
||||||
|
|| source().contains("property=\"html\""))
|
||||||
|
throw new AssertionError("Expected two unbound targets before visual authoring");
|
||||||
|
String current = normalized(source());
|
||||||
click(pane, "Save");
|
click(pane, "Save");
|
||||||
await(() -> Files.readString(path).equals(current));
|
await(() -> normalized(Files.readString(path)).equals(current));
|
||||||
edt(
|
edt(
|
||||||
() -> {
|
() -> {
|
||||||
FileEditorManager.getInstance(project).closeFile(file);
|
FileEditorManager.getInstance(project).closeFile(file);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
pane = openDesigner(project, file);
|
pane = openDesigner(project, file);
|
||||||
if (!source().equals(current)) throw new AssertionError("Reopen lost document settings");
|
if (!normalized(source()).equals(current))
|
||||||
|
throw new AssertionError("Reopen lost document settings");
|
||||||
step("Edited four media labels, visibility and fixed suggestions; saved and reopened");
|
step("Edited four media labels, visibility and fixed suggestions; saved and reopened");
|
||||||
click(pane, "Form preview");
|
click(pane, "Form preview");
|
||||||
click(pane, "Build and Refresh");
|
click(pane, "Build and Refresh");
|
||||||
await(() -> fx(() -> ((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == 2));
|
await(() -> fx(() -> ((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == 2));
|
||||||
|
bindFromModel("html", "article", "html");
|
||||||
|
bindFromModel("tags", "dynamic", "suggestionsSource");
|
||||||
|
String bound = normalized(source());
|
||||||
|
click(pane, "Save");
|
||||||
|
await(() -> normalized(Files.readString(path)).equals(bound));
|
||||||
|
edt(
|
||||||
|
() -> {
|
||||||
|
FileEditorManager.getInstance(project).closeFile(file);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
pane = openDesigner(project, file);
|
||||||
|
if (!normalized(source()).equals(bound))
|
||||||
|
throw new AssertionError("Reopen lost direct bindings");
|
||||||
|
Files.copy(path, output.resolve("saved-bindings.fxml"));
|
||||||
|
checkSavedBinding("HtmlViewer #article", "html", "html");
|
||||||
|
checkSavedBinding("AutoCompleteTextField #dynamic", "suggestionsSource", "tags");
|
||||||
|
click(pane, "Form preview");
|
||||||
|
click(pane, "Build and Refresh");
|
||||||
|
await(() -> fx(() -> ((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == 2));
|
||||||
choose("preview-example", "saved-invoice");
|
choose("preview-example", "saved-invoice");
|
||||||
frame("invoice", "Rechnung", 0xff294973);
|
frame("invoice", "Rechnung", 0xff294973);
|
||||||
click(pane, "Interactive preview");
|
click(pane, "Interactive preview");
|
||||||
@@ -83,6 +107,98 @@ public final class SavedDocumentWorkflowProbe extends FormWorkflowProbe {
|
|||||||
+ " frames, document replacement, error recovery and live suggestion popups.\n");
|
+ " frames, document replacement, error recovery and live suggestion popups.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IntelliJ can strip indentation from empty lines left by element removal on save.
|
||||||
|
private static String normalized(String source) {
|
||||||
|
return source.replaceAll("(?m)^[ \t]+$", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSavedBinding(String control, String property, String path) throws Exception {
|
||||||
|
controls(true);
|
||||||
|
choose("form-control", control);
|
||||||
|
choose("form-property", property);
|
||||||
|
click(pane, "Bind property");
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() ->
|
||||||
|
((TextField) pane.lookup("#direct-property")).getText().equals(property)
|
||||||
|
&& ((TextField) pane.lookup("#direct-path")).getText().equals(path)
|
||||||
|
&& ((ComboBox<?>) pane.lookup("#direct-direction"))
|
||||||
|
.getValue()
|
||||||
|
.equals("view")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindFromModel(String path, String control, String property) throws Exception {
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
var group =
|
||||||
|
(TitledPane)
|
||||||
|
pane.lookupAll(".titled-pane").stream()
|
||||||
|
.filter(n -> n instanceof TitledPane t && t.getText().equals("Bindings"))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow();
|
||||||
|
group.setAnimated(false);
|
||||||
|
group.setExpanded(true);
|
||||||
|
var tabs = (TabPane) group.getContent();
|
||||||
|
tabs.getSelectionModel()
|
||||||
|
.select(
|
||||||
|
tabs.getTabs().stream()
|
||||||
|
.filter(t -> t.getText().equals("Discover targets"))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow());
|
||||||
|
pane.applyCss();
|
||||||
|
pane.layout();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
click(pane, "Discover bindings");
|
||||||
|
await(() -> fx(() -> !((ComboBox<?>) pane.lookup("#binding-path")).getItems().isEmpty()));
|
||||||
|
choose("binding-direction", "view");
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() ->
|
||||||
|
((ComboBox<?>) pane.lookup("#binding-path"))
|
||||||
|
.getItems().stream().anyMatch(a -> a.toString().startsWith(path + " : "))));
|
||||||
|
choose("binding-path", path + " : ");
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
var targets = (TableView<Target>) pane.lookup("#binding-targets");
|
||||||
|
var target =
|
||||||
|
targets.getItems().stream()
|
||||||
|
.filter(
|
||||||
|
t ->
|
||||||
|
t.control().equals(control)
|
||||||
|
&& t.property().equals(property)
|
||||||
|
&& t.status().equals("COMPATIBLE"))
|
||||||
|
.findFirst();
|
||||||
|
if (target.isEmpty()) return false;
|
||||||
|
targets.getSelectionModel().select(target.get());
|
||||||
|
return true;
|
||||||
|
}));
|
||||||
|
click(pane, "Use selected target");
|
||||||
|
if (!fx(
|
||||||
|
() ->
|
||||||
|
((TextField) pane.lookup("#direct-path")).getText().equals(path)
|
||||||
|
&& ((ComboBox<?>) pane.lookup("#direct-direction")).getValue().equals("view")))
|
||||||
|
throw new AssertionError("Wrong source or direction for " + property);
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
var editor = pane.lookup("#direct-bindings").getParent();
|
||||||
|
ImageIO.write(
|
||||||
|
SwingFXUtils.fromFXImage(editor.snapshot(null, null), null),
|
||||||
|
"png",
|
||||||
|
output.resolve("binding-" + control + ".png").toFile());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
click(pane, "Apply binding");
|
||||||
|
await(() -> source().contains("property=\"" + property + "\""));
|
||||||
|
step(
|
||||||
|
"Created " + control + "." + property + " from compatible source " + path + " toward view");
|
||||||
|
}
|
||||||
|
|
||||||
private void frame(String id, String title, int accent) throws Exception {
|
private void frame(String id, String title, int accent) throws Exception {
|
||||||
await(
|
await(
|
||||||
() ->
|
() ->
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode i
|
|||||||
shutil.copyfile(base / "intellij.png", output / (mode + ".png"))
|
shutil.copyfile(base / "intellij.png", output / (mode + ".png"))
|
||||||
(evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n")
|
(evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n")
|
||||||
finally:
|
finally:
|
||||||
for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
|
for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
|
||||||
if (base / name).exists():
|
if (base / name).exists():
|
||||||
shutil.copyfile(base / name, evidence / name)
|
shutil.copyfile(base / name, evidence / name)
|
||||||
workers = descendant_workers(pid)
|
workers = descendant_workers(pid)
|
||||||
|
|||||||
@@ -41,6 +41,15 @@ if args.archiver:
|
|||||||
file = project / f"src/main/resources/de/neitzel/archiver/ui/{view}.fxml"
|
file = project / f"src/main/resources/de/neitzel/archiver/ui/{view}.fxml"
|
||||||
if args.saved_document:
|
if args.saved_document:
|
||||||
file = project / "src/designer/resources/de/neitzel/archiver/preview/SavedDocument.fxml"
|
file = project / "src/designer/resources/de/neitzel/archiver/preview/SavedDocument.fxml"
|
||||||
|
if args.check:
|
||||||
|
# Start the authoring test with both destinations unbound in the disposable copy.
|
||||||
|
source = file.read_text()
|
||||||
|
for control, prop, path in (("article", "html", "html"), ("dynamic", "suggestionsSource", "tags")):
|
||||||
|
declaration = f'<DirectBinding control="{control}" property="{prop}" path="{path}" direction="view"/>'
|
||||||
|
if source.count(declaration) != 1:
|
||||||
|
raise ValueError(f"Expected the shipped sample binding for {control}.{prop}")
|
||||||
|
source = source.replace(declaration, "")
|
||||||
|
file.write_text(source)
|
||||||
else:
|
else:
|
||||||
subprocess.run([sys.executable, ROOT / "scripts/prepare-fixture-host.py", "--destination", project,
|
subprocess.run([sys.executable, ROOT / "scripts/prepare-fixture-host.py", "--destination", project,
|
||||||
"--target-java-home", args.target_java_home, "--mode", args.mode], check=True)
|
"--target-java-home", args.target_java_home, "--mode", args.mode], check=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user