Resolve generic JavaFX binding targets and verify them in IntelliJ
This commit is contained in:
@@ -87,6 +87,8 @@ In `ArchiveWindow.fxml`, select a layout branch to split it or an outer side are
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
Use `--import-form` with `scripts/check-ide-host.py --archiver ../Archiver` and the same JDK and IDEA options to verify seven generic binding targets. The check saves and reopens bindings on the folder grid and import selector, then exercises the free, conflicting and busy import examples in the registered editor.
|
||||||
|
|
||||||
Use `--document-tabs` with the Archiver host check to open the production archive window and select **Archiver · HTML-Dokumenttabs**. The check switches from the invoice to the delivery note and back, reads each WebView, and checks the actual suggestion popup for the same prefix in both tabs.
|
Use `--document-tabs` with the Archiver host check to open the production archive window and select **Archiver · HTML-Dokumenttabs**. The check switches from the invoice to the delivery note and back, reads each WebView, and checks the actual suggestion popup for the same prefix in both tabs.
|
||||||
|
|
||||||
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.
|
||||||
|
|||||||
+40
-55
@@ -31,27 +31,23 @@ public final class BindingDiscovery {
|
|||||||
|
|
||||||
private record TargetType(Class<?> type, boolean writable, Class<?> listElement) {}
|
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) {
|
private boolean knownListPair(String path, TargetType target, String direction) {
|
||||||
return direction.equals("view")
|
return direction.equals("view")
|
||||||
&& listElements.containsKey(path)
|
&& listElements.containsKey(path)
|
||||||
&& target.listElement() != null;
|
&& target.listElement() != null
|
||||||
|
&& target.type() != null
|
||||||
|
&& target.type().isAssignableFrom(paths.get(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean disjointCollectionTypes(Class<?> source, Class<?> target) {
|
||||||
|
if (source == null || target == null || source == Object.class || target == Object.class)
|
||||||
|
return false;
|
||||||
|
return (Collection.class.isAssignableFrom(source)
|
||||||
|
|| Map.class.isAssignableFrom(source)
|
||||||
|
|| Collection.class.isAssignableFrom(target)
|
||||||
|
|| Map.class.isAssignableFrom(target))
|
||||||
|
&& !source.isAssignableFrom(target)
|
||||||
|
&& !target.isAssignableFrom(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<String> actionHandlers = new HashSet<>();
|
private final Set<String> actionHandlers = new HashSet<>();
|
||||||
@@ -352,6 +348,7 @@ public final class BindingDiscovery {
|
|||||||
if (b.length > 512 * 1024) throw new IOException("Component FXML exceeds limit");
|
if (b.length > 512 * 1024) throw new IOException("Component FXML exceeds limit");
|
||||||
componentModel = model(parse(new String(b, java.nio.charset.StandardCharsets.UTF_8)));
|
componentModel = model(parse(new String(b, java.nio.charset.StandardCharsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
var fieldTypes = GenericPropertyType.controlBindings(owner.controller, id, control);
|
||||||
for (Method m : control.getMethods()) {
|
for (Method m : control.getMethods()) {
|
||||||
if (Modifier.isStatic(m.getModifiers())
|
if (Modifier.isStatic(m.getModifiers())
|
||||||
|| m.getParameterCount() != 0
|
|| m.getParameterCount() != 0
|
||||||
@@ -360,10 +357,12 @@ public final class BindingDiscovery {
|
|||||||
String property = m.getName().substring(0, m.getName().length() - 8);
|
String property = m.getName().substring(0, m.getName().length() - 8);
|
||||||
if (property.isEmpty()) continue;
|
if (property.isEmpty()) continue;
|
||||||
Class<?> getter = valueType(control, property);
|
Class<?> getter = valueType(control, property);
|
||||||
Class<?> value = propertyType(m.getGenericReturnType(), Map.of());
|
var signature = GenericPropertyType.of(control, m, fieldTypes);
|
||||||
|
Class<?> value = signature.value();
|
||||||
if (value == Number.class && getter != null && Number.class.isAssignableFrom(box(getter)))
|
if (value == Number.class && getter != null && Number.class.isAssignableFrom(box(getter)))
|
||||||
value = getter;
|
value = getter;
|
||||||
else if (value != null && getter != null && box(value) != box(getter)) value = null;
|
else if (value != null && getter != null && !box(getter).isAssignableFrom(box(value)))
|
||||||
|
value = null;
|
||||||
boolean constrained = false;
|
boolean constrained = false;
|
||||||
if (property.equals("model") && !componentModel.isEmpty()) {
|
if (property.equals("model") && !componentModel.isEmpty()) {
|
||||||
value = load(componentModel);
|
value = load(componentModel);
|
||||||
@@ -371,7 +370,9 @@ public final class BindingDiscovery {
|
|||||||
}
|
}
|
||||||
var target =
|
var target =
|
||||||
new TargetType(
|
new TargetType(
|
||||||
value, Property.class.isAssignableFrom(m.getReturnType()), listElement(m));
|
value,
|
||||||
|
Property.class.isAssignableFrom(m.getReturnType()),
|
||||||
|
signature.listElement());
|
||||||
targetTypes.put(id + "." + property, target);
|
targetTypes.put(id + "." + property, target);
|
||||||
String status, reason;
|
String status, reason;
|
||||||
if (!Property.class.isAssignableFrom(m.getReturnType())) {
|
if (!Property.class.isAssignableFrom(m.getReturnType())) {
|
||||||
@@ -386,7 +387,8 @@ public final class BindingDiscovery {
|
|||||||
|| value == Object.class) {
|
|| value == Object.class) {
|
||||||
status = "UNRESOLVED";
|
status = "UNRESOLVED";
|
||||||
reason =
|
reason =
|
||||||
"Declared types are insufficient; rebuild with specific signatures/Model metadata.";
|
"Declared types are insufficient. Declare the fx:id field with its concrete generic"
|
||||||
|
+ " type in the FXML controller and rebuild.";
|
||||||
} else if (knownListPair(selected, target, direction)) {
|
} else if (knownListPair(selected, target, direction)) {
|
||||||
boolean matches = listElements.get(selected) == target.listElement();
|
boolean matches = listElements.get(selected) == target.listElement();
|
||||||
status = matches ? "COMPATIBLE" : "INCOMPATIBLE";
|
status = matches ? "COMPATIBLE" : "INCOMPATIBLE";
|
||||||
@@ -394,14 +396,17 @@ public final class BindingDiscovery {
|
|||||||
matches
|
matches
|
||||||
? "Matching observable list element type: " + target.listElement().getName()
|
? "Matching observable list element type: " + target.listElement().getName()
|
||||||
: "Observable list element types differ.";
|
: "Observable list element types differ.";
|
||||||
|
} else if (disjointCollectionTypes(source, value)) {
|
||||||
|
status = "INCOMPATIBLE";
|
||||||
|
reason = "Collection and scalar types cannot be directly bound.";
|
||||||
} 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)
|
||||||
|| Map.class.isAssignableFrom(value)) {
|
|| Map.class.isAssignableFrom(value)) {
|
||||||
status = "UNRESOLVED";
|
status = "UNRESOLVED";
|
||||||
reason =
|
reason =
|
||||||
"Collection variance requires further metadata; use Repeat/Table for Model"
|
"Unresolved collection element types. Declare concrete element types on the model"
|
||||||
+ " collections.";
|
+ " and the fx:id controller field.";
|
||||||
} else {
|
} else {
|
||||||
Class<?> a = box(source), b = box(value);
|
Class<?> a = box(source), b = box(value);
|
||||||
boolean view = b.isAssignableFrom(a), back = a.isAssignableFrom(b);
|
boolean view = b.isAssignableFrom(a), back = a.isAssignableFrom(b);
|
||||||
@@ -551,13 +556,15 @@ 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);
|
var signature = GenericPropertyType.of(vm, m, Map.of());
|
||||||
|
Class<?> element = signature.listElement();
|
||||||
if (element != null) listElements.put(name, element);
|
if (element != null) listElements.put(name, element);
|
||||||
Class<?> value = propertyType(m.getGenericReturnType(), Map.of());
|
Class<?> value = signature.value();
|
||||||
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)))
|
||||||
value = getter;
|
value = getter;
|
||||||
else if (value != null && getter != null && box(value) != box(getter)) value = null;
|
else if (value != null && getter != null && !box(getter).isAssignableFrom(box(value)))
|
||||||
|
value = null;
|
||||||
boolean readOnly = !Property.class.isAssignableFrom(m.getReturnType());
|
boolean readOnly = !Property.class.isAssignableFrom(m.getReturnType());
|
||||||
if (readOnly) readOnlySources.add(name);
|
if (readOnly) readOnlySources.add(name);
|
||||||
paths.put(name, value == null ? Object.class : value);
|
paths.put(name, value == null ? Object.class : value);
|
||||||
@@ -743,6 +750,9 @@ public final class BindingDiscovery {
|
|||||||
severity = "ERROR";
|
severity = "ERROR";
|
||||||
message = "Observable list element types differ.";
|
message = "Observable list element types differ.";
|
||||||
}
|
}
|
||||||
|
} else if (disjointCollectionTypes(source, target.type())) {
|
||||||
|
severity = "ERROR";
|
||||||
|
message = "Collection and scalar types cannot be directly bound.";
|
||||||
} else if (target.type() == null
|
} else if (target.type() == null
|
||||||
|| source == Object.class
|
|| source == Object.class
|
||||||
|| target.type() == Object.class
|
|| target.type() == Object.class
|
||||||
@@ -751,7 +761,9 @@ public final class BindingDiscovery {
|
|||||||
|| Map.class.isAssignableFrom(source)
|
|| Map.class.isAssignableFrom(source)
|
||||||
|| Map.class.isAssignableFrom(target.type())) {
|
|| Map.class.isAssignableFrom(target.type())) {
|
||||||
severity = "WARNING";
|
severity = "WARNING";
|
||||||
message = "Value types require additional metadata";
|
message =
|
||||||
|
"Value types require additional metadata. Declare concrete types on the model and the"
|
||||||
|
+ " fx:id controller field.";
|
||||||
} else {
|
} else {
|
||||||
Class<?> a = box(source), b = box(target.type());
|
Class<?> a = box(source), b = box(target.type());
|
||||||
if ((!direction.equals("model") && !b.isAssignableFrom(a))
|
if ((!direction.equals("model") && !b.isAssignableFrom(a))
|
||||||
@@ -808,33 +820,6 @@ public final class BindingDiscovery {
|
|||||||
return candidates.iterator().next();
|
return candidates.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Class<?> propertyType(Type type, Map<TypeVariable<?>, Type> inherited) {
|
|
||||||
Class<?> raw;
|
|
||||||
var bindings = new HashMap<>(inherited);
|
|
||||||
if (type instanceof ParameterizedType p && p.getRawType() instanceof Class<?> c) {
|
|
||||||
raw = c;
|
|
||||||
for (int i = 0; i < c.getTypeParameters().length; i++) {
|
|
||||||
Type argument = p.getActualTypeArguments()[i];
|
|
||||||
if (argument instanceof TypeVariable<?> v) argument = bindings.getOrDefault(v, v);
|
|
||||||
bindings.put(c.getTypeParameters()[i], argument);
|
|
||||||
}
|
|
||||||
} else if (type instanceof Class<?> c) raw = c;
|
|
||||||
else return null;
|
|
||||||
if (raw == ObservableValue.class) {
|
|
||||||
Type value = bindings.get(raw.getTypeParameters()[0]);
|
|
||||||
return value instanceof Class<?> c
|
|
||||||
? c
|
|
||||||
: value instanceof ParameterizedType p && p.getRawType() instanceof Class<?> c ? c : null;
|
|
||||||
}
|
|
||||||
for (Type parent : raw.getGenericInterfaces()) {
|
|
||||||
Class<?> value = propertyType(parent, bindings);
|
|
||||||
if (value != null) return value;
|
|
||||||
}
|
|
||||||
return raw.getGenericSuperclass() == null
|
|
||||||
? null
|
|
||||||
: propertyType(raw.getGenericSuperclass(), bindings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Class<?> valueType(Class<?> control, String name) {
|
private static Class<?> valueType(Class<?> control, String name) {
|
||||||
String suffix = Character.toUpperCase(name.charAt(0)) + name.substring(1);
|
String suffix = Character.toUpperCase(name.charAt(0)) + name.substring(1);
|
||||||
for (String prefix : List.of("get", "is"))
|
for (String prefix : List.of("get", "is"))
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package de.neitzel.fxdesigner.target;
|
||||||
|
|
||||||
|
import java.lang.reflect.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
|
||||||
|
/** Resolves JavaFX accessor signatures without constructing a controller or control. */
|
||||||
|
record GenericPropertyType(Class<?> value, Class<?> listElement) {
|
||||||
|
static Map<TypeVariable<?>, Type> controlBindings(
|
||||||
|
Class<?> controller, String id, Class<?> control) {
|
||||||
|
for (Class<?> declaring = controller;
|
||||||
|
declaring != null;
|
||||||
|
declaring = declaring.getSuperclass()) {
|
||||||
|
try {
|
||||||
|
Field field = declaring.getDeclaredField(id);
|
||||||
|
int modifiers = field.getModifiers();
|
||||||
|
if (Modifier.isStatic(modifiers)
|
||||||
|
|| Modifier.isFinal(modifiers)
|
||||||
|
|| !(Modifier.isPublic(modifiers) || field.isAnnotationPresent(FXML.class))
|
||||||
|
|| !field.getType().isAssignableFrom(control)) continue;
|
||||||
|
var inherited = bindings(controller, declaring, Map.of());
|
||||||
|
return bindArguments(field.getGenericType(), inherited);
|
||||||
|
} catch (NoSuchFieldException ignored) {
|
||||||
|
// FXMLLoader also looks for inherited controller fields.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
static GenericPropertyType of(
|
||||||
|
Class<?> receiver, Method accessor, Map<TypeVariable<?>, Type> fields) {
|
||||||
|
var scope = bindings(receiver, accessor.getDeclaringClass(), fields);
|
||||||
|
var valueScope = bindings(accessor.getGenericReturnType(), ObservableValue.class, scope);
|
||||||
|
Type type = resolve(ObservableValue.class.getTypeParameters()[0], valueScope);
|
||||||
|
Class<?> raw = raw(type);
|
||||||
|
Class<?> element = null;
|
||||||
|
if (raw != null && ObservableList.class.isAssignableFrom(raw)) {
|
||||||
|
var listScope = bindings(type, ObservableList.class, valueScope);
|
||||||
|
var item = resolve(ObservableList.class.getTypeParameters()[0], listScope);
|
||||||
|
if (item instanceof Class<?> exact) element = exact;
|
||||||
|
}
|
||||||
|
return new GenericPropertyType(raw, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Class<?> raw(Type type) {
|
||||||
|
if (type instanceof ParameterizedType p) return (Class<?>) p.getRawType();
|
||||||
|
return type instanceof Class<?> c ? c : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Type resolve(Type type, Map<TypeVariable<?>, Type> scope) {
|
||||||
|
while (type instanceof TypeVariable<?> v && scope.containsKey(v)) type = scope.get(v);
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<TypeVariable<?>, Type> bindArguments(
|
||||||
|
Type type, Map<TypeVariable<?>, Type> scope) {
|
||||||
|
if (!(type instanceof ParameterizedType p)) return scope;
|
||||||
|
var result = new HashMap<>(scope);
|
||||||
|
var vars = raw(type).getTypeParameters();
|
||||||
|
var args = p.getActualTypeArguments();
|
||||||
|
for (int i = 0; i < vars.length; i++) {
|
||||||
|
Type argument = resolve(args[i], scope);
|
||||||
|
// A field can type an ancestor (ComboBoxBase<String>) while the FXML declares
|
||||||
|
// a raw subclass (ComboBox). An unbound subclass variable adds no information.
|
||||||
|
if (argument instanceof TypeVariable<?> && scope.containsKey(vars[i])) continue;
|
||||||
|
if (!vars[i].equals(argument)) result.put(vars[i], argument);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<TypeVariable<?>, Type> bindings(
|
||||||
|
Type type, Class<?> target, Map<TypeVariable<?>, Type> scope) {
|
||||||
|
var raw = raw(type);
|
||||||
|
if (raw == null || !target.isAssignableFrom(raw)) return scope;
|
||||||
|
var local = bindArguments(type, scope);
|
||||||
|
if (raw == target) return local;
|
||||||
|
for (Type parent : raw.getGenericInterfaces()) {
|
||||||
|
if (target.isAssignableFrom(raw(parent))) return bindings(parent, target, local);
|
||||||
|
}
|
||||||
|
return bindings(raw.getGenericSuperclass(), target, local);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -222,7 +222,7 @@ final class RepeatDiscovery {
|
|||||||
if (!Property.class.isAssignableFrom(accessor.getReturnType())
|
if (!Property.class.isAssignableFrom(accessor.getReturnType())
|
||||||
|| !ControllerMetadata.accessible(accessor.getDeclaringClass(), true))
|
|| !ControllerMetadata.accessible(accessor.getDeclaringClass(), true))
|
||||||
throw new IllegalArgumentException("Component needs an accessible writable modelProperty");
|
throw new IllegalArgumentException("Component needs an accessible writable modelProperty");
|
||||||
Class<?> property = BindingDiscovery.propertyType(accessor.getGenericReturnType(), Map.of());
|
Class<?> property = GenericPropertyType.of(type, accessor, Map.of()).value();
|
||||||
Document doc = resource(type);
|
Document doc = resource(type);
|
||||||
Element root = doc.getDocumentElement();
|
Element root = doc.getDocumentElement();
|
||||||
if (!"http://javafx.com/fxml/1".equals(root.getNamespaceURI())
|
if (!"http://javafx.com/fxml/1".equals(root.getNamespaceURI())
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package de.neitzel.fxdesigner.target;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.ComboBoxBase;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class GenericPropertyTypeTest {
|
||||||
|
static class Base<T> {
|
||||||
|
@FXML private ComboBox<T> inherited;
|
||||||
|
@FXML private ComboBoxBase<Long> baseControl;
|
||||||
|
@FXML private ComboBox<? extends Number> bounded;
|
||||||
|
@FXML private ComboBox<List<String>> nested;
|
||||||
|
private ComboBox<String> uninjected;
|
||||||
|
@FXML private List<String> wrongControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Controller extends Base<Integer> {}
|
||||||
|
|
||||||
|
private GenericPropertyType signature(String id, String property) throws Exception {
|
||||||
|
var field = GenericPropertyType.controlBindings(Controller.class, id, ComboBox.class);
|
||||||
|
return GenericPropertyType.of(
|
||||||
|
ComboBox.class, ComboBox.class.getMethod(property + "Property"), field);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void resolvesInheritedControllerAndControlArgumentsWithoutStartingJavaFx() throws Exception {
|
||||||
|
assertEquals(Integer.class, signature("inherited", "value").value());
|
||||||
|
assertEquals(Integer.class, signature("inherited", "items").listElement());
|
||||||
|
assertEquals(Long.class, signature("baseControl", "value").value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void unknownOrIncompatibleFieldsDoNotCertifyListElementTypes() throws Exception {
|
||||||
|
for (String id : List.of("bounded", "nested", "uninjected", "missing", "wrongControl"))
|
||||||
|
assertNull(signature(id, "items").listElement(), id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ Discovery owns a separate workflow so it does not replace the canvas or interact
|
|||||||
|
|
||||||
FXML parsing disables external entities and DOCTYPE. Inputs, scene-node counts, path expansion, target counts and protocol payloads are bounded. Ambiguous imports, duplicate IDs, missing classes, invalid XML and absent declarations produce diagnostics. Attached-property binding discovery, open child-draft metadata overlays, broader custom metadata and complete collection compatibility remain later extensions, not silently inferred support.
|
FXML parsing disables external entities and DOCTYPE. Inputs, scene-node counts, path expansion, target counts and protocol payloads are bounded. Ambiguous imports, duplicate IDs, missing classes, invalid XML and absent declarations produce diagnostics. Attached-property binding discovery, open child-draft metadata overlays, broader custom metadata and complete collection compatibility remain later extensions, not silently inferred support.
|
||||||
|
|
||||||
|
A field matching the FXML ID can supply generic arguments that are erased in the FXML element. For example, declaring `@FXML private ComboBox<String> security` on the controller types both `security.value` and the elements of `security.items`. The worker follows inherited controller fields, control superclasses and JavaFX property interfaces using compiled signatures. An invariant observable-list binding toward the view requires matching element types. Incompatible list elements and unrelated scalar destinations receive a diagnostic. Wildcards and raw selectors retain an unresolved result until the project provides a concrete type.
|
||||||
|
|
||||||
## Qualification
|
## Qualification
|
||||||
|
|
||||||
Tests cover non-initializing signature discovery, nested and collection metadata, direction-dependent assignability, read-only targets, incompatible targets, secure parsing, metadata codec bounds and capability negotiation. Real classpath/module-path Person fixtures check Component Model compatibility and absence of Model, Controller and provider construction/initialization. Connected contracts test the worker protocol in both document adapters; live shared Kit checks use the same browser in standalone and the registered IntelliJ editor and verify source preservation.
|
Tests cover non-initializing signature discovery, nested and collection metadata, direction-dependent assignability, read-only targets, incompatible targets, secure parsing, metadata codec bounds and capability negotiation. Real classpath/module-path Person fixtures check Component Model compatibility and absence of Model, Controller and provider construction/initialization. Connected contracts test the worker protocol in both document adapters; live shared Kit checks use the same browser in standalone and the registered IntelliJ editor and verify source preservation.
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package qualification;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.nio.file.*;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import javafx.stage.*;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
/** Reads the visible rows and drives the real import controls in the worker's interactive stage. */
|
||||||
|
public final class ImportTargetProbe {
|
||||||
|
public static void premain(String directory) {
|
||||||
|
if (System.getProperty("sun.java.command", "")
|
||||||
|
.startsWith("de.neitzel.fxdesigner.target.WorkerMain "))
|
||||||
|
Thread.ofPlatform().daemon().start(() -> Probe.run(Path.of(directory)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class Probe {
|
||||||
|
static void run(Path directory) {
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
Thread.sleep(150);
|
||||||
|
var task = new FutureTask<>(() -> inspect(directory));
|
||||||
|
try {
|
||||||
|
Platform.runLater(task);
|
||||||
|
} catch (IllegalStateException booting) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (task.get(15, TimeUnit.SECONDS)) return;
|
||||||
|
}
|
||||||
|
} catch (Throwable failure) {
|
||||||
|
var trace = new java.io.StringWriter();
|
||||||
|
failure.printStackTrace(new java.io.PrintWriter(trace));
|
||||||
|
try {
|
||||||
|
Files.writeString(directory.resolve("target-error.txt"), trace.toString());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean inspect(Path directory) throws Exception {
|
||||||
|
var stage =
|
||||||
|
Window.getWindows().stream()
|
||||||
|
.filter(Stage.class::isInstance)
|
||||||
|
.map(Stage.class::cast)
|
||||||
|
.filter(
|
||||||
|
w ->
|
||||||
|
w.isShowing()
|
||||||
|
&& w.getTitle() != null
|
||||||
|
&& w.getTitle().startsWith("Neitzel preview"))
|
||||||
|
.findFirst();
|
||||||
|
if (stage.isEmpty()) return false;
|
||||||
|
Node root = stage.get().getScene().getRoot();
|
||||||
|
String attempt = Files.readString(directory.resolve("import-attempt"));
|
||||||
|
String result;
|
||||||
|
if (attempt.equals("import-grid")) {
|
||||||
|
var cells =
|
||||||
|
root.lookupAll("*").stream()
|
||||||
|
.filter(Labeled.class::isInstance)
|
||||||
|
.map(n -> ((Labeled) n).getText())
|
||||||
|
.toList();
|
||||||
|
if (!cells.contains("Musterrechnung.pdf") || !cells.contains("Lieferbrief.txt"))
|
||||||
|
return false;
|
||||||
|
result = "Visible rows: Musterrechnung.pdf, Lieferbrief.txt";
|
||||||
|
} else {
|
||||||
|
var form = root.lookup("#form");
|
||||||
|
if (form == null) return false;
|
||||||
|
var name = (TextField) form.lookup("#name");
|
||||||
|
var folders = (ComboBox<?>) form.lookup("#folders");
|
||||||
|
var free = (Button) form.lookup("#useFreeName");
|
||||||
|
var target = (Label) form.lookup("#target");
|
||||||
|
var status = (Label) form.lookup("#status");
|
||||||
|
if (attempt.equals("import-free")) {
|
||||||
|
check(
|
||||||
|
target.getText().equals("Archivwurzel")
|
||||||
|
&& name.getText().equals("Rechnung.md")
|
||||||
|
&& !form.isDisabled(),
|
||||||
|
"Initial free name");
|
||||||
|
name.setText("Entwurf.md");
|
||||||
|
folders.getSelectionModel().select(1);
|
||||||
|
check(
|
||||||
|
target.getText().equals("Belege")
|
||||||
|
&& name.getText().equals("Entwurf.md")
|
||||||
|
&& !free.isVisible()
|
||||||
|
&& !free.isManaged(),
|
||||||
|
"Folder/name write-back");
|
||||||
|
folders.getSelectionModel().select(0);
|
||||||
|
check(
|
||||||
|
target.getText().equals("Archivwurzel") && name.getText().equals("Entwurf.md"),
|
||||||
|
"Return to root");
|
||||||
|
result = "Edited name Entwurf.md retained across Archivwurzel -> Belege -> Archivwurzel";
|
||||||
|
} else if (attempt.equals("import-busy")) {
|
||||||
|
check(
|
||||||
|
form.isDisabled()
|
||||||
|
&& name.isDisabled()
|
||||||
|
&& status.getText().contains("Datei wird abgelegt"),
|
||||||
|
"Busy draft must block input");
|
||||||
|
result = "Accepted draft entered busy state and disabled the form";
|
||||||
|
} else {
|
||||||
|
check(
|
||||||
|
attempt.equals("import-collision")
|
||||||
|
&& name.getText().equals("Rechnung.md")
|
||||||
|
&& target.getText().equals("Belege")
|
||||||
|
&& free.isVisible()
|
||||||
|
&& free.isManaged()
|
||||||
|
&& status.getText().contains("Dateiname belegt. Vorschlag: Rechnung (2).md"),
|
||||||
|
"Expected initial collision: "
|
||||||
|
+ name.getText()
|
||||||
|
+ " / "
|
||||||
|
+ target.getText()
|
||||||
|
+ " / "
|
||||||
|
+ status.getText());
|
||||||
|
picture(form, directory.resolve("import-collision.png"));
|
||||||
|
free.fire();
|
||||||
|
check(
|
||||||
|
name.getText().equals("Rechnung (2).md")
|
||||||
|
&& !free.isVisible()
|
||||||
|
&& !free.isManaged()
|
||||||
|
&& !status.getText().contains("belegt"),
|
||||||
|
"Accept free name");
|
||||||
|
picture(form, directory.resolve("import-accepted.png"));
|
||||||
|
result =
|
||||||
|
"Belege/Rechnung.md -> Rechnung (2).md; collision cleared, button invisible and"
|
||||||
|
+ " unmanaged";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Files.writeString(directory.resolve("result-" + attempt), result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void check(boolean condition, String message) {
|
||||||
|
if (!condition) throw new AssertionError(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void picture(Node node, Path file) throws Exception {
|
||||||
|
node.getScene().getRoot().applyCss();
|
||||||
|
node.getScene().getRoot().layout();
|
||||||
|
var image = node.snapshot(null, null);
|
||||||
|
int width = (int) image.getWidth(), height = (int) image.getHeight();
|
||||||
|
var buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
image
|
||||||
|
.getPixelReader()
|
||||||
|
.getPixels(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
javafx.scene.image.PixelFormat.getIntArgbInstance(),
|
||||||
|
pixels,
|
||||||
|
0,
|
||||||
|
width);
|
||||||
|
buffer.setRGB(0, 0, width, height, pixels, 0, width);
|
||||||
|
ImageIO.write(buffer, "png", file.toFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
package qualification;
|
||||||
|
|
||||||
|
import static qualification.WorkflowProbe.*;
|
||||||
|
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
|
import de.neitzel.fxdesigner.protocol.BindingMetadata.Target;
|
||||||
|
import java.nio.file.*;
|
||||||
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
/** Exercises generic discovery, persists two bindings, then drives the actual target views. */
|
||||||
|
public final class ImportWorkflowProbe extends FormWorkflowProbe {
|
||||||
|
@Override
|
||||||
|
void verify(Project project) throws Exception {
|
||||||
|
open(project, "ConnectionForm", 2);
|
||||||
|
discover();
|
||||||
|
target("securityChoices", "view", "security", "items", "COMPATIBLE");
|
||||||
|
target("protocol", "both", "protocol", "value", "COMPATIBLE");
|
||||||
|
target("security", "both", "security", "value", "COMPATIBLE");
|
||||||
|
|
||||||
|
open(project, "FolderTab", 1);
|
||||||
|
discover();
|
||||||
|
target("view", "both", "view", "value", "COMPATIBLE");
|
||||||
|
target("grouping", "both", "grouping", "value", "COMPATIBLE");
|
||||||
|
target("view", "both", "grouping", "value", "CONVERTER_REQUIRED");
|
||||||
|
target("rows", "view", "profiles", "items", "INCOMPATIBLE");
|
||||||
|
target("rows", "view", "clearLayout", "accessibleHelp", "INCOMPATIBLE");
|
||||||
|
target("view", "both", "untypedPick", "value", "UNRESOLVED");
|
||||||
|
target("rows", "view", "grid", "items", "COMPATIBLE");
|
||||||
|
applyAndReopen(project, "FolderTab", 1, "grid", "items", "rows", "view");
|
||||||
|
preview("archive-folder", "import-grid");
|
||||||
|
|
||||||
|
open(project, "ImportForm", 3);
|
||||||
|
discover();
|
||||||
|
target("folder", "both", "folders", "value", "COMPATIBLE");
|
||||||
|
applyAndReopen(project, "ImportForm", 3, "folders", "value", "folder", "both");
|
||||||
|
preview("import-free", "import-free");
|
||||||
|
preview("import-collision", "import-collision");
|
||||||
|
preview("import-busy", "import-busy");
|
||||||
|
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void open(Project project, String form, int count) throws Exception {
|
||||||
|
var path =
|
||||||
|
Path.of(project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui", form + ".fxml");
|
||||||
|
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
|
||||||
|
pane = openDesigner(project, file);
|
||||||
|
fx(pane::flush).toCompletableFuture().get(10, java.util.concurrent.TimeUnit.SECONDS);
|
||||||
|
click(pane, "Form preview");
|
||||||
|
click(pane, "Build and Refresh");
|
||||||
|
await(
|
||||||
|
() -> fx(() -> ((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == count));
|
||||||
|
// The initial native document sync invalidates discovery while the first preview is loading.
|
||||||
|
// Wait for the displayed revision before selecting a source in the inspector.
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
String state = ((Label) pane.lookup("#preview-state")).getText();
|
||||||
|
if (state.startsWith("Preview failed")
|
||||||
|
&& form.equals("FolderTab")
|
||||||
|
&& !((TextArea) pane.lookup("#fxml-source"))
|
||||||
|
.getText()
|
||||||
|
.contains("path=\"rows\"")) return true;
|
||||||
|
if (state.startsWith("Preview failed")
|
||||||
|
|| state.startsWith("Preview unavailable")
|
||||||
|
|| state.startsWith("Preview blocked"))
|
||||||
|
throw new AssertionError(form + " initial preview: " + state);
|
||||||
|
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
|
||||||
|
&& state.contains("revision");
|
||||||
|
}));
|
||||||
|
step("Opened " + form + " with " + count + " examples");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void discover() 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(
|
||||||
|
() -> {
|
||||||
|
if (!((ComboBox<?>) pane.lookup("#binding-path")).getItems().isEmpty())
|
||||||
|
return true;
|
||||||
|
var message = ((Label) pane.lookup("#binding-status")).getText();
|
||||||
|
if (message.startsWith("Document changed")
|
||||||
|
|| message.startsWith("Build changed")) {
|
||||||
|
((Button)
|
||||||
|
pane.lookupAll(".button").stream()
|
||||||
|
.filter(
|
||||||
|
n ->
|
||||||
|
n instanceof Button b
|
||||||
|
&& b.getText().equals("Discover bindings"))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow())
|
||||||
|
.fire();
|
||||||
|
}
|
||||||
|
if (message.startsWith("Discovery unavailable"))
|
||||||
|
throw new AssertionError(message);
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void target(String path, String dir, String id, String property, String status)
|
||||||
|
throws Exception {
|
||||||
|
var prefix = path + " : ";
|
||||||
|
choose("binding-direction", dir);
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() ->
|
||||||
|
((ComboBox<?>) pane.lookup("#binding-path"))
|
||||||
|
.getItems().stream().anyMatch(x -> x.toString().startsWith(prefix))));
|
||||||
|
choose("binding-path", prefix);
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
var paths = (ComboBox<?>) pane.lookup("#binding-path");
|
||||||
|
var direction = (ComboBox<?>) pane.lookup("#binding-direction");
|
||||||
|
if (paths.getValue() == null
|
||||||
|
|| !paths.getValue().toString().startsWith(prefix)
|
||||||
|
|| !dir.equals(direction.getValue())) return false;
|
||||||
|
var table = (TableView<Target>) pane.lookup("#binding-targets");
|
||||||
|
var found =
|
||||||
|
table.getItems().stream()
|
||||||
|
.filter(
|
||||||
|
t ->
|
||||||
|
t.control().equals(id)
|
||||||
|
&& t.property().equals(property)
|
||||||
|
&& t.status().equals(status))
|
||||||
|
.findFirst();
|
||||||
|
found.ifPresent(t -> table.getSelectionModel().select(t));
|
||||||
|
return found.isPresent();
|
||||||
|
}));
|
||||||
|
step(path + " -> " + id + "." + property + " (" + dir + ") " + status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyAndReopen(
|
||||||
|
Project project, String form, int count, String id, String prop, String path, String dir)
|
||||||
|
throws Exception {
|
||||||
|
click(pane, "Use selected target");
|
||||||
|
if (!fx(
|
||||||
|
() ->
|
||||||
|
((TextField) pane.lookup("#direct-path")).getText().equals(path)
|
||||||
|
&& ((ComboBox<?>) pane.lookup("#direct-direction")).getValue().equals(dir)))
|
||||||
|
throw new AssertionError("Wrong binding");
|
||||||
|
click(pane, "Apply binding");
|
||||||
|
String declaration =
|
||||||
|
"control=\""
|
||||||
|
+ id
|
||||||
|
+ "\" property=\""
|
||||||
|
+ prop
|
||||||
|
+ "\" path=\""
|
||||||
|
+ path
|
||||||
|
+ "\" direction=\""
|
||||||
|
+ dir
|
||||||
|
+ "\"";
|
||||||
|
await(() -> source().contains(declaration));
|
||||||
|
click(pane, "Save");
|
||||||
|
await(() -> Files.readString(Path.of(file.getPath())).contains(declaration));
|
||||||
|
edt(
|
||||||
|
() -> {
|
||||||
|
FileEditorManager.getInstance(project).closeFile(file);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
open(project, form, count);
|
||||||
|
if (!source().contains(declaration)) throw new AssertionError("Binding was lost on reopen");
|
||||||
|
step("Applied, saved and reopened " + declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void preview(String example, String attempt) throws Exception {
|
||||||
|
choose("preview-example", example);
|
||||||
|
String label =
|
||||||
|
fx(
|
||||||
|
() ->
|
||||||
|
((de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example)
|
||||||
|
((ComboBox<?>) pane.lookup("#preview-example")).getValue())
|
||||||
|
.label());
|
||||||
|
await(
|
||||||
|
() ->
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
String state = ((Label) pane.lookup("#preview-state")).getText();
|
||||||
|
if (state.startsWith("Preview failed")
|
||||||
|
|| state.startsWith("Preview blocked")
|
||||||
|
|| state.startsWith("Preview unavailable")) throw new AssertionError(state);
|
||||||
|
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
|
||||||
|
&& state.contains(label);
|
||||||
|
}));
|
||||||
|
if (attempt.equals("import-collision"))
|
||||||
|
fx(
|
||||||
|
() -> {
|
||||||
|
ImageIO.write(
|
||||||
|
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
|
||||||
|
"png",
|
||||||
|
output.resolve("intellij.png").toFile());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
Files.writeString(output.resolve("import-attempt"), attempt);
|
||||||
|
click(pane, "Interactive preview");
|
||||||
|
awaitTarget("result-" + attempt);
|
||||||
|
step(Files.readString(output.resolve("result-" + attempt)));
|
||||||
|
click(pane, "Stop preview");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,10 +26,11 @@ p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a di
|
|||||||
forms = p.add_mutually_exclusive_group()
|
forms = p.add_mutually_exclusive_group()
|
||||||
forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
|
forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
|
||||||
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
|
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
|
||||||
|
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
|
||||||
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
|
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
|
||||||
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
|
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
|
||||||
args = p.parse_args()
|
args = p.parse_args()
|
||||||
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs) and not args.archiver:
|
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form) and not args.archiver:
|
||||||
p.error("Selecting an Archiver view requires --archiver")
|
p.error("Selecting an Archiver view requires --archiver")
|
||||||
if args.repeat < 1:
|
if args.repeat < 1:
|
||||||
p.error("--repeat must be positive")
|
p.error("--repeat must be positive")
|
||||||
@@ -41,7 +42,7 @@ modes = ("classpath",) if args.archiver else (("classpath", "modulepath") if arg
|
|||||||
for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes):
|
for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes):
|
||||||
crashes = NativeCrashGuard(ROOT)
|
crashes = NativeCrashGuard(ROOT)
|
||||||
launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij",
|
launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij",
|
||||||
"--check", *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home,
|
"--check", *(["--import-form"] if args.import_form else []), *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home,
|
||||||
"--target-java-home", args.target_java_home, "--idea-home", args.idea_home],
|
"--target-java-home", args.target_java_home, "--idea-home", args.idea_home],
|
||||||
cwd=ROOT, text=True, capture_output=True, timeout=60)
|
cwd=ROOT, text=True, capture_output=True, timeout=60)
|
||||||
if launch.returncode:
|
if launch.returncode:
|
||||||
@@ -85,7 +86,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", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
|
for name in ("import-collision.png", "import-accepted.png", "result-import-free", "result-import-busy", "result-import-collision", "result-import-grid", "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", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.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)
|
||||||
|
|||||||
@@ -22,10 +22,11 @@ p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archi
|
|||||||
forms = p.add_mutually_exclusive_group()
|
forms = p.add_mutually_exclusive_group()
|
||||||
forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
|
forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
|
||||||
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
|
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
|
||||||
|
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
|
||||||
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
|
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
|
||||||
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
|
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
|
||||||
args = p.parse_args()
|
args = p.parse_args()
|
||||||
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs) and not args.archiver:
|
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form) and not args.archiver:
|
||||||
p.error("Selecting an Archiver view requires --archiver")
|
p.error("Selecting an Archiver view requires --archiver")
|
||||||
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
|
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
|
||||||
project = base / "project"
|
project = base / "project"
|
||||||
@@ -40,6 +41,22 @@ if args.archiver:
|
|||||||
view = "FolderTab"
|
view = "FolderTab"
|
||||||
shutil.copyfile(args.grid_docking, project / "src/main/resources/ReferenceWorkspace.fxml")
|
shutil.copyfile(args.grid_docking, project / "src/main/resources/ReferenceWorkspace.fxml")
|
||||||
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.import_form:
|
||||||
|
file = file.with_name("ConnectionForm.fxml")
|
||||||
|
if args.check:
|
||||||
|
# Author two shipped bindings again in the disposable copy. One deliberately
|
||||||
|
# untyped selector exercises the diagnostic without changing the product form.
|
||||||
|
for form, declaration in [
|
||||||
|
(file.with_name("ImportForm.fxml"), '<DirectBinding control="folders" property="value" path="folder" direction="both"/>'),
|
||||||
|
(file.with_name("FolderTab.fxml"), '<DirectBinding control="grid" property="items" path="rows" direction="view"/>'),
|
||||||
|
]:
|
||||||
|
source = form.read_text()
|
||||||
|
if source.count(declaration) != 1:
|
||||||
|
raise ValueError(f"Expected the shipped binding in {form.name}")
|
||||||
|
source = "".join(line for line in source.splitlines(keepends=True) if line.strip() != declaration)
|
||||||
|
if form.name == "FolderTab.fxml":
|
||||||
|
source = source.replace("</VBox>", '<ComboBox fx:id="untypedPick" visible="false" managed="false"/></VBox>')
|
||||||
|
form.write_text(source)
|
||||||
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:
|
if args.check:
|
||||||
@@ -81,13 +98,15 @@ else:
|
|||||||
suite = "Connection"
|
suite = "Connection"
|
||||||
elif args.grid_docking:
|
elif args.grid_docking:
|
||||||
suite = "GridDock"
|
suite = "GridDock"
|
||||||
|
elif args.import_form:
|
||||||
|
suite = "Import"
|
||||||
elif args.document_tabs:
|
elif args.document_tabs:
|
||||||
suite = "DocumentTabs"
|
suite = "DocumentTabs"
|
||||||
elif args.saved_document:
|
elif args.saved_document:
|
||||||
suite = "SavedDocument"
|
suite = "SavedDocument"
|
||||||
probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe"
|
probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe"
|
||||||
files = [sources / "WorkflowProbe.java"]
|
files = [sources / "WorkflowProbe.java"]
|
||||||
if args.connection_form or args.saved_document or args.document_tabs:
|
if args.connection_form or args.saved_document or args.document_tabs or args.import_form:
|
||||||
files.append(sources / "FormWorkflowProbe.java")
|
files.append(sources / "FormWorkflowProbe.java")
|
||||||
if args.archiver:
|
if args.archiver:
|
||||||
files.append(sources / f"{probe}.java")
|
files.append(sources / f"{probe}.java")
|
||||||
|
|||||||
Reference in New Issue
Block a user