diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/ManagerUtilsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/ManagerUtilsTest.java
index 77efcd2cc..278ebca9f 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/ManagerUtilsTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/ManagerUtilsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
+ * Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@@ -144,12 +144,11 @@ public void test_ensure_ResourceManager() throws Exception {
}
private void parseShell() throws Exception {
- shell =
- parseComposite(
- "// filler filler filler",
- "public class Test extends Shell {",
- " public Test() {",
- " }",
- "}");
+ shell = parseComposite("""
+ // filler filler filler
+ public class Test extends Shell {
+ public Test() {
+ }
+ }""");
}
}
diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/ClipboardTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/ClipboardTest.java
index 4b53f46f0..8e7a177ac 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/ClipboardTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/ClipboardTest.java
@@ -141,17 +141,16 @@ private void check_propertiesPaste(String invocationCode) throws Exception {
private void check_propertiesPaste(String invocationCode_1, String invocationCode_2)
throws Exception {
m_waitForAutoBuild = true;
- final CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = new Button(this, SWT.BORDER | SWT.CHECK);",
- " button." + invocationCode_1 + ";",
- " }",
- " }",
- "}");
+ final CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = new Button(this, SWT.BORDER | SWT.CHECK);
+ button.%s;
+ }
+ }
+ }""".formatted(invocationCode_1));
final RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout();
shell.refresh();
// create memento for "button"
@@ -167,20 +166,20 @@ private void check_propertiesPaste(String invocationCode_1, String invocationCod
rowLayout.command_CREATE(button, null);
memento.apply();
});
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = new Button(this, SWT.BORDER | SWT.CHECK);",
- " button." + invocationCode_1 + ";",
- " }",
- " {",
- " Button button = new Button(this, SWT.BORDER | SWT.CHECK);",
- " button." + invocationCode_2 + ";",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = new Button(this, SWT.BORDER | SWT.CHECK);
+ button.%s;
+ }
+ {
+ Button button = new Button(this, SWT.BORDER | SWT.CHECK);
+ button.%s;
+ }
+ }
+ }""".formatted(invocationCode_1, invocationCode_2));
}
}
@@ -194,16 +193,15 @@ private void check_propertiesPaste(String invocationCode_1, String invocationCod
*/
@Test
public void test_liveImageSize() throws Exception {
- final CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 20, 200, 100);",
- " }",
- " }",
- "}");
+ final CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 20, 200, 100);
+ }
+ }
+ }""");
final AbsoluteLayoutInfo absoluteLayout = (AbsoluteLayoutInfo) shell.getLayout();
shell.refresh();
// create memento for "control"
@@ -251,16 +249,15 @@ public void test_liveImageSize() throws Exception {
*/
@Test
public void test_asserts() throws Exception {
- final CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 20, 200, 100);",
- " }",
- " }",
- "}");
+ final CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 20, 200, 100);
+ }
+ }
+ }""");
final AbsoluteLayoutInfo absoluteLayout = (AbsoluteLayoutInfo) shell.getLayout();
shell.refresh();
// create memento for "control"
@@ -296,7 +293,7 @@ public void test_asserts() throws Exception {
/**
* Does copy/paste for first child of parsed {@link CompositeInfo} with {@link RowLayoutInfo}.
*/
- private void layouts_doCopy(String[] sourceLines, String[] targetLines) throws Exception {
+ private void layouts_doCopy(String sourceLines, String targetLines) throws Exception {
final CompositeInfo shell = parseComposite(sourceLines);
final RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout();
shell.refresh();
@@ -311,502 +308,476 @@ private void layouts_doCopy(String[] sourceLines, String[] targetLines) throws E
@Test
public void test_factoryStatic() throws Exception {
- setFileContentSrc(
- "test/StaticFactory.java",
- getTestSource(
- "public final class StaticFactory {",
- " public static Button createButton(Composite parent, String text) {",
- " Button button = new Button(parent, SWT.NONE);",
- " button.setText(text);",
- " return button;",
- " }",
- "}"));
+ setFileContentSrc("test/StaticFactory.java", getTestSource("""
+ public final class StaticFactory {
+ public static Button createButton(Composite parent, String text) {
+ Button button = new Button(parent, SWT.NONE);
+ button.setText(text);
+ return button;
+ }
+ }"""));
waitForAutoBuild();
//
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = StaticFactory.createButton(this, \"button\");",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = StaticFactory.createButton(this, \"button\");",
- " }",
- " {",
- " Button button = StaticFactory.createButton(this, \"button\");",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = StaticFactory.createButton(this, "button");
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = StaticFactory.createButton(this, "button");
+ }
+ {
+ Button button = StaticFactory.createButton(this, "button");
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_viewer_1() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " TableViewer viewer = new TableViewer(this, SWT.BORDER);",
- " viewer.setUseHashlookup(true);",
- " viewer.getTable().setHeaderVisible(true);",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " TableViewer viewer = new TableViewer(this, SWT.BORDER);",
- " viewer.setUseHashlookup(true);",
- " viewer.getTable().setHeaderVisible(true);",
- " }",
- " {",
- " TableViewer viewer = new TableViewer(this, SWT.BORDER);",
- " viewer.setUseHashlookup(true);",
- " Table table = viewer.getTable();",
- " table.setHeaderVisible(true);",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ TableViewer viewer = new TableViewer(this, SWT.BORDER);
+ viewer.setUseHashlookup(true);
+ viewer.getTable().setHeaderVisible(true);
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ TableViewer viewer = new TableViewer(this, SWT.BORDER);
+ viewer.setUseHashlookup(true);
+ viewer.getTable().setHeaderVisible(true);
+ }
+ {
+ TableViewer viewer = new TableViewer(this, SWT.BORDER);
+ viewer.setUseHashlookup(true);
+ Table table = viewer.getTable();
+ table.setHeaderVisible(true);
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_exposedSubComponent() throws Exception {
- setFileContentSrc(
- "test/MyComposite.java",
- getTestSource(
- "public class MyComposite extends Composite {",
- " private Button m_button;",
- " public MyComposite(Composite parent, int style) {",
- " super(parent, style);",
- " setLayout(new RowLayout());",
- " m_button = new Button(this, SWT.NONE);",
- " }",
- " public Button getButton() {",
- " return m_button;",
- " }",
- "}"));
+ setFileContentSrc("test/MyComposite.java", getTestSource("""
+ public class MyComposite extends Composite {
+ private Button m_button;
+ public MyComposite(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new RowLayout());
+ m_button = new Button(this, SWT.NONE);
+ }
+ public Button getButton() {
+ return m_button;
+ }
+ }"""));
waitForAutoBuild();
// do copy/paste
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " MyComposite myComposite = new MyComposite(this, SWT.NONE);",
- " myComposite.getButton().setText(\"button\");",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " MyComposite myComposite = new MyComposite(this, SWT.NONE);",
- " myComposite.getButton().setText(\"button\");",
- " }",
- " {",
- " MyComposite myComposite = new MyComposite(this, SWT.NONE);",
- " myComposite.getButton().setText(\"button\");",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ MyComposite myComposite = new MyComposite(this, SWT.NONE);
+ myComposite.getButton().setText("button");
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ MyComposite myComposite = new MyComposite(this, SWT.NONE);
+ myComposite.getButton().setText("button");
+ }
+ {
+ MyComposite myComposite = new MyComposite(this, SWT.NONE);
+ myComposite.getButton().setText("button");
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_viewer_2() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " table.setHeaderVisible(true);",
- " TableViewer viewer = new TableViewer(table);",
- " viewer.setUseHashlookup(true);",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " table.setHeaderVisible(true);",
- " TableViewer viewer = new TableViewer(table);",
- " viewer.setUseHashlookup(true);",
- " }",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " table.setHeaderVisible(true);",
- " TableViewer viewer = new TableViewer(table);",
- " viewer.setUseHashlookup(true);",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Table table = new Table(this, SWT.BORDER);
+ table.setHeaderVisible(true);
+ TableViewer viewer = new TableViewer(table);
+ viewer.setUseHashlookup(true);
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Table table = new Table(this, SWT.BORDER);
+ table.setHeaderVisible(true);
+ TableViewer viewer = new TableViewer(table);
+ viewer.setUseHashlookup(true);
+ }
+ {
+ Table table = new Table(this, SWT.BORDER);
+ table.setHeaderVisible(true);
+ TableViewer viewer = new TableViewer(table);
+ viewer.setUseHashlookup(true);
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_Table() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"AAA\");",
- " }",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"BBB\");",
- " }",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"AAA\");",
- " }",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"BBB\");",
- " }",
- " }",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"AAA\");",
- " }",
- " {",
- " TableColumn tableColumn = new TableColumn(table, SWT.NONE);",
- " tableColumn.setWidth(100);",
- " tableColumn.setText(\"BBB\");",
- " }",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Table table = new Table(this, SWT.BORDER);
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("AAA");
+ }
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("BBB");
+ }
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Table table = new Table(this, SWT.BORDER);
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("AAA");
+ }
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("BBB");
+ }
+ }
+ {
+ Table table = new Table(this, SWT.BORDER);
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("AAA");
+ }
+ {
+ TableColumn tableColumn = new TableColumn(table, SWT.NONE);
+ tableColumn.setWidth(100);
+ tableColumn.setText("BBB");
+ }
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_AbsoluteLayout_implicit() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_AbsoluteLayout_null() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(null);",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(null);",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(null);",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(null);
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(null);
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(null);
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_AbsoluteLayout_withComponent() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"button\");",
- " button.setBounds(10, 20, 200, 100);",
- " }",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"button\");",
- " button.setBounds(10, 20, 200, 100);",
- " }",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"button\");",
- " button.setBounds(10, 20, 200, 100);",
- " }",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("button");
+ button.setBounds(10, 20, 200, 100);
+ }
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("button");
+ button.setBounds(10, 20, 200, 100);
+ }
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("button");
+ button.setBounds(10, 20, 200, 100);
+ }
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_FillLayout() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new FillLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"second button\");",
- " }",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new FillLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"second button\");",
- " }",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new FillLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " button.setText(\"second button\");",
- " }",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new FillLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("second button");
+ }
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new FillLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("second button");
+ }
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new FillLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ button.setText("second button");
+ }
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_RowLayout() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setLayoutData(new RowData(100, 200));",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.RADIO);",
- " RowData rowData = new RowData();",
- " rowData.width = 100;",
- " button.setLayoutData(rowData);",
- " }",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setLayoutData(new RowData(100, 200));",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.RADIO);",
- " RowData rowData = new RowData();",
- " rowData.width = 100;",
- " button.setLayoutData(rowData);",
- " }",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setLayoutData(new RowData(100, 200));",
- " }",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " {",
- " Button button = new Button(composite, SWT.RADIO);",
- " button.setLayoutData(new RowData(100, SWT.DEFAULT));",
- " }",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setLayoutData(new RowData(100, 200));
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ {
+ Button button = new Button(composite, SWT.RADIO);
+ RowData rowData = new RowData();
+ rowData.width = 100;
+ button.setLayoutData(rowData);
+ }
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setLayoutData(new RowData(100, 200));
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ {
+ Button button = new Button(composite, SWT.RADIO);
+ RowData rowData = new RowData();
+ rowData.width = 100;
+ button.setLayoutData(rowData);
+ }
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setLayoutData(new RowData(100, 200));
+ }
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ {
+ Button button = new Button(composite, SWT.RADIO);
+ button.setLayoutData(new RowData(100, SWT.DEFAULT));
+ }
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
@Test
public void test_layouts_GridLayout() throws Exception {
- String[] sourceLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new GridLayout(2, false));",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " GridData gridData = new GridData();",
- " gridData.horizontalAlignment = GridData.FILL;",
- " button.setLayoutData(gridData);",
- " }",
- " new Label(composite, SWT.NONE);",
- " new Label(composite, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " }",
- " }",
- "}"};
- String[] targetLines =
- new String[]{
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new GridLayout(2, false));",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " GridData gridData = new GridData();",
- " gridData.horizontalAlignment = GridData.FILL;",
- " button.setLayoutData(gridData);",
- " }",
- " new Label(composite, SWT.NONE);",
- " new Label(composite, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new GridLayout(2, false));",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));",
- " }",
- " new Label(composite, SWT.NONE);",
- " new Label(composite, SWT.NONE);",
- " {",
- " Button button = new Button(composite, SWT.CHECK);",
- " }",
- " }",
- " }",
- "}"};
+ String sourceLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ {
+ Button button = new Button(composite, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ button.setLayoutData(gridData);
+ }
+ new Label(composite, SWT.NONE);
+ new Label(composite, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ }
+ }
+ }""";
+ String targetLines = """
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ {
+ Button button = new Button(composite, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ button.setLayoutData(gridData);
+ }
+ new Label(composite, SWT.NONE);
+ new Label(composite, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ }
+ new Label(composite, SWT.NONE);
+ new Label(composite, SWT.NONE);
+ {
+ Button button = new Button(composite, SWT.CHECK);
+ }
+ }
+ }
+ }""";
layouts_doCopy(sourceLines, targetLines);
}
}
diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/jface/ViewerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/jface/ViewerTest.java
index ea17612c0..bb819ccf0 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/jface/ViewerTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/jface/ViewerTest.java
@@ -77,14 +77,13 @@ public void _test_exit() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_normalNoControl_hasExpression() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
VariableSupport variableSupport = table.getVariableSupport();
NodeTarget nodeTarget = getNodeStatementTarget(shell, false, 1);
@@ -98,77 +97,74 @@ public void test_normalNoControl_hasExpression() throws Exception {
@Test
public void test_normalNoControl_getReferenceExpression_viewerAsTarget() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
VariableSupport variableSupport = table.getVariableSupport();
NodeTarget nodeTarget = getNodeStatementTarget(shell, false, 1);
// ask for expression, so materialize
assertEquals("table", variableSupport.getReferenceExpression(nodeTarget));
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ }
+ }""");
}
@Test
public void test_normalNoControl_getReferenceExpression_blockAsTarget() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
VariableSupport variableSupport = table.getVariableSupport();
NodeTarget nodeTarget = getNodeBlockTarget(shell, false);
// ask for expression, so materialize
assertEquals("table", variableSupport.getReferenceExpression(nodeTarget));
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ }
+ }""");
}
@Test
public void test_normalNoControl_getAccessExpression_blockAsTarget() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
VariableSupport variableSupport = table.getVariableSupport();
NodeTarget nodeTarget = getNodeBlockTarget(shell, false);
// ask for expression, so materialize
assertEquals("table.", variableSupport.getAccessExpression(nodeTarget));
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ }
+ }""");
}
/**
@@ -176,14 +172,14 @@ public void test_normalNoControl_getAccessExpression_blockAsTarget() throws Exce
*/
@Test
public void test_parseAnonymous_standalone() throws Exception {
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER) {",
- " };",
- " }",
- "}");
+ parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER) {
+ };
+ }
+ }""");
refresh();
assertNoErrors(m_lastParseInfo);
}
@@ -193,15 +189,15 @@ public void test_parseAnonymous_standalone() throws Exception {
*/
@Test
public void test_parseAnonymous_wrapper() throws Exception {
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " Table table = new Table(this, SWT.BORDER);",
- " TableViewer tableViewer = new TableViewer(table) {",
- " };",
- " }",
- "}");
+ parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ Table table = new Table(this, SWT.BORDER);
+ TableViewer tableViewer = new TableViewer(table) {
+ };
+ }
+ }""");
refresh();
assertNoErrors(m_lastParseInfo);
}
@@ -211,14 +207,13 @@ public void test_parseAnonymous_wrapper() throws Exception {
*/
@Test
public void test_exposeViewer() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
ViewerInfo viewer = (ViewerInfo) table.getChildrenJava().get(0);
// check for expose action
@@ -233,51 +228,49 @@ public void test_exposeViewer() throws Exception {
viewer,
"getTableViewer",
"public");
- assertEditor(
- "class Test extends Shell {",
- " private TableViewer tableViewer;",
- " public Test() {",
- " setLayout(new FillLayout());",
- " tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- " public TableViewer getTableViewer() {",
- " return tableViewer;",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ private TableViewer tableViewer;
+ public Test() {
+ setLayout(new FillLayout());
+ tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ public TableViewer getTableViewer() {
+ return tableViewer;
+ }
+ }""");
}
@Test
public void test_exposedViewer() throws Exception {
- setFileContentSrc(
- "test/MyComposite.java",
- getTestSource(
- "public class MyComposite extends Composite {",
- " private TableViewer m_viewer;",
- " public MyComposite(Composite parent, int style) {",
- " super(parent, style);",
- " setLayout(new FillLayout());",
- " m_viewer = new TableViewer(this, SWT.BORDER);",
- " }",
- " public TableViewer getViewer() {",
- " return m_viewer;",
- " }",
- "}"));
+ setFileContentSrc("test/MyComposite.java", getTestSource("""
+ public class MyComposite extends Composite {
+ private TableViewer m_viewer;
+ public MyComposite(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ m_viewer = new TableViewer(this, SWT.BORDER);
+ }
+ public TableViewer getViewer() {
+ return m_viewer;
+ }
+ }"""));
waitForAutoBuild();
// parse
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " MyComposite composite = new MyComposite(this, SWT.NONE);",
- " }",
- "}");
- assertHierarchy(
- "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new MyComposite(this, SWT.NONE)/}",
- " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}",
- " {new: test.MyComposite} {local-unique: composite} {/new MyComposite(this, SWT.NONE)/}",
- " {implicit-layout: org.eclipse.swt.layout.FillLayout} {implicit-layout} {}",
- " {viewer: public org.eclipse.swt.widgets.Table org.eclipse.jface.viewers.TableViewer.getTable()} {viewer} {}",
- " {method: public org.eclipse.jface.viewers.TableViewer test.MyComposite.getViewer()} {property} {}");
+ parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ MyComposite composite = new MyComposite(this, SWT.NONE);
+ }
+ }""");
+ assertHierarchy("""
+ {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new MyComposite(this, SWT.NONE)/}
+ {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}
+ {new: test.MyComposite} {local-unique: composite} {/new MyComposite(this, SWT.NONE)/}
+ {implicit-layout: org.eclipse.swt.layout.FillLayout} {implicit-layout} {}
+ {viewer: public org.eclipse.swt.widgets.Table org.eclipse.jface.viewers.TableViewer.getTable()} {viewer} {}
+ {method: public org.eclipse.jface.viewers.TableViewer test.MyComposite.getViewer()} {property} {}""");
}
////////////////////////////////////////////////////////////////////////////
@@ -287,15 +280,14 @@ public void test_exposedViewer() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_parseNormalNoControl() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " tableViewer.setUseHashlookup(true);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ tableViewer.setUseHashlookup(true);
+ }
+ }""");
assertEquals(2, shell.getChildrenJava().size());
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
// check viewer
@@ -338,37 +330,36 @@ public void test_parseNormalNoControl() throws Exception {
{
assertTrue(table.canDelete());
table.delete();
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ }
+ }""");
}
}
@Test
public void test_normalNoControl_materialize() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
// materialize Table
table.addMethodInvocation("setHeaderVisible(boolean)", "true");
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " table.setHeaderVisible(true);",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ }
+ }""");
// check supports
assertInstanceOf(WrapperMethodControlCreationSupport.class, table.getCreationSupport());
assertInstanceOf(LocalUniqueVariableSupport.class, table.getVariableSupport());
@@ -381,179 +372,174 @@ public void test_normalNoControl_materialize() throws Exception {
@Test
public void test_normalNoControl_move() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Composite composite = new Composite(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Composite composite = new Composite(this, SWT.NONE);
+ }
+ }""");
FillLayoutInfo fillLayout = (FillLayoutInfo) shell.getLayout();
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
// do move
fillLayout.command_MOVE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " Composite composite = new Composite(this, SWT.NONE);",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ Composite composite = new Composite(this, SWT.NONE);
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
}
@Test
public void test_normalNoControl_reparent() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " //",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " //",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ //
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ //
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
// prepare composite
CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(1);
RowLayoutInfo rowLayout = (RowLayoutInfo) composite.getLayout();
// do reparent
rowLayout.command_MOVE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " //",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " //",
- " TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ //
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ //
+ TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);
+ }
+ }""");
}
@Test
public void test_normalWithControl_reparent() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " //",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " //",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ //
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ //
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
// prepare composite
CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(1);
RowLayoutInfo rowLayout = (RowLayoutInfo) composite.getLayout();
// do reparent
rowLayout.command_MOVE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " //",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setLayout(new RowLayout());",
- " //",
- " TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);",
- " Table table = tableViewer.getTable();",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ //
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setLayout(new RowLayout());
+ //
+ TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);
+ Table table = tableViewer.getTable();
+ }
+ }""");
}
@Test
public void test_materialized_move() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- " {",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " Table table = tableViewer.getTable();",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = new Button(this, SWT.NONE);
+ }
+ {
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ Table table = tableViewer.getTable();
+ }
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo table = shell.getChildrenControls().get(1);
RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout();
// do move
rowLayout.command_MOVE(table, button);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " Table table = tableViewer.getTable();",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ Table table = tableViewer.getTable();
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ }
+ }
+ }""");
}
@Test
public void test_newCreated_move() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = new Button(this, SWT.NONE);
+ }
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
RowLayoutInfo rowLayout = (RowLayoutInfo) shell.getLayout();
// do create
ViewerInfo viewer = createTableViewer(m_lastEditor);
ControlInfo table = (ControlInfo) viewer.getWrapper().getWrappedInfo();
rowLayout.command_CREATE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- " {",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " Table table = tableViewer.getTable();",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ Button button = new Button(this, SWT.NONE);
+ }
+ {
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ Table table = tableViewer.getTable();
+ }
+ }
+ }""");
// do move
rowLayout.command_MOVE(table, button);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new RowLayout());",
- " {",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " Table table = tableViewer.getTable();",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new RowLayout());
+ {
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ Table table = tableViewer.getTable();
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ }
+ }
+ }""");
}
////////////////////////////////////////////////////////////////////////////
@@ -563,23 +549,23 @@ public void test_newCreated_move() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_parseAroundTable() throws Exception {
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " {",
- " Table table = new Table(this, SWT.BORDER);",
- " TableViewer viewer = new TableViewer(table);",
- " viewer.getTable().setEnabled(false);",
- " }",
- " }",
- "}");
+ parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ {
+ Table table = new Table(this, SWT.BORDER);
+ TableViewer viewer = new TableViewer(table);
+ viewer.getTable().setEnabled(false);
+ }
+ }
+ }""");
// hierarchy
- assertHierarchy(
- "{this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new Table(this, SWT.BORDER)/}",
- " {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}",
- " {new: org.eclipse.swt.widgets.Table} {local-unique: table} {/new Table(this, SWT.BORDER)/ /new TableViewer(table)/ /viewer.getTable().setEnabled(false)/}",
- " {new: org.eclipse.jface.viewers.TableViewer} {local-unique: viewer} {/new TableViewer(table)/ /viewer.getTable()/}");
+ assertHierarchy("""
+ {this: org.eclipse.swt.widgets.Shell} {this} {/setLayout(new FillLayout())/ /new Table(this, SWT.BORDER)/}
+ {new: org.eclipse.swt.layout.FillLayout} {empty} {/setLayout(new FillLayout())/}
+ {new: org.eclipse.swt.widgets.Table} {local-unique: table} {/new Table(this, SWT.BORDER)/ /new TableViewer(table)/ /viewer.getTable().setEnabled(false)/}
+ {new: org.eclipse.jface.viewers.TableViewer} {local-unique: viewer} {/new TableViewer(table)/ /viewer.getTable()/}""");
TableInfo table = getJavaInfoByName("table");
ViewerInfo viewer = getJavaInfoByName("viewer");
assertSame(table, viewer.getParent());
@@ -596,14 +582,13 @@ public void test_parseAroundTable() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_property_useHashlookup() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
ViewerInfo viewer = (ViewerInfo) table.getChildrenJava().get(0);
Property property = viewer.getPropertyByTitle("useHashlookup");
@@ -611,35 +596,34 @@ public void test_property_useHashlookup() throws Exception {
assertEquals(Boolean.FALSE, property.getValue());
// set "true" - add invocation
property.setValue(Boolean.TRUE);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " tableViewer.setUseHashlookup(true);",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ tableViewer.setUseHashlookup(true);
+ }
+ }""");
// set "false" - remove invocation
property.setValue(Boolean.FALSE);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
}
@Test
public void test_property_style() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
ViewerInfo viewer = (ViewerInfo) table.getChildrenJava().get(0);
//
@@ -649,14 +633,13 @@ public void test_property_style() throws Exception {
@Test
public void test_contentProvider() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ }
+ }""");
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
ViewerInfo viewer = (ViewerInfo) table.getChildrenJava().get(0);
//
@@ -667,23 +650,23 @@ public void test_contentProvider() throws Exception {
// add new provider
{
propertyEditor.activate(null, property, null);
- assertEditor(
- "class Test extends Shell {",
- " private static class ContentProvider implements IStructuredContentProvider {",
- " public Object[] getElements(Object inputElement) {",
- " return new Object[0];",
- " }",
- " public void dispose() {",
- " }",
- " public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {",
- " }",
- " }",
- " public Test() {",
- " setLayout(new FillLayout());",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER);",
- " tableViewer.setContentProvider(new ContentProvider());",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ private static class ContentProvider implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ return new Object[0];
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+ public Test() {
+ setLayout(new FillLayout());
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER);
+ tableViewer.setContentProvider(new ContentProvider());
+ }
+ }""");
assertEquals("test.Test.ContentProvider", getPropertyText(property));
}
// just kick "doubleClick", no result tested
@@ -723,12 +706,12 @@ public void accept(SWTBot bot) {
@Test
public void test_noRootComposite() throws Exception {
Throwable e = assertThrows(Throwable.class, () -> {
- parseComposite(
- "public class Test {",
- " public Test(Composite parent) {",
- " TableViewer tableViewer = new TableViewer(parent, SWT.BORDER);",
- " }",
- "}");
+ parseComposite("""
+ public class Test {
+ public Test(Composite parent) {
+ TableViewer tableViewer = new TableViewer(parent, SWT.BORDER);
+ }
+ }""");
});
Throwable rootCause = DesignerExceptionUtils.getRootCause(e);
Assertions.assertThat(rootCause).isExactlyInstanceOf(NoEntryPointError.class);
@@ -741,12 +724,12 @@ public void test_noRootComposite() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_CREATE_liveImage() throws Exception {
- parseComposite(
- "// filler filler filler",
- "class Test extends Shell {",
- " public Test() {",
- " }",
- "}");
+ parseComposite("""
+ // filler filler filler
+ class Test extends Shell {
+ public Test() {
+ }
+ }""");
// prepare viewer and table
ViewerInfo viewer = createTableViewer(m_lastEditor);
TableInfo table = (TableInfo) viewer.getWrapper().getWrappedInfo();
@@ -761,62 +744,54 @@ public void test_CREATE_liveImage() throws Exception {
*/
@Test
public void test_CREATE_liveImage_forcedSize() throws Exception {
- setFileContentSrc(
- "test/MyTable.java",
- getTestSource(
- "public class MyTable extends Table {",
- " public MyTable(Composite parent, int style) {",
- " super(parent, style);",
- " }",
- " protected void checkSubclass () {",
- " }",
- "}"));
- setFileContentSrc(
- "test/MyTableViewer.java",
- getTestSource(
- "public class MyTableViewer extends TableViewer {",
- " public MyTableViewer(Composite parent) {",
- " super(new MyTable(parent, SWT.NO_SCROLL));",
- " }",
- " public MyTable getMyTable() {",
- " return (MyTable) getTable();",
- " }",
- "}"));
- setFileContentSrc(
- "test/MyTable.wbp-component.xml",
- getSourceDQ(
- "",
- "",
- " ",
- " 200",
- " 150",
- " ",
- ""));
- setFileContentSrc(
- "test/MyTableViewer.wbp-component.xml",
- getSourceDQ(
- "",
- "",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " getMyTable",
- " ",
- ""));
+ setFileContentSrc("test/MyTable.java", getTestSource("""
+ public class MyTable extends Table {
+ public MyTable(Composite parent, int style) {
+ super(parent, style);
+ }
+ protected void checkSubclass () {
+ }
+ }"""));
+ setFileContentSrc("test/MyTableViewer.java", getTestSource("""
+ public class MyTableViewer extends TableViewer {
+ public MyTableViewer(Composite parent) {
+ super(new MyTable(parent, SWT.NO_SCROLL));
+ }
+ public MyTable getMyTable() {
+ return (MyTable) getTable();
+ }
+ }"""));
+ setFileContentSrc("test/MyTable.wbp-component.xml", """
+
+
+
+ 200
+ 150
+
+ """);
+ setFileContentSrc("test/MyTableViewer.wbp-component.xml", """
+
+
+
+
+
+
+
+
+
+
+
+ getMyTable
+
+ """);
waitForAutoBuild();
// parse
- parseComposite(
- "// filler filler filler",
- "class Test extends Shell {",
- " public Test() {",
- " }",
- "}");
+ parseComposite("""
+ // filler filler filler
+ class Test extends Shell {
+ public Test() {
+ }
+ }""");
// prepare viewer and table
ViewerInfo viewer = createViewer(m_lastEditor, "test.MyTableViewer");
TableInfo table = (TableInfo) viewer.getWrapper().getWrappedInfo();
@@ -832,13 +807,12 @@ public void test_CREATE_liveImage_forcedSize() throws Exception {
@Test
public void test_CREATE() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ }
+ }""");
FillLayoutInfo fillLayout = (FillLayoutInfo) shell.getLayout();
// prepare Viewer
ViewerInfo viewer = createTableViewer(m_lastEditor);
@@ -858,16 +832,16 @@ public void test_CREATE() throws Exception {
}
// create
fillLayout.command_CREATE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " {",
- " TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " Table table = tableViewer.getTable();",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ {
+ TableViewer tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ Table table = tableViewer.getTable();
+ }
+ }
+ }""");
// check table
{
assertSame(shell, table.getParent());
@@ -916,13 +890,12 @@ public void test_CREATE() throws Exception {
*/
@Test
public void test_CREATE_useFieldVariable() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " setLayout(new FillLayout());",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ setLayout(new FillLayout());
+ }
+ }""");
FillLayoutInfo fillLayout = (FillLayoutInfo) shell.getLayout();
// prepare Viewer and Table
ViewerInfo viewer = createTableViewer(m_lastEditor);
@@ -931,18 +904,18 @@ public void test_CREATE_useFieldVariable() throws Exception {
GenerationSettings settings = viewer.getDescription().getToolkit().getGenerationSettings();
settings.setVariable(FieldUniqueVariableDescription.INSTANCE);
fillLayout.command_CREATE(table, null);
- assertEditor(
- "class Test extends Shell {",
- " private Table table;",
- " private TableViewer tableViewer;",
- " public Test() {",
- " setLayout(new FillLayout());",
- " {",
- " tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);",
- " table = tableViewer.getTable();",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ private Table table;
+ private TableViewer tableViewer;
+ public Test() {
+ setLayout(new FillLayout());
+ {
+ tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ table = tableViewer.getTable();
+ }
+ }
+ }""");
}
/**
diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutOrderingTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutOrderingTest.java
index aa8f3c3fe..3815a6bfa 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutOrderingTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutOrderingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
+ * Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@@ -51,16 +51,15 @@ public void _test_exit() throws Exception {
*/
@Test
public void test_enablement() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo text = shell.getChildrenControls().get(1);
ControlInfo table = shell.getChildrenControls().get(2);
@@ -95,121 +94,117 @@ public void test_enablement() throws Exception {
@Test
public void test_bringToFront() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo text = shell.getChildrenControls().get(1);
ControlInfo table = shell.getChildrenControls().get(2);
// run action
getOrderAction(createOrderManager(table), "Bring to Front").run();
// check result
- assertEditor(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Table table = new Table(this, SWT.NONE);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " }",
- "}");
+ assertEditor("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Table table = new Table(this, SWT.NONE);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ }
+ }""");
Assertions.assertThat(shell.getChildrenControls()).containsExactly(table, button, text);
}
@Test
public void test_bringForward() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo text = shell.getChildrenControls().get(1);
ControlInfo table = shell.getChildrenControls().get(2);
// run action
getOrderAction(createOrderManager(table), "Bring Forward").run();
// check result
- assertEditor(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " }",
- "}");
+ assertEditor("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ }
+ }""");
Assertions.assertThat(shell.getChildrenControls()).containsExactly(button, table, text);
}
@Test
public void test_sendToBack() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo text = shell.getChildrenControls().get(1);
ControlInfo table = shell.getChildrenControls().get(2);
// run action
getOrderAction(createOrderManager(button), "Send to Back").run();
// check result
- assertEditor(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " Button button = new Button(this, SWT.NONE);",
- " }",
- "}");
+ assertEditor("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ Button button = new Button(this, SWT.NONE);
+ }
+ }""");
Assertions.assertThat(shell.getChildrenControls()).containsExactly(text, table, button);
}
@Test
public void test_sendBackward() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Button button = new Button(this, SWT.NONE);",
- " Text text = new Text(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Button button = new Button(this, SWT.NONE);
+ Text text = new Text(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
ControlInfo text = shell.getChildrenControls().get(1);
ControlInfo table = shell.getChildrenControls().get(2);
// run action
getOrderAction(createOrderManager(button), "Send Backward").run();
// check result
- assertEditor(
- "public class Test extends Shell {",
- " public Test() {",
- " setLayout(null);",
- " Text text = new Text(this, SWT.NONE);",
- " Button button = new Button(this, SWT.NONE);",
- " Table table = new Table(this, SWT.NONE);",
- " }",
- "}");
+ assertEditor("""
+ public class Test extends Shell {
+ public Test() {
+ setLayout(null);
+ Text text = new Text(this, SWT.NONE);
+ Button button = new Button(this, SWT.NONE);
+ Table table = new Table(this, SWT.NONE);
+ }
+ }""");
Assertions.assertThat(shell.getChildrenControls()).containsExactly(text, button, table);
}
diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java
index 6f0ada8a0..5fc8a2aab 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Google, Inc.
+ * Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@@ -51,31 +51,30 @@ public void _test_exit() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_selectionActions() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 27, 83, 22);",
- " button.setText('New Button1');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(41, 129, 134, 84);",
- " button.setText('New Button');",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(286, 135, 134, 120);",
- " {",
- " Label label = new Label(composite, SWT.NONE);",
- " label.setBounds(41, 53, 51, 13);",
- " label.setText('New Label');",
- " }",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 27, 83, 22);
+ button.setText("New Button1");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(41, 129, 134, 84);
+ button.setText("New Button");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(286, 135, 134, 120);
+ {
+ Label label = new Label(composite, SWT.NONE);
+ label.setBounds(41, 53, 51, 13);
+ label.setText("New Label");
+ }
+ }
+ }
+ }""");
ControlInfo button = shell.getChildrenControls().get(0);
CompositeInfo composite = (CompositeInfo) shell.getChildrenControls().get(2);
ControlInfo label = composite.getChildrenControls().get(0);
@@ -176,21 +175,21 @@ public void test_selectionActions() throws Exception {
*/
@Test
public void test_align_left_edges_1a() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(20, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(20, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align left edges", true);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(20, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(20, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align left edges", true);
}
/**
@@ -198,21 +197,21 @@ public void test_align_left_edges_1a() throws Exception {
*/
@Test
public void test_align_left_edges_1b() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align left edges", false);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align left edges", false);
}
/**
@@ -220,25 +219,25 @@ public void test_align_left_edges_1b() throws Exception {
*/
@Test
public void test_align_left_edges_2a() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(30, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(25, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align left edges", true);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(30, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(25, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align left edges", true);
}
/**
@@ -246,25 +245,25 @@ public void test_align_left_edges_2a() throws Exception {
*/
@Test
public void test_align_left_edges_2b() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align left edges", false);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align left edges", false);
}
/**
@@ -272,21 +271,21 @@ public void test_align_left_edges_2b() throws Exception {
*/
@Test
public void test_align_right_edges_1a() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(20, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align right edges", true);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(20, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align right edges", true);
}
/**
@@ -294,21 +293,21 @@ public void test_align_right_edges_1a() throws Exception {
*/
@Test
public void test_align_right_edges_1b() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(-40, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align right edges", false);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(-40, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align right edges", false);
}
/**
@@ -316,25 +315,25 @@ public void test_align_right_edges_1b() throws Exception {
*/
@Test
public void test_align_right_edges_2a() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(80, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(25, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align right edges", true);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(80, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(25, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align right edges", true);
}
/**
@@ -342,25 +341,25 @@ public void test_align_right_edges_2a() throws Exception {
*/
@Test
public void test_align_right_edges_2b() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(-45, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align right edges", false);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(-45, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align right edges", false);
}
/**
@@ -368,21 +367,21 @@ public void test_align_right_edges_2b() throws Exception {
*/
@Test
public void test_align_horizontal_centers_1a() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(45, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(20, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align horizontal centers", true);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(45, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(20, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align horizontal centers", true);
}
/**
@@ -390,21 +389,21 @@ public void test_align_horizontal_centers_1a() throws Exception {
*/
@Test
public void test_align_horizontal_centers_1b() throws Exception {
- check_align_horizontal(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(-15, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align horizontal centers", false);
+ check_align_horizontal("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(-15, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", "Align horizontal centers", false);
}
/**
@@ -412,25 +411,25 @@ public void test_align_horizontal_centers_1b() throws Exception {
*/
@Test
public void test_align_horizontal_centers_2a() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(55, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(25, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align horizontal centers", true);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(55, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(25, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align horizontal centers", true);
}
/**
@@ -438,67 +437,67 @@ public void test_align_horizontal_centers_2a() throws Exception {
*/
@Test
public void test_align_horizontal_centers_2b() throws Exception {
- check_align_horizontal2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(-20, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align horizontal centers", false);
+ check_align_horizontal2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(-20, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align horizontal centers", false);
}
- private void check_align_horizontal(String[] expectedSource, String action, boolean toUp)
+ private void check_align_horizontal(String expectedSource, String action, boolean toUp)
throws Exception {
- check_align(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(20, 50, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, expectedSource, action, toUp);
+ check_align("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(20, 50, 150, 30);
+ button.setText("111");
+ }
+ }
+ }""", expectedSource, action, toUp);
}
- private void check_align_horizontal2(String[] expectedSource, String action, boolean toUp)
+ private void check_align_horizontal2(String expectedSource, String action, boolean toUp)
throws Exception {
- check_align2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 20);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(5, 40, 300, 100);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(25, 55, 150, 30);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, expectedSource, action, toUp);
+ check_align2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 20);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(5, 40, 300, 100);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(25, 55, 150, 30);
+ button.setText("111");
+ }
+ }
+ }
+ }""", expectedSource, action, toUp);
}
////////////////////////////////////////////////////////////////////////////
@@ -511,21 +510,21 @@ private void check_align_horizontal2(String[] expectedSource, String action, boo
*/
@Test
public void test_align_top_edges_1a() throws Exception {
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 100, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align top edges", true);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 100, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align top edges", true);
}
/**
@@ -533,21 +532,21 @@ public void test_align_top_edges_1a() throws Exception {
*/
@Test
public void test_align_top_edges_1b() throws Exception {
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 10, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align top edges", false);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 10, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align top edges", false);
}
/**
@@ -555,25 +554,25 @@ public void test_align_top_edges_1b() throws Exception {
*/
@Test
public void test_align_top_edges_2a() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 100, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 95, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align top edges", true);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 100, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 95, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align top edges", true);
}
/**
@@ -581,25 +580,25 @@ public void test_align_top_edges_2a() throws Exception {
*/
@Test
public void test_align_top_edges_2b() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 5, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align top edges", false);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 5, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align top edges", false);
}
/**
@@ -608,21 +607,21 @@ public void test_align_top_edges_2b() throws Exception {
@Test
public void test_align_bottom_edges_1a() throws Exception {
// y2:100 + h2:80 - h1:40 = y1:140
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 140, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align bottom edges", true);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 140, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align bottom edges", true);
}
/**
@@ -631,21 +630,21 @@ public void test_align_bottom_edges_1a() throws Exception {
@Test
public void test_align_bottom_edges_1b() throws Exception {
// y2:100 + h2:80 - h1:40 = y1:140
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, -30, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align bottom edges", false);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, -30, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align bottom edges", false);
}
/**
@@ -653,25 +652,25 @@ public void test_align_bottom_edges_1b() throws Exception {
*/
@Test
public void test_align_bottom_edges_2a() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 140, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 95, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align bottom edges", true);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 140, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 95, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align bottom edges", true);
}
/**
@@ -679,25 +678,25 @@ public void test_align_bottom_edges_2a() throws Exception {
*/
@Test
public void test_align_bottom_edges_2b() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, -35, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align bottom edges", false);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, -35, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align bottom edges", false);
}
/**
@@ -706,21 +705,21 @@ public void test_align_bottom_edges_2b() throws Exception {
@Test
public void test_align_vertical_centers_1a() throws Exception {
// y2:100 + (h2:80 / 2) - (h1:40 / 2) = y1:120
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 120, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align vertical centers", true);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 120, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align vertical centers", true);
}
/**
@@ -729,21 +728,21 @@ public void test_align_vertical_centers_1a() throws Exception {
@Test
public void test_align_vertical_centers_1b() throws Exception {
// y2:100 + (h2:80 / 2) - (h1:40 / 2) = y1:120
- check_align_vertical(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, -10, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Align vertical centers", false);
+ check_align_vertical("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, -10, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Align vertical centers", false);
}
/**
@@ -751,25 +750,25 @@ public void test_align_vertical_centers_1b() throws Exception {
*/
@Test
public void test_align_vertical_centers_2a() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 120, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 95, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align vertical centers", true);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 120, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 95, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align vertical centers", true);
}
/**
@@ -777,67 +776,67 @@ public void test_align_vertical_centers_2a() throws Exception {
*/
@Test
public void test_align_vertical_centers_2b() throws Exception {
- check_align_vertical2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, -15, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, "Align vertical centers", false);
+ check_align_vertical2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, -15, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", "Align vertical centers", false);
}
- private void check_align_vertical(String[] newSource, String action, boolean toUp)
+ private void check_align_vertical(String newSource, String action, boolean toUp)
throws Exception {
- check_align(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, newSource, action, toUp);
+ check_align("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", newSource, action, toUp);
}
- private void check_align_vertical2(String[] newSource, String action, boolean toUp)
+ private void check_align_vertical2(String newSource, String action, boolean toUp)
throws Exception {
- check_align2(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Composite composite = new Composite(this, SWT.NONE);",
- " composite.setBounds(65, 5, 300, 300);",
- " {",
- " Button button = new Button(composite, SWT.NONE);",
- " button.setBounds(5, 95, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- " }",
- "}"}, newSource, action, toUp);
+ check_align2("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Composite composite = new Composite(this, SWT.NONE);
+ composite.setBounds(65, 5, 300, 300);
+ {
+ Button button = new Button(composite, SWT.NONE);
+ button.setBounds(5, 95, 100, 80);
+ button.setText("111");
+ }
+ }
+ }
+ }""", newSource, action, toUp);
}
////////////////////////////////////////////////////////////////////////////
@@ -847,68 +846,68 @@ private void check_align_vertical2(String[] newSource, String action, boolean to
////////////////////////////////////////////////////////////////////////////
@Test
public void test_align_replicate_width() throws Exception {
- check_align(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 100, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Replicate width", true);
+ check_align("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", """
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 100, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Replicate width", true);
}
@Test
public void test_align_replicate_height() throws Exception {
- check_align(new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 40);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, new String[]{
- "class Test extends Shell {",
- " Test() {",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 80);",
- " button.setText(\"000\");",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(70, 100, 100, 80);",
- " button.setText(\"111\");",
- " }",
- " }",
- "}"}, "Replicate height", true);
+ check_align("""
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 40);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", """
+ class Test extends Shell {
+ Test() {
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 80);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(70, 100, 100, 80);
+ button.setText("111");
+ }
+ }
+ }""", "Replicate height", true);
}
////////////////////////////////////////////////////////////////////////////
@@ -921,23 +920,22 @@ public void test_align_replicate_height() throws Exception {
*/
@Test
public void test_align_space_equally_1() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " Test() {",
- " setSize(600, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(30, 90, 100, 70);",
- " button.setText('000');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(40, 200, 50, 30);",
- " button.setText('111');",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ Test() {
+ setSize(600, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(30, 90, 100, 70);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(40, 200, 50, 30);
+ button.setText("111");
+ }
+ }
+ }""");
setupSelectionActions(shell);
shell.refresh();
// prepare selection
@@ -951,22 +949,22 @@ public void test_align_space_equally_1() throws Exception {
findAction(actions, "Space equally, horizontally").run();
findAction(actions, "Space equally, vertically").run();
//
- assertEditor(
- "class Test extends Shell {",
- " Test() {",
- " setSize(600, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(150, 100, 100, 70);",
- " button.setText('000');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(400, 270, 50, 30);",
- " button.setText('111');",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ Test() {
+ setSize(600, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(150, 100, 100, 70);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(400, 270, 50, 30);
+ button.setText("111");
+ }
+ }
+ }""");
}
/**
@@ -974,28 +972,27 @@ public void test_align_space_equally_1() throws Exception {
*/
@Test
public void test_align_space_equally_2() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " Test() {",
- " setSize(400, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 50);",
- " button.setText('000');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(90, 90, 60, 60);",
- " button.setText('111');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(220, 220, 70, 70);",
- " button.setText('222');",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ Test() {
+ setSize(400, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 50);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(90, 90, 60, 60);
+ button.setText("111");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(220, 220, 70, 70);
+ button.setText("222");
+ }
+ }
+ }""");
setupSelectionActions(shell);
shell.refresh();
// prepare selection
@@ -1015,27 +1012,27 @@ public void test_align_space_equally_2() throws Exception {
ReflectionUtils.setField(DesignerPlugin.class, "m_ctrlPressed", false);
}
//
- assertEditor(
- "class Test extends Shell {",
- " Test() {",
- " setSize(400, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 50, 50);",
- " button.setText('000');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(110, 110, 60, 60);",
- " button.setText('111');",
- " }",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(220, 220, 70, 70);",
- " button.setText('222');",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ Test() {
+ setSize(400, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 50, 50);
+ button.setText("000");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(110, 110, 60, 60);
+ button.setText("111");
+ }
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(220, 220, 70, 70);
+ button.setText("222");
+ }
+ }
+ }""");
}
////////////////////////////////////////////////////////////////////////////
@@ -1046,18 +1043,17 @@ public void test_align_space_equally_2() throws Exception {
@Disabled
@Test
public void test_align_center_in_window() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " Test() {",
- " setSize(600, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(10, 10, 60, 40);",
- " button.setText('000');",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ Test() {
+ setSize(600, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(10, 10, 60, 40);
+ button.setText("000");
+ }
+ }
+ }""");
setupSelectionActions(shell);
shell.refresh();
// prepare selection
@@ -1070,17 +1066,17 @@ public void test_align_center_in_window() throws Exception {
findAction(actions, "Center horizontally in window").run();
findAction(actions, "Center vertically in window").run();
//
- assertEditor(
- "class Test extends Shell {",
- " Test() {",
- " setSize(600, 400);",
- " {",
- " Button button = new Button(this, SWT.NONE);",
- " button.setBounds(262, 180, 60, 40);",
- " button.setText('000');",
- " }",
- " }",
- "}");
+ assertEditor("""
+ class Test extends Shell {
+ Test() {
+ setSize(600, 400);
+ {
+ Button button = new Button(this, SWT.NONE);
+ button.setBounds(262, 180, 60, 40);
+ button.setText("000");
+ }
+ }
+ }""");
}
////////////////////////////////////////////////////////////////////////////
@@ -1090,27 +1086,26 @@ public void test_align_center_in_window() throws Exception {
////////////////////////////////////////////////////////////////////////////
@Test
public void test_ScrolledComposite_onWayToRoot() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "class Test extends Shell {",
- " public Test() {",
- " ScrolledComposite scrolledComposite = new ScrolledComposite(this, SWT.NONE);",
- " {",
- " Composite composite = new Composite(scrolledComposite, SWT.NONE);",
- " composite.setLayout(null);",
- " {",
- " Button button_1 = new Button(composite, SWT.NONE);",
- " button_1.setBounds(10, 10, 100, 20);",
- " }",
- " {",
- " Button button_2 = new Button(composite, SWT.NONE);",
- " button_2.setBounds(20, 100, 100, 20);",
- " }",
- " scrolledComposite.setContent(composite);",
- " scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));",
- " }",
- " }",
- "}");
+ CompositeInfo shell = parseComposite("""
+ class Test extends Shell {
+ public Test() {
+ ScrolledComposite scrolledComposite = new ScrolledComposite(this, SWT.NONE);
+ {
+ Composite composite = new Composite(scrolledComposite, SWT.NONE);
+ composite.setLayout(null);
+ {
+ Button button_1 = new Button(composite, SWT.NONE);
+ button_1.setBounds(10, 10, 100, 20);
+ }
+ {
+ Button button_2 = new Button(composite, SWT.NONE);
+ button_2.setBounds(20, 100, 100, 20);
+ }
+ scrolledComposite.setContent(composite);
+ scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+ }
+ }""");
shell.refresh();
//
// prepare selection
@@ -1136,8 +1131,8 @@ public void test_ScrolledComposite_onWayToRoot() throws Exception {
// Utils
//
////////////////////////////////////////////////////////////////////////////
- private void check_align(String[] initialSource,
- String[] expectedSource,
+ private void check_align(String initialSource,
+ String expectedSource,
String action,
boolean toUp) throws Exception {
CompositeInfo shell = parseComposite(initialSource);
@@ -1161,8 +1156,8 @@ private void check_align(String[] initialSource,
assertEditor(expectedSource);
}
- private void check_align2(String[] initialSource,
- String[] expectedSource,
+ private void check_align2(String initialSource,
+ String expectedSource,
String action,
boolean toUp) throws Exception {
CompositeInfo shell = parseComposite(initialSource);
diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutTest.java
index dfab5748d..4cbf3811d 100644
--- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutTest.java
+++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2025 Google, Inc. and others.
+ * Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
@@ -104,24 +104,23 @@ public void _test_exit() throws Exception {
*/
@Test
public void test_invalidAbsoluteLayoutToolkit() throws Exception {
- CompositeInfo shell =
- parseComposite(
- "public class Test {",
- " /**",
- " * @wbp.nonvisual location=571,523",
- " */",
- " private static final Object myStaticBean = new java.util.ArrayList