Edit and exercise Archiver CommandBindings in the IntelliJ designer
This commit is contained in:
@@ -34,6 +34,26 @@ class FxmlProjectionTest {
|
||||
assertTrue(restored.contains("neitzel-model"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void editsTheStatusBarBesideAnAttachedMarginWithoutChangingItsXml() throws Exception {
|
||||
String source = """
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import de.neitzel.fx.view.BindingList?>
|
||||
<BorderPane xmlns:fx="http://javafx.com/fxml/1">
|
||||
<fx:define><BindingList/></fx:define>
|
||||
<bottom><HBox spacing='8'>
|
||||
<BorderPane.margin><Insets top='5' right='12' bottom='9' left='12'/></BorderPane.margin>
|
||||
</HBox></bottom>
|
||||
</BorderPane>
|
||||
""";
|
||||
var projection = new FxmlProjection(source);
|
||||
String projected = projection.project();
|
||||
String edited = projection.restore(projected.replace("spacing=\"8\"", "spacing=\"10\""));
|
||||
assertEquals(source.replace("spacing='8'", "spacing='10'"), edited);
|
||||
assertEquals(source, projection.restore(projected));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsExternalEntitiesAndExecutableFXML() throws Exception {
|
||||
assertThrows(
|
||||
|
||||
@@ -96,6 +96,26 @@ class ReferenceDocumentTest {
|
||||
assertTrue(twice.contains("f:id='childCopy2'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void copiesMenuCommandsWithFreshIdsAndTracksTargetsForDestinationValidation() throws Exception {
|
||||
String text =
|
||||
"<?import de.neitzel.fx.view.*?><?import javafx.scene.control.*?>"
|
||||
+ "<Menu xmlns:fx='http://javafx.com/fxml/1' fx:id='file'><fx:define><BindingList>"
|
||||
+ "<CommandBinding control='open' path='open'/></BindingList></fx:define>"
|
||||
+ "<items><MenuItem fx:id='open' accelerator='Shortcut+O'/></items></Menu>";
|
||||
var menu = new ReferenceDocument(text);
|
||||
var clip = menu.copy(index(menu, "open"), "source");
|
||||
var copied = menu.paste(clip, index(menu, "file"), "destination");
|
||||
assertEquals(Set.of("openCopy"), copied.importedCommandTargets());
|
||||
String result = apply(text, copied);
|
||||
assertTrue(result.contains("fx:id='openCopy' accelerator='Shortcut+O'"));
|
||||
assertTrue(result.contains("control='openCopy' path='open'"));
|
||||
var layout = new ReferenceDocument(XML);
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> layout.paste(clip, index(layout, "box"), "destination"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void carriesNamespacesImportsAndReportsDestinationContextDifferences() throws Exception {
|
||||
String source =
|
||||
|
||||
Reference in New Issue
Block a user