diff --git a/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormLayoutInfo.java b/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormLayoutInfo.java index dca6f3b44..5342fd01d 100644 --- a/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormLayoutInfo.java +++ b/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormLayoutInfo.java @@ -61,7 +61,7 @@ import com.jgoodies.forms.layout.FormSpec; import com.jgoodies.forms.layout.FormSpecs; import com.jgoodies.forms.layout.RowSpec; -import com.jgoodies.forms.util.DefaultUnitConverter; +import com.jgoodies.forms.util.UnitConverter; import org.apache.commons.collections4.BidiMap; import org.apache.commons.collections4.bidimap.DualHashBidiMap; @@ -1440,7 +1440,7 @@ protected void refresh_afterCreate2() throws Exception { } // initialize default sizes in pixels { - DefaultUnitConverter converter = DefaultUnitConverter.getInstance(); + UnitConverter converter = FormSizeConstantInfo.getUnitConverter(); // m_defaultColumnSize = converter.millimeterAsPixel(DEFAULT_SIZE, container); m_defaultRowSize = converter.millimeterAsPixel(DEFAULT_SIZE, container); diff --git a/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormSizeConstantInfo.java b/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormSizeConstantInfo.java index 3d49c0c1b..34ef692b9 100644 --- a/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormSizeConstantInfo.java +++ b/org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/model/FormSizeConstantInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2025 Google, Inc. and others. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -26,6 +26,7 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; +import java.util.Objects; import javax.swing.JFrame; @@ -36,6 +37,7 @@ * @coverage swing.FormLayout.model */ public final class FormSizeConstantInfo { + private static UnitConverter m_unitConverter = DefaultUnitConverter.getInstance(); private double m_value; private Unit m_unit; @@ -112,6 +114,20 @@ public void setUnit(Unit unit) throws Exception { m_unit = unit; } + /** + * @return the {@link UnitConverter} + */ + public static UnitConverter getUnitConverter() { + return m_unitConverter; + } + + /** + * Sets the {@link UnitConverter}. + */ + public static void setUnitConverter(UnitConverter unitConverter) { + m_unitConverter = Objects.requireNonNull(unitConverter); + } + //////////////////////////////////////////////////////////////////////////// // // Object @@ -182,7 +198,7 @@ private static double convertValue(double value, Unit oldUnit, Unit newUnit) thr * @return the value in pixels for value in given {@link Unit}. */ public static int convertToPixels(double value, Unit unit) { - UnitConverter converter = DefaultUnitConverter.getInstance(); + UnitConverter converter = getUnitConverter(); // int pixels = 0; if (unit == ConstantSize.PIXEL) { @@ -231,7 +247,7 @@ public static double convertFromPixels(int pixels, Unit unit) throws Exception { * in pixels. */ private static int convertFromPixelsInt(int pixels, String methodName) throws Exception { - UnitConverter converter = DefaultUnitConverter.getInstance(); + UnitConverter converter = getUnitConverter(); Method method = UnitConverter.class.getMethod(methodName, new Class[]{int.class, Component.class}); int result = 0; @@ -251,7 +267,7 @@ private static int convertFromPixelsInt(int pixels, String methodName) throws Ex * in pixels. */ private static double convertFromPixelsDouble(int pixels, String methodName) throws Exception { - UnitConverter converter = DefaultUnitConverter.getInstance(); + UnitConverter converter = getUnitConverter(); Method method = UnitConverter.class.getMethod(methodName, new Class[]{double.class, Component.class}); double result = 0; diff --git a/org.eclipse.wb.tests/META-INF/MANIFEST.MF b/org.eclipse.wb.tests/META-INF/MANIFEST.MF index 61bd13ba4..c8a94ee8c 100644 --- a/org.eclipse.wb.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.wb.tests/META-INF/MANIFEST.MF @@ -148,8 +148,10 @@ Export-Package: org.eclipse.wb.tests.designer;x-internal:=true, org.eclipse.wb.tests.draw2d;x-internal:=true, org.eclipse.wb.tests.gef;x-internal:=true, org.eclipse.wb.tests.utils;x-internal:=true -Import-Package: com.jgoodies.forms.factories;version="[1.9.0,2.0.0]", +Import-Package: com.jgoodies.common.bean;version="[1.8.1,2.0.0)", + com.jgoodies.forms.factories;version="[1.9.0,2.0.0]", com.jgoodies.forms.layout;version="[1.9.0,2.0.0]", + com.jgoodies.forms.util;version="[1.9.0,2.0.0)", net.miginfocom.layout;version="[11.3.0,12.0.0]", net.miginfocom.swing;version="[11.3.0,12.0.0]", org.apache.commons.collections4;version="[4.4.0,5.0.0)", diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/AbstractFormLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/AbstractFormLayoutTest.java index 13cd19867..53d9337bc 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/AbstractFormLayoutTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/AbstractFormLayoutTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -13,13 +13,21 @@ package org.eclipse.wb.tests.designer.swing.model.layout.FormLayout; import org.eclipse.wb.internal.core.utils.jdt.core.CodeUtils; +import org.eclipse.wb.internal.swing.FormLayout.model.FormSizeConstantInfo; import org.eclipse.wb.internal.swing.laf.LafSupport; import org.eclipse.wb.tests.designer.swing.model.layout.AbstractLayoutTest; import com.jgoodies.forms.layout.FormLayout; +import com.jgoodies.forms.layout.Sizes; +import com.jgoodies.forms.util.AbstractUnitConverter; +import com.jgoodies.forms.util.DefaultUnitConverter; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import java.awt.Component; + /** * Abstract test for {@link FormLayout}. * @@ -33,6 +41,18 @@ public abstract class AbstractFormLayoutTest extends AbstractLayoutTest { // Life cycle // //////////////////////////////////////////////////////////////////////////// + @BeforeAll + public static void setUpUnitConverter() { + FormSizeConstantInfo.setUnitConverter(new UnitConverterStub()); + Sizes.setUnitConverter(new UnitConverterStub()); + } + + @AfterAll + public static void tearDownUnitConverter() { + Sizes.setUnitConverter(DefaultUnitConverter.getInstance()); + FormSizeConstantInfo.setUnitConverter(DefaultUnitConverter.getInstance()); + } + @Override @BeforeEach public void setUp() throws Exception { @@ -66,4 +86,23 @@ public String getTestSource(String... lines) { } return super.getTestSource(lines); } + + private static class UnitConverterStub extends AbstractUnitConverter { + private static final long serialVersionUID = 1L; + + @Override + protected double getDialogBaseUnitsX(Component component) { + return 6; + } + + @Override + protected double getDialogBaseUnitsY(Component component) { + return 12; + } + + @Override + protected int getScreenResolution(Component c) { + return 96; + } + } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/CellConstraintsSupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/CellConstraintsSupportTest.java index b1620d0f5..60f33a68d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/CellConstraintsSupportTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/CellConstraintsSupportTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2025 Google, Inc. and others. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -53,23 +53,22 @@ public void setUp() throws Exception { super.setUp(); // if (m_testProject != null) { - m_panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 2');", - " }", - " }", - "}"); + m_panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 2"); + } + } + }"""); m_panel.refresh(); // m_button = m_panel.getChildrenComponents().get(0); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/DefaultComponentFactoryTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/DefaultComponentFactoryTest.java index eec99a00d..df2b06718 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/DefaultComponentFactoryTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/DefaultComponentFactoryTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -29,7 +29,6 @@ import com.jgoodies.forms.factories.DefaultComponentFactory; import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -57,22 +56,21 @@ public void _test_exit() throws Exception { */ @Test public void test_createLabel() throws Exception { - ContainerInfo panel = - parseContainer( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createLabel('A');", - " add(label);", - " }", - " }", - " // filler filler filler", - "}"); - assertHierarchy( - "{this: javax.swing.JPanel} {this} {/add(label)/}", - " {implicit-layout: java.awt.FlowLayout} {implicit-layout} {}", - " {opaque} {local-unique: label} {/DefaultComponentFactory.getInstance().createLabel('A')/ /add(label)/}"); + ContainerInfo panel = parseContainer(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createLabel("A"); + add(label); + } + } + // filler filler filler + }"""); + assertHierarchy(""" + {this: javax.swing.JPanel} {this} {/add(label)/} + {implicit-layout: java.awt.FlowLayout} {implicit-layout} {} + {opaque} {local-unique: label} {/DefaultComponentFactory.getInstance().createLabel("A")/ /add(label)/}"""); panel.refresh(); ComponentInfo component = panel.getChildrenComponents().get(0); // CreationSupport @@ -82,47 +80,45 @@ public void test_createLabel() throws Exception { assertTrue(JavaInfoUtils.canReparent(component)); // "text" property component.getPropertyByTitle("text").setValue("B"); - assertEditor( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createLabel('B');", - " add(label);", - " }", - " }", - " // filler filler filler", - "}"); + assertEditor(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createLabel("B"); + add(label); + } + } + // filler filler filler + }"""); // delete assertTrue(component.canDelete()); component.delete(); - assertEditor( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "public class Test extends JPanel {", - " public Test() {", - " }", - " // filler filler filler", - "}"); + assertEditor(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + public class Test extends JPanel { + public Test() { + } + // filler filler filler + }"""); } /** * Test for {@link DefaultComponentFactoryCreateLabelEntryInfo}. */ @DisposeProjectAfter - @Disabled @Test public void test_createLabel_tool() throws Exception { do_projectDispose(); do_projectCreate(); m_useFormsImports = false; // parse - ContainerInfo panel = - parseContainer( - "// filler filler filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + // filler filler filler filler filler + public class Test extends JPanel { + public Test() { + } + }"""); ToolEntryInfo entry = new DefaultComponentFactoryCreateLabelEntryInfo(); assertEquals(entry.getClass().getName(), entry.getId()); assertNotNull(entry.getIcon()); @@ -142,23 +138,23 @@ public void test_createLabel_tool() throws Exception { Image image = newComponent.getImage(); assertNotNull(image); org.eclipse.swt.graphics.Rectangle bounds = image.getBounds(); - Assertions.assertThat(bounds.width).isGreaterThan(50).isLessThan(100); + Assertions.assertThat(bounds.width).isGreaterThan(50).isLessThan(150); Assertions.assertThat(bounds.height).isGreaterThan(10).isLessThan(20); image.dispose(); } // add object ((FlowLayoutInfo) panel.getLayout()).add(newComponent, null); - assertEditor( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "// filler filler filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createLabel('New JGoodies label');", - " add(label);", - " }", - " }", - "}"); + assertEditor(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + // filler filler filler filler filler + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createLabel("New JGoodies label"); + add(label); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -171,37 +167,36 @@ public void test_createLabel_tool() throws Exception { */ @Test public void test_createTitle() throws Exception { - ContainerInfo panel = - parseContainer( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createTitle('A');", - " add(label);", - " }", - " }", - "}"); - assertHierarchy( - "{this: javax.swing.JPanel} {this} {/add(label)/}", - " {implicit-layout: java.awt.FlowLayout} {implicit-layout} {}", - " {opaque} {local-unique: label} {/DefaultComponentFactory.getInstance().createTitle('A')/ /add(label)/}"); + ContainerInfo panel = parseContainer(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createTitle("A"); + add(label); + } + } + }"""); + assertHierarchy(""" + {this: javax.swing.JPanel} {this} {/add(label)/} + {implicit-layout: java.awt.FlowLayout} {implicit-layout} {} + {opaque} {local-unique: label} {/DefaultComponentFactory.getInstance().createTitle("A")/ /add(label)/}"""); panel.refresh(); ComponentInfo component = panel.getChildrenComponents().get(0); // CreationSupport assertInstanceOf(DefaultComponentFactoryCreationSupport.class, component.getCreationSupport()); // "text" property component.getPropertyByTitle("text").setValue("B"); - assertEditor( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createTitle('B');", - " add(label);", - " }", - " }", - "}"); + assertEditor(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createTitle("B"); + add(label); + } + } + }"""); } @Test @@ -210,13 +205,12 @@ public void test_createTitle_tool() throws Exception { do_projectCreate(); m_useFormsImports = false; // parse - ContainerInfo panel = - parseContainer( - "// filler filler filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + // filler filler filler filler filler + public class Test extends JPanel { + public Test() { + } + }"""); ToolEntryInfo entry = new DefaultComponentFactoryCreateTitleEntryInfo(); assertEquals(entry.getClass().getName(), entry.getId()); assertNotNull(entry.getIcon()); @@ -233,16 +227,16 @@ public void test_createTitle_tool() throws Exception { newComponent.getCreationSupport()); // add object ((FlowLayoutInfo) panel.getLayout()).add(newComponent, null); - assertEditor( - "import com.jgoodies.forms.factories.DefaultComponentFactory;", - "// filler filler filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " {", - " JLabel label = DefaultComponentFactory.getInstance().createTitle('New JGoodies title');", - " add(label);", - " }", - " }", - "}"); + assertEditor(""" + import com.jgoodies.forms.factories.DefaultComponentFactory; + // filler filler filler filler filler + public class Test extends JPanel { + public Test() { + { + JLabel label = DefaultComponentFactory.getInstance().createTitle("New JGoodies title"); + add(label); + } + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormColumnInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormColumnInfoTest.java index e3dc1cf46..8757541d0 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormColumnInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormColumnInfoTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -31,22 +31,21 @@ public class FormColumnInfoTest extends AbstractFormLayoutTest { //////////////////////////////////////////////////////////////////////////// @Test public void test_insert_onColumn() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '3, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "3, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -56,43 +55,42 @@ public void test_insert_onColumn() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '5, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "5, 1"); + } + } + }"""); } @Test public void test_insert_onGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '3, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "3, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -102,38 +100,37 @@ public void test_insert_onGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '5, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "5, 1"); + } + } + }"""); } @Test public void test_insert_lastWithGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -143,31 +140,30 @@ public void test_insert_lastWithGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_insert_lastWithoutGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -177,17 +173,17 @@ public void test_insert_lastWithoutGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -197,26 +193,25 @@ public void test_insert_lastWithoutGap() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_deleteColumn_nextGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '3, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "3, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -226,43 +221,42 @@ public void test_deleteColumn_nextGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("333"); + add(button, "1, 1"); + } + } + }"""); } @Test public void test_deleteColumn_span() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1, 2, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '3, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1, 2, 1"); + } + { + JButton button = new JButton("333"); + add(button, "3, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -272,49 +266,48 @@ public void test_deleteColumn_span() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '2, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "2, 1"); + } + } + }"""); } @Test public void test_deleteColumn_prevGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '4, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "2, 1"); + } + { + JButton button = new JButton("333"); + add(button, "4, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -324,44 +317,43 @@ public void test_deleteColumn_prevGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('333');", - " add(button, '2, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("333"); + add(button, "2, 1"); + } + } + }"""); } @Test public void test_deleteGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '3, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "3, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -371,24 +363,24 @@ public void test_deleteGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '2, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "2, 1"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -398,20 +390,19 @@ public void test_deleteGap() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_deleteContents() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -421,15 +412,15 @@ public void test_deleteContents() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -439,25 +430,24 @@ public void test_deleteContents() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_split() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '2, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + { + JButton button = new JButton(); + add(button, "2, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -467,26 +457,26 @@ public void test_split() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1, 3, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '4, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1, 3, 1"); + } + { + JButton button = new JButton(); + add(button, "4, 1"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -496,20 +486,19 @@ public void test_split() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_moveColumn_noOp() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -524,22 +513,21 @@ public void test_moveColumn_noOp() throws Exception { @Test public void test_moveColumn_backward_gap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '2, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "2, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -549,41 +537,40 @@ public void test_moveColumn_backward_gap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '3, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "3, 1"); + } + } + }"""); } @Test public void test_moveColumn_forward_gap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '2, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "2, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -593,37 +580,36 @@ public void test_moveColumn_forward_gap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); } @Test public void test_moveColumn_noGaps() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward { @@ -634,17 +620,17 @@ public void test_moveColumn_noGaps() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } // forward { @@ -655,49 +641,48 @@ public void test_moveColumn_noGaps() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } } @Test public void test_moveColumn_backward_Last2Inner() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '4, 1');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '6, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "2, 1"); + } + { + JButton button = new JButton("444"); + add(button, "4, 1"); + } + { + JButton button = new JButton("666"); + add(button, "6, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -707,57 +692,56 @@ public void test_moveColumn_backward_Last2Inner() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '6, 1');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '4, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "2, 1"); + } + { + JButton button = new JButton("444"); + add(button, "6, 1"); + } + { + JButton button = new JButton("666"); + add(button, "4, 1"); + } + } + }"""); } @Test public void test_moveColumn_backward_Last2First() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '4, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "2, 1"); + } + { + JButton button = new JButton("444"); + add(button, "4, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -767,42 +751,41 @@ public void test_moveColumn_backward_Last2First() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '4, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '2, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "4, 1"); + } + { + JButton button = new JButton("444"); + add(button, "2, 1"); + } + } + }"""); } @Test public void test_moveColumn_backward_2FirstNoGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -812,45 +795,44 @@ public void test_moveColumn_backward_2FirstNoGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_moveColumn_spanned_backwardExpand_forwardCollapse() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '2, 1, 3, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '6, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "2, 1, 3, 1"); + } + { + JButton button = new JButton(); + add(button, "6, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward expand { @@ -861,29 +843,29 @@ public void test_moveColumn_spanned_backwardExpand_forwardCollapse() throws Exce panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '2, 1, 5, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '4, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "2, 1, 5, 1"); + } + { + JButton button = new JButton(); + add(button, "4, 1"); + } + } + }"""); } // forward collapse { @@ -894,60 +876,59 @@ public void test_moveColumn_spanned_backwardExpand_forwardCollapse() throws Exce panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '2, 1, 3, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '6, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "2, 1, 3, 1"); + } + { + JButton button = new JButton(); + add(button, "6, 1"); + } + } + }"""); } } @Test public void test_moveColumn_spanned_backwardCollapse_forwardExpand() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '4, 1, 5, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '6, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "4, 1, 5, 1"); + } + { + JButton button = new JButton(); + add(button, "6, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward collapse { @@ -958,31 +939,31 @@ public void test_moveColumn_spanned_backwardCollapse_forwardExpand() throws Exce panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '6, 1, 3, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '4, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "6, 1, 3, 1"); + } + { + JButton button = new JButton(); + add(button, "4, 1"); + } + } + }"""); } // forward expand { @@ -993,31 +974,31 @@ public void test_moveColumn_spanned_backwardCollapse_forwardExpand() throws Exce panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '4, 1, 5, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '6, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "4, 1, 5, 1"); + } + { + JButton button = new JButton(); + add(button, "6, 1"); + } + } + }"""); } } @@ -1026,33 +1007,32 @@ public void test_moveColumn_spanned_backwardCollapse_forwardExpand() throws Exce */ @Test public void test_moveColumn_forward_firstGapPrev2Last() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '4, 1');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '6, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "2, 1"); + } + { + JButton button = new JButton("444"); + add(button, "4, 1"); + } + { + JButton button = new JButton("666"); + add(button, "6, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1062,49 +1042,48 @@ public void test_moveColumn_forward_firstGapPrev2Last() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.BUTTON_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '6, 1');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '2, 1');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '4, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.BUTTON_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "6, 1"); + } + { + JButton button = new JButton("444"); + add(button, "2, 1"); + } + { + JButton button = new JButton("666"); + add(button, "4, 1"); + } + } + }"""); } @Test public void test_moveColumn_forward_firstGapNext2Inner() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1114,35 +1093,34 @@ public void test_moveColumn_forward_firstGapNext2Inner() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_moveColumn_forward_first2Last() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1152,36 +1130,35 @@ public void test_moveColumn_forward_first2Last() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_moveColumn_forward_firstNextGap2BeforeGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1191,18 +1168,18 @@ public void test_moveColumn_forward_firstNextGap2BeforeGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.MIN_COLSPEC,", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.MIN_COLSPEC, + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormDimensionInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormDimensionInfoTest.java index 53715805a..119450e29 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormDimensionInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormDimensionInfoTest.java @@ -24,7 +24,6 @@ import com.jgoodies.forms.layout.Size; import com.jgoodies.forms.layout.Sizes; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.lang.reflect.Method; @@ -264,7 +263,6 @@ public void test_rowTemplates() throws Exception { // Convert to GAP template // //////////////////////////////////////////////////////////////////////////// - @Disabled @Test public void test_convertToNearestGap_columns() throws Exception { check_convertToNearestGap_column("4px", 5, "LABEL_COMPONENT_GAP_COLSPEC"); @@ -279,7 +277,6 @@ public void test_convertToNearestGap_columns() throws Exception { check_convertToNearestGap_column("20px", 5, null); } - @Disabled @Test public void test_convertToNearestGap_rows() throws Exception { check_convertToNearestGap_row("4px", 5, "LABEL_COMPONENT_GAP_ROWSPEC"); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutConverterTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutConverterTest.java index 0d2a2648f..ca99647de 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutConverterTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutConverterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -18,7 +18,6 @@ import com.jgoodies.forms.layout.FormLayout; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -34,14 +33,13 @@ public class FormLayoutConverterTest extends AbstractFormLayoutTest { //////////////////////////////////////////////////////////////////////////// @Test public void test_empty() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(null);", - " setSize(450, 300);", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(null); + setSize(450, 300); + } + }"""); // panel.refresh(); try { @@ -50,37 +48,35 @@ public void test_empty() throws Exception { panel.refresh_dispose(); } // - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setSize(450, 300);", - " setLayout(new FormLayout(new ColumnSpec[] {},", - " new RowSpec[] {}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setSize(450, 300); + setLayout(new FormLayout(new ColumnSpec[] {}, + new RowSpec[] {})); + } + }"""); } - @Disabled @Test public void test_oneRow() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(null);", - " setSize(450, 300);", - " {", - " JButton button = new JButton('000');", - " button.setBounds(4, 10, 100, 30);", - " add(button);", - " }", - " {", - " JButton button2 = new JButton('222');", - " button2.setBounds(120, 11, 80, 20);", - " add(button2);", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(null); + setSize(450, 300); + { + JButton button = new JButton("000"); + button.setBounds(4, 10, 100, 30); + add(button); + } + { + JButton button2 = new JButton("222"); + button2.setBounds(120, 11, 80, 20); + add(button2); + } + } + }"""); // panel.refresh(); try { @@ -89,28 +85,28 @@ public void test_oneRow() throws Exception { panel.refresh_dispose(); } // - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setSize(450, 300);", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " ColumnSpec.decode('100px'),", - " ColumnSpec.decode('16px'),", - " ColumnSpec.decode('80px'),},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " RowSpec.decode('30px'),}));", - " {", - " JButton button = new JButton('000');", - " add(button, '2, 2, fill, fill');", - " }", - " {", - " JButton button2 = new JButton('222');", - " add(button2, '4, 2, fill, top');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setSize(450, 300); + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + ColumnSpec.decode("100px"), + FormSpecs.UNRELATED_GAP_COLSPEC, + ColumnSpec.decode("80px"),}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + RowSpec.decode("30px"),})); + { + JButton button = new JButton("000"); + add(button, "2, 2, fill, fill"); + } + { + JButton button2 = new JButton("222"); + add(button2, "4, 2, fill, top"); + } + } + }"""); { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); assertEquals(4, layout.getColumns().size()); @@ -118,32 +114,30 @@ public void test_oneRow() throws Exception { } } - @Disabled @Test public void test_twoRows_spanColumns() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(null);", - " setSize(450, 300);", - " {", - " JButton button = new JButton();", - " button.setBounds(0, 10, 100, 40);", - " add(button);", - " }", - " {", - " JButton button2 = new JButton();", - " button2.setBounds(108, 10, 80, 20);", - " add(button2);", - " }", - " {", - " JButton button3 = new JButton();", - " button3.setBounds(45, 60, 90, 40);", - " add(button3);", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(null); + setSize(450, 300); + { + JButton button = new JButton(); + button.setBounds(0, 10, 100, 40); + add(button); + } + { + JButton button2 = new JButton(); + button2.setBounds(108, 10, 80, 20); + add(button2); + } + { + JButton button3 = new JButton(); + button3.setBounds(45, 60, 90, 40); + add(button3); + } + } + }"""); // panel.refresh(); try { @@ -152,86 +146,92 @@ public void test_twoRows_spanColumns() throws Exception { panel.refresh_dispose(); } // - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setSize(450, 300);", - " setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('100px'),", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('80px'),},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " RowSpec.decode('40px'),", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " RowSpec.decode('40px'),}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 2, fill, fill');", - " }", - " {", - " JButton button2 = new JButton();", - " add(button2, '3, 2, fill, top');", - " }", - " {", - " JButton button3 = new JButton();", - " add(button3, '1, 4, 3, 1, center, fill');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setSize(450, 300); + setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("100px"), + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("80px"),}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + RowSpec.decode("40px"), + FormSpecs.UNRELATED_GAP_ROWSPEC, + RowSpec.decode("40px"),})); + { + JButton button = new JButton(); + add(button, "1, 2, fill, fill"); + } + { + JButton button2 = new JButton(); + add(button2, "3, 2, fill, top"); + } + { + JButton button3 = new JButton(); + add(button3, "1, 4, 3, 1, center, fill"); + } + } + }"""); } - @Disabled @Test public void test_Switching_fromGridBagLayout() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " GridBagLayout gridBagLayout = new GridBagLayout();", - " gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };", - " gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 };", - " gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };", - " gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };", - " setLayout(gridBagLayout);", - " {", - " JComboBox comboBox = new JComboBox();", - " GridBagConstraints gbc = new GridBagConstraints();", - " gbc.insets = new Insets(0, 0, 5, 5);", - " gbc.fill = GridBagConstraints.HORIZONTAL;", - " gbc.gridx = 1;", - " gbc.gridy = 0;", - " add(comboBox, gbc);", - " }", - " {", - " JLabel label = new JLabel('New label');", - " GridBagConstraints gbc = new GridBagConstraints();", - " gbc.insets = new Insets(0, 0, 5, 5);", - " gbc.anchor = GridBagConstraints.EAST;", - " gbc.gridx = 0;", - " gbc.gridy = 1;", - " add(label, gbc);", - " }", - " {", - " JTextField textField = new JTextField();", - " GridBagConstraints gbc = new GridBagConstraints();", - " gbc.gridwidth = 2;", - " gbc.insets = new Insets(0, 0, 5, 5);", - " gbc.fill = GridBagConstraints.HORIZONTAL;", - " gbc.gridx = 1;", - " gbc.gridy = 1;", - " add(textField, gbc);", - " textField.setColumns(10);", - " }", - " {", - " JButton button = new JButton('New button');", - " GridBagConstraints gbc = new GridBagConstraints();", - " gbc.gridx = 2;", - " gbc.gridy = 2;", - " add(button, gbc);", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + GridBagLayout gridBagLayout = new GridBagLayout(); + gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; + gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 }; + gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; + gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; + setLayout(gridBagLayout); + { + JComboBox comboBox = new JComboBox(); + comboBox.setMinimumSize(new Dimension(46, 20)); + comboBox.setPreferredSize(new Dimension(46, 20)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(0, 0, 5, 5); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.gridx = 1; + gbc.gridy = 0; + add(comboBox, gbc); + } + { + JLabel label = new JLabel("New label"); + label.setMinimumSize(new Dimension(46, 20)); + label.setPreferredSize(new Dimension(46, 20)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(0, 0, 5, 5); + gbc.anchor = GridBagConstraints.EAST; + gbc.gridx = 0; + gbc.gridy = 1; + add(label, gbc); + } + { + JTextField textField = new JTextField(); + textField.setMinimumSize(new Dimension(140, 20)); + textField.setPreferredSize(new Dimension(140, 20)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = 2; + gbc.insets = new Insets(0, 0, 5, 5); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.gridx = 1; + gbc.gridy = 1; + add(textField, gbc); + textField.setColumns(10); + } + { + JButton button = new JButton("New button"); + button.setMinimumSize(new Dimension(89, 23)); + button.setPreferredSize(new Dimension(89, 23)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 2; + gbc.gridy = 2; + add(button, gbc); + } + } + }"""); panel.refresh(); // set FormLayout try { @@ -239,39 +239,47 @@ public void test_Switching_fromGridBagLayout() throws Exception { } finally { panel.refresh_dispose(); } - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('46px'),", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " ColumnSpec.decode('305px'),", - " FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,", - " ColumnSpec.decode('89px'),},", - " new RowSpec[] {", - " RowSpec.decode('20px'),", - " FormSpecs.LINE_GAP_ROWSPEC,", - " RowSpec.decode('20px'),", - " FormSpecs.LINE_GAP_ROWSPEC,", - " RowSpec.decode('23px'),}));", - " {", - " JComboBox comboBox = new JComboBox();", - " add(comboBox, '3, 1, fill, center');", - " }", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 3, right, center');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '3, 3, 3, 1, fill, center');", - " textField.setColumns(10);", - " }", - " {", - " JButton button = new JButton('New button');", - " add(button, '5, 5, center, center');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("46px"), + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + ColumnSpec.decode("305px"), + FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, + ColumnSpec.decode("89px"),}, + new RowSpec[] { + RowSpec.decode("20px"), + FormSpecs.LINE_GAP_ROWSPEC, + RowSpec.decode("20px"), + FormSpecs.LINE_GAP_ROWSPEC, + RowSpec.decode("23px"),})); + { + JComboBox comboBox = new JComboBox(); + comboBox.setMinimumSize(new Dimension(46, 20)); + comboBox.setPreferredSize(new Dimension(46, 20)); + add(comboBox, "3, 1, fill, center"); + } + { + JLabel label = new JLabel("New label"); + label.setMinimumSize(new Dimension(46, 20)); + label.setPreferredSize(new Dimension(46, 20)); + add(label, "1, 3, right, center"); + } + { + JTextField textField = new JTextField(); + textField.setMinimumSize(new Dimension(140, 20)); + textField.setPreferredSize(new Dimension(140, 20)); + add(textField, "3, 3, 3, 1, fill, center"); + textField.setColumns(10); + } + { + JButton button = new JButton("New button"); + button.setMinimumSize(new Dimension(89, 23)); + button.setPreferredSize(new Dimension(89, 23)); + add(button, "5, 5, center, center"); + } + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGefTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGefTest.java index 2ee67f0aa..3123b3d67 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGefTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGefTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2025 Google, Inc. and others. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -861,7 +861,6 @@ public Test() { { ComponentInfo button_2 = getJavaInfoByName("button_2"); canvas.target(button_2).inX(0.5).outY(ROW_GAP + 1).move(); - waitEventLoop(1000 * 5); canvas.assertCommandNull(); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGroupsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGroupsTest.java index 7b0789efa..bd064676b 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGroupsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutGroupsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -35,20 +35,19 @@ public class FormLayoutGroupsTest extends AbstractFormLayoutTest { //////////////////////////////////////////////////////////////////////////// @Test public void test_parsing() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 3}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 3}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -80,21 +79,20 @@ public void test_parsing() throws Exception { @Test public void test_removeFromGroup() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 4}, new int[]{2, 3}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 4}, new int[]{2, 3}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -109,36 +107,35 @@ public void test_removeFromGroup() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 3}});", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 3}}); + } + }"""); } @Test public void test_unGroupColumns() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 2}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 2}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -161,35 +158,34 @@ public void test_unGroupColumns() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + } + }"""); } @Test public void test_groupNew() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -219,35 +215,34 @@ public void test_groupNew() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 4}, new int[]{3, 5}});", - " setLayout(formLayout);", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + formLayout.setColumnGroups(new int[][]{new int[]{1, 4}, new int[]{3, 5}}); + setLayout(formLayout); + } + }"""); } @Test public void test_ignoreOne() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); String expectedSource = m_lastEditor.getSource(); // @@ -270,20 +265,19 @@ public void test_ignoreOne() throws Exception { @Test public void test_groupWithExisting() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 2}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 2}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -308,38 +302,37 @@ public void test_groupWithExisting() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 2, 3}});", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 2, 3}}); + } + }"""); } @Test public void test_groupIgnoreTwoGroups() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setColumnGroups(new int[][]{new int[]{1, 2}, new int[]{3, 4}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setColumnGroups(new int[][]{new int[]{1, 2}, new int[]{3, 4}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); String expectedSource = m_lastEditor.getSource(); // @@ -375,20 +368,19 @@ public void test_groupIgnoreTwoGroups() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_groupRows() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setRowGroups(new int[][]{new int[]{1, 2}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setRowGroups(new int[][]{new int[]{1, 2}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -413,36 +405,35 @@ public void test_groupRows() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setRowGroups(new int[][]{new int[]{1, 2, 3}});", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setRowGroups(new int[][]{new int[]{1, 2, 3}}); + } + }"""); } @Test public void test_unGroupRows() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " formLayout.setRowGroups(new int[][]{new int[]{1, 2}});", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + formLayout.setRowGroups(new int[][]{new int[]{1, 2}}); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -468,16 +459,16 @@ public void test_unGroupRows() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " FormLayout formLayout = new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,});", - " setLayout(formLayout);", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + FormLayout formLayout = new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,}); + setLayout(formLayout); + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutParametersTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutParametersTest.java index 16680fd98..018a6a413 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutParametersTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutParametersTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -59,16 +59,15 @@ public void tearDown() throws Exception { */ @Test public void test_CREATE_Text() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); // create ExecutionUtils.run(panel, () -> { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); @@ -76,20 +75,20 @@ public void test_CREATE_Text() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JTextField textField = new JTextField();", - " add(textField, '1, 1, fill, default');", - " textField.setColumns(10);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JTextField textField = new JTextField(); + add(textField, "1, 1, fill, default"); + textField.setColumns(10); + } + } + }"""); } /** @@ -97,16 +96,15 @@ public void test_CREATE_Text() throws Exception { */ @Test public void test_CREATE_Text_disabled() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); // create Activator.getDefault().getPreferenceStore().setValue(IPreferenceConstants.P_ENABLE_GRAB, false); ExecutionUtils.run(panel, () -> { @@ -115,20 +113,20 @@ public void test_CREATE_Text_disabled() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JTextField textField = new JTextField();", - " add(textField, '1, 1');", - " textField.setColumns(10);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JTextField textField = new JTextField(); + add(textField, "1, 1"); + textField.setColumns(10); + } + } + }"""); } /** @@ -136,16 +134,15 @@ public void test_CREATE_Text_disabled() throws Exception { */ @Test public void test_CREATE_Table() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); // create ExecutionUtils.run(panel, () -> { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); @@ -153,19 +150,19 @@ public void test_CREATE_Table() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " RowSpec.decode('default:grow'),}));", - " {", - " JTable table = new JTable();", - " add(table, '1, 1, fill, fill');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + RowSpec.decode("default:grow"),})); + { + JTable table = new JTable(); + add(table, "1, 1, fill, fill"); + } + } + }"""); } /** @@ -175,26 +172,23 @@ public void test_CREATE_Table() throws Exception { */ @Test public void test_CREATE_Table_onImplicit() throws Exception { - setFileContentSrc( - "test/MyPanel.java", - getTestSource( - "public class MyPanel extends JPanel {", - " public MyPanel() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}")); + setFileContentSrc("test/MyPanel.java", getTestSource(""" + public class MyPanel extends JPanel { + public MyPanel() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }""")); waitForAutoBuild(); // parse - final ContainerInfo panel = - parseContainer( - "// filler filler filler", - "public class Test extends MyPanel {", - " public Test() {", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + // filler filler filler + public class Test extends MyPanel { + public Test() { + } + }"""); // create ExecutionUtils.run(panel, () -> { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); @@ -202,16 +196,16 @@ public void test_CREATE_Table_onImplicit() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "// filler filler filler", - "public class Test extends MyPanel {", - " public Test() {", - " {", - " JTable table = new JTable();", - " add(table, '1, 1, fill, fill');", - " }", - " }", - "}"); + assertEditor(""" + // filler filler filler + public class Test extends MyPanel { + public Test() { + { + JTable table = new JTable(); + add(table, "1, 1, fill, fill"); + } + } + }"""); } /** @@ -220,22 +214,21 @@ public void test_CREATE_Table_onImplicit() throws Exception { */ @Test public void test_CREATE_LabelBeforeText() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JTextField textField = new JTextField();", - " add(textField, '2, 1, fill, default');", - " }", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JTextField textField = new JTextField(); + add(textField, "2, 1, fill, default"); + } + } + }"""); // create ExecutionUtils.run(panel, () -> { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); @@ -243,25 +236,25 @@ public void test_CREATE_LabelBeforeText() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '2, 1, fill, default');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + { + JTextField textField = new JTextField(); + add(textField, "2, 1, fill, default"); + } + } + }"""); } /** @@ -271,23 +264,22 @@ public void test_CREATE_LabelBeforeText() throws Exception { */ @Test public void test_CREATE_LabelBeforeText_gap() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JTextField textField = new JTextField();", - " add(textField, '3, 1, fill, default');", - " }", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JTextField textField = new JTextField(); + add(textField, "3, 1, fill, default"); + } + } + }"""); // create ExecutionUtils.run(panel, () -> { FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); @@ -295,26 +287,26 @@ public void test_CREATE_LabelBeforeText_gap() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '3, 1, fill, default');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + { + JTextField textField = new JTextField(); + add(textField, "3, 1, fill, default"); + } + } + }"""); } /** @@ -322,22 +314,21 @@ public void test_CREATE_LabelBeforeText_gap() throws Exception { */ @Test public void test_CREATE_LabelBeforeText_disabled() throws Exception { - final ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JTextField textField = new JTextField();", - " add(textField, '2, 1, fill, default');", - " }", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JTextField textField = new JTextField(); + add(textField, "2, 1, fill, default"); + } + } + }"""); // create Activator.getDefault().getPreferenceStore().setValue( IPreferenceConstants.P_ENABLE_RIGHT_ALIGNMENT, @@ -348,25 +339,25 @@ public void test_CREATE_LabelBeforeText_disabled() throws Exception { layout.command_CREATE(newComponent, 1, false, 1, false); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '2, 1, fill, default');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1"); + } + { + JTextField textField = new JTextField(); + add(textField, "2, 1, fill, default"); + } + } + }"""); } /** @@ -375,22 +366,21 @@ public void test_CREATE_LabelBeforeText_disabled() throws Exception { */ @Test public void test_CREATE_TextAfterLabel() throws Exception { - final ContainerInfo panel = - parseContainer( - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + } + }"""); panel.refresh(); // add new component ExecutionUtils.run(panel, () -> { @@ -399,26 +389,26 @@ public void test_CREATE_TextAfterLabel() throws Exception { layout.command_CREATE(newComponent, 2, false, 1, false); }); // check result - assertEditor( - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '2, 1, fill, default');", - " textField.setColumns(10);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + { + JTextField textField = new JTextField(); + add(textField, "2, 1, fill, default"); + textField.setColumns(10); + } + } + }"""); } /** @@ -428,23 +418,22 @@ public void test_CREATE_TextAfterLabel() throws Exception { */ @Test public void test_CREATE_TextAfterLabel_gap() throws Exception { - final ContainerInfo panel = - parseContainer( - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " }", - "}"); + final ContainerInfo panel = parseContainer(""" + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + } + }"""); panel.refresh(); // add new component ExecutionUtils.run(panel, () -> { @@ -453,27 +442,27 @@ public void test_CREATE_TextAfterLabel_gap() throws Exception { layout.command_CREATE(newComponent, 3, false, 1, false); }); // check result - assertEditor( - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " RowSpec.decode('default:grow'),}));", - " {", - " JLabel label = new JLabel('New label');", - " add(label, '1, 1, right, default');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '3, 1, fill, default');", - " textField.setColumns(10);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + RowSpec.decode("default:grow"),})); + { + JLabel label = new JLabel("New label"); + add(label, "1, 1, right, default"); + } + { + JTextField textField = new JTextField(); + add(textField, "3, 1, fill, default"); + textField.setColumns(10); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutSelectionActionsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutSelectionActionsTest.java index f49330f72..3e89e23e9 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutSelectionActionsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutSelectionActionsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -37,48 +37,47 @@ public class FormLayoutSelectionActionsTest extends AbstractFormLayoutTest { //////////////////////////////////////////////////////////////////////////// @Test public void test_selectionActions() throws Exception { - ContainerInfo panel = - parseContainer( - "import com.jgoodies.forms.layout.*;", - "import com.jgoodies.forms.factories.*;", - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('New button');", - " add(button, '6, 6');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '12, 12, left, default');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + import com.jgoodies.forms.layout.*; + import com.jgoodies.forms.factories.*; + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("New button"); + add(button, "6, 6"); + } + { + JTextField textField = new JTextField(); + add(textField, "12, 12, left, default"); + } + } + }"""); // panel.refresh(); // @@ -115,46 +114,46 @@ public void test_selectionActions() throws Exception { leftAction.setChecked(true); leftAction.run(); // - assertEditor( - "import com.jgoodies.forms.layout.*;", - "import com.jgoodies.forms.factories.*;", - "class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('New button');", - " add(button, '6, 6, left, default');", - " }", - " {", - " JTextField textField = new JTextField();", - " add(textField, '12, 12, left, default');", - " }", - " }", - "}"); + assertEditor(""" + import com.jgoodies.forms.layout.*; + import com.jgoodies.forms.factories.*; + class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("New button"); + add(button, "6, 6, left, default"); + } + { + JTextField textField = new JTextField(); + add(textField, "12, 12, left, default"); + } + } + }"""); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutTest.java index 810bc5242..37d102f09 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutTest.java @@ -87,18 +87,17 @@ public void test_Activator() throws Exception { */ @Test public void test_object() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " ColumnSpec.decode('70dlu'),", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("70dlu"), + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // check columns @@ -137,28 +136,25 @@ public void test_object() throws Exception { */ @Test public void test_useJPannel_withFormLayout() throws Exception { - setFileContentSrc( - "test/MyPanel.java", - getTestSource( - "public class MyPanel extends JPanel {", - " public MyPanel() {", - " setLayout(new FormLayout());", - " }", - "}")); + setFileContentSrc("test/MyPanel.java", getTestSource(""" + public class MyPanel extends JPanel { + public MyPanel() { + setLayout(new FormLayout()); + } + }""")); waitForAutoBuild(); // parse - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " add(new MyPanel());", - " }", - "}"); - assertHierarchy( - "{this: javax.swing.JPanel} {this} {/add(new MyPanel())/}", - " {implicit-layout: java.awt.FlowLayout} {implicit-layout} {}", - " {new: test.MyPanel} {empty} {/add(new MyPanel())/}", - " {implicit-layout: com.jgoodies.forms.layout.FormLayout} {implicit-layout} {}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + add(new MyPanel()); + } + }"""); + assertHierarchy(""" + {this: javax.swing.JPanel} {this} {/add(new MyPanel())/} + {implicit-layout: java.awt.FlowLayout} {implicit-layout} {} + {new: test.MyPanel} {empty} {/add(new MyPanel())/} + {implicit-layout: com.jgoodies.forms.layout.FormLayout} {implicit-layout} {}"""); // refresh panel.refresh(); assertNoErrors(panel); @@ -169,20 +165,19 @@ public void test_useJPannel_withFormLayout() throws Exception { */ @Test public void test_withJTable() throws Exception { - ContainerInfo frame = - parseContainer( - "public class Test extends JFrame {", - " public Test() {", - " getContentPane().setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('default:grow'),},", - " new RowSpec[] {", - " RowSpec.decode('default:grow'),}));", - " {", - " JTable table = new JTable();", - " getContentPane().add(table, '1, 1, fill, fill');", - " }", - " }", - "}"); + ContainerInfo frame = parseContainer(""" + public class Test extends JFrame { + public Test() { + getContentPane().setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("default:grow"),}, + new RowSpec[] { + RowSpec.decode("default:grow"),})); + { + JTable table = new JTable(); + getContentPane().add(table, "1, 1, fill, fill"); + } + } + }"""); frame.refresh(); ContainerInfo contentPane = (ContainerInfo) frame.getChildrenComponents().get(0); ComponentInfo table = contentPane.getChildrenComponents().get(0); @@ -195,17 +190,16 @@ public void test_withJTable() throws Exception { */ @Test public void test_DimensionsProperty() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); panel.refresh(); // columnSpecs @@ -233,14 +227,13 @@ public void test_DimensionsProperty() throws Exception { */ @Test public void test_editColumnsRowsActions() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {},", - " new RowSpec[] {}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] {}, + new RowSpec[] {})); + } + }"""); // check for actions MenuManager menuManager = getDesignerMenuManager(); panel.getBroadcastObject().addContextMenu(List.of(panel), panel, menuManager); @@ -253,31 +246,30 @@ public void test_editColumnsRowsActions() throws Exception { */ @Test public void test_setColumns() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // assertEquals(2, layout.getColumns().size()); layout.setColumns(new ArrayList<>()); assertEquals(0, layout.getColumns().size()); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] {}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } /** @@ -285,17 +277,16 @@ public void test_setColumns() throws Exception { */ @Test public void test_setRows() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // @@ -303,33 +294,32 @@ public void test_setRows() throws Exception { // layout.setRows(new ArrayList<>()); assertEquals(0, layout.getRows().size()); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] {})); + } + }"""); } @Test public void test_getMinimumSize() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '1,1,2,1');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "1,1,2,1"); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // @@ -343,20 +333,19 @@ public void test_getMinimumSize() throws Exception { */ @Test public void test_gridInfo() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " ColumnSpec.decode('120px'),", - " ColumnSpec.decode('50px'),", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " RowSpec.decode('40px'),", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '1,1,2,1');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + ColumnSpec.decode("120px"), + ColumnSpec.decode("50px"), + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + RowSpec.decode("40px"), + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "1,1,2,1"); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); ComponentInfo button = panel.getChildrenComponents().get(0); @@ -394,14 +383,13 @@ public void test_gridInfo() throws Exception { */ @Test public void test_gridInfo_insets() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setBorder(new EmptyBorder(10, 20, 30, 40));", - " setLayout(new FormLayout());", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setBorder(new EmptyBorder(10, 20, 30, 40)); + setLayout(new FormLayout()); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); panel.refresh(); // @@ -419,36 +407,35 @@ public void test_gridInfo_insets() throws Exception { */ @Test public void test_normalizeSpanning_1() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '1, 1');", - " add(new JButton(), '2, 2');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "1, 1"); + add(new JButton(), "2, 2"); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // layout.normalizeSpanning(); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '1, 1');", - " add(new JButton(), '2, 2');", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "1, 1"); + add(new JButton(), "2, 2"); + } + }"""); } /** @@ -456,44 +443,43 @@ public void test_normalizeSpanning_1() throws Exception { */ @Test public void test_normalizeSpanning_2() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '2, 2');", - " add(new JButton(), '4, 4');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "2, 2"); + add(new JButton(), "4, 4"); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // layout.normalizeSpanning(); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '2, 2');", - " add(new JButton(), '4, 4');", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "2, 2"); + add(new JButton(), "4, 4"); + } + }"""); } /** @@ -501,38 +487,37 @@ public void test_normalizeSpanning_2() throws Exception { */ @Test public void test_normalizeSpanning_3() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '2, 2');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "2, 2"); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // layout.normalizeSpanning(); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " add(new JButton(), '2, 2');", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC,}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + add(new JButton(), "2, 2"); + } + }"""); } /** @@ -540,38 +525,37 @@ public void test_normalizeSpanning_3() throws Exception { */ @Test public void test_normalizeSpanning_4() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.UNRELATED_GAP_COLSPEC,", - " FormSpecs.PREF_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '4, 4');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.UNRELATED_GAP_COLSPEC, + FormSpecs.PREF_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "4, 4"); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // layout.normalizeSpanning(); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '2, 2');", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "2, 2"); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -581,22 +565,21 @@ public void test_normalizeSpanning_4() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_getColumnComponentsCounts() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " add(new JButton(), '1,1,2,1');", - " add(new JButton(), '1,2,1,1');", - " add(new JButton(), '3,2,1,1');", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + add(new JButton(), "1,1,2,1"); + add(new JButton(), "1,2,1,1"); + add(new JButton(), "3,2,1,1"); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); assertArrayEquals(new int[] { 2, 0, 1 }, layout.getColumnComponentsCounts()); assertArrayEquals(new int[] { 1, 2 }, layout.getRowComponentsCounts()); @@ -612,27 +595,26 @@ public void test_getColumnComponentsCounts() throws Exception { */ @Test public void test_writeEmpty() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] {})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // remove columns layout.getColumns().clear(); layout.writeDimensions(); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {},", - " new RowSpec[] {}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] {}, + new RowSpec[] {})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -645,22 +627,21 @@ public void test_writeEmpty() throws Exception { */ @Test public void test_setLayout() throws Exception { - ContainerInfo panel = - parseContainer( - "// filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + // filler filler filler + public class Test extends JPanel { + public Test() { + } + }"""); setLayout(panel, FormLayout.class); - assertEditor( - "// filler filler filler", - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {},", - " new RowSpec[] {}));", - " }", - "}"); + assertEditor(""" + // filler filler filler + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] {}, + new RowSpec[] {})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -673,35 +654,34 @@ public void test_setLayout() throws Exception { */ @Test public void test_CREATE_1() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // create ComponentInfo newComponent = createJButton(); layout.command_CREATE(newComponent, 1, false, 1, false); assertInstanceOf(InvocationChildAssociation.class, newComponent.getAssociation()); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); } /** @@ -709,13 +689,12 @@ public void test_CREATE_1() throws Exception { */ @Test public void test_CREATE_2() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(''));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout("")); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // initial state @@ -732,21 +711,21 @@ public void test_CREATE_2() throws Exception { // assertEquals(2, layout.getColumns().size()); assertEquals(2, layout.getRows().size()); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '2, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "2, 2"); + } + } + }"""); } /** @@ -755,42 +734,41 @@ public void test_CREATE_2() throws Exception { */ @Test public void test_CREATE_3() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '2, 2');", - " }", - " {", - " JButton button = new JButton('222');", - " add(button, '4, 4');", - " }", - " {", - " JButton button = new JButton('col span');", - " add(button, '1, 6, 6, 1');", - " }", - " {", - " JButton button = new JButton('row span');", - " add(button, '6, 1, 1, 6');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "2, 2"); + } + { + JButton button = new JButton("222"); + add(button, "4, 4"); + } + { + JButton button = new JButton("col span"); + add(button, "1, 6, 6, 1"); + } + { + JButton button = new JButton("row span"); + add(button, "6, 1, 1, 6"); + } + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // initial state @@ -803,49 +781,49 @@ public void test_CREATE_3() throws Exception { // assertEquals(8, layout.getColumns().size()); assertEquals(8, layout.getRows().size()); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '2, 2');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '4, 4');", - " }", - " {", - " JButton button = new JButton('222');", - " add(button, '6, 6');", - " }", - " {", - " JButton button = new JButton('col span');", - " add(button, '1, 8, 8, 1');", - " }", - " {", - " JButton button = new JButton('row span');", - " add(button, '8, 1, 1, 8');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "2, 2"); + } + { + JButton button = new JButton(); + add(button, "4, 4"); + } + { + JButton button = new JButton("222"); + add(button, "6, 6"); + } + { + JButton button = new JButton("col span"); + add(button, "1, 8, 8, 1"); + } + { + JButton button = new JButton("row span"); + add(button, "8, 1, 1, 8"); + } + } + }"""); } /** @@ -853,38 +831,37 @@ public void test_CREATE_3() throws Exception { */ @Test public void test_CREATE_4() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout());", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout()); + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // create ComponentInfo newComponent = createJButton(); layout.command_CREATE(newComponent, 4, false, 4, false); assertInstanceOf(InvocationChildAssociation.class, newComponent.getAssociation()); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '4, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "4, 4"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -897,21 +874,20 @@ public void test_CREATE_4() throws Exception { */ @Test public void test_PASTE() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " button.setEnabled(false);", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + button.setEnabled(false); + add(button, "1, 1"); + } + } + }"""); panel.refresh(); final FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // prepare memento @@ -927,29 +903,29 @@ public void test_PASTE() throws Exception { memento.apply(); }); // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " button.setEnabled(false);", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton();", - " button.setEnabled(false);", - " add(button, '3, 3');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + button.setEnabled(false); + add(button, "1, 1"); + } + { + JButton button = new JButton(); + button.setEnabled(false); + add(button, "3, 3"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -962,42 +938,41 @@ public void test_PASTE() throws Exception { */ @Test public void test_MOVE() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '2, 2');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "2, 2"); + } + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); ComponentInfo button = panel.getChildrenComponents().get(0); // move layout.command_MOVE(button, 1, false, 1, false); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.RELATED_GAP_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -1010,26 +985,25 @@ public void test_MOVE() throws Exception { */ @Test public void test_ADD() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JPanel panel = new JPanel();", - " add(panel, '1, 1');", - " {", - " JButton button = new JButton();", - " panel.add(button);", - " }", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JPanel panel = new JPanel(); + add(panel, "1, 1"); + { + JButton button = new JButton(); + panel.add(button); + } + } + } + }"""); panel.refresh(); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); ContainerInfo innerPanel = (ContainerInfo) panel.getChildrenComponents().get(0); @@ -1047,25 +1021,25 @@ public void test_ADD() throws Exception { assertEquals(CellConstraints.DEFAULT, ReflectionUtils.getFieldObject(constraints, "alignV")); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JPanel panel = new JPanel();", - " add(panel, '1, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '2, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JPanel panel = new JPanel(); + add(panel, "1, 1"); + } + { + JButton button = new JButton(); + add(button, "2, 2"); + } + } + }"""); } /** @@ -1073,51 +1047,50 @@ public void test_ADD() throws Exception { */ @Test public void test_ADD_OUT() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JPanel panel = new JPanel();", - " add(panel, '1, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '2, 2');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JPanel panel = new JPanel(); + add(panel, "1, 1"); + } + { + JButton button = new JButton(); + add(button, "2, 2"); + } + } + }"""); panel.refresh(); ContainerInfo innerPanel = (ContainerInfo) panel.getChildrenComponents().get(0); ComponentInfo button = panel.getChildrenComponents().get(1); // move FlowLayoutInfo flowLayout = (FlowLayoutInfo) innerPanel.getLayout(); flowLayout.move(button, null); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JPanel panel = new JPanel();", - " add(panel, '1, 1');", - " {", - " JButton button = new JButton();", - " panel.add(button);", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JPanel panel = new JPanel(); + add(panel, "1, 1"); + { + JButton button = new JButton(); + panel.add(button); + } + } + } + }"""); // check that layout does not have cached CellConstraintsSupport assertThrows(AssertionFailedException.class, () -> FormLayoutInfo.getConstraints(button)); } @@ -1127,33 +1100,32 @@ public void test_ADD_OUT() throws Exception { */ @Test public void test_DELETE() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); panel.refresh(); ComponentInfo button = panel.getChildrenComponents().get(0); // delete button.delete(); - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); // check that layout does not have cached CellConstraintsSupport assertThrows(AssertionFailedException.class, () -> FormLayoutInfo.getConstraints(button)); } @@ -1168,13 +1140,12 @@ public void test_DELETE() throws Exception { */ @Test public void test_canChangeDimensions_constructor() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout());", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout()); + } + }"""); // FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); assertTrue(layout.canChangeDimensions()); @@ -1185,26 +1156,23 @@ public void test_canChangeDimensions_constructor() throws Exception { */ @Test public void test_canChangeDimensions_implicit() throws Exception { - setFileContentSrc( - "test/MyPanel.java", - getTestSource( - "// filler filler filler filler filler", - "// filler filler filler filler filler", - "public class MyPanel extends JPanel {", - " public MyPanel() {", - " setLayout(new FormLayout());", - " }", - "}")); + setFileContentSrc("test/MyPanel.java", getTestSource(""" + // filler filler filler filler filler + // filler filler filler filler filler + public class MyPanel extends JPanel { + public MyPanel() { + setLayout(new FormLayout()); + } + }""")); waitForAutoBuild(); // parse - ContainerInfo panel = - parseContainer( - "// filler filler filler filler filler", - "// filler filler filler filler filler", - "public class Test extends MyPanel {", - " public Test() {", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + // filler filler filler filler filler + // filler filler filler filler filler + public class Test extends MyPanel { + public Test() { + } + }"""); // FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); assertFalse(layout.canChangeDimensions()); @@ -1220,28 +1188,26 @@ public void test_canChangeDimensions_implicit() throws Exception { */ @Test public void test_checkForActive_whenContributeProperties() throws Exception { - String[] lines = - { - "public class MyPanel extends JPanel {", - " public MyPanel() {", - " setLayout(new FormLayout());", - " }", - "}"}; - setFileContentSrc("test/MyPanel.java", getTestSource(lines)); + setFileContentSrc("test/MyPanel.java", getTestSource(""" + public class MyPanel extends JPanel { + public MyPanel() { + setLayout(new FormLayout()); + } + } + """)); waitForAutoBuild(); // parse - ContainerInfo panel = - parseContainer( - "public class Test extends MyPanel {", - " public Test() {", - " setLayout(new GridLayout());", - " add(new JButton());", - " }", - "}"); - assertHierarchy( - "{this: test.MyPanel} {this} {/setLayout(new GridLayout())/ /add(new JButton())/}", - " {new: java.awt.GridLayout} {empty} {/setLayout(new GridLayout())/}", - " {new: javax.swing.JButton} {empty} {/add(new JButton())/}"); + ContainerInfo panel = parseContainer(""" + public class Test extends MyPanel { + public Test() { + setLayout(new GridLayout()); + add(new JButton()); + } + }"""); + assertHierarchy(""" + {this: test.MyPanel} {this} {/setLayout(new GridLayout())/ /add(new JButton())/} + {new: java.awt.GridLayout} {empty} {/setLayout(new GridLayout())/} + {new: javax.swing.JButton} {empty} {/add(new JButton())/}"""); ComponentInfo button = panel.getChildrenComponents().get(0); assertNull(button.getPropertyByTitle("Constraints")); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormRowInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormRowInfoTest.java index 93fdc2dd1..62bbb45e7 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormRowInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormRowInfoTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -31,22 +31,21 @@ public class FormRowInfoTest extends AbstractFormLayoutTest { //////////////////////////////////////////////////////////////////////////// @Test public void test_insert_onRow() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 3');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 3"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -56,43 +55,42 @@ public void test_insert_onRow() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 5');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 5"); + } + } + }"""); } @Test public void test_insert_onGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 3');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 3"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -102,38 +100,37 @@ public void test_insert_onGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 5');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 5"); + } + } + }"""); } @Test public void test_insert_lastWithGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -143,31 +140,30 @@ public void test_insert_lastWithGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_insert_lastWithoutGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -177,17 +173,17 @@ public void test_insert_lastWithoutGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -197,26 +193,25 @@ public void test_insert_lastWithoutGap() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_deleteRow_nextGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 3');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "1, 3"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -226,43 +221,42 @@ public void test_deleteRow_nextGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("333"); + add(button, "1, 1"); + } + } + }"""); } @Test public void test_deleteRow_span() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1, 1, 2');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 3');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1, 1, 2"); + } + { + JButton button = new JButton("333"); + add(button, "1, 3"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -272,49 +266,48 @@ public void test_deleteRow_span() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "1, 2"); + } + } + }"""); } @Test public void test_deleteRow_prevGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 4');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 2"); + } + { + JButton button = new JButton("333"); + add(button, "1, 4"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -324,44 +317,43 @@ public void test_deleteRow_prevGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("333"); + add(button, "1, 2"); + } + } + }"""); } @Test public void test_deleteGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 3');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "1, 3"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -371,24 +363,24 @@ public void test_deleteGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('111');", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton('333');", - " add(button, '1, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("111"); + add(button, "1, 1"); + } + { + JButton button = new JButton("333"); + add(button, "1, 2"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -398,20 +390,19 @@ public void test_deleteGap() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_deleteContents() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -421,15 +412,15 @@ public void test_deleteContents() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -439,25 +430,24 @@ public void test_deleteContents() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_split() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 2');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + { + JButton button = new JButton(); + add(button, "1, 2"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // panel.refresh(); @@ -467,26 +457,26 @@ public void test_split() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1, 1, 3');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1, 1, 3"); + } + { + JButton button = new JButton(); + add(button, "1, 4"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -496,20 +486,19 @@ public void test_split() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_move_noOp() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -524,22 +513,21 @@ public void test_move_noOp() throws Exception { @Test public void test_move_backward_gap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 2');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 2"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -549,41 +537,40 @@ public void test_move_backward_gap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 3');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 3"); + } + } + }"""); } @Test public void test_move_forward_gap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 2');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 2"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -593,37 +580,36 @@ public void test_move_forward_gap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,}));", - " {", - " JButton button = new JButton();", - " add(button, '1, 1');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC,})); + { + JButton button = new JButton(); + add(button, "1, 1"); + } + } + }"""); } @Test public void test_move_noGaps() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward { @@ -634,17 +620,17 @@ public void test_move_noGaps() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + } + }"""); } // forward { @@ -655,49 +641,48 @@ public void test_move_noGaps() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + } + }"""); } } @Test public void test_move_backward_Last2Inner() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 4');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '1, 6');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 2"); + } + { + JButton button = new JButton("444"); + add(button, "1, 4"); + } + { + JButton button = new JButton("666"); + add(button, "1, 6"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -707,57 +692,56 @@ public void test_move_backward_Last2Inner() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 6');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '1, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 2"); + } + { + JButton button = new JButton("444"); + add(button, "1, 6"); + } + { + JButton button = new JButton("666"); + add(button, "1, 4"); + } + } + }"""); } @Test public void test_move_backward_Last2First() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 4');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 2"); + } + { + JButton button = new JButton("444"); + add(button, "1, 4"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -767,42 +751,41 @@ public void test_move_backward_Last2First() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 4');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 4"); + } + { + JButton button = new JButton("444"); + add(button, "1, 2"); + } + } + }"""); } @Test public void test_move_backward_2FirstNoGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -812,45 +795,44 @@ public void test_move_backward_2FirstNoGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + } + }"""); } @Test public void test_move_spanned_backwardExpand_forwardCollapse() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 2, 1, 3');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 6');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 2, 1, 3"); + } + { + JButton button = new JButton(); + add(button, "1, 6"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward expand { @@ -861,29 +843,29 @@ public void test_move_spanned_backwardExpand_forwardCollapse() throws Exception panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 2, 1, 5');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 2, 1, 5"); + } + { + JButton button = new JButton(); + add(button, "1, 4"); + } + } + }"""); } // forward collapse { @@ -894,60 +876,59 @@ public void test_move_spanned_backwardExpand_forwardCollapse() throws Exception panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 2, 1, 3');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 6');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 2, 1, 3"); + } + { + JButton button = new JButton(); + add(button, "1, 6"); + } + } + }"""); } } @Test public void test_move_spanned_backwardCollapse_forwardExpand() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 4, 1, 5');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 6');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 4, 1, 5"); + } + { + JButton button = new JButton(); + add(button, "1, 6"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // backward collapse { @@ -958,31 +939,31 @@ public void test_move_spanned_backwardCollapse_forwardExpand() throws Exception panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 6, 1, 3');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 6, 1, 3"); + } + { + JButton button = new JButton(); + add(button, "1, 4"); + } + } + }"""); } // forward expand { @@ -993,31 +974,31 @@ public void test_move_spanned_backwardCollapse_forwardExpand() throws Exception panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " {", - " JButton button = new JButton('spanned');", - " add(button, '1, 4, 1, 5');", - " }", - " {", - " JButton button = new JButton();", - " add(button, '1, 6');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + { + JButton button = new JButton("spanned"); + add(button, "1, 4, 1, 5"); + } + { + JButton button = new JButton(); + add(button, "1, 6"); + } + } + }"""); } } @@ -1026,33 +1007,32 @@ public void test_move_spanned_backwardCollapse_forwardExpand() throws Exception */ @Test public void test_move_forward_firstGapPrev2Last() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 4');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '1, 6');", - " }", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 2"); + } + { + JButton button = new JButton("444"); + add(button, "1, 4"); + } + { + JButton button = new JButton("666"); + add(button, "1, 6"); + } + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1062,49 +1042,48 @@ public void test_move_forward_firstGapPrev2Last() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.GLUE_ROWSPEC,", - " FormSpecs.UNRELATED_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " {", - " JButton button = new JButton('222');", - " add(button, '1, 6');", - " }", - " {", - " JButton button = new JButton('444');", - " add(button, '1, 2');", - " }", - " {", - " JButton button = new JButton('666');", - " add(button, '1, 4');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.GLUE_ROWSPEC, + FormSpecs.UNRELATED_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + { + JButton button = new JButton("222"); + add(button, "1, 6"); + } + { + JButton button = new JButton("444"); + add(button, "1, 2"); + } + { + JButton button = new JButton("666"); + add(button, "1, 4"); + } + } + }"""); } @Test public void test_move_forward_firstGapNext2Inner() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1114,35 +1093,34 @@ public void test_move_forward_firstGapNext2Inner() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } @Test public void test_move_forward_first2Last() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1152,36 +1130,35 @@ public void test_move_forward_first2Last() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC,})); + } + }"""); } @Test public void test_move_forward_firstNextGap2BeforeGap() throws Exception { - ContainerInfo panel = - parseContainer( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + ContainerInfo panel = parseContainer(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); FormLayoutInfo layout = (FormLayoutInfo) panel.getLayout(); // move panel.refresh(); @@ -1191,18 +1168,18 @@ public void test_move_forward_firstNextGap2BeforeGap() throws Exception { panel.refresh_dispose(); } // check source - assertEditor( - "public class Test extends JPanel {", - " public Test() {", - " setLayout(new FormLayout(new ColumnSpec[] {", - " FormSpecs.DEFAULT_COLSPEC,},", - " new RowSpec[] {", - " FormSpecs.PREF_ROWSPEC,", - " FormSpecs.RELATED_GAP_ROWSPEC,", - " FormSpecs.MIN_ROWSPEC,", - " FormSpecs.PARAGRAPH_GAP_ROWSPEC,", - " FormSpecs.DEFAULT_ROWSPEC,}));", - " }", - "}"); + assertEditor(""" + public class Test extends JPanel { + public Test() { + setLayout(new FormLayout(new ColumnSpec[] { + FormSpecs.DEFAULT_COLSPEC,}, + new RowSpec[] { + FormSpecs.PREF_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.MIN_ROWSPEC, + FormSpecs.PARAGRAPH_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC,})); + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormSizeInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormSizeInfoTest.java index dc4b1ad9d..da11a2332 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormSizeInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormSizeInfoTest.java @@ -23,7 +23,6 @@ import com.jgoodies.forms.layout.Sizes; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -61,7 +60,6 @@ public void _test_exit() throws Exception { /** * Test for {@link FormSizeConstantInfo}. */ - @Disabled @Test public void test_FormSizeConstantInfo() throws Exception { FormSizeConstantInfo size = new FormSizeConstantInfo(25, ConstantSize.PIXEL); @@ -131,7 +129,6 @@ public void test_FormSizeConstantInfo_convertSpecial() throws Exception { /** * Test for {@link FormSizeConstantInfo#convertFromPixels(int, Unit)} */ - @Disabled @Test public void test_FormSizeConstantInfo_convertFromPixels() throws Exception { { @@ -139,7 +136,7 @@ public void test_FormSizeConstantInfo_convertFromPixels() throws Exception { check_convertFromPixels(50, ConstantSize.PIXEL, expected); } { - double expected = 39.0; + double expected = 38.0; check_convertFromPixels(50, ConstantSize.POINT, expected); } { @@ -171,7 +168,6 @@ private void check_convertFromPixels(int pixels, Unit unit, double expected) thr /** * Test for {@link FormSizeConstantInfo#convertToPixels(double, Unit)} */ - @Disabled @Test public void test_FormSizeConstantInfo_convertToPixels() throws Exception { {