diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/e4/E4PartTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/e4/E4PartTest.java index 3030a5eab5..f6f30a51d6 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/e4/E4PartTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/e4/E4PartTest.java @@ -47,24 +47,23 @@ public void setUp() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_0() throws Exception { - E4PartInfo part = - parseJavaInfo( - "import jakarta.annotation.PostConstruct;", - "import jakarta.annotation.PreDestroy;", - "public class Test {", - " public Test() {", - " }", - " @PostConstruct", - " public void createControls(Composite parent) {", - " parent.setLayout(new GridLayout(1, false));", - " Button button = new Button(parent, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{parameter} {parent} {/parent.setLayout(new GridLayout(1, false))/ /new Button(parent, SWT.NONE)/}", - " {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout(1, false))/}", - " {new: org.eclipse.swt.widgets.Button} {local-unique: button} {/new Button(parent, SWT.NONE)/}", - " {virtual-layout_data: org.eclipse.swt.layout.GridData} {virtual-layout-data} {}"); + E4PartInfo part = parseJavaInfo(""" + import jakarta.annotation.PostConstruct; + import jakarta.annotation.PreDestroy; + public class Test { + public Test() { + } + @PostConstruct + public void createControls(Composite parent) { + parent.setLayout(new GridLayout(1, false)); + Button button = new Button(parent, SWT.NONE); + } + }"""); + assertHierarchy(""" + {parameter} {parent} {/parent.setLayout(new GridLayout(1, false))/ /new Button(parent, SWT.NONE)/} + {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout(1, false))/} + {new: org.eclipse.swt.widgets.Button} {local-unique: button} {/new Button(parent, SWT.NONE)/} + {virtual-layout_data: org.eclipse.swt.layout.GridData} {virtual-layout-data} {}"""); part.refresh(); assertNoErrors(part); // check bounds diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ColumnLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ColumnLayoutTest.java index a42db2fa76..ebae7c9f05 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ColumnLayoutTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ColumnLayoutTest.java @@ -52,51 +52,49 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_LayoutData_implicit() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); ColumnLayoutDataInfo columnData = ColumnLayoutInfo.getColumnData(button); columnData.setWidthHint(100); columnData.setHeightHint(200); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " ColumnLayoutData columnLayoutData = new ColumnLayoutData();", - " columnLayoutData.heightHint = 200;", - " columnLayoutData.widthHint = 100;", - " button.setLayoutData(columnLayoutData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + { + ColumnLayoutData columnLayoutData = new ColumnLayoutData(); + columnLayoutData.heightHint = 200; + columnLayoutData.widthHint = 100; + button.setLayoutData(columnLayoutData); + } + } + } + }"""); } @Test public void test_LayoutData_explicit() throws Exception { - CompositeInfo shell = - parseJavaInfo( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new ColumnLayoutData(100, 200));", - " }", - " }", - "}"); + CompositeInfo shell = parseJavaInfo(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new ColumnLayoutData(100, 200)); + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); ColumnLayoutDataInfo columnData = ColumnLayoutInfo.getColumnData(button); @@ -105,21 +103,20 @@ public void test_LayoutData_explicit() throws Exception { @Test public void test_copyPaste() throws Exception { - CompositeInfo shell = - parseJavaInfo( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new ColumnLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setLayoutData(new ColumnLayoutData(100, 200));", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseJavaInfo(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new ColumnLayout()); + { + Button button = new Button(composite, SWT.NONE); + button.setLayoutData(new ColumnLayoutData(100, 200)); + } + } + } + }"""); shell.refresh(); FillLayoutInfo fillLayout = (FillLayoutInfo) shell.getLayout(); // do copy @@ -134,48 +131,47 @@ public void test_copyPaste() throws Exception { fillLayout.command_CREATE(newComposite, null); memento.apply(); } - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new ColumnLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setLayoutData(new ColumnLayoutData(100, 200));", - " }", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new ColumnLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " {", - " button.setLayoutData(new ColumnLayoutData(100, 200));", - " }", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new ColumnLayout()); + { + Button button = new Button(composite, SWT.NONE); + button.setLayoutData(new ColumnLayoutData(100, 200)); + } + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new ColumnLayout()); + { + Button button = new Button(composite, SWT.NONE); + { + button.setLayoutData(new ColumnLayoutData(100, 200)); + } + } + } + } + }"""); } @Test public void test_selectionActions_1() throws Exception { - CompositeInfo shell = - parseJavaInfo( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " ColumnLayoutData columnLayoutData = new ColumnLayoutData();", - " button.setLayoutData(columnLayoutData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseJavaInfo(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + { + ColumnLayoutData columnLayoutData = new ColumnLayoutData(); + button.setLayoutData(columnLayoutData); + } + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); // prepare actions @@ -195,20 +191,20 @@ public void test_selectionActions_1() throws Exception { // leftAction.setChecked(true); leftAction.run(); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " ColumnLayoutData columnLayoutData = new ColumnLayoutData();", - " columnLayoutData.horizontalAlignment = ColumnLayoutData.LEFT;", - " button.setLayoutData(columnLayoutData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + { + ColumnLayoutData columnLayoutData = new ColumnLayoutData(); + columnLayoutData.horizontalAlignment = ColumnLayoutData.LEFT; + button.setLayoutData(columnLayoutData); + } + } + } + }"""); } } @@ -217,13 +213,12 @@ public void test_selectionActions_1() throws Exception { */ @Test public void test_selectionActions_2() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + } + }"""); shell.refresh(); // prepare actions List actions = getSelectionActions(); @@ -236,14 +231,13 @@ public void test_selectionActions_2() throws Exception { */ @Test public void test_selectionActions_3() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " Button button = new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + Button button = new Button(this, SWT.NONE); + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); // prepare actions @@ -262,35 +256,34 @@ public void test_selectionActions_3() throws Exception { */ @Test public void test_convertFrom() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " ColumnLayoutData columnLayoutData = new ColumnLayoutData();", - " columnLayoutData.horizontalAlignment = ColumnLayoutData.RIGHT;", - " button.setLayoutData(columnLayoutData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + { + ColumnLayoutData columnLayoutData = new ColumnLayoutData(); + columnLayoutData.horizontalAlignment = ColumnLayoutData.RIGHT; + button.setLayoutData(columnLayoutData); + } + } + } + }"""); shell.refresh(); // LayoutInfo gridLayout = createJavaInfo("org.eclipse.swt.layout.GridLayout"); shell.setLayout(gridLayout); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new GridLayout(1, false));", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new GridLayout(1, false)); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + } + } + }"""); } /** @@ -298,35 +291,34 @@ public void test_convertFrom() throws Exception { */ @Test public void test_convertTo() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new GridLayout(1, false));", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new GridLayout(1, false)); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + } + } + }"""); shell.refresh(); // LayoutInfo columnLayout = createJavaInfo("org.eclipse.ui.forms.widgets.ColumnLayout"); shell.setLayout(columnLayout); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new ColumnLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " ColumnLayoutData columnLayoutData = new ColumnLayoutData();", - " columnLayoutData.horizontalAlignment = ColumnLayoutData.RIGHT;", - " button.setLayoutData(columnLayoutData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new ColumnLayout()); + { + Button button = new Button(this, SWT.NONE); + { + ColumnLayoutData columnLayoutData = new ColumnLayoutData(); + columnLayoutData.horizontalAlignment = ColumnLayoutData.RIGHT; + button.setLayoutData(columnLayoutData); + } + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/DetailsPageTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/DetailsPageTest.java index 53905b1e3c..002a90b4c4 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/DetailsPageTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/DetailsPageTest.java @@ -41,28 +41,27 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_0() throws Exception { - DetailsPageInfo page = - parseJavaInfo( - "public abstract class Test implements IDetailsPage {", - " private IManagedForm managedForm;", - " public Test() {", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " parent.setLayout(new FillLayout());", - " Composite composite = managedForm.getToolkit().createComposite(parent, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.IDetailsPage} {this} {}", - " {parameter} {parent} {/parent.setLayout(new FillLayout())/ /managedForm.getToolkit().createComposite(parent, SWT.NONE)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/}", - " {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}"); + DetailsPageInfo page = parseJavaInfo(""" + public abstract class Test implements IDetailsPage { + private IManagedForm managedForm; + public Test() { + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + parent.setLayout(new FillLayout()); + Composite composite = managedForm.getToolkit().createComposite(parent, SWT.NONE); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.IDetailsPage} {this} {} + {parameter} {parent} {/parent.setLayout(new FillLayout())/ /managedForm.getToolkit().createComposite(parent, SWT.NONE)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/} + {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}"""); // refresh page.refresh(); assertNoErrors(page); @@ -82,28 +81,28 @@ public void test_0() throws Exception { @Test public void test_FormToolkit_inLocalVariable() throws Exception { - parseJavaInfo( - "public abstract class Test implements IDetailsPage {", - " private IManagedForm managedForm;", - " public Test() {", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " parent.setLayout(new FillLayout());", - " FormToolkit toolkit = managedForm.getToolkit();", - " Composite composite = toolkit.createComposite(parent, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.IDetailsPage} {this} {}", - " {parameter} {parent} {/parent.setLayout(new FillLayout())/ /toolkit.createComposite(parent, SWT.NONE)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/}", - " {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/toolkit.createComposite(parent, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {toolkitAccess: toolkit} {toolkitAccess} {/toolkit.createComposite(parent, SWT.NONE)/}"); + parseJavaInfo(""" + public abstract class Test implements IDetailsPage { + private IManagedForm managedForm; + public Test() { + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + parent.setLayout(new FillLayout()); + FormToolkit toolkit = managedForm.getToolkit(); + Composite composite = toolkit.createComposite(parent, SWT.NONE); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.IDetailsPage} {this} {} + {parameter} {parent} {/parent.setLayout(new FillLayout())/ /toolkit.createComposite(parent, SWT.NONE)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/} + {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/toolkit.createComposite(parent, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {toolkitAccess: toolkit} {toolkitAccess} {/toolkit.createComposite(parent, SWT.NONE)/}"""); } /** @@ -111,29 +110,28 @@ public void test_FormToolkit_inLocalVariable() throws Exception { */ @Test public void test_callDefaultSuper() throws Exception { - DetailsPageInfo page = - parseJavaInfo( - "public abstract class Test implements IDetailsPage {", - " private IManagedForm managedForm;", - " public Test() {", - " super();", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " parent.setLayout(new FillLayout());", - " Composite composite = managedForm.getToolkit().createComposite(parent, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.IDetailsPage} {this} {}", - " {parameter} {parent} {/parent.setLayout(new FillLayout())/ /managedForm.getToolkit().createComposite(parent, SWT.NONE)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/}", - " {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}"); + DetailsPageInfo page = parseJavaInfo(""" + public abstract class Test implements IDetailsPage { + private IManagedForm managedForm; + public Test() { + super(); + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + parent.setLayout(new FillLayout()); + Composite composite = managedForm.getToolkit().createComposite(parent, SWT.NONE); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.IDetailsPage} {this} {} + {parameter} {parent} {/parent.setLayout(new FillLayout())/ /managedForm.getToolkit().createComposite(parent, SWT.NONE)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/parent.setLayout(new FillLayout())/} + {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {/managedForm.getToolkit().createComposite(parent, SWT.NONE)/}"""); // refresh page.refresh(); assertNoErrors(page); @@ -141,24 +139,23 @@ public void test_callDefaultSuper() throws Exception { @Test public void test_parseNoUsingFormToolkit() throws Exception { - DetailsPageInfo page = - parseJavaInfo( - "public abstract class Test implements IDetailsPage {", - " private IManagedForm managedForm;", - " public Test() {", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.IDetailsPage} {this} {}", - " {parameter} {parent} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"); + DetailsPageInfo page = parseJavaInfo(""" + public abstract class Test implements IDetailsPage { + private IManagedForm managedForm; + public Test() { + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.IDetailsPage} {this} {} + {parameter} {parent} {} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"""); // refresh page.refresh(); assertNoErrors(page); @@ -166,25 +163,24 @@ public void test_parseNoUsingFormToolkit() throws Exception { @Test public void test_setLayout_forParent() throws Exception { - DetailsPageInfo page = - parseJavaInfo( - "public abstract class Test implements IDetailsPage {", - " private IManagedForm managedForm;", - " public Test() {", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " parent.setLayout(new GridLayout());", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.IDetailsPage} {this} {}", - " {parameter} {parent} {/parent.setLayout(new GridLayout())/}", - " {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout())/}", - " {instance factory container}", - " {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"); + DetailsPageInfo page = parseJavaInfo(""" + public abstract class Test implements IDetailsPage { + private IManagedForm managedForm; + public Test() { + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + parent.setLayout(new GridLayout()); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.IDetailsPage} {this} {} + {parameter} {parent} {/parent.setLayout(new GridLayout())/} + {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout())/} + {instance factory container} + {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"""); // refresh page.refresh(); assertNoErrors(page); @@ -199,34 +195,31 @@ public void test_setLayout_forParent() throws Exception { */ @Test public void test_extendAbstractClass() throws Exception { - setFileContentSrc( - "test/AbstractPage.java", - getSourceDQ( - "package test;", - "import org.eclipse.ui.forms.IDetailsPage;", - "public abstract class AbstractPage implements IDetailsPage {", - "}")); + setFileContentSrc("test/AbstractPage.java", """ + package test; + import org.eclipse.ui.forms.IDetailsPage; + public abstract class AbstractPage implements IDetailsPage { + }"""); waitForAutoBuild(); // parse - DetailsPageInfo page = - parseJavaInfo( - "public abstract class Test extends AbstractPage {", - " private IManagedForm managedForm;", - " public Test() {", - " }", - " public void initialize(IManagedForm form) {", - " managedForm = form;", - " }", - " public void createContents(Composite parent) {", - " parent.setLayout(new GridLayout());", - " }", - "}"); - assertHierarchy( - "{this: test.AbstractPage} {this} {}", - " {parameter} {parent} {/parent.setLayout(new GridLayout())/}", - " {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout())/}", - " {instance factory container}", - " {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"); + DetailsPageInfo page = parseJavaInfo(""" + public abstract class Test extends AbstractPage { + private IManagedForm managedForm; + public Test() { + } + public void initialize(IManagedForm form) { + managedForm = form; + } + public void createContents(Composite parent) { + parent.setLayout(new GridLayout()); + } + }"""); + assertHierarchy(""" + {this: test.AbstractPage} {this} {} + {parameter} {parent} {/parent.setLayout(new GridLayout())/} + {new: org.eclipse.swt.layout.GridLayout} {empty} {/parent.setLayout(new GridLayout())/} + {instance factory container} + {toolkitAccess: managedForm.getToolkit()} {toolkitAccess} {}"""); // refresh page.refresh(); assertNoErrors(page); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormPageTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormPageTest.java index 54f27047e5..5f73a7576a 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormPageTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormPageTest.java @@ -43,33 +43,32 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_0() throws Exception { - FormPageInfo page = - parseJavaInfo( - "import org.eclipse.ui.forms.editor.*;", - "public class Test extends FormPage {", - " /**", - " * @wbp.eval.method.parameter id 'Some id'", - " * @wbp.eval.method.parameter title 'Some title'", - " */", - " public Test(FormEditor editor, String id, String title) {", - " super(editor, id, title);", - " }", - " protected void createFormContent(IManagedForm managedForm) {", - " FormToolkit toolkit = managedForm.getToolkit();", - " ScrolledForm form = managedForm.getForm();", - " form.setText('Empty FormPage');", - " }", - "}"); + FormPageInfo page = parseJavaInfo(""" + import org.eclipse.ui.forms.editor.*; + public class Test extends FormPage { + /** + * @wbp.eval.method.parameter id "Some id" + * @wbp.eval.method.parameter title "Some title" + */ + public Test(FormEditor editor, String id, String title) { + super(editor, id, title); + } + protected void createFormContent(IManagedForm managedForm) { + FormToolkit toolkit = managedForm.getToolkit(); + ScrolledForm form = managedForm.getForm(); + form.setText("Empty FormPage"); + } + }"""); // check hierarchy - assertHierarchy( - "{this: org.eclipse.ui.forms.editor.FormPage} {this} {}", - " {parameter} {managedForm} {/managedForm.getToolkit()/ /managedForm.getForm()/}", - " {method: public org.eclipse.ui.forms.widgets.ScrolledForm org.eclipse.ui.forms.ManagedForm.getForm()} {property} {/managedForm.getForm()/ /form.setText('Empty FormPage')/}", - " {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.ScrolledForm.getBody()} {property} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {method: public org.eclipse.ui.forms.widgets.FormToolkit org.eclipse.ui.forms.ManagedForm.getToolkit()} {property} {/managedForm.getToolkit()/}", - " {instance factory container}", - " {method: public org.eclipse.ui.forms.widgets.FormToolkit org.eclipse.ui.forms.ManagedForm.getToolkit()} {property} {/managedForm.getToolkit()/}"); + assertHierarchy(""" + {this: org.eclipse.ui.forms.editor.FormPage} {this} {} + {parameter} {managedForm} {/managedForm.getToolkit()/ /managedForm.getForm()/} + {method: public org.eclipse.ui.forms.widgets.ScrolledForm org.eclipse.ui.forms.ManagedForm.getForm()} {property} {/managedForm.getForm()/ /form.setText("Empty FormPage")/} + {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.ScrolledForm.getBody()} {property} {} + {implicit-layout: absolute} {implicit-layout} {} + {method: public org.eclipse.ui.forms.widgets.FormToolkit org.eclipse.ui.forms.ManagedForm.getToolkit()} {property} {/managedForm.getToolkit()/} + {instance factory container} + {method: public org.eclipse.ui.forms.widgets.FormToolkit org.eclipse.ui.forms.ManagedForm.getToolkit()} {property} {/managedForm.getToolkit()/}"""); ManagedFormInfo managedForm = (ManagedFormInfo) page.getChildrenJava().get(0); ScrolledFormInfo scrolledForm = (ScrolledFormInfo) managedForm.getChildrenJava().get(0); // refresh @@ -83,20 +82,19 @@ public void test_0() throws Exception { @Test public void test_severalConstructors() throws Exception { useStrictEvaluationMode(false); - FormPageInfo page = - parseJavaInfo( - "import org.eclipse.ui.forms.editor.*;", - "public class Test extends FormPage {", - " public Test(String id, String title) {", - " super(id, title);", - " }", - " public Test(FormEditor editor, String id, String title) {", - " super(editor, id, title);", - " }", - " protected void createFormContent(IManagedForm managedForm) {", - " ScrolledForm form = managedForm.getForm();", - " }", - "}"); + FormPageInfo page = parseJavaInfo(""" + import org.eclipse.ui.forms.editor.*; + public class Test extends FormPage { + public Test(String id, String title) { + super(id, title); + } + public Test(FormEditor editor, String id, String title) { + super(editor, id, title); + } + protected void createFormContent(IManagedForm managedForm) { + ScrolledForm form = managedForm.getForm(); + } + }"""); page.refresh(); assertNoErrors(page); } @@ -106,36 +104,31 @@ public void test_severalConstructors() throws Exception { */ @Test public void test_subclassFormEditor() throws Exception { - setFileContentSrc( - "test/MyFormEditor.java", - getTestSource( - "import org.eclipse.ui.forms.editor.*;", - "public abstract class MyFormEditor extends FormEditor {", - " public MyFormEditor() {", - " }", - "}")); - setFileContentSrc( - "test/MyFormPage.java", - getTestSource( - "import org.eclipse.ui.forms.editor.*;", - "public abstract class MyFormPage extends FormPage {", - " public MyFormPage(MyFormEditor editor) {", - " super(editor, 'id', 'title');", - " }", - "}")); + setFileContentSrc("test/MyFormEditor.java", getTestSource(""" + import org.eclipse.ui.forms.editor.*; + public abstract class MyFormEditor extends FormEditor { + public MyFormEditor() { + } + }""")); + setFileContentSrc("test/MyFormPage.java", getTestSource(""" + import org.eclipse.ui.forms.editor.*; + public abstract class MyFormPage extends FormPage { + public MyFormPage(MyFormEditor editor) { + super(editor, "id", "title"); + } + }""")); waitForAutoBuild(); // parse - FormPageInfo page = - parseJavaInfo( - "import org.eclipse.ui.forms.editor.*;", - "public class Test extends MyFormPage {", - " public Test(MyFormEditor editor) {", - " super(editor);", - " }", - " protected void createFormContent(IManagedForm managedForm) {", - " ScrolledForm form = managedForm.getForm();", - " }", - "}"); + FormPageInfo page = parseJavaInfo(""" + import org.eclipse.ui.forms.editor.*; + public class Test extends MyFormPage { + public Test(MyFormEditor editor) { + super(editor); + } + protected void createFormContent(IManagedForm managedForm) { + ScrolledForm form = managedForm.getForm(); + } + }"""); page.refresh(); assertNoErrors(page); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTest.java index 5ebe949446..31626b45b6 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTest.java @@ -56,14 +56,13 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_properties() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); assertNotNull(form.getPropertyByTitle("Style")); @@ -79,14 +78,13 @@ public void test_properties() throws Exception { */ @Test public void test_getHead_getBody() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // getHead() and getBody() should be exposed @@ -116,18 +114,17 @@ public void test_getHead_getBody() throws Exception { */ @Test public void test_head_getHeadClient() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " {", - " Button buttonHead = new Button(form.getHead(), SWT.NONE);", - " form.setHeadClient(buttonHead);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + { + Button buttonHead = new Button(form.getHead(), SWT.NONE); + form.setHeadClient(buttonHead); + } + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); CompositeInfo head = (CompositeInfo) form.getChildrenControls().get(0); @@ -144,32 +141,31 @@ public void test_head_getHeadClient() throws Exception { */ @Test public void test_head_setHeadClient() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.NONE);", - " form.setEnabled(true);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.NONE); + form.setEnabled(true); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // set "head client" ControlInfo button = BTestUtils.createButton(); form.setHeadClient(button); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.NONE);", - " form.setEnabled(true);", - " {", - " Button button = new Button(form.getHead(), SWT.NONE);", - " form.setHeadClient(button);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.NONE); + form.setEnabled(true); + { + Button button = new Button(form.getHead(), SWT.NONE); + form.setHeadClient(button); + } + } + }"""); assertSame(button, form.getHeadClient()); } @@ -178,34 +174,33 @@ public void test_head_setHeadClient() throws Exception { */ @Test public void test_head_MoveOut() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " {", - " Button button = new Button(form.getHead(), SWT.NONE);", - " form.setHeadClient(button);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + { + Button button = new Button(form.getHead(), SWT.NONE); + form.setHeadClient(button); + } + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); ControlInfo button = form.getHeadClient(); // do move RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout(); rowLayout.command_MOVE(button, null); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); assertNull(form.getHeadClient()); } @@ -214,33 +209,32 @@ public void test_head_MoveOut() throws Exception { */ @Test public void test_head_MoveIn() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); ControlInfo button = shell.getChildrenControls().get(1); // do move form.setHeadClient(button); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Form form = new Form(this, SWT.NONE);", - " {", - " Button button = new Button(form.getHead(), SWT.NONE);", - " form.setHeadClient(button);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Form form = new Form(this, SWT.NONE); + { + Button button = new Button(form.getHead(), SWT.NONE); + form.setHeadClient(button); + } + } + }"""); assertSame(button, form.getHeadClient()); } @@ -254,26 +248,25 @@ public void test_head_MoveIn() throws Exception { */ @Test public void test_exposedManagers_0() throws Exception { - CompositeInfo shell = - parseComposite( - "import org.eclipse.jface.action.*;", - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + import org.eclipse.jface.action.*; + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); shell.refresh(); // check hierarchy - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new Form(this, SWT.BORDER)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}", - " {new: org.eclipse.ui.forms.widgets.Form} {local-unique: form} {/new Form(this, SWT.BORDER)/}", - " {method: public org.eclipse.jface.action.IToolBarManager org.eclipse.ui.forms.widgets.Form.getToolBarManager()} {property} {}", - " {method: public org.eclipse.jface.action.IMenuManager org.eclipse.ui.forms.widgets.Form.getMenuManager()} {property} {}", - " {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.Form.getHead()} {property} {}", - " {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.Form.getBody()} {property} {}", - " {implicit-layout: absolute} {implicit-layout} {}"); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new Form(this, SWT.BORDER)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/} + {new: org.eclipse.ui.forms.widgets.Form} {local-unique: form} {/new Form(this, SWT.BORDER)/} + {method: public org.eclipse.jface.action.IToolBarManager org.eclipse.ui.forms.widgets.Form.getToolBarManager()} {property} {} + {method: public org.eclipse.jface.action.IMenuManager org.eclipse.ui.forms.widgets.Form.getMenuManager()} {property} {} + {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.Form.getHead()} {property} {} + {method: public org.eclipse.swt.widgets.Composite org.eclipse.ui.forms.widgets.Form.getBody()} {property} {} + {implicit-layout: absolute} {implicit-layout} {}"""); } /** @@ -281,15 +274,14 @@ public void test_exposedManagers_0() throws Exception { */ @Test public void test_exposedManagers_toolBarManager() throws Exception { - CompositeInfo shell = - parseComposite( - "import org.eclipse.jface.action.*;", - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + import org.eclipse.jface.action.*; + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // exposed (and now empty) ToolBarManager should be not very wide, because Form has not so much space @@ -305,16 +297,15 @@ public void test_exposedManagers_toolBarManager() throws Exception { */ @Test public void test_exposedManagers_menuManager() throws Exception { - CompositeInfo shell = - parseComposite( - "import org.eclipse.jface.action.*;", - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " form.setText('Some text');", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + import org.eclipse.jface.action.*; + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + form.setText("Some text"); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // exposed MenuManager and its IMenuPopupInfo @@ -333,37 +324,36 @@ public void test_exposedManagers_menuManager() throws Exception { */ @Test public void test_exposedManagers_createAction() throws Exception { - CompositeInfo shell = - parseComposite( - "import org.eclipse.jface.action.*;", - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + import org.eclipse.jface.action.*; + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // add new Action ActionInfo newAction = ActionContainerInfo.createNew(shell); form.getToolBarManager().command_CREATE(newAction, null); - assertEditor( - "import org.eclipse.jface.action.*;", - "public class Test extends Shell {", - " private Action action;", - " public Test() {", - " createActions();", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " form.getToolBarManager().add(action);", - " }", - " private void createActions() {", - " {", - " action = new Action('New Action') {", - " };", - " }", - " }", - "}"); + assertEditor(""" + import org.eclipse.jface.action.*; + public class Test extends Shell { + private Action action; + public Test() { + createActions(); + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + form.getToolBarManager().add(action); + } + private void createActions() { + { + action = new Action("New Action") { + }; + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -377,15 +367,14 @@ public void test_exposedManagers_createAction() throws Exception { */ @Test public void test_FormToolkit_decorateFormHeading() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent());", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent()); + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); shell.refresh(); FormInfo form = (FormInfo) shell.getChildrenControls().get(0); // decoration: false -> true @@ -395,15 +384,15 @@ public void test_FormToolkit_decorateFormHeading() throws Exception { // decorate := true decorateAction.setChecked(true); decorateAction.run(); - assertEditor( - "public class Test extends Shell {", - " private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent());", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " m_toolkit.decorateFormHeading(form);", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent()); + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + m_toolkit.decorateFormHeading(form); + } + }"""); } // decoration: true -> false { @@ -412,14 +401,14 @@ public void test_FormToolkit_decorateFormHeading() throws Exception { // decorate := false decorateAction.setChecked(false); decorateAction.run(); - assertEditor( - "public class Test extends Shell {", - " private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent());", - " public Test() {", - " setLayout(new FillLayout());", - " Form form = new Form(this, SWT.BORDER);", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private FormToolkit m_toolkit = new FormToolkit(Display.getCurrent()); + public Test() { + setLayout(new FillLayout()); + Form form = new Form(this, SWT.BORDER); + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTextTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTextTest.java index 22685a8d4f..811d8d83da 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTextTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormTextTest.java @@ -48,16 +48,15 @@ public void _test_exit() throws Exception { */ @Test public void test_create() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new RowLayout());", - " FormText formText = m_toolkit.createFormText(this, true);", - " formText.setText('abc', false, false);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new RowLayout()); + FormText formText = m_toolkit.createFormText(this, true); + formText.setText("abc", false, false); + } + }"""); shell.refresh(); } @@ -66,13 +65,12 @@ public void test_create() throws Exception { */ @Test public void test_zeroSize() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " FormText formText = new FormText(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + FormText formText = new FormText(this, SWT.NONE); + } + }"""); shell.refresh(); assertNoErrors(shell); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitAccessTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitAccessTest.java index c9c693acc2..840d825950 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitAccessTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitAccessTest.java @@ -70,37 +70,31 @@ public class Test { @Test public void test_toolkitMethod_public() throws Exception { - setFileContentSrc( - "test/MyForm.java", - getSource( - "package test;", - "import org.eclipse.ui.forms.*;", - "import org.eclipse.ui.forms.widgets.*;", - "public class MyForm {", - " public FormToolkit getPublicToolkit() {", - " return null;", - " }", - "}")); + setFileContentSrc("test/MyForm.java", getSource(""" + package test; + import org.eclipse.ui.forms.*; + import org.eclipse.ui.forms.widgets.*; + public class MyForm { + public FormToolkit getPublicToolkit() { + return null; + } + }""")); waitForAutoBuild(); - TypeDeclaration typeDeclaration = - createTypeDeclaration( - "test", - "Test.java", - getSource( - "package test;", - "import org.eclipse.ui.forms.*;", - "import org.eclipse.ui.forms.widgets.*;", - "public class Test extends MyForm {", - " public void isToolkit_1() {", - " int a;", - " }", - " public void isToolkit_2() {", - " System.out.println();", - " }", - " public void isToolkit_3() {", - " getPublicToolkit();", - " }", - "}")); + TypeDeclaration typeDeclaration = createTypeDeclaration("test", "Test.java", getSource(""" + package test; + import org.eclipse.ui.forms.*; + import org.eclipse.ui.forms.widgets.*; + public class Test extends MyForm { + public void isToolkit_1() { + int a; + } + public void isToolkit_2() { + System.out.println(); + } + public void isToolkit_3() { + getPublicToolkit(); + } + }""")); FormToolkitAccess toolkitAccess = FormToolkitAccess.getOrFail(typeDeclaration); assertEquals("getPublicToolkit()", toolkitAccess.getReferenceExpression()); assertToolkitNode(false, toolkitAccess, typeDeclaration, "isToolkit_1"); @@ -110,28 +104,22 @@ public void test_toolkitMethod_public() throws Exception { @Test public void test_toolkitMethod_protected() throws Exception { - setFileContentSrc( - "test/MyForm.java", - getSource( - "package test;", - "import org.eclipse.ui.forms.*;", - "import org.eclipse.ui.forms.widgets.*;", - "public class MyForm {", - " public FormToolkit getProtectedToolkit() {", - " return null;", - " }", - "}")); + setFileContentSrc("test/MyForm.java", getSource(""" + package test; + import org.eclipse.ui.forms.*; + import org.eclipse.ui.forms.widgets.*; + public class MyForm { + public FormToolkit getProtectedToolkit() { + return null; + } + }""")); waitForAutoBuild(); - TypeDeclaration typeDeclaration = - createTypeDeclaration( - "test", - "Test.java", - getSource( - "package test;", - "import org.eclipse.ui.forms.*;", - "import org.eclipse.ui.forms.widgets.*;", - "public class Test extends MyForm {", - "}")); + TypeDeclaration typeDeclaration = createTypeDeclaration("test", "Test.java", getSource(""" + package test; + import org.eclipse.ui.forms.*; + import org.eclipse.ui.forms.widgets.*; + public class Test extends MyForm { + }""")); FormToolkitAccess toolkitAccess = FormToolkitAccess.getOrFail(typeDeclaration); assertEquals("getProtectedToolkit()", toolkitAccess.getReferenceExpression()); } @@ -193,17 +181,15 @@ public void foo() { @Test public void test_formMethod() throws Exception { - setFileContentSrc( - "test/MyForm.java", - getSource( - "package test;", - "import org.eclipse.ui.forms.*;", - "import org.eclipse.ui.forms.widgets.*;", - "public class MyForm {", - " public IManagedForm getMyForm() {", - " return null;", - " }", - "}")); + setFileContentSrc("test/MyForm.java", getSource(""" + package test; + import org.eclipse.ui.forms.*; + import org.eclipse.ui.forms.widgets.*; + public class MyForm { + public IManagedForm getMyForm() { + return null; + } + }""")); waitForAutoBuild(); TypeDeclaration typeDeclaration = createTypeDeclaration_Test(""" import org.eclipse.ui.forms.*; @@ -304,40 +290,35 @@ private static void assertToolkitNode(boolean expectedResult, */ @Test public void test_toolkitAccessSupports() throws Exception { - setFileContentSrc( - "test/MyShell.java", - getTestSource( - "public abstract class MyShell extends Shell {", - " protected IManagedForm m_managedForm;", - " public void initialize(IManagedForm form) {", - " m_managedForm = form;", - " }", - " public abstract void createContents(Composite parent);", - " protected void checkSubclass () {}", - "}")); - setFileContentSrc( - "test/MyShell.wbp-component.xml", - getSourceDQ( - "", - "", - " ", - " createContents(org.eclipse.swt.widgets.Composite)", - " ", - "")); + setFileContentSrc("test/MyShell.java", getTestSource(""" + public abstract class MyShell extends Shell { + protected IManagedForm m_managedForm; + public void initialize(IManagedForm form) { + m_managedForm = form; + } + public abstract void createContents(Composite parent); + protected void checkSubclass () {} + }""")); + setFileContentSrc("test/MyShell.wbp-component.xml", """ + + + + createContents(org.eclipse.swt.widgets.Composite) + + """); waitForAutoBuild(); // parse - CompositeInfo shell = - parseComposite( - "public class Test extends MyShell {", - " public Test() {", - " createContents(this);", - " }", - " public void createContents(Composite parent) {", - " }", - " private void isToolkit_1() {", - " m_managedForm.getToolkit();", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends MyShell { + public Test() { + createContents(this); + } + public void createContents(Composite parent) { + } + private void isToolkit_1() { + m_managedForm.getToolkit(); + } + }"""); TypeDeclaration typeDeclaration = JavaInfoUtils.getTypeDeclaration(shell); // prepare toolkit, its creation/variable supports FormToolkitAccess toolkitAccess = FormToolkitAccess.getOrFail(typeDeclaration); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitTest.java index df0a2f9257..00c5141d10 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/FormToolkitTest.java @@ -52,14 +52,13 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_parse() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + } + }"""); shell.refresh(); InstanceFactoryInfo toolkit = getToolkit(); ComponentDescription description = toolkit.getDescription(); @@ -80,23 +79,23 @@ public void test_parse() throws Exception { @Test public void test_createFormToolkit_usingStaticFactory() throws Exception { m_waitForAutoBuild = true; - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = createFormToolkit();", - " public Test() {", - " }", - " /**", - " * @wbp.factory", - " */", - " private static FormToolkit createFormToolkit() {", - " return new FormToolkit(Display.getDefault());", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {static factory: test.Test createFormToolkit()} {field-initializer: m_toolkit} {/createFormToolkit()/}"); + parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = createFormToolkit(); + public Test() { + } + /** + * @wbp.factory + */ + private static FormToolkit createFormToolkit() { + return new FormToolkit(Display.getDefault()); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {static factory: test.Test createFormToolkit()} {field-initializer: m_toolkit} {/createFormToolkit()/}"""); } /** @@ -104,20 +103,20 @@ public void test_createFormToolkit_usingStaticFactory() throws Exception { */ @Test public void test_createFormToolkit_inInitializer_instance() throws Exception { - parseComposite( - "public class Test extends Shell {", - " private FormToolkit m_toolkit;", - " {", - " m_toolkit = new FormToolkit(Display.getDefault());", - " }", - " public Test() {", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-unique: m_toolkit} {/new FormToolkit(Display.getDefault())/}"); + parseComposite(""" + public class Test extends Shell { + private FormToolkit m_toolkit; + { + m_toolkit = new FormToolkit(Display.getDefault()); + } + public Test() { + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-unique: m_toolkit} {/new FormToolkit(Display.getDefault())/}"""); } /** @@ -125,33 +124,32 @@ public void test_createFormToolkit_inInitializer_instance() throws Exception { */ @Test public void test_createFormToolkit_inInitializer_static() throws Exception { - parseComposite( - "public class Test extends Shell {", - " private static FormToolkit m_toolkit;", - " static {", - " m_toolkit = new FormToolkit(Display.getDefault());", - " }", - " public Test() {", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-unique: m_toolkit} {/new FormToolkit(Display.getDefault())/}"); + parseComposite(""" + public class Test extends Shell { + private static FormToolkit m_toolkit; + static { + m_toolkit = new FormToolkit(Display.getDefault()); + } + public Test() { + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-unique: m_toolkit} {/new FormToolkit(Display.getDefault())/}"""); } @Test public void test_createText() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new RowLayout());", - " Text text = m_toolkit.createText(this, 'text', SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new RowLayout()); + Text text = m_toolkit.createText(this, "text", SWT.NONE); + } + }"""); shell.refresh(); // check for Text widget ControlInfo text = shell.getChildrenControls().get(0); @@ -161,21 +159,20 @@ public void test_createText() throws Exception { @Test public void test_createTable_separateStatement() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " m_toolkit.createTable(this, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /m_toolkit.createTable(this, SWT.NONE)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}", - " {instance factory: {field-initializer: m_toolkit} createTable(org.eclipse.swt.widgets.Composite,int)} {empty} {/m_toolkit.createTable(this, SWT.NONE)/}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /m_toolkit.createTable(this, SWT.NONE)/}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + m_toolkit.createTable(this, SWT.NONE); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /m_toolkit.createTable(this, SWT.NONE)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/} + {instance factory: {field-initializer: m_toolkit} createTable(org.eclipse.swt.widgets.Composite,int)} {empty} {/m_toolkit.createTable(this, SWT.NONE)/} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /m_toolkit.createTable(this, SWT.NONE)/}"""); // refresh() shell.refresh(); assertNoErrors(shell); @@ -183,23 +180,22 @@ public void test_createTable_separateStatement() throws Exception { @Test public void test_createLabel_separateStatement_GridLayout() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new GridLayout());", - " m_toolkit.createLabel(this, 'Some text', SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new GridLayout()); + m_toolkit.createLabel(this, "Some text", SWT.NONE); + } + }"""); shell.refresh(); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new GridLayout())/ /m_toolkit.createLabel(this, 'Some text', SWT.NONE)/}", - " {new: org.eclipse.swt.layout.GridLayout} {empty} {/setLayout(new GridLayout())/}", - " {instance factory: {field-initializer: m_toolkit} createLabel(org.eclipse.swt.widgets.Composite,java.lang.String,int)} {empty} {/m_toolkit.createLabel(this, 'Some text', SWT.NONE)/}", - " {virtual-layout_data: org.eclipse.swt.layout.GridData} {virtual-layout-data} {}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /m_toolkit.createLabel(this, 'Some text', SWT.NONE)/}"); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new GridLayout())/ /m_toolkit.createLabel(this, "Some text", SWT.NONE)/} + {new: org.eclipse.swt.layout.GridLayout} {empty} {/setLayout(new GridLayout())/} + {instance factory: {field-initializer: m_toolkit} createLabel(org.eclipse.swt.widgets.Composite,java.lang.String,int)} {empty} {/m_toolkit.createLabel(this, "Some text", SWT.NONE)/} + {virtual-layout_data: org.eclipse.swt.layout.GridData} {virtual-layout-data} {} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /m_toolkit.createLabel(this, "Some text", SWT.NONE)/}"""); ControlInfo label = shell.getChildrenControls().get(0); // check that "label" is visible IObjectPresentation presentation = shell.getPresentation(); @@ -214,20 +210,19 @@ public void test_createLabel_separateStatement_GridLayout() throws Exception { */ @Test public void test_FormToolkit_asConstructorParameter() throws Exception { - CompositeInfo composite = - parseComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style, FormToolkit toolkit) {", - " super(parent, style);", - " toolkit.createTable(this, SWT.NONE);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Composite} {this} {/toolkit.createTable(this, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory: {toolkit} createTable(org.eclipse.swt.widgets.Composite,int)} {empty} {/toolkit.createTable(this, SWT.NONE)/}", - " {instance factory container}", - " {parameter} {toolkit} {/toolkit.createTable(this, SWT.NONE)/}"); + CompositeInfo composite = parseComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style, FormToolkit toolkit) { + super(parent, style); + toolkit.createTable(this, SWT.NONE); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Composite} {this} {/toolkit.createTable(this, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory: {toolkit} createTable(org.eclipse.swt.widgets.Composite,int)} {empty} {/toolkit.createTable(this, SWT.NONE)/} + {instance factory container} + {parameter} {toolkit} {/toolkit.createTable(this, SWT.NONE)/}"""); // refresh() composite.refresh(); assertNoErrors(composite); @@ -241,18 +236,17 @@ public void test_FormToolkit_asConstructorParameter() throws Exception { */ @Test public void test_FormToolkit_asConstructorParameter2() throws Exception { - CompositeInfo composite = - parseComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style, FormToolkit toolkit) {", - " super(parent, style);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Composite} {this} {}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {parameter} {toolkit} {}"); + CompositeInfo composite = parseComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style, FormToolkit toolkit) { + super(parent, style); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Composite} {this} {} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {parameter} {toolkit} {}"""); // refresh() composite.refresh(); assertNoErrors(composite); @@ -264,21 +258,20 @@ public void test_FormToolkit_asConstructorParameter2() throws Exception { */ @Test public void test_FormToolkit_asEntryPoint_methodParameter() throws Exception { - CompositeInfo composite = - parseComposite( - "public class Test {", - " /**", - " * @wbp.parser.entryPoint", - " */", - " public void createClient(Section section, FormToolkit toolkit) {", - " Composite container = toolkit.createComposite(section);", - " }", - "}"); - assertHierarchy( - "{instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {parameter} {toolkit} {/toolkit.createComposite(section)/}"); + CompositeInfo composite = parseComposite(""" + public class Test { + /** + * @wbp.parser.entryPoint + */ + public void createClient(Section section, FormToolkit toolkit) { + Composite container = toolkit.createComposite(section); + } + }"""); + assertHierarchy(""" + {instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {parameter} {toolkit} {/toolkit.createComposite(section)/}"""); // refresh() composite.refresh(); assertNoErrors(composite); @@ -291,91 +284,88 @@ public void test_FormToolkit_asEntryPoint_methodParameter() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_paintBordersFor_whenDropNewComposite() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + } + }"""); shell.refresh(); // ControlInfo newComposite = createJavaInfo("org.eclipse.swt.widgets.Composite"); shell.getLayout().command_CREATE(newComposite, null); - assertEditor( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " m_toolkit.adapt(composite);", - " m_toolkit.paintBordersFor(composite);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + m_toolkit.adapt(composite); + m_toolkit.paintBordersFor(composite); + } + } + }"""); } @Test public void test_adapt_whenDropNonFormControl() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + } + }"""); shell.refresh(); // ControlInfo newButton = BTestUtils.createButton(); shell.getLayout().command_CREATE(newButton, null); - assertEditor( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " m_toolkit.adapt(button, true, true);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + { + Button button = new Button(this, SWT.NONE); + m_toolkit.adapt(button, true, true); + } + } + }"""); } @Test public void test_adapt_whenDropNonFormControl_ignoreFillers() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // ControlInfo newButton = BTestUtils.createButton(); layout.command_CREATE(newButton, 0, false, 1, false); - assertEditor( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " m_toolkit.adapt(button, true, true);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + m_toolkit.adapt(button, true, true); + } + } + }"""); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/MasterDetailsBlockTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/MasterDetailsBlockTest.java index fec4c5d6e2..272b922f84 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/MasterDetailsBlockTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/MasterDetailsBlockTest.java @@ -38,28 +38,27 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_0() throws Exception { - MasterDetailsBlockInfo page = - parseJavaInfo( - "public abstract class Test extends MasterDetailsBlock {", - " private FormToolkit m_toolkit;", - " public Test() {", - " }", - " protected void createMasterPart(IManagedForm managedForm, Composite parent) {", - " m_toolkit = managedForm.getToolkit();", - " Composite composite = m_toolkit.createComposite(parent, SWT.NONE);", - " }", - " protected void registerPages(DetailsPart part) {", - " }", - " protected void createToolBarActions(IManagedForm managedForm) {", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.MasterDetailsBlock} {this} {}", - " {parameter} {parent} {/m_toolkit.createComposite(parent, SWT.NONE)/}", - " {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/m_toolkit.createComposite(parent, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {toolkitAccess: m_toolkit} {toolkitAccess} {/m_toolkit.createComposite(parent, SWT.NONE)/ /managedForm.getToolkit()/}"); + MasterDetailsBlockInfo page = parseJavaInfo(""" + public abstract class Test extends MasterDetailsBlock { + private FormToolkit m_toolkit; + public Test() { + } + protected void createMasterPart(IManagedForm managedForm, Composite parent) { + m_toolkit = managedForm.getToolkit(); + Composite composite = m_toolkit.createComposite(parent, SWT.NONE); + } + protected void registerPages(DetailsPart part) { + } + protected void createToolBarActions(IManagedForm managedForm) { + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.MasterDetailsBlock} {this} {} + {parameter} {parent} {/m_toolkit.createComposite(parent, SWT.NONE)/} + {instance factory: {toolkitAccess} createComposite(org.eclipse.swt.widgets.Composite,int)} {local-unique: composite} {/m_toolkit.createComposite(parent, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {toolkitAccess: m_toolkit} {toolkitAccess} {/m_toolkit.createComposite(parent, SWT.NONE)/ /managedForm.getToolkit()/}"""); // refresh page.refresh(); assertNoErrors(page); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ScrolledFormTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ScrolledFormTest.java index 6bed771160..a7a4396bf0 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ScrolledFormTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/ScrolledFormTest.java @@ -43,14 +43,13 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_0() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " ScrolledForm form = new ScrolledForm(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + ScrolledForm form = new ScrolledForm(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + } + }"""); shell.refresh(); ScrolledFormInfo form = (ScrolledFormInfo) shell.getChildrenControls().get(0); // we use constructor with style, so we have "Style" property diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionPartTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionPartTest.java index ac00bb1dbe..bb9742dfde 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionPartTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionPartTest.java @@ -44,26 +44,25 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_withFormToolkit() throws Exception { - SectionPartInfo part = - parseJavaInfo( - "public class Test extends SectionPart {", - " public Test(Composite parent, FormToolkit toolkit, int style) {", - " super(parent, toolkit, style);", - " createClient(getSection(), toolkit);", - " }", - " private void createClient(Section section, FormToolkit toolkit) {", - " section.setText('New SectionPart');", - " Composite container = toolkit.createComposite(section);", - " section.setClient(container);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.SectionPart} {this} {}", - " {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /section.setText('New SectionPart')/ /toolkit.createComposite(section)/ /section.setClient(container)/}", - " {instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {parameter} {toolkit} {/toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"); + SectionPartInfo part = parseJavaInfo(""" + public class Test extends SectionPart { + public Test(Composite parent, FormToolkit toolkit, int style) { + super(parent, toolkit, style); + createClient(getSection(), toolkit); + } + private void createClient(Section section, FormToolkit toolkit) { + section.setText("New SectionPart"); + Composite container = toolkit.createComposite(section); + section.setClient(container); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.SectionPart} {this} {} + {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /section.setText("New SectionPart")/ /toolkit.createComposite(section)/ /section.setClient(container)/} + {instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {parameter} {toolkit} {/toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"""); SectionInfo section = part.getSection(); // refresh part.refresh(); @@ -79,25 +78,24 @@ public void test_withFormToolkit() throws Exception { */ @Test public void test_additionalConstructorParameter() throws Exception { - SectionPartInfo part = - parseJavaInfo( - "public class Test extends SectionPart {", - " public Test(Composite parent, FormToolkit toolkit, int style, int foo) {", - " super(parent, toolkit, style);", - " createClient(getSection(), toolkit);", - " }", - " private void createClient(Section section, FormToolkit toolkit) {", - " Composite container = toolkit.createComposite(section);", - " section.setClient(container);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.SectionPart} {this} {}", - " {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /toolkit.createComposite(section)/ /section.setClient(container)/}", - " {instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {parameter} {toolkit} {/toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"); + SectionPartInfo part = parseJavaInfo(""" + public class Test extends SectionPart { + public Test(Composite parent, FormToolkit toolkit, int style, int foo) { + super(parent, toolkit, style); + createClient(getSection(), toolkit); + } + private void createClient(Section section, FormToolkit toolkit) { + Composite container = toolkit.createComposite(section); + section.setClient(container); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.SectionPart} {this} {} + {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /toolkit.createComposite(section)/ /section.setClient(container)/} + {instance factory: {toolkit} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {parameter} {toolkit} {/toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"""); // refresh part.refresh(); assertNoErrors(part); @@ -108,13 +106,12 @@ public void test_additionalConstructorParameter() throws Exception { */ @Test public void test_disposing() throws Exception { - SectionPartInfo part = - parseJavaInfo( - "public class Test extends SectionPart {", - " public Test(Composite parent, FormToolkit toolkit, int style) {", - " super(parent, toolkit, style);", - " }", - "}"); + SectionPartInfo part = parseJavaInfo(""" + public class Test extends SectionPart { + public Test(Composite parent, FormToolkit toolkit, int style) { + super(parent, toolkit, style); + } + }"""); part.refresh(); assertNoErrors(part); // @@ -135,30 +132,30 @@ public void test_disposing() throws Exception { @Test public void test_withFormPage() throws Exception { - parseJavaInfo( - "public class Test extends SectionPart {", - " /**", - " * @wbp.parser.constructor", - " */", - " public Test(FormPage formPage, Composite parent) {", - " this(parent, formPage.getManagedForm().getToolkit(), Section.DESCRIPTION);", - " }", - " public Test(Composite parent, FormToolkit toolkit, int style) {", - " super(parent, toolkit, style);", - " createClient(getSection(), toolkit);", - " }", - " private void createClient(Section section, FormToolkit toolkit) {", - " Composite container = toolkit.createComposite(section);", - " section.setClient(container);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.ui.forms.SectionPart} {this} {}", - " {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /toolkit.createComposite(section)/ /section.setClient(container)/}", - " {instance factory: {empty} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {instance factory container}", - " {opaque} {empty} {/formPage.getManagedForm().getToolkit()/ /toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"); + parseJavaInfo(""" + public class Test extends SectionPart { + /** + * @wbp.parser.constructor + */ + public Test(FormPage formPage, Composite parent) { + this(parent, formPage.getManagedForm().getToolkit(), Section.DESCRIPTION); + } + public Test(Composite parent, FormToolkit toolkit, int style) { + super(parent, toolkit, style); + createClient(getSection(), toolkit); + } + private void createClient(Section section, FormToolkit toolkit) { + Composite container = toolkit.createComposite(section); + section.setClient(container); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.ui.forms.SectionPart} {this} {} + {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {/createClient(getSection(), toolkit)/ /toolkit.createComposite(section)/ /section.setClient(container)/} + {instance factory: {empty} createComposite(org.eclipse.swt.widgets.Composite)} {local-unique: container} {/toolkit.createComposite(section)/ /section.setClient(container)/} + {implicit-layout: absolute} {implicit-layout} {} + {instance factory container} + {opaque} {empty} {/formPage.getManagedForm().getToolkit()/ /toolkit.createComposite(section)/ /createClient(getSection(), toolkit)/}"""); } //////////////////////////////////////////////////////////////////////////// @@ -168,32 +165,29 @@ public void test_withFormPage() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_useSectionPart() throws Exception { - setFileContentSrc( - "test/MySectionPart.java", - getTestSource( - "public class MySectionPart extends SectionPart {", - " public MySectionPart(Composite parent, FormToolkit toolkit, int style) {", - " super(parent, toolkit, style);", - " }", - "}")); + setFileContentSrc("test/MySectionPart.java", getTestSource(""" + public class MySectionPart extends SectionPart { + public MySectionPart(Composite parent, FormToolkit toolkit, int style) { + super(parent, toolkit, style); + } + }""")); waitForAutoBuild(); // parse - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault());", - " public Test() {", - " setLayout(new FillLayout());", - " MySectionPart part = new MySectionPart(this, m_toolkit, Section.TITLE_BAR);", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}", - " {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {}", - " {new: test.MySectionPart} {local-unique: part} {/new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit m_toolkit = new FormToolkit(Display.getDefault()); + public Test() { + setLayout(new FillLayout()); + MySectionPart part = new MySectionPart(this, m_toolkit, Section.TITLE_BAR); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/} + {viewer: public org.eclipse.ui.forms.widgets.Section org.eclipse.ui.forms.SectionPart.getSection()} {viewer} {} + {new: test.MySectionPart} {local-unique: part} {/new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: m_toolkit} {/new FormToolkit(Display.getDefault())/ /new MySectionPart(this, m_toolkit, Section.TITLE_BAR)/}"""); // refresh() shell.refresh(); assertNoErrors(shell); @@ -201,13 +195,12 @@ public void test_useSectionPart() throws Exception { @Test public void test_liveImage() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + } + }"""); shell.refresh(); SectionPartInfo newSectionPart = createJavaInfo("org.eclipse.ui.forms.SectionPart"); SectionInfo newSection = (SectionInfo) newSectionPart.getWrapper().getWrappedInfo(); @@ -216,62 +209,60 @@ public void test_liveImage() throws Exception { @Test public void test_CREATE() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + } + }"""); shell.refresh(); SectionPartInfo newSectionPart = createJavaInfo("org.eclipse.ui.forms.SectionPart"); SectionInfo newSection = (SectionInfo) newSectionPart.getWrapper().getWrappedInfo(); // create shell.getLayout().command_CREATE(newSection, null); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " SectionPart sectionPart = new SectionPart(this, new FormToolkit(Display.getCurrent()), Section.TWISTIE | Section.TITLE_BAR);", - " Section section = sectionPart.getSection();", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new FillLayout()); + { + SectionPart sectionPart = new SectionPart(this, new FormToolkit(Display.getCurrent()), Section.TWISTIE | Section.TITLE_BAR); + Section section = sectionPart.getSection(); + } + } + }"""); } @Test public void test_CREATE_withToolkit() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " private final FormToolkit formToolkit = new FormToolkit(Display.getCurrent());", - " public Test() {", - " setLayout(new FillLayout());", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/}", - " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}", - " {instance factory container}", - " {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: formToolkit} {/new FormToolkit(Display.getCurrent())/}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + private final FormToolkit formToolkit = new FormToolkit(Display.getCurrent()); + public Test() { + setLayout(new FillLayout()); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/} + {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/} + {instance factory container} + {new: org.eclipse.ui.forms.widgets.FormToolkit} {field-initializer: formToolkit} {/new FormToolkit(Display.getCurrent())/}"""); shell.refresh(); // create new SectionPartInfo newSectionPart = createJavaInfo("org.eclipse.ui.forms.SectionPart"); SectionInfo newSection = (SectionInfo) newSectionPart.getWrapper().getWrappedInfo(); // create shell.getLayout().command_CREATE(newSection, null); - assertEditor( - "public class Test extends Shell {", - " private final FormToolkit formToolkit = new FormToolkit(Display.getCurrent());", - " public Test() {", - " setLayout(new FillLayout());", - " {", - " SectionPart sectionPart = new SectionPart(this, formToolkit, Section.TWISTIE | Section.TITLE_BAR);", - " Section section = sectionPart.getSection();", - " formToolkit.paintBordersFor(section);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + private final FormToolkit formToolkit = new FormToolkit(Display.getCurrent()); + public Test() { + setLayout(new FillLayout()); + { + SectionPart sectionPart = new SectionPart(this, formToolkit, Section.TWISTIE | Section.TITLE_BAR); + Section section = sectionPart.getSection(); + formToolkit.paintBordersFor(section); + } + } + }"""); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionTest.java index fb6044f383..732bdef246 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/SectionTest.java @@ -43,14 +43,13 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_properties() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Section composite = new Section(this, Section.TWISTIE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Section composite = new Section(this, Section.TWISTIE); + } + }"""); shell.refresh(); SectionInfo composite = (SectionInfo) shell.getChildrenControls().get(0); assertNotNull(composite.getPropertyByTitle("SectionStyle")); @@ -62,14 +61,13 @@ public void test_properties() throws Exception { */ @Test public void test_getDescriptionControl() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new RowLayout());", - " Section composite = new Section(this, Section.DESCRIPTION);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new RowLayout()); + Section composite = new Section(this, Section.DESCRIPTION); + } + }"""); shell.refresh(); SectionInfo composite = (SectionInfo) shell.getChildrenControls().get(0); // no any children expected - only possible child is exposed using getDescriptionControl() @@ -88,13 +86,12 @@ public void test_getDescriptionControl() throws Exception { */ @Test public void test_zeroSize_absoluteLayout() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " Section section = new Section(this, Section.TITLE_BAR);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + Section section = new Section(this, Section.TITLE_BAR); + } + }"""); shell.refresh(); assertNoErrors(shell); } @@ -106,22 +103,21 @@ public void test_zeroSize_absoluteLayout() throws Exception { */ @Test public void test_zeroSize_GridLayout() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new GridLayout(1, false));", - " setSize(450, 300);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new GridData(100, 500));", - " }", - " {", - " Section section = new Section(this, Section.TITLE_BAR);", - " section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new GridLayout(1, false)); + setSize(450, 300); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new GridData(100, 500)); + } + { + Section section = new Section(this, Section.TITLE_BAR); + section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } + } + }"""); shell.refresh(); assertNoErrors(shell); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TabelWrapLayoutParametersTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TabelWrapLayoutParametersTest.java index 241a02cb3a..106c682935 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TabelWrapLayoutParametersTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TabelWrapLayoutParametersTest.java @@ -54,34 +54,33 @@ public void _test_exit() throws Exception { */ @Test public void test_CREATE_Text() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); ControlInfo newText = BTestUtils.createControl("org.eclipse.swt.widgets.Text"); layout.command_CREATE(newText, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Text text = new Text(this, SWT.BORDER);", - " text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Text text = new Text(this, SWT.BORDER); + text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); + } + } + }"""); } /** @@ -89,16 +88,15 @@ public void test_CREATE_Text() throws Exception { */ @Test public void test_CREATE_Text_disabled() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); shell.refresh(); // @@ -108,18 +106,18 @@ public void test_CREATE_Text_disabled() throws Exception { preferences.setValue(IPreferenceConstants.P_ENABLE_GRAB, false); ControlInfo newText = BTestUtils.createControl("org.eclipse.swt.widgets.Text"); layout.command_CREATE(newText, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Text text = new Text(this, SWT.BORDER);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Text text = new Text(this, SWT.BORDER); + } + } + }"""); } finally { preferences.restore(); } @@ -130,36 +128,35 @@ public void test_CREATE_Text_disabled() throws Exception { */ @Test public void test_CREATE_Table() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); ControlInfo newTable = BTestUtils.createControl("org.eclipse.swt.widgets.Table"); layout.command_CREATE(newTable, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Table table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);", - " table.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));", - " table.setHeaderVisible(true);", - " table.setLinesVisible(true);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Table table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION); + table.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + } + } + }"""); } /** @@ -168,44 +165,43 @@ public void test_CREATE_Table() throws Exception { */ @Test public void test_CREATE_LabelBeforeText() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Text text = new Text(this, SWT.BORDER);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Text text = new Text(this, SWT.BORDER); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); ControlInfo newLabel = BTestUtils.createControl("org.eclipse.swt.widgets.Label"); layout.command_CREATE(newLabel, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));", - " label.setText('New Label');", - " }", - " {", - " Text text = new Text(this, SWT.BORDER);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); + label.setText("New Label"); + } + { + Text text = new Text(this, SWT.BORDER); + } + } + }"""); } /** @@ -213,21 +209,20 @@ public void test_CREATE_LabelBeforeText() throws Exception { */ @Test public void test_CREATE_LabelBeforeText_disabled() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Text text = new Text(this, SWT.BORDER);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Text text = new Text(this, SWT.BORDER); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -237,23 +232,23 @@ public void test_CREATE_LabelBeforeText_disabled() throws Exception { preferences.setValue(IPreferenceConstants.P_ENABLE_RIGHT_ALIGNMENT, false); ControlInfo newLabel = BTestUtils.createControl("org.eclipse.swt.widgets.Label"); layout.command_CREATE(newLabel, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " label.setText('New Label');", - " }", - " {", - " Text text = new Text(this, SWT.BORDER);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + label.setText("New Label"); + } + { + Text text = new Text(this, SWT.BORDER); + } + } + }"""); } finally { preferences.restore(); } @@ -265,43 +260,42 @@ public void test_CREATE_LabelBeforeText_disabled() throws Exception { */ @Test public void test_CREATE_TextAfterLabel() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + new Label(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); ControlInfo newText = BTestUtils.createControl("org.eclipse.swt.widgets.Text"); layout.command_CREATE(newText, 1, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));", - " }", - " {", - " Text text = new Text(this, SWT.BORDER);", - " text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); + } + { + Text text = new Text(this, SWT.BORDER); + text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); + } + } + }"""); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapDataTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapDataTest.java index a54afcc266..008fa8fc6c 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapDataTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapDataTest.java @@ -52,16 +52,15 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_getSmallAlignmentImage() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); // @@ -118,20 +117,19 @@ private static void check_getSmallAlignmentImage(TableWrapDataInfo layoutData, */ @Test public void test_horizontalAlignment_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -142,54 +140,54 @@ public void test_horizontalAlignment_1() throws Exception { // set CENTER tableWrapData.setHorizontalAlignment(TableWrapData.CENTER); assertEquals(TableWrapData.CENTER, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.CENTER, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.CENTER, TableWrapData.TOP)); + } + } + }"""); // set RIGHT tableWrapData.setHorizontalAlignment(TableWrapData.RIGHT); assertEquals(TableWrapData.RIGHT, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP)); + } + } + }"""); // set FILL tableWrapData.setHorizontalAlignment(TableWrapData.FILL); assertEquals(TableWrapData.FILL, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP)); + } + } + }"""); // set LEFT tableWrapData.setHorizontalAlignment(TableWrapData.LEFT); assertEquals(TableWrapData.LEFT, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -197,21 +195,20 @@ public void test_horizontalAlignment_1() throws Exception { */ @Test public void test_horizontalAlignment_2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.align = TableWrapData.LEFT;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.align = TableWrapData.LEFT; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -222,66 +219,66 @@ public void test_horizontalAlignment_2() throws Exception { // set CENTER tableWrapData.setHorizontalAlignment(TableWrapData.CENTER); assertEquals(TableWrapData.CENTER, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.align = TableWrapData.CENTER;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.align = TableWrapData.CENTER; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set RIGHT tableWrapData.setHorizontalAlignment(TableWrapData.RIGHT); assertEquals(TableWrapData.RIGHT, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.align = TableWrapData.RIGHT;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.align = TableWrapData.RIGHT; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set FILL tableWrapData.setHorizontalAlignment(TableWrapData.FILL); assertEquals(TableWrapData.FILL, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.align = TableWrapData.FILL;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.align = TableWrapData.FILL; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set LEFT tableWrapData.setHorizontalAlignment(TableWrapData.LEFT); assertEquals(TableWrapData.LEFT, tableWrapData.getHorizontalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -289,16 +286,15 @@ public void test_horizontalAlignment_2() throws Exception { */ @Test public void test_horizontalGrab() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -308,32 +304,32 @@ public void test_horizontalGrab() throws Exception { // grab := true tableWrapData.setHorizontalGrab(true); assertTrue(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // grab := false tableWrapData.setHorizontalGrab(false); assertFalse(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -343,20 +339,19 @@ public void test_horizontalGrab() throws Exception { */ @Test public void test_horizontalFillGrab_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -368,30 +363,30 @@ public void test_horizontalFillGrab_1() throws Exception { tableWrapData.setHorizontalGrab(true); assertEquals(TableWrapData.FILL, tableWrapData.getHorizontalAlignment()); assertTrue(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP)); + } + } + }"""); // grab := false tableWrapData.setHorizontalGrab(false); assertEquals(TableWrapData.FILL, tableWrapData.getHorizontalAlignment()); assertFalse(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP)); + } + } + }"""); } /** @@ -403,21 +398,20 @@ public void test_horizontalFillGrab_1() throws Exception { */ @Test public void test_horizontalFillGrab_2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -429,34 +423,34 @@ public void test_horizontalFillGrab_2() throws Exception { ExecutionUtils.run(shell, () -> tableWrapData.setHorizontalAlignment(TableWrapData.FILL)); assertEquals(TableWrapData.FILL, tableWrapData.getHorizontalAlignment()); assertTrue(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP)); + } + } + }"""); // alignment := LEFT ExecutionUtils.run(shell, () -> tableWrapData.setHorizontalAlignment(TableWrapData.LEFT)); assertEquals(TableWrapData.LEFT, tableWrapData.getHorizontalAlignment()); assertTrue(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } /** @@ -466,20 +460,19 @@ public void test_horizontalFillGrab_2() throws Exception { */ @Test public void test_horizontalFillGrab_3() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -491,20 +484,20 @@ public void test_horizontalFillGrab_3() throws Exception { tableWrapData.setHorizontalGrab(true); assertEquals(TableWrapData.LEFT, tableWrapData.getHorizontalAlignment()); assertTrue(tableWrapData.getHorizontalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } /** @@ -512,24 +505,23 @@ public void test_horizontalFillGrab_3() throws Exception { */ @Test public void test_horizontalSpan_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -539,35 +531,35 @@ public void test_horizontalSpan_1() throws Exception { // horizontalSpan := 2 tableWrapData.setHorizontalSpan(2); assertEquals(2, tableWrapData.getHorizontalSpan()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2)); + } + } + }"""); // horizontalSpan := default tableWrapData.getPropertyByTitle("colspan").setValue(Property.UNKNOWN_VALUE); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); { tableWrapData = layout.getTableWrapData(button); assertEquals(1, tableWrapData.getHorizontalSpan()); @@ -584,20 +576,19 @@ public void test_horizontalSpan_1() throws Exception { */ @Test public void test_verticalAlignment_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -608,54 +599,54 @@ public void test_verticalAlignment_1() throws Exception { // set MIDDLE tableWrapData.setVerticalAlignment(TableWrapData.MIDDLE); assertEquals(TableWrapData.MIDDLE, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE)); + } + } + }"""); // set BOTTOM tableWrapData.setVerticalAlignment(TableWrapData.BOTTOM); assertEquals(TableWrapData.BOTTOM, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM)); + } + } + }"""); // set FILL tableWrapData.setVerticalAlignment(TableWrapData.FILL); assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL)); + } + } + }"""); // set TOP tableWrapData.setVerticalAlignment(TableWrapData.TOP); assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -663,21 +654,20 @@ public void test_verticalAlignment_1() throws Exception { */ @Test public void test_verticalAlignment_2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.valign = TableWrapData.TOP;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.valign = TableWrapData.TOP; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -688,66 +678,66 @@ public void test_verticalAlignment_2() throws Exception { // set MIDDLE tableWrapData.setVerticalAlignment(TableWrapData.MIDDLE); assertEquals(TableWrapData.MIDDLE, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.valign = TableWrapData.MIDDLE;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.valign = TableWrapData.MIDDLE; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set BOTTOM tableWrapData.setVerticalAlignment(TableWrapData.BOTTOM); assertEquals(TableWrapData.BOTTOM, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.valign = TableWrapData.BOTTOM;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.valign = TableWrapData.BOTTOM; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set FILL tableWrapData.setVerticalAlignment(TableWrapData.FILL); assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.valign = TableWrapData.FILL;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.valign = TableWrapData.FILL; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // set TOP tableWrapData.setVerticalAlignment(TableWrapData.TOP); assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -755,21 +745,20 @@ public void test_verticalAlignment_2() throws Exception { */ @Test public void test_verticalAlignment_3() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -781,20 +770,20 @@ public void test_verticalAlignment_3() throws Exception { tableWrapData.setVerticalAlignment(TableWrapData.MIDDLE); assertEquals(TableWrapData.MIDDLE, tableWrapData.getVerticalAlignment()); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } /** @@ -802,16 +791,15 @@ public void test_verticalAlignment_3() throws Exception { */ @Test public void test_verticalGrab() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -821,32 +809,32 @@ public void test_verticalGrab() throws Exception { // grab := true tableWrapData.setVerticalGrab(true); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); // grab := false tableWrapData.setVerticalGrab(false); assertFalse(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } /** @@ -856,17 +844,16 @@ public void test_verticalGrab() throws Exception { */ @Test public void test_verticalFillGrab_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL)); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -878,30 +865,30 @@ public void test_verticalFillGrab_1() throws Exception { tableWrapData.setVerticalGrab(true); assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment()); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB)); + } + } + }"""); // grab := false tableWrapData.setVerticalGrab(false); assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment()); assertFalse(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL)); + } + } + }"""); } /** @@ -912,21 +899,20 @@ public void test_verticalFillGrab_1() throws Exception { */ @Test public void test_verticalFillGrab_2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -938,34 +924,34 @@ public void test_verticalFillGrab_2() throws Exception { ExecutionUtils.run(shell, () -> tableWrapData.setVerticalAlignment(TableWrapData.FILL)); assertEquals(TableWrapData.FILL, tableWrapData.getVerticalAlignment()); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB)); + } + } + }"""); // alignment := TOP ExecutionUtils.run(shell, () -> tableWrapData.setVerticalAlignment(TableWrapData.TOP)); assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment()); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } /** @@ -975,20 +961,19 @@ public void test_verticalFillGrab_2() throws Exception { */ @Test public void test_verticalFillGrab_3() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -1000,20 +985,20 @@ public void test_verticalFillGrab_3() throws Exception { tableWrapData.setVerticalGrab(true); assertEquals(TableWrapData.TOP, tableWrapData.getVerticalAlignment()); assertTrue(tableWrapData.getVerticalGrab()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } /** @@ -1021,23 +1006,22 @@ public void test_verticalFillGrab_3() throws Exception { */ @Test public void test_verticalSpan_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1));", - " }", - " new Button(this, SWT.NONE);", - " new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1)); + } + new Button(this, SWT.NONE); + new Button(this, SWT.NONE); + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); @@ -1047,39 +1031,39 @@ public void test_verticalSpan_1() throws Exception { // verticalSpan := 2 tableWrapData.setVerticalSpan(2); assertEquals(2, tableWrapData.getVerticalSpan()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1));", - " }", - " new Button(this, SWT.NONE);", - " new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1)); + } + new Button(this, SWT.NONE); + new Button(this, SWT.NONE); + } + }"""); // verticalSpan := default tableWrapData.getPropertyByTitle("rowspan").setValue(Property.UNKNOWN_VALUE); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " new Button(this, SWT.NONE);", - " new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + } + new Button(this, SWT.NONE); + new Button(this, SWT.NONE); + } + }"""); { tableWrapData = layout.getTableWrapData(button); assertEquals(1, tableWrapData.getVerticalSpan()); @@ -1093,16 +1077,15 @@ public void test_verticalSpan_1() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_contextMenu_horizontal() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); // @@ -1131,50 +1114,49 @@ public void test_contextMenu_horizontal() throws Exception { IAction action = findChildAction(manager2, "&Right"); action.setChecked(true); action.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1)); + } + } + }"""); } // use "Grab action" { IAction action = findChildAction(manager2, "&Grab excess space"); action.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } } @Test public void test_contextMenu_vertical() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); ControlInfo button = shell.getChildrenControls().get(0); // TableWrapDataInfo layoutData = (TableWrapDataInfo) button.getChildrenJava().get(0); @@ -1201,35 +1183,35 @@ public void test_contextMenu_vertical() throws Exception { IAction action = findChildAction(manager2, "&Bottom"); action.setChecked(true); action.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1)); + } + } + }"""); } // use "Grab action" { IAction action = findChildAction(manager2, "&Grab excess space"); action.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } } finally { shell.refresh_dispose(); @@ -1243,194 +1225,187 @@ public void test_contextMenu_vertical() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_deleteIfDefault_constructor0() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData());", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData()); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor1_yes() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor1_no() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT)); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor2_yes() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor2_no() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM)); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor4_yes() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } @Test public void test_deleteIfDefault_constructor4_no() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1));", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1)); + } + } + }"""); shell.refresh(); // refresh(), force check ExecutionUtils.refresh(shell); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1)); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -1443,18 +1418,17 @@ public void test_deleteIfDefault_constructor4_no() throws Exception { */ @Test public void test_hasParentLayout_notCompatible() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " public Test() {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData());", - " }", - "}"); - assertHierarchy( - "{this: org.eclipse.swt.widgets.Shell} {this} {/new Button(this, SWT.NONE)/}", - " {implicit-layout: absolute} {implicit-layout} {}", - " {new: org.eclipse.swt.widgets.Button} {local-unique: button} {/new Button(this, SWT.NONE)/ /button.setLayoutData(new TableWrapData())/}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + public Test() { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData()); + } + }"""); + assertHierarchy(""" + {this: org.eclipse.swt.widgets.Shell} {this} {/new Button(this, SWT.NONE)/} + {implicit-layout: absolute} {implicit-layout} {} + {new: org.eclipse.swt.widgets.Button} {local-unique: button} {/new Button(this, SWT.NONE)/ /button.setLayoutData(new TableWrapData())/}"""); // shell.refresh(); assertNoErrors(shell); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutClipboardTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutClipboardTest.java index d64df7bd9d..bf49397562 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutClipboardTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutClipboardTest.java @@ -42,24 +42,23 @@ public void _test_exit() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_simpleSingleControl() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new RowLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.topMargin = 20;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new RowLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = 20; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); shell.refresh(); RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout(); // prepare memento @@ -72,65 +71,64 @@ public void test_simpleSingleControl() throws Exception { CompositeInfo newComposite = (CompositeInfo) memento.create(shell); rowLayout.command_CREATE(newComposite, null); memento.apply(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new RowLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.topMargin = 20;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.topMargin = 20;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new RowLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = 20; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + } + } + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = 20; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); } @Test public void test_grid2x2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new RowLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " new Label(composite, SWT.NONE);", - " new Label(composite, SWT.NONE);", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new RowLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); shell.refresh(); RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout(); // prepare memento @@ -143,45 +141,45 @@ public void test_grid2x2() throws Exception { CompositeInfo newComposite = (CompositeInfo) memento.create(shell); rowLayout.command_CREATE(newComposite, null); memento.apply(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new RowLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));", - " }", - " new Label(composite, SWT.NONE);", - " new Label(composite, SWT.NONE);", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " composite.setLayout(layout);", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));", - " }", - " new Label(composite, SWT.NONE);", - " new Label(composite, SWT.NONE);", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new RowLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP)); + } + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + { + Button button = new Button(composite, SWT.NONE); + } + } + { + Composite composite = new Composite(this, SWT.NONE); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + composite.setLayout(layout); + } + { + Button button = new Button(composite, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP)); + } + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutExposedTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutExposedTest.java index b61dbdac52..0f81c0f396 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutExposedTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutExposedTest.java @@ -53,13 +53,12 @@ public void _test_exit() throws Exception { public void test_deleteExposedComponent_noExplicitData() throws Exception { configureForDelete(); // parse - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + } + }"""); shell.refresh(); CompositeInfo myComposite = (CompositeInfo) shell.getChildrenControls().get(0); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) myComposite.getLayout(); @@ -76,12 +75,12 @@ public void test_deleteExposedComponent_noExplicitData() throws Exception { // delete, no visible change expected assertTrue(button.canDelete()); button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + } + }"""); assertFalse(button.isDeleted()); // check new TableWrapData { @@ -99,14 +98,13 @@ public void test_deleteExposedComponent_noExplicitData() throws Exception { public void test_deleteExposedComponent_withExplicitData() throws Exception { configureForDelete(); // parse - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " myComposite.getButton().setLayoutData(new TableWrapData());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + myComposite.getButton().setLayoutData(new TableWrapData()); + } + }"""); shell.refresh(); CompositeInfo myComposite = (CompositeInfo) shell.getChildrenControls().get(0); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) myComposite.getLayout(); @@ -123,12 +121,12 @@ public void test_deleteExposedComponent_withExplicitData() throws Exception { // delete, "explicit" TableWrapData is gone assertTrue(button.canDelete()); button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + } + }"""); assertTrue(myComposite.getChildren().contains(button)); // check new TableWrapData { @@ -144,50 +142,46 @@ public void test_deleteExposedComponent_withExplicitData() throws Exception { */ @Test public void test_deleteWhenTwoExposed() throws Exception { - createASTCompilationUnit( - "test", - "MyComposite.java", - getTestSource( - "public class MyComposite extends Composite {", - " private Button m_button;", - " private Text m_text;", - " public MyComposite(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " m_button = new Button(this, SWT.NONE);", - " m_text = new Text(this, SWT.NONE);", - " }", - " public Button getButton() {", - " return m_button;", - " }", - " public Text getText() {", - " return m_text;", - " }", - "}")); + createASTCompilationUnit("test", "MyComposite.java", getTestSource(""" + public class MyComposite extends Composite { + private Button m_button; + private Text m_text; + public MyComposite(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + m_button = new Button(this, SWT.NONE); + m_text = new Text(this, SWT.NONE); + } + public Button getButton() { + return m_button; + } + public Text getText() { + return m_text; + } + }""")); waitForAutoBuild(); // parse - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + } + }"""); shell.refresh(); CompositeInfo myComposite = (CompositeInfo) shell.getChildrenControls().get(0); ControlInfo button = myComposite.getChildrenControls().get(0); // do operations { button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " MyComposite myComposite = new MyComposite(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + MyComposite myComposite = new MyComposite(this, SWT.NONE); + } + }"""); } } @@ -195,26 +189,23 @@ public void test_deleteWhenTwoExposed() throws Exception { * Configures project for delete tests. */ private void configureForDelete() throws Exception { - createASTCompilationUnit( - "test", - "MyComposite.java", - getTestSource( - "public class MyComposite extends Composite {", - " private Button m_button;", - " public MyComposite(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " m_button = new Button(this, SWT.NONE);", - " m_button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE));", - " }", - " public Button getButton() {", - " return m_button;", - " }", - "}")); + createASTCompilationUnit("test", "MyComposite.java", getTestSource(""" + public class MyComposite extends Composite { + private Button m_button; + public MyComposite(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + m_button = new Button(this, SWT.NONE); + m_button.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE)); + } + public Button getButton() { + return m_button; + } + }""")); waitForAutoBuild(); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutGefTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutGefTest.java index b11d1effae..2e80bf94d2 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutGefTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutGefTest.java @@ -58,25 +58,24 @@ public void _test_exit() throws Exception { */ @Test public void test_deleteChildAndAncestorResize() throws Exception { - CompositeInfo shell = - openComposite( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new TableWrapLayout());", - " {", - " Label label = new Label(composite, SWT.NONE);", - " label.setText('Label');", - " }", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setText('Button');", - " }", - " }", - " }", - "}"); + CompositeInfo shell = openComposite(""" + public class Test extends Shell { + public Test() { + setLayout(new TableWrapLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new TableWrapLayout()); + { + Label label = new Label(composite, SWT.NONE); + label.setText("Label"); + } + { + Button button = new Button(composite, SWT.NONE); + button.setText("Button"); + } + } + } + }"""); CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(0); ControlInfo button = composite.getChildrenControls().get(1); // select "button" @@ -87,20 +86,20 @@ public void test_deleteChildAndAncestorResize() throws Exception { IAction deleteAction = getDeleteAction(); assertTrue(deleteAction.isEnabled()); deleteAction.run(); - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new TableWrapLayout());", - " {", - " Label label = new Label(composite, SWT.NONE);", - " label.setText('Label');", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(new TableWrapLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new TableWrapLayout()); + { + Label label = new Label(composite, SWT.NONE); + label.setText("Label"); + } + } + } + }"""); } } @@ -111,25 +110,24 @@ public void test_deleteChildAndAncestorResize() throws Exception { @Test public void test_replaceGridLayout_withAbsolute() throws Exception { prepareComponent(); - CompositeInfo shell = - openComposite( - "public class Test extends Shell {", - " public Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = openComposite(""" + public class Test extends Shell { + public Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button_1 = new Button(this, SWT.NONE); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button_2 = new Button(this, SWT.NONE); + } + } + }"""); // select "shell", so show headers canvas.select(shell); waitEventLoop(0); @@ -142,20 +140,20 @@ public void test_replaceGridLayout_withAbsolute() throws Exception { waitEventLoop(0); } // validate - assertEditor( - "public class Test extends Shell {", - " public Test() {", - " setLayout(null);", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setBounds(5, 5, 100, 50);", - " }", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " button_2.setBounds(110, 60, 100, 50);", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Shell { + public Test() { + setLayout(null); + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setBounds(5, 5, 100, 50); + } + { + Button button_2 = new Button(this, SWT.NONE); + button_2.setBounds(110, 60, 100, 50); + } + } + }"""); } /** @@ -164,18 +162,17 @@ public void test_replaceGridLayout_withAbsolute() throws Exception { */ @Test public void test_change_numColumns() throws Exception { - CompositeInfo shell = - openComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " Button button_00 = new Button(this, SWT.NONE);", - " Button button_01 = new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = openComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + Button button_00 = new Button(this, SWT.NONE); + Button button_01 = new Button(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // select "shell", so show headers canvas.select(shell); @@ -188,18 +185,18 @@ public void test_change_numColumns() throws Exception { assertNoLoggedExceptions(); assertEquals(2, layout.getColumns().size()); assertEquals(1, layout.getRows().size()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " Button button_00 = new Button(this, SWT.NONE);", - " Button button_01 = new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + Button button_00 = new Button(this, SWT.NONE); + Button button_01 = new Button(this, SWT.NONE); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -209,37 +206,36 @@ public void test_change_numColumns() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_setSizeHint_height() throws Exception { - CompositeInfo shell = - openComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + CompositeInfo shell = openComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); ControlInfo button = shell.getChildrenControls().get(0); // resize SOUTH of "button" canvas.toResizeHandle(button, "resize_size", PositionConstants.SOUTH).beginDrag(); canvas.target(button).in(0, 50).drag(); canvas.endDrag(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData twd_button = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " twd_button.heightHint = 50;", - " button.setLayoutData(twd_button);", - " }", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData twd_button = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + twd_button.heightHint = 50; + button.setLayoutData(twd_button); + } + button.setText("New Button"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -249,18 +245,17 @@ public void test_setSizeHint_height() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_CREATE_filled() throws Exception { - CompositeInfo composite = - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + CompositeInfo composite = openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); // loadButtonWithText(); canvas.moveTo(composite, M, M); @@ -269,312 +264,310 @@ public void test_CREATE_filled() throws Exception { @Test public void test_CREATE_virtual_0x0() throws Exception { - CompositeInfo composite = - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " }", - "}"); + CompositeInfo composite = openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + } + }"""); // loadButtonWithText(); canvas.moveTo(composite, M, M); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } @Test public void test_CREATE_virtual_0x1() throws Exception { - CompositeInfo composite = - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo composite = openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); // loadButtonWithText(); canvas.moveTo(composite, M + VS + VG, M); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } @Test public void test_CREATE_appendToColumn_1x0() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); JavaInfo existingButton = getJavaInfoByName("existingButton"); // loadButtonWithText(); canvas.target(existingButton).inX(0.5).outY(S + 1).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } @Test public void test_CREATE_appendToRow_0x1() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); JavaInfo existingButton = getJavaInfoByName("existingButton"); // loadButtonWithText(); canvas.target(existingButton).inY(0.5).outX(S + 1).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } @Test public void test_CREATE_beforeFirstRow() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); JavaInfo existingButton = getJavaInfoByName("existingButton"); // loadButtonWithText(); canvas.target(existingButton).inX(0.5).outY(-2).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); } @Test public void test_CREATE_beforeFirstColumn() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); JavaInfo existingButton = getJavaInfoByName("existingButton"); // loadButtonWithText(); canvas.target(existingButton).inY(0.5).outX(-2).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('Existing Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("Existing Button"); + } + } + }"""); } @Test public void test_CREATE_insertColumn() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setText('Button 1');", - " }", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " button_2.setText('Button 2');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setText("Button 1"); + } + { + Button button_2 = new Button(this, SWT.NONE); + button_2.setText("Button 2"); + } + } + }"""); JavaInfo button_1 = getJavaInfoByName("button_1"); // loadButtonWithText(); canvas.target(button_1).inY(0.5).outX(S / 2).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setText('Button 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " button_2.setText('Button 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setText("Button 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button button_2 = new Button(this, SWT.NONE); + button_2.setText("Button 2"); + } + } + }"""); } @Test public void test_CREATE_insertRow() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setText('Button 1');", - " }", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " button_2.setText('Button 2');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setText("Button 1"); + } + { + Button button_2 = new Button(this, SWT.NONE); + button_2.setText("Button 2"); + } + } + }"""); JavaInfo button_1 = getJavaInfoByName("button_1"); // loadButtonWithText(); canvas.target(button_1).inX(0.5).outY(S / 2).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setText('Button 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button button_2 = new Button(this, SWT.NONE);", - " button_2.setText('Button 2');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setText("Button 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button button_2 = new Button(this, SWT.NONE); + button_2.setText("Button 2"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -584,37 +577,37 @@ public void test_CREATE_insertRow() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_PASTE_virtual_1x0() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('My Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("My Button"); + } + } + }"""); JavaInfo existingButton = getJavaInfoByName("existingButton"); // doCopyPaste(existingButton); canvas.target(existingButton).inX(0.5).outY(S + 1).move(); canvas.click(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('My Button');", - " }", - " {", - " Button existingButton = new Button(this, SWT.NONE);", - " existingButton.setText('My Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("My Button"); + } + { + Button existingButton = new Button(this, SWT.NONE); + existingButton.setText("My Button"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -624,73 +617,73 @@ public void test_PASTE_virtual_1x0() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_MOVE_virtual_1x0() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('Existing Button');", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setText("Existing Button"); + } + } + }"""); JavaInfo button = getJavaInfoByName("button"); // canvas.beginDrag(button); canvas.target(button).inX(0.5).outY(S + 1).drag(); canvas.endDrag(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new TableWrapLayout());", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('Existing Button');", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new TableWrapLayout()); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("Existing Button"); + } + } + }"""); } @Test public void test_ADD_virtual_0x0() throws Exception { - openComposite( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new FillLayout());", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('Existing Button');", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new TableWrapLayout());", - " }", - " }", - "}"); + openComposite(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new FillLayout()); + { + Button button = new Button(this, SWT.NONE); + button.setText("Existing Button"); + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new TableWrapLayout()); + } + } + }"""); JavaInfo button = getJavaInfoByName("button"); JavaInfo composite = getJavaInfoByName("composite"); // canvas.beginDrag(button); canvas.dragTo(composite, M + VS / 2, M + VS / 2); canvas.endDrag(); - assertEditor( - "public class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new FillLayout());", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new TableWrapLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " button.setText('Existing Button');", - " }", - " }", - " }", - "}"); + assertEditor(""" + public class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new FillLayout()); + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new TableWrapLayout()); + { + Button button = new Button(composite, SWT.NONE); + button.setText("Existing Button"); + } + } + } + }"""); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutSelectionActionsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutSelectionActionsTest.java index 9c74745224..d3d7372b60 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutSelectionActionsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutSelectionActionsTest.java @@ -59,16 +59,15 @@ private static void hasAction(List actions, String title, boolean checke @Test public void test_selectionActions_emptySelection() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); shell.refresh(); // prepare actions List actions; @@ -83,19 +82,18 @@ public void test_selectionActions_emptySelection() throws Exception { @Test public void test_selectionActions_invalidSelection() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(0); // prepare actions @@ -111,29 +109,28 @@ public void test_selectionActions_invalidSelection() throws Exception { @Test public void test_selectionActions_state() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " label.setText(\"Label:\");", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + label.setText("Label:"); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); ControlInfo label = shell.getChildrenControls().get(0); ControlInfo button = shell.getChildrenControls().get(1); @@ -168,27 +165,26 @@ public void test_selectionActions_state() throws Exception { @Test public void test_grabAction() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(1); // prepare actions @@ -204,27 +200,27 @@ public void test_grabAction() throws Exception { assertFalse(verticalGrab.isChecked()); verticalGrab.setChecked(true); verticalGrab.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.grabVertical = true;", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.grabVertical = true; + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } // use "horizontal grab" action { @@ -232,52 +228,51 @@ public void test_grabAction() throws Exception { assertTrue(horizontalGrab.isChecked()); horizontalGrab.setChecked(false); horizontalGrab.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + } + } + }"""); } } @Test public void test_alignmentAction() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);", - " button.setLayoutData(tableWrapData);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); + button.setLayoutData(tableWrapData); + } + } + } + }"""); shell.refresh(); ControlInfo button = shell.getChildrenControls().get(1); // prepare actions @@ -292,46 +287,46 @@ public void test_alignmentAction() throws Exception { IAction rightAlignment = findAction(actions, "Right"); rightAlignment.setChecked(true); rightAlignment.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP)); + } + } + }"""); } // set "bottom" alignment { IAction bottomAction = findAction(actions, "Bottom"); bottomAction.setChecked(true); bottomAction.run(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.BOTTOM));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Label label = new Label(this, SWT.NONE); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.BOTTOM)); + } + } + }"""); } } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutTest.java index 9b9d96f23d..f3ee939154 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/forms/table/TableWrapLayoutTest.java @@ -68,13 +68,12 @@ public void _test_exit() throws Exception { */ @Test public void test_parseEmpty() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setLayout(new TableWrapLayout());", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setLayout(new TableWrapLayout()); + } + }"""); shell.refresh(); shell.refresh_dispose(); } @@ -84,21 +83,20 @@ public void test_parseEmpty() throws Exception { */ @Test public void test_excludeFillersFromPresentationChildren() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + } + new Label(this, SWT.NONE); + } + }"""); // shell.refresh(); try { @@ -127,36 +125,35 @@ public void test_excludeFillersFromPresentationChildren() throws Exception { */ @Test public void test_gridInfo() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.colspan = 2;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.colspan = 2; + button.setLayoutData(tableWrapData); + } + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button_0 = shell.getChildrenControls().get(0); ControlInfo button_1 = shell.getChildrenControls().get(3); @@ -226,19 +223,18 @@ public void test_gridInfo() throws Exception { */ @Test public void test_gridInfo2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " setSize(300, 200);", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " new Button(this, SWT.NONE);", - " new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + setSize(300, 200); + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + new Button(this, SWT.NONE); + new Button(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button_0 = shell.getChildrenControls().get(0); ControlInfo button_1 = shell.getChildrenControls().get(1); @@ -254,17 +250,16 @@ public void test_gridInfo2() throws Exception { */ @Test public void test_gridInfo_empty() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -284,27 +279,26 @@ public void test_gridInfo_empty() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_setCells_horizontalSpan() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); // @@ -320,26 +314,26 @@ public void test_setCells_horizontalSpan() throws Exception { } // set horizontal span layout.command_setCells(button, new Rectangle(0, 0, 2, 1), true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2));", - " button.setText('000');", - " }", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2)); + button.setText("000"); + } + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); // check TableWrapData { assertEquals(0, getInt(layoutData, "x")); @@ -354,80 +348,78 @@ public void test_setCells_horizontalSpan() throws Exception { @Test public void test_setCells_horizontalSpan2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2);", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2); + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); // layout.command_setCells(button, new Rectangle(0, 0, 1, 1), true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } @Test public void test_setCells_verticalSpan() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(0); // @@ -443,26 +435,26 @@ public void test_setCells_verticalSpan() throws Exception { } // set vertical span layout.command_setCells(button, new Rectangle(0, 0, 1, 2), true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1));", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1)); + button.setText("000"); + } + new Label(this, SWT.LEFT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); // check TableWrapData { assertEquals(0, getInt(layoutData, "x")); @@ -477,112 +469,110 @@ public void test_setCells_verticalSpan() throws Exception { @Test public void test_setCells_verticalSpan2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1);", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('111');", - " }", - " new Label(this, SWT.RIGHT);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1); + button.setLayoutData(tableWrapData); + } + button.setText("111"); + } + new Label(this, SWT.RIGHT); + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(1); // layout.command_setCells(button, new Rectangle(1, 1, 1, 1), true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } @Test public void test_setCells_move() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(2); // shell.refresh(); try { layout.command_setCells(button, new Rectangle(1, 0, 1, 1), true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); // check x/y for new filler { ControlInfo filler = shell.getChildrenControls().get(2); @@ -607,55 +597,54 @@ public void test_setCells_move() throws Exception { */ @Test public void test_delete_replaceWithFillers() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); ControlInfo button = shell.getChildrenControls().get(2); // shell.refresh(); try { button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -666,33 +655,32 @@ public void test_delete_replaceWithFillers() throws Exception { */ @Test public void test_delete_keepOneColumn() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); ControlInfo button = shell.getChildrenControls().get(0); // shell.refresh(); try { button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -700,29 +688,28 @@ public void test_delete_keepOneColumn() throws Exception { @Test public void test_delete_removeEmptyDimensions() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(5); // @@ -735,19 +722,19 @@ public void test_delete_removeEmptyDimensions() throws Exception { } // button.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -760,56 +747,55 @@ public void test_delete_removeEmptyDimensions() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_CREATE_inEmptyCell() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -817,58 +803,57 @@ public void test_CREATE_inEmptyCell() throws Exception { @Test public void test_CREATE_insertRow() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 1, true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -876,58 +861,57 @@ public void test_CREATE_insertRow() throws Exception { @Test public void test_CREATE_insertColumn() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, true, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " new Label(this, SWT.LEFT);", - " new Label(this, SWT.RIGHT);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + new Label(this, SWT.LEFT); + new Label(this, SWT.RIGHT); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -935,61 +919,60 @@ public void test_CREATE_insertColumn() throws Exception { @Test public void test_CREATE_insertColumnRow() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 0, true, 0, true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); // delete - should return in initial state newButton.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -997,44 +980,43 @@ public void test_CREATE_insertColumnRow() throws Exception { @Test public void test_CREATE_appendRow() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 0, false, 2, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1042,45 +1024,44 @@ public void test_CREATE_appendRow() throws Exception { @Test public void test_CREATE_appendColumn() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 2, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1088,46 +1069,45 @@ public void test_CREATE_appendColumn() throws Exception { @Test public void test_CREATE_appendColumnRow() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 1, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1135,66 +1115,65 @@ public void test_CREATE_appendColumnRow() throws Exception { @Test public void test_CREATE_insertColumnHorizontalSpan() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2);", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 2); + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, true, 1, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 3));", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 3)); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1202,66 +1181,65 @@ public void test_CREATE_insertColumnHorizontalSpan() throws Exception { @Test public void test_CREATE_insertRowVerticalSpan() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1);", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1); + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 1, true); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 3, 1));", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 3, 1)); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1273,42 +1251,41 @@ public void test_CREATE_insertRowVerticalSpan() throws Exception { */ @Test public void test_CREATE_notBalanced() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); shell.refresh(); // ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 1, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -1318,41 +1295,40 @@ public void test_CREATE_notBalanced() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_CREATE_Shell_open() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test {", - " public static void main(String[] args) {", - " Shell shell = new Shell();", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " shell.setLayout(layout);", - " }", - " shell.open();", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test { + public static void main(String[] args) { + Shell shell = new Shell(); + { + TableWrapLayout layout = new TableWrapLayout(); + shell.setLayout(layout); + } + shell.open(); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 0, false); - assertEditor( - "public class Test {", - " public static void main(String[] args) {", - " Shell shell = new Shell();", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " shell.setLayout(layout);", - " }", - " new Label(shell, SWT.NONE);", - " {", - " Button button = new Button(shell, SWT.NONE);", - " button.setText('New Button');", - " }", - " shell.open();", - " }", - "}"); + assertEditor(""" + public class Test { + public static void main(String[] args) { + Shell shell = new Shell(); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + shell.setLayout(layout); + } + new Label(shell, SWT.NONE); + { + Button button = new Button(shell, SWT.NONE); + button.setText("New Button"); + } + shell.open(); + } + }"""); } finally { shell.refresh_dispose(); } @@ -1360,41 +1336,40 @@ public void test_CREATE_Shell_open() throws Exception { @Test public void test_CREATE_Shell_layout() throws Exception { - CompositeInfo shell = - parseComposite( - "public class Test {", - " public static void main(String[] args) {", - " Shell shell = new Shell();", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " shell.setLayout(layout);", - " }", - " shell.layout();", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + public class Test { + public static void main(String[] args) { + Shell shell = new Shell(); + { + TableWrapLayout layout = new TableWrapLayout(); + shell.setLayout(layout); + } + shell.layout(); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 1, false, 0, false); - assertEditor( - "public class Test {", - " public static void main(String[] args) {", - " Shell shell = new Shell();", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " shell.setLayout(layout);", - " }", - " new Label(shell, SWT.NONE);", - " {", - " Button button = new Button(shell, SWT.NONE);", - " button.setText('New Button');", - " }", - " shell.layout();", - " }", - "}"); + assertEditor(""" + public class Test { + public static void main(String[] args) { + Shell shell = new Shell(); + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + shell.setLayout(layout); + } + new Label(shell, SWT.NONE); + { + Button button = new Button(shell, SWT.NONE); + button.setText("New Button"); + } + shell.layout(); + } + }"""); } finally { shell.refresh_dispose(); } @@ -1407,30 +1382,29 @@ public void test_CREATE_Shell_layout() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_columnAccess() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('1 x 1');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("1 x 1"); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); final TableWrapColumnInfo column = layout.getColumns().get(0); @@ -1441,67 +1415,67 @@ public void test_columnAccess() throws Exception { assertEquals(TableWrapData.LEFT, column.getAlignment().intValue()); // flip grab column.flipGrab(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabHorizontal = true;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('1 x 1');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabHorizontal = true; + button.setLayoutData(tableWrapData); + } + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("1 x 1"); + } + } + }"""); assertEquals("left, grab", column.getTitle()); // set alignment ExecutionUtils.run(shell, () -> column.setAlignment(TableWrapData.FILL)); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('1 x 1');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("1 x 1"); + } + } + }"""); assertEquals("fill, grab", column.getTitle()); // set different alignment for "0 x 1" button { @@ -1519,47 +1493,46 @@ public void test_columnAccess() throws Exception { } // delete column.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('1 x 1');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("1 x 1"); + } + } + }"""); } @Test public void test_rowAccess() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('1 x 1');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("1 x 1"); + } + } + }"""); shell.refresh(); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); final TableWrapRowInfo row = layout.getRows().get(1); @@ -1570,67 +1543,67 @@ public void test_rowAccess() throws Exception { assertEquals(TableWrapData.TOP, row.getAlignment().intValue()); // flip grab row.flipGrab(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('1 x 1');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + button.setText("1 x 1"); + } + } + }"""); assertEquals("top, grab", row.getTitle()); // set alignment ExecutionUtils.run(shell, () -> row.setAlignment(TableWrapData.FILL)); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 0');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1));", - " button.setText('0 x 1');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1));", - " button.setText('1 x 1');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 0"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1)); + button.setText("0 x 1"); + } + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL_GRAB, 1, 1)); + button.setText("1 x 1"); + } + } + }"""); assertEquals("fill, grab", row.getTitle()); // set different alignment for "0 x 1" button { @@ -1651,55 +1624,54 @@ public void test_rowAccess() throws Exception { } // delete row.delete(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('0 x 0');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("0 x 0"); + } + } + }"""); } @Test public void test_deleteColumn() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.colspan = 3;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.colspan = 3; + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -1710,33 +1682,33 @@ public void test_deleteColumn() throws Exception { } finally { shell.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.colspan = 2;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.colspan = 2; + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1744,27 +1716,26 @@ public void test_deleteColumn() throws Exception { @Test public void test_deleteColumn_deleteAlsoEmptyRows() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -1775,19 +1746,19 @@ public void test_deleteColumn_deleteAlsoEmptyRows() throws Exception { } finally { shell.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1795,38 +1766,37 @@ public void test_deleteColumn_deleteAlsoEmptyRows() throws Exception { @Test public void test_deleteRow() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.rowspan = 3;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button_1 = new Button(this, SWT.NONE);", - " button_1.setText('New Button');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.rowspan = 3; + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button_1 = new Button(this, SWT.NONE); + button_1.setText("New Button"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -1838,33 +1808,33 @@ public void test_deleteRow() throws Exception { shell.endEdit(); } // - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData();", - " tableWrapData.rowspan = 2;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(); + tableWrapData.rowspan = 2; + button.setLayoutData(tableWrapData); + } + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1872,27 +1842,26 @@ public void test_deleteRow() throws Exception { @Test public void test_deleteRow_deleteAlsoEmptyColumns() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -1903,19 +1872,19 @@ public void test_deleteRow_deleteAlsoEmptyColumns() throws Exception { } finally { shell.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -1928,27 +1897,26 @@ public void test_deleteRow_deleteAlsoEmptyColumns() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_MOVE_COLUMN_before() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -1959,26 +1927,26 @@ public void test_MOVE_COLUMN_before() throws Exception { } finally { layout.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + new Label(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -1986,27 +1954,26 @@ public void test_MOVE_COLUMN_before() throws Exception { @Test public void test_MOVE_COLUMN_after() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -2017,26 +1984,26 @@ public void test_MOVE_COLUMN_after() throws Exception { } finally { layout.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + new Label(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -2049,27 +2016,26 @@ public void test_MOVE_COLUMN_after() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_MOVE_ROW_before() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -2080,26 +2046,26 @@ public void test_MOVE_ROW_before() throws Exception { } finally { layout.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -2107,27 +2073,26 @@ public void test_MOVE_ROW_before() throws Exception { @Test public void test_MOVE_ROW_after() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -2138,26 +2103,26 @@ public void test_MOVE_ROW_after() throws Exception { } finally { layout.endEdit(); } - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -2170,59 +2135,58 @@ public void test_MOVE_ROW_after() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_MOVE() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(2); // shell.refresh(); try { layout.command_MOVE(button, 1, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('000');", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('111');", - " }", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('222');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("000"); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("111"); + } + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setText("222"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -2230,23 +2194,22 @@ public void test_MOVE() throws Exception { @Test public void test_MOVE_out() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new RowLayout());", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new RowLayout()); + } + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(0); RowLayoutInfo layout = (RowLayoutInfo) composite.getLayout(); ControlInfo button = shell.getChildrenControls().get(1); @@ -2254,22 +2217,22 @@ public void test_MOVE_out() throws Exception { shell.refresh(); try { layout.command_MOVE(button, null); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new RowLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new RowLayout()); + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -2277,43 +2240,42 @@ public void test_MOVE_out() throws Exception { @Test public void test_MOVE_error_1() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 4;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " Button button = new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 4; + setLayout(layout); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + Button button = new Button(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(7); // shell.refresh(); try { layout.command_MOVE(button, 1, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 2;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " Button button = new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 2; + setLayout(layout); + } + new Label(this, SWT.NONE); + Button button = new Button(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -2321,23 +2283,22 @@ public void test_MOVE_error_1() throws Exception { @Test public void test_MOVE_error_2() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " layout.numColumns = 3;", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " Button button = new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 3; + setLayout(layout); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + Button button = new Button(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = shell.getChildrenControls().get(5); // @@ -2345,16 +2306,16 @@ public void test_MOVE_error_2() throws Exception { try { layout.command_MOVE(button, 0, false, 0, false); layout.getGridInfo(); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " Button button = new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + Button button = new Button(this, SWT.NONE); + } + }"""); } finally { shell.refresh_dispose(); } @@ -2367,23 +2328,22 @@ public void test_MOVE_error_2() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_ADD() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new RowLayout());", - " {", - " Button button = new Button(composite, SWT.NONE);", - " }", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new RowLayout()); + { + Button button = new Button(composite, SWT.NONE); + } + } + } + }"""); CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(0); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); ControlInfo button = composite.getChildrenControls().get(0); @@ -2391,22 +2351,22 @@ public void test_ADD() throws Exception { shell.refresh(); try { layout.command_ADD(button, 0, false, 1, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Composite composite = new Composite(this, SWT.NONE);", - " composite.setLayout(new RowLayout());", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Composite composite = new Composite(this, SWT.NONE); + composite.setLayout(new RowLayout()); + } + { + Button button = new Button(this, SWT.NONE); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -2419,35 +2379,34 @@ public void test_ADD() throws Exception { //////////////////////////////////////////////////////////////////////////// @Test public void test_CREATE_noReference() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); try { ControlInfo newButton = BTestUtils.createControl("org.eclipse.swt.widgets.Button"); layout.command_CREATE(newButton, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + Button button = new Button(this, SWT.NONE); + button.setText("New Button"); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -2455,16 +2414,15 @@ public void test_CREATE_noReference() throws Exception { @Test public void test_CREATE_viewer() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); // shell.refresh(); @@ -2473,20 +2431,20 @@ public void test_CREATE_viewer() throws Exception { TableInfo table = (TableInfo) JavaInfoUtils.getWrapped(viewer); // layout.command_CREATE(table, 0, false, 0, false); - assertEditor( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " {", - " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);", - " Table table = tableViewer.getTable();", - " table.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + { + TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION); + Table table = tableViewer.getTable(); + table.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1)); + } + } + }"""); } finally { shell.refresh_dispose(); } @@ -2503,18 +2461,17 @@ public void test_CREATE_viewer() throws Exception { */ @Test public void test_DELETE_removeFillers() throws Exception { - CompositeInfo shell = - parseComposite( - "class Test extends Shell {", - " Test() {", - " {", - " TableWrapLayout layout = new TableWrapLayout();", - " setLayout(layout);", - " }", - " new Label(this, SWT.NONE);", - " new Button(this, SWT.NONE);", - " }", - "}"); + CompositeInfo shell = parseComposite(""" + class Test extends Shell { + Test() { + { + TableWrapLayout layout = new TableWrapLayout(); + setLayout(layout); + } + new Label(this, SWT.NONE); + new Button(this, SWT.NONE); + } + }"""); TableWrapLayoutInfo layout = (TableWrapLayoutInfo) shell.getLayout(); shell.refresh(); // initially 2 controls - filler and Button @@ -2522,12 +2479,12 @@ public void test_DELETE_removeFillers() throws Exception { // after delete - only Button layout.delete(); assertEquals(1, shell.getChildrenControls().size()); - assertEditor( - "class Test extends Shell {", - " Test() {", - " new Button(this, SWT.NONE);", - " }", - "}"); + assertEditor(""" + class Test extends Shell { + Test() { + new Button(this, SWT.NONE); + } + }"""); } //////////////////////////////////////////////////////////////////////////// @@ -2541,76 +2498,75 @@ public void test_DELETE_removeFillers() throws Exception { */ @Test public void test_Switching_fromGridLayout() throws Exception { - CompositeInfo composite = - parseComposite( - "class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " setLayout(new GridLayout(3, false));", - " {", - " Label label = new Label(this, SWT.NONE);", - " label.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1));", - " label.setText('New Label');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Text text = new Text(this, SWT.BORDER);", - " text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " button.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1));", - " button.setText('New Button');", - " }", - " }", - "}"); + CompositeInfo composite = parseComposite(""" + class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + setLayout(new GridLayout(3, false)); + { + Label label = new Label(this, SWT.NONE); + label.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1)); + label.setText("New Label"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Text text = new Text(this, SWT.BORDER); + text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1)); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + button.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1)); + button.setText("New Button"); + } + } + }"""); composite.refresh(); // set TableWrapLayout TableWrapLayoutInfo tableWrapLayout = (TableWrapLayoutInfo) BTestUtils.createLayout("org.eclipse.ui.forms.widgets.TableWrapLayout"); composite.setLayout(tableWrapLayout); - assertEditor( - "class Test extends Composite {", - " public Test(Composite parent, int style) {", - " super(parent, style);", - " {", - " TableWrapLayout tableWrapLayout = new TableWrapLayout();", - " tableWrapLayout.numColumns = 3;", - " setLayout(tableWrapLayout);", - " }", - " {", - " Label label = new Label(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1);", - " tableWrapData.grabHorizontal = true;", - " label.setLayoutData(tableWrapData);", - " }", - " label.setText('New Label');", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Text text = new Text(this, SWT.BORDER);", - " text.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 2));", - " }", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " new Label(this, SWT.NONE);", - " {", - " Button button = new Button(this, SWT.NONE);", - " {", - " TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);", - " tableWrapData.grabVertical = true;", - " button.setLayoutData(tableWrapData);", - " }", - " button.setText('New Button');", - " }", - " }", - "}"); + assertEditor(""" + class Test extends Composite { + public Test(Composite parent, int style) { + super(parent, style); + { + TableWrapLayout tableWrapLayout = new TableWrapLayout(); + tableWrapLayout.numColumns = 3; + setLayout(tableWrapLayout); + } + { + Label label = new Label(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.BOTTOM, 1, 1); + tableWrapData.grabHorizontal = true; + label.setLayoutData(tableWrapData); + } + label.setText("New Label"); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Text text = new Text(this, SWT.BORDER); + text.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 2)); + } + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + new Label(this, SWT.NONE); + { + Button button = new Button(this, SWT.NONE); + { + TableWrapData tableWrapData = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1); + tableWrapData.grabVertical = true; + button.setLayoutData(tableWrapData); + } + button.setText("New Button"); + } + } + }"""); } ////////////////////////////////////////////////////////////////////////////