diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/DesignerPluginTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/DesignerPluginTest.java index f14b4eadde..31e3b9343d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/DesignerPluginTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/DesignerPluginTest.java @@ -56,15 +56,12 @@ public void test_getDefault() { public void test_log_message() { final String message = "Information message"; ILog log = DesignerPlugin.getDefault().getLog(); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - assertEquals(IStatus.INFO, status.getSeverity()); - assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); - assertEquals(IStatus.INFO, status.getCode()); - assertEquals(message, status.getMessage()); - assertNull(status.getException()); - } + ILogListener logListener = (status, plugin) -> { + assertEquals(IStatus.INFO, status.getSeverity()); + assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); + assertEquals(IStatus.INFO, status.getCode()); + assertEquals(message, status.getMessage()); + assertNull(status.getException()); }; // try { @@ -79,14 +76,11 @@ public void logging(IStatus status, String plugin) { public void test_log_Exception() { final Exception exception = new Exception(); ILog log = DesignerPlugin.getDefault().getLog(); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - assertEquals(IStatus.ERROR, status.getSeverity()); - assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); - assertEquals(IStatus.ERROR, status.getCode()); - assertSame(exception, status.getException()); - } + ILogListener logListener = (status, plugin) -> { + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); + assertEquals(IStatus.ERROR, status.getCode()); + assertSame(exception, status.getException()); }; // try { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/TestProject.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/TestProject.java index 548f69f6db..a04cfb5419 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/TestProject.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/TestProject.java @@ -19,8 +19,6 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourceAttributes; import org.eclipse.core.resources.ResourcesPlugin; @@ -389,18 +387,15 @@ public static void waitForAutoBuild() { */ private void clearReadOnlyFlag() throws CoreException { if (m_project.isOpen()) { - m_project.accept(new IResourceVisitor() { - @Override - public boolean visit(IResource resource) throws CoreException { - if (resource instanceof IFile file) { - ResourceAttributes resourceAttributes = file.getResourceAttributes(); - if (resourceAttributes != null) { - resourceAttributes.setReadOnly(false); - file.setResourceAttributes(resourceAttributes); - } + m_project.accept(resource -> { + if (resource instanceof IFile file) { + ResourceAttributes resourceAttributes = file.getResourceAttributes(); + if (resourceAttributes != null) { + resourceAttributes.setReadOnly(false); + file.setResourceAttributes(resourceAttributes); } - return true; } + return true; }); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/eval/ExecutionFlowUtilsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/eval/ExecutionFlowUtilsTest.java index 6b8b98d1ef..d2c5e2516f 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/eval/ExecutionFlowUtilsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/eval/ExecutionFlowUtilsTest.java @@ -930,14 +930,7 @@ public void test_visit_AnonymousClassDeclaration_withInvocation_doVisit(String r @Test public void test_findLastAssignment_variable() throws Exception { String code = "void root() {int value = 0; System.out.println(value);}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0); - } - }); + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0)); } /** @@ -1001,68 +994,33 @@ void root() { @Test public void test_findLastAssignment_variable_reassign() throws Exception { String code = "void root() {int value = 0; value = 1; System.out.println(value);}"; - check_findLastAssignment(code, 2, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return ((ExpressionStatement) statements[1]).getExpression(); - } - }); + check_findLastAssignment(code, 2, (typeDeclaration, methodDeclaration, statements) -> ((ExpressionStatement) statements[1]).getExpression()); } @Test public void test_findLastAssignment_variable_reassign2() throws Exception { String code = "void root() {int value; value = 0; System.out.println(value); value = 1; System.out.println(value);}"; - check_findLastAssignment(code, 4, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return ((ExpressionStatement) statements[3]).getExpression(); - } - }); + check_findLastAssignment(code, 4, (typeDeclaration, methodDeclaration, statements) -> ((ExpressionStatement) statements[3]).getExpression()); } @Test public void test_findLastAssignment_variable_reassign_later() throws Exception { String code = "void root() {int value = 0; System.out.println(value); value = 1;}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0); - } - }); + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0)); } @Test public void test_findLastAssignment_variable_sameInDifferentMethod() throws Exception { String code = "void root() {int value = 0; foo(); System.out.println(value);} void foo() {int value = 1;}"; - check_findLastAssignment(code, 2, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0); - } - }); + check_findLastAssignment(code, 2, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0)); } @Test public void test_findLastAssignment_FieldDeclaration() throws Exception { String code = "int value = 0; void root() {System.out.println(value);}"; - check_findLastAssignment(code, 0, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) typeDeclaration.getFields()[0].fragments().get(0); - } - }); + check_findLastAssignment(code, 0, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) typeDeclaration.getFields()[0].fragments().get(0)); } /** @@ -1181,42 +1139,22 @@ public void test_findLastAssignment_FieldDeclaration_noValue() throws Exception @Test public void test_findLastAssignment_FieldDeclaration_variable_thisMethod() throws Exception { String code = "int value = 0; void root() {int value = 1; System.out.println(value);}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0); - } - }); + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) ((VariableDeclarationStatement) statements[0]).fragments().get(0)); } @Test public void test_findLastAssignment_FieldDeclaration_reassign_thisMethod() throws Exception { String code = "int value = 0; void root() {value = 1; System.out.println(value);}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return ((ExpressionStatement) statements[0]).getExpression(); - } - }); + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> ((ExpressionStatement) statements[0]).getExpression()); } @Test public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod() throws Exception { String code = "int value = 0; void root() {foo(); System.out.println(value);} void foo() {value = 1;}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - Statement statement = - (Statement) typeDeclaration.getMethods()[1].getBody().statements().get(0); - return ((ExpressionStatement) statement).getExpression(); - } + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> { + Statement statement = (Statement) typeDeclaration.getMethods()[1].getBody().statements().get(0); + return ((ExpressionStatement) statement).getExpression(); }); } @@ -1224,55 +1162,27 @@ public ASTNode getExpected(TypeDeclaration typeDeclaration, public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod2() throws Exception { String code = "int value = 0; void root() {System.out.println(value); foo();} void foo() {value = 1;}"; - check_findLastAssignment(code, 0, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) typeDeclaration.getFields()[0].fragments().get(0); - } - }); + check_findLastAssignment(code, 0, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) typeDeclaration.getFields()[0].fragments().get(0)); } @Test public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod3() throws Exception { String code = "int value = 0; void foo() {value = 1;} void root() {System.out.println(value); foo();}"; - check_findLastAssignment(code, 0, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) typeDeclaration.getFields()[0].fragments().get(0); - } - }); + check_findLastAssignment(code, 0, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) typeDeclaration.getFields()[0].fragments().get(0)); } @Test public void test_findLastAssignment_FieldDeclaration_reassign_otherMethod4() throws Exception { String code = "int value = 0; void root() {foo(); System.out.println(value);} void foo() {int value = 1;}"; - check_findLastAssignment(code, 1, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) typeDeclaration.getFields()[0].fragments().get(0); - } - }); + check_findLastAssignment(code, 1, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) typeDeclaration.getFields()[0].fragments().get(0)); } @Test public void test_findLastAssignment_parameters() throws Exception { String code = "void root(int value) {System.out.println(value);}"; - check_findLastAssignment(code, "root(int)", 0, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) methodDeclaration.parameters().get(0); - } - }); + check_findLastAssignment(code, "root(int)", 0, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) methodDeclaration.parameters().get(0)); } @Test @@ -1320,14 +1230,7 @@ public void foo(int value) { @Test public void test_findLastAssignment_parameters_hide_field() throws Exception { String code = "int value = 1; void root(int value) {System.out.println(value);}"; - check_findLastAssignment(code, "root(int)", 0, new I_findLastAssignment() { - @Override - public ASTNode getExpected(TypeDeclaration typeDeclaration, - MethodDeclaration methodDeclaration, - Statement[] statements) { - return (ASTNode) methodDeclaration.parameters().get(0); - } - }); + check_findLastAssignment(code, "root(int)", 0, (typeDeclaration, methodDeclaration, statements) -> (ASTNode) methodDeclaration.parameters().get(0)); } /** diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/DefaultObjectPresentationTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/DefaultObjectPresentationTest.java index de5e2fa4ba..644ef39ddf 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/DefaultObjectPresentationTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/DefaultObjectPresentationTest.java @@ -54,12 +54,9 @@ public void test_getChildrenTree() throws Exception { parent.addChild(child_2); parent.addChild(child_3); // filter out "child_2" from "tree children" - parent.addBroadcastListener(new ObjectInfoChildTree() { - @Override - public void invoke(ObjectInfo object, boolean[] visible) throws Exception { - if (object == child_2) { - visible[0] = false; - } + parent.addBroadcastListener((ObjectInfoChildTree) (object, visible) -> { + if (object == child_2) { + visible[0] = false; } }); // check "tree children" @@ -84,12 +81,9 @@ public void test_getChildrenTree_childrenBroadcast() throws Exception { parent.addChild(child_2); parent.addChild(child_3); // move "child_1" to the end - parent.addBroadcastListener(new ObjectInfoChildrenTree() { - @Override - public void invoke(ObjectInfo p, List children) throws Exception { - children.remove(child_1); - children.add(child_1); - } + parent.addBroadcastListener((ObjectInfoChildrenTree) (p, children) -> { + children.remove(child_1); + children.add(child_1); }); // check "tree children" List children = parent.getPresentation().getChildrenTree(); @@ -109,12 +103,9 @@ public void test_getChildrenGraphical() throws Exception { parent.addChild(child_2); parent.addChild(child_3); // filter out "child_2" from "graphical children" - parent.addBroadcastListener(new ObjectInfoChildGraphical() { - @Override - public void invoke(ObjectInfo object, boolean[] visible) throws Exception { - if (object == child_2) { - visible[0] = false; - } + parent.addBroadcastListener((ObjectInfoChildGraphical) (object, visible) -> { + if (object == child_2) { + visible[0] = false; } }); // check "graphical children" @@ -139,12 +130,9 @@ public void test_getChildrenGraphical_childrenBroadcast() throws Exception { parent.addChild(child_2); parent.addChild(child_3); // move "child_1" to the end - parent.addBroadcastListener(new ObjectInfoChildrenGraphical() { - @Override - public void invoke(List children) throws Exception { - children.remove(child_1); - children.add(child_1); - } + parent.addBroadcastListener((ObjectInfoChildrenGraphical) children -> { + children.remove(child_1); + children.add(child_1); }); // check "graphical children" List children = parent.getPresentation().getChildrenGraphical(); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/JavaInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/JavaInfoTest.java index 6572c039ed..e5e4baeedc 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/JavaInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/JavaInfoTest.java @@ -524,15 +524,11 @@ public void test_setVariableBroadcast() throws Exception { } // final AtomicInteger count = new AtomicInteger(); - button.addBroadcastListener(new JavaInfoSetVariable() { - @Override - public void invoke(JavaInfo javaInfo, VariableSupport oldVariable, VariableSupport newVariable) - throws Exception { - assertSame(button, javaInfo); - assertSame(expected_oldVariable, oldVariable); - assertSame(expected_newVariable, newVariable); - count.incrementAndGet(); - } + button.addBroadcastListener((JavaInfoSetVariable) (javaInfo, oldVariable, newVariable) -> { + assertSame(button, javaInfo); + assertSame(expected_oldVariable, oldVariable); + assertSame(expected_newVariable, newVariable); + count.incrementAndGet(); }); button.setVariableSupport(expected_newVariable); assertEquals(1, count.get()); @@ -1438,12 +1434,9 @@ public void test_getProperties_allProperties() throws Exception { // initially "panel" has properties Assertions.assertThat(panel.getProperties()).isNotEmpty(); // add allProperties() listener - panel.addBroadcastListener(new ObjectInfoAllProperties() { - @Override - public void invoke(ObjectInfo object, List properties) throws Exception { - if (object == panel) { - properties.clear(); - } + panel.addBroadcastListener((ObjectInfoAllProperties) (object, properties) -> { + if (object == panel) { + properties.clear(); } }); Assertions.assertThat(panel.getProperties()).isEmpty(); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/ObjectInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/ObjectInfoTest.java index 05413803b3..ee890ef37d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/ObjectInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/ObjectInfoTest.java @@ -79,12 +79,7 @@ protected List getPropertyList() throws Exception { // initially has property Assertions.assertThat(object.getProperties()).containsOnly(someProperty); // add broadcast to remove all properties - object.addBroadcastListener(new ObjectInfoAllProperties() { - @Override - public void invoke(ObjectInfo o, List properties) throws Exception { - properties.clear(); - } - }); + object.addBroadcastListener((ObjectInfoAllProperties) (o, properties) -> properties.clear()); Assertions.assertThat(object.getProperties()).isEmpty(); } @@ -362,18 +357,8 @@ public void test_addChild_1() throws Exception { ObjectInfo child_2 = new TestObjectInfo("child_2"); // add listener final StringBuffer buffer = new StringBuffer(); - parent.addBroadcastListener(new ObjectInfoChildAddBefore() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) { - buffer.append("childAddBefore " + _parent + " " + _child + "\n"); - } - }); - parent.addBroadcastListener(new ObjectInfoChildAddAfter() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child) { - buffer.append("childAddAfter " + _parent + " " + _child + "\n"); - } - }); + parent.addBroadcastListener((ObjectInfoChildAddBefore) (_parent, _child, nextChild) -> buffer.append("childAddBefore " + _parent + " " + _child + "\n")); + parent.addBroadcastListener((ObjectInfoChildAddAfter) (_parent, _child) -> buffer.append("childAddAfter " + _parent + " " + _child + "\n")); // build hierarchy parent.addChild(child_1); parent.addChild(child_2); @@ -683,18 +668,8 @@ public void test_broadcast() throws Exception { TestObjectInfo child_2 = new TestObjectInfo("child_2"); // add listener final StringBuffer buffer = new StringBuffer(); - parent.addBroadcastListener(new ObjectInfoChildAddBefore() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) { - buffer.append("childAddBefore " + _parent + " " + _child + "\n"); - } - }); - parent.addBroadcastListener(new ObjectInfoChildAddAfter() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child) { - buffer.append("childAddAfter " + _parent + " " + _child + "\n"); - } - }); + parent.addBroadcastListener((ObjectInfoChildAddBefore) (_parent, _child, nextChild) -> buffer.append("childAddBefore " + _parent + " " + _child + "\n")); + parent.addBroadcastListener((ObjectInfoChildAddAfter) (_parent, _child) -> buffer.append("childAddAfter " + _parent + " " + _child + "\n")); ObjectEventListener listener = new ObjectEventListener() { @Override public void childRemoveBefore(ObjectInfo _parent, ObjectInfo _child) throws Exception { @@ -731,12 +706,7 @@ public void test_broadcast_duplicate() throws Exception { TestObjectInfo child = new TestObjectInfo("child"); // add listener (2 times!) final StringBuffer buffer = new StringBuffer(); - ObjectInfoChildAddBefore listener = new ObjectInfoChildAddBefore() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) { - buffer.append("childAddBefore " + _parent + " " + _child + "\n"); - } - }; + ObjectInfoChildAddBefore listener = (_parent, _child, nextChild) -> buffer.append("childAddBefore " + _parent + " " + _child + "\n"); parent.addBroadcastListener(listener); parent.addBroadcastListener(listener); // do operations, only one record expected @@ -831,12 +801,9 @@ public void test_addChild_otherNext() throws Exception { parent.addChild(child_1, null); parent.addChild(child_2, null); // add listener for re-targeting, instead of "last" add as "first" - ObjectInfoChildAddBefore listener = new ObjectInfoChildAddBefore() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) { - if (nextChild[0] == null) { - nextChild[0] = child_1; - } + ObjectInfoChildAddBefore listener = (_parent, _child, nextChild) -> { + if (nextChild[0] == null) { + nextChild[0] = child_1; } }; parent.addBroadcastListener(listener); @@ -862,12 +829,7 @@ public void test_broadcast_targetBroadcastListener() throws Exception { // add child and listener (bound to child) parent.addChild(child); final StringBuffer buffer = new StringBuffer(); - ObjectInfoChildAddBefore listener = new ObjectInfoChildAddBefore() { - @Override - public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) { - buffer.append("childAddBefore " + _parent + " " + _child + "\n"); - } - }; + ObjectInfoChildAddBefore listener = (_parent, _child, nextChild) -> buffer.append("childAddBefore " + _parent + " " + _child + "\n"); child.addBroadcastListener(listener); // re-target listener to "parent" child.targetBroadcastListener(parent); @@ -896,12 +858,7 @@ public void test_broadcast_interface() throws Exception { TestObjectInfo parent = new TestObjectInfo("parent"); // add listener final StringBuffer buffer = new StringBuffer(); - BroadcastTestInterface listener = new BroadcastTestInterface() { - @Override - public void invoke() { - buffer.append("invoke"); - } - }; + BroadcastTestInterface listener = () -> buffer.append("invoke"); parent.addBroadcastListener(listener); // send broadcast parent.getBroadcast(BroadcastTestInterface.class).invoke(); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/creation/ConstructorCreationSupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/creation/ConstructorCreationSupportTest.java index 8980d553d2..0f24169faa 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/creation/ConstructorCreationSupportTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/creation/ConstructorCreationSupportTest.java @@ -664,12 +664,7 @@ public void test_clipboard_typeArguments() throws Exception { // do copy/paste { ComponentInfo button = getJavaInfoByName("button"); - doCopyPaste(button, new PasteProcedure() { - @Override - public void run(ComponentInfo copy) throws Exception { - ((FlowLayoutInfo) panel.getLayout()).add(copy, null); - } - }); + doCopyPaste(button, copy -> ((FlowLayoutInfo) panel.getLayout()).add(copy, null)); assertEditor( "public class Test extends JPanel {", " public Test() {", @@ -726,12 +721,7 @@ public void test_clipboard_anonymousClassDeclaration() throws Exception { // do copy/paste { ComponentInfo button = getJavaInfoByName("button"); - doCopyPaste(button, new PasteProcedure() { - @Override - public void run(ComponentInfo copy) throws Exception { - ((FlowLayoutInfo) panel.getLayout()).add(copy, null); - } - }); + doCopyPaste(button, copy -> ((FlowLayoutInfo) panel.getLayout()).add(copy, null)); assertEditor( "public class Test extends JPanel {", " public Test() {", diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/SwingParserTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/SwingParserTest.java index 4913ec2047..b57d4ddade 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/SwingParserTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/SwingParserTest.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.wb.tests.designer.core.model.parser; -import org.eclipse.wb.core.model.JavaInfo; import org.eclipse.wb.core.model.association.RootAssociation; import org.eclipse.wb.core.model.broadcast.JavaInfoSetObjectAfter; import org.eclipse.wb.internal.core.eval.evaluators.AnonymousEvaluationError; @@ -541,12 +540,9 @@ public static void main(String[] args) { assertTrue(panel.getChildrenJava().get(1) instanceof ContainerInfo); // check that JavaEventListener works final boolean objectWasSet[] = new boolean[1]; - panel.addBroadcastListener(new JavaInfoSetObjectAfter() { - @Override - public void invoke(JavaInfo target, Object o) throws Exception { - if (target == panel) { - objectWasSet[0] = true; - } + panel.addBroadcastListener((JavaInfoSetObjectAfter) (target, o) -> { + if (target == panel) { + objectWasSet[0] = true; } }); // check creation diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java index 649fe5b03c..b7d1065f66 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/EventsPropertyTest.java @@ -47,8 +47,6 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -430,17 +428,9 @@ private void onButton_keyPressed(KeyEvent e) { * Deletes value of given {@link Property} and clicks "OK" in confirmation dialog. */ private static void deleteEventPropertyWithGUI(final Property property) throws Exception { - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - property.setValue(Property.UNKNOWN_VALUE); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Confirm").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> property.setValue(Property.UNKNOWN_VALUE), bot -> { + SWTBot shell = bot.shell("Confirm").bot(); + shell.button("OK").click(); }); } @@ -502,17 +492,9 @@ public void keyPressed(KeyEvent e) { final Property keyPressedProperty = getEventsListenerMethod(panel, "key", "pressed"); String expectedSource = m_lastEditor.getSource(); // press "Cancel", so don't delete - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - keyPressedProperty.setValue(Property.UNKNOWN_VALUE); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Confirm").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> keyPressedProperty.setValue(Property.UNKNOWN_VALUE), bot -> { + SWTBot shell = bot.shell("Confirm").bot(); + shell.button("Cancel").click(); }); // no change expected assertEditor(expectedSource, m_lastEditor); @@ -858,18 +840,10 @@ public Test() { private static void deleteInnerListener_twoUsages(final Property property, final String multiButton) throws Exception { - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - property.setValue(Property.UNKNOWN_VALUE); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Confirm").bot(); - shell.button("OK").click(); - bot.shell("Confirm").bot().button(multiButton).click(); - } + new UiContext().executeAndCheck(() -> property.setValue(Property.UNKNOWN_VALUE), bot -> { + SWTBot shell = bot.shell("Confirm").bot(); + shell.button("OK").click(); + bot.shell("Confirm").bot().button(multiButton).click(); }); } @@ -1902,12 +1876,7 @@ public Test() { DesignPageSite.Helper.setSite(panel, DesignPageSite.EMPTY); // final AtomicReference broSpec = new AtomicReference<>(); - panel.addBroadcastListener(new JavaInfoEventOpen() { - @Override - public void invoke(JavaInfo javaInfo, String spec) throws Exception { - broSpec.set(spec); - } - }); + panel.addBroadcastListener((JavaInfoEventOpen) (javaInfo, spec) -> broSpec.set(spec)); // call open() EventsProperty eventsProperty = (EventsProperty) panel.getPropertyByTitle("Events"); eventsProperty.openStubMethod(name); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/ExposePropertySupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/ExposePropertySupportTest.java index 43b3c99be7..3fee3825c7 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/ExposePropertySupportTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/ExposePropertySupportTest.java @@ -32,8 +32,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -396,40 +394,32 @@ public Test() { // prepare action final IAction action = getExposeAction(button, "text"); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Expose property").bot(); + // prepare widgets + SWTBotText textWidget = shell.textWithLabel("Property name:"); + SWTBotStyledText previewWidget = bot.styledTextWithLabel("Preview:"); + SWTBotButton okButton = shell.button("OK"); + // initial state + { + assertEquals("buttonText", textWidget.getText()); + Assertions.assertThat(previewWidget.getText()).contains("getButtonText()"); + assertTrue(okButton.isEnabled()); } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Expose property").bot(); - // prepare widgets - SWTBotText textWidget = shell.textWithLabel("Property name:"); - SWTBotStyledText previewWidget = bot.styledTextWithLabel("Preview:"); - SWTBotButton okButton = shell.button("OK"); - // initial state - { - assertEquals("buttonText", textWidget.getText()); - Assertions.assertThat(previewWidget.getText()).contains("getButtonText()"); - assertTrue(okButton.isEnabled()); - } - // set wrong property name - { - textWidget.setText("wrong name"); - assertEquals(previewWidget.getText(), "No preview"); - assertFalse(okButton.isEnabled()); - } - // set good name again - { - textWidget.setText("myText"); - Assertions.assertThat(previewWidget.getText()).contains("getMyText()"); - assertTrue(okButton.isEnabled()); - } - // OK - okButton.click(); + // set wrong property name + { + textWidget.setText("wrong name"); + assertEquals(previewWidget.getText(), "No preview"); + assertFalse(okButton.isEnabled()); } + // set good name again + { + textWidget.setText("myText"); + Assertions.assertThat(previewWidget.getText()).contains("getMyText()"); + assertTrue(okButton.isEnabled()); + } + // OK + okButton.click(); }); assertEditor(""" public class Test extends JPanel { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyCategoryProvidersTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyCategoryProvidersTest.java index 393c89031d..8db3bc4ba6 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyCategoryProvidersTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyCategoryProvidersTest.java @@ -110,14 +110,11 @@ public void test_combine_empty() throws Exception { */ @Test public void test_combine_atLeastNormal() throws Exception { - PropertyCategoryProvider atLeastNormal = new PropertyCategoryProvider() { - @Override - public PropertyCategory getCategory(Property property) { - if (property.getCategory() == PropertyCategory.ADVANCED) { - return PropertyCategory.NORMAL; - } - return null; + PropertyCategoryProvider atLeastNormal = property -> { + if (property.getCategory() == PropertyCategory.ADVANCED) { + return PropertyCategory.NORMAL; } + return null; }; PropertyCategoryProvider provider = PropertyCategoryProviders.combine(atLeastNormal, PropertyCategoryProviders.fromProperty()); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyTest.java index 2e0154dc2c..daff5ebb03 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/PropertyTest.java @@ -506,13 +506,7 @@ public Test() { }"""); Property enabledProperty = panel.getPropertyByTitle("enabled"); // add listener that prevents "enabled" modification - panel.addBroadcastListener(new GenericPropertySetValue() { - @Override - public void invoke(GenericPropertyImpl property, Object[] value, boolean[] shouldSetValue) - throws Exception { - shouldSetValue[0] &= !"enabled".equals(property.getTitle()); - } - }); + panel.addBroadcastListener((GenericPropertySetValue) (property, value, shouldSetValue) -> shouldSetValue[0] &= !"enabled".equals(property.getTitle())); // try to set value enabledProperty.setValue(Boolean.FALSE); assertEditor(""" @@ -538,13 +532,9 @@ public Test() { }"""); Property enabledProperty = panel.getPropertyByTitle("enabled"); // add listener that on "enabled" modification modifies also "visible" - panel.addBroadcastListener(new GenericPropertySetValue() { - @Override - public void invoke(GenericPropertyImpl property, Object[] value, boolean[] shouldSetValue) - throws Exception { - if ("enabled".equals(property.getTitle())) { - property.getJavaInfo().getPropertyByTitle("visible").setValue(value[0]); - } + panel.addBroadcastListener((GenericPropertySetValue) (property, value, shouldSetValue) -> { + if ("enabled".equals(property.getTitle())) { + property.getJavaInfo().getPropertyByTitle("visible").setValue(value[0]); } }); // try to set value @@ -676,13 +666,9 @@ public Test() { // initially normal, boolean value assertEquals(Boolean.TRUE, enabledProperty.getValue()); // add listener that forces "enabled" value - panel.addBroadcastListener(new GenericPropertyGetValueEx() { - @Override - public void invoke(GenericPropertyImpl property, Expression expression, Object[] value) - throws Exception { - if (property == enabledProperty) { - value[0] = "String, not boolean"; - } + panel.addBroadcastListener((GenericPropertyGetValueEx) (property, expression, value) -> { + if (property == enabledProperty) { + value[0] = "String, not boolean"; } }); // ask for value @@ -707,13 +693,10 @@ public Test() { // initially normal, boolean value assertEquals(Boolean.TRUE, enabledProperty.getValue()); // add listener that forces "enabled" value - panel.addBroadcastListener(new GenericPropertyGetValue() { - @Override - public void invoke(GenericPropertyImpl property, Object[] value) throws Exception { - if (property == enabledProperty) { - assertSame(Property.UNKNOWN_VALUE, value[0]); - value[0] = "String, not boolean"; - } + panel.addBroadcastListener((GenericPropertyGetValue) (property, value) -> { + if (property == enabledProperty) { + assertSame(Property.UNKNOWN_VALUE, value[0]); + value[0] = "String, not boolean"; } }); // ask for value @@ -738,13 +721,10 @@ public Test() { // initially normal, boolean value assertEquals(Boolean.TRUE, enabledProperty.getValue()); // add listener that forces "enabled" value - panel.addBroadcastListener(new GenericPropertyGetValue() { - @Override - public void invoke(GenericPropertyImpl property, Object[] value) throws Exception { - if (property == enabledProperty) { - assertSame(Property.UNKNOWN_VALUE, value[0]); - value[0] = null; - } + panel.addBroadcastListener((GenericPropertyGetValue) (property, value) -> { + if (property == enabledProperty) { + assertSame(Property.UNKNOWN_VALUE, value[0]); + value[0] = null; } }); // ask for value diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ByteObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ByteObjectPropertyEditorTest.java index ae81d56a81..6816f882db 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ByteObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ByteObjectPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -185,17 +183,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notByte"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notByte"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/DoubleObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/DoubleObjectPropertyEditorTest.java index ff75e0a7fe..561ebade8b 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/DoubleObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/DoubleObjectPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -185,17 +183,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notDouble"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notDouble"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InnerClassPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InnerClassPropertyEditorTest.java index c4c7cd11fe..5fb5ffd311 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InnerClassPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InnerClassPropertyEditorTest.java @@ -22,14 +22,10 @@ import org.eclipse.wb.tests.designer.swing.SwingModelTest; import org.eclipse.wb.tests.gef.UiContext; -import org.eclipse.swtbot.swt.finder.SWTBot; - import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -135,17 +131,7 @@ public Test() { // use GUI to set "ExternalLabelProvider" { // open dialog and animate it - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "ExternalLabelPro", "OK"); - } - }); + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> animateOpenTypeSelection(bot, "ExternalLabelPro", "OK")); // check source assertEditor(""" public class Test extends JPanel { @@ -192,18 +178,10 @@ public Test() { // use GUI to set "ExternalLabelProvider" { // open dialog and animate it - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "AbstractLabelPro", "OK"); - // shows Error, close it - bot.shell("Error").bot().button("OK").click(); - } + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> { + animateOpenTypeSelection(bot, "AbstractLabelPro", "OK"); + // shows Error, close it + bot.shell("Error").bot().button("OK").click(); }); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InstanceObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InstanceObjectPropertyEditorTest.java index 48e151e1db..10119b2934 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InstanceObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/InstanceObjectPropertyEditorTest.java @@ -22,10 +22,6 @@ import org.eclipse.wb.tests.designer.swing.SwingModelTest; import org.eclipse.wb.tests.gef.UiContext; -import org.eclipse.swtbot.swt.finder.SWTBot; - -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -161,17 +157,7 @@ public Test() { // use GUI to set "ExternalLabelProvider" { // open dialog and animate it - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "JButton", "OK"); - } - }); + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> animateOpenTypeSelection(bot, "JButton", "OK")); // check source assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerArrayPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerArrayPropertyEditorTest.java index b62ee18054..12468fd5f7 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerArrayPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerArrayPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -156,17 +154,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notInteger"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notInteger"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerObjectPropertyEditorTest.java index 6fda92e2df..71b8d666fd 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerObjectPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -185,17 +183,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notInteger"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notInteger"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerPropertyEditorTest.java index 916fe4a926..e44971bf76 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/IntegerPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -156,17 +154,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notInteger"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notInteger"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/LongObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/LongObjectPropertyEditorTest.java index e49c8b3b4c..7e90429fd2 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/LongObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/LongObjectPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -185,17 +183,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notLong"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notLong"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ObjectPropertyEditorTest.java index 9a59663079..7f9b6708dd 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ObjectPropertyEditorTest.java @@ -31,8 +31,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -113,44 +111,36 @@ public Test() { final PropertyEditor propertyEditor = property.getEditor(); assertSame(propertyEditor, ObjectPropertyEditor.INSTANCE); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> { + SWTBot shell = bot.shell("value").bot(); + SWTBotTreeItem panelItem = shell.tree().expandNode("(javax.swing.JPanel)"); + SWTBotButton okButton = shell.button("OK"); + // initially "panel" selected, so invalid + assertFalse(okButton.isEnabled()); + // prepare "non-visual beans" item + SWTBotTreeItem beansContainer; + { + SWTBotTreeItem[] childItems = panelItem.getItems(); + Assertions.assertThat(childItems).hasSize(1); + assertEquals("(non-visual beans)", childItems[0].getText()); + beansContainer = childItems[0]; } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("value").bot(); - SWTBotTreeItem panelItem = shell.tree().expandNode("(javax.swing.JPanel)"); - SWTBotButton okButton = shell.button("OK"); - // initially "panel" selected, so invalid - assertFalse(okButton.isEnabled()); - // prepare "non-visual beans" item - SWTBotTreeItem beansContainer; - { - SWTBotTreeItem[] childItems = panelItem.getItems(); - Assertions.assertThat(childItems).hasSize(1); - assertEquals("(non-visual beans)", childItems[0].getText()); - beansContainer = childItems[0]; - } - // prepare "object_1" - SWTBotTreeItem myObjectItem; - { - SWTBotTreeItem[] beanItems = beansContainer.getItems(); - Assertions.assertThat(beanItems).hasSize(1); - assertEquals("object_1", beanItems[0].getText()); - myObjectItem = beanItems[0]; - } - // container - invalid - beansContainer.select(); - assertFalse(okButton.isEnabled()); - // "object_1" - valid - myObjectItem.select(); - assertTrue(okButton.isEnabled()); - // click OK - okButton.click(); + // prepare "object_1" + SWTBotTreeItem myObjectItem; + { + SWTBotTreeItem[] beanItems = beansContainer.getItems(); + Assertions.assertThat(beanItems).hasSize(1); + assertEquals("object_1", beanItems[0].getText()); + myObjectItem = beanItems[0]; } + // container - invalid + beansContainer.select(); + assertFalse(okButton.isEnabled()); + // "object_1" - valid + myObjectItem.select(); + assertTrue(okButton.isEnabled()); + // click OK + okButton.click(); }); // check assertEditor(""" @@ -204,29 +194,21 @@ public Test() { final PropertyEditor propertyEditor = property.getEditor(); assertSame(propertyEditor, ObjectPropertyEditor.INSTANCE); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("button").bot(); - SWTBotTreeItem panelItem = shell.tree().expandNode("(javax.swing.JPanel)"); - SWTBotButton okButton = shell.button("OK"); - // initially "panel" selected, so invalid - assertFalse(okButton.isEnabled()); - // prepare items - SWTBotTreeItem[] childItems = panelItem.getItems(); - Assertions.assertThat(childItems).hasSize(1); - assertEquals("button", childItems[0].getText()); - // JButton - valid - childItems[0].click(); - assertTrue(okButton.isEnabled()); - // click OK - okButton.click(); - } + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> { + SWTBot shell = bot.shell("button").bot(); + SWTBotTreeItem panelItem = shell.tree().expandNode("(javax.swing.JPanel)"); + SWTBotButton okButton = shell.button("OK"); + // initially "panel" selected, so invalid + assertFalse(okButton.isEnabled()); + // prepare items + SWTBotTreeItem[] childItems = panelItem.getItems(); + Assertions.assertThat(childItems).hasSize(1); + assertEquals("button", childItems[0].getText()); + // JButton - valid + childItems[0].click(); + assertTrue(okButton.isEnabled()); + // click OK + okButton.click(); }); // check assertEditor(""" @@ -276,21 +258,13 @@ public Test() { final PropertyEditor propertyEditor = property.getEditor(); assertSame(propertyEditor, ObjectPropertyEditor.INSTANCE); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("button").bot(); - // "button_2" is selected - TableCollection selection = shell.tree().selection(); - assertEquals(selection.rowCount(), 1); - assertEquals(selection.get(0, 0), "button_2"); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> { + SWTBot shell = bot.shell("button").bot(); + // "button_2" is selected + TableCollection selection = shell.tree().selection(); + assertEquals(selection.rowCount(), 1); + assertEquals(selection.get(0, 0), "button_2"); + shell.button("Cancel").click(); }); } @@ -376,17 +350,9 @@ public Test() { final PropertyEditor propertyEditor = property.getEditor(); assertSame(propertyEditor, ObjectPropertyEditor.INSTANCE); // animate - just open and ensure that dialog opened (no exception during this) - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("labelFor").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> { + SWTBot shell = bot.shell("labelFor").bot(); + shell.button("Cancel").click(); }); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ShortObjectPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ShortObjectPropertyEditorTest.java index 6aac097a27..7d200c58d9 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ShortObjectPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/ShortObjectPropertyEditorTest.java @@ -19,8 +19,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -185,17 +183,9 @@ public Test() { panel.refresh(); // final Property property = panel.getPropertyByTitle("foo"); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(property, "notShort"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("foo").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(property, "notShort"), bot -> { + SWTBot shell = bot.shell("foo").bot(); + shell.button("OK").click(); }); assertEditor(""" // filler filler filler diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/Snippet142.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/Snippet142.java index 3ec88a8c74..081a8216ca 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/Snippet142.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/table/Snippet142.java @@ -17,7 +17,6 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class Snippet142 { @@ -29,24 +28,9 @@ public static void main(String[] args) { button.setText("Click"); shell.pack(); shell.open(); - button.addListener(SWT.MouseEnter, new Listener() { - @Override - public void handleEvent(Event e) { - System.out.println("enter: " + e); - } - }); - button.addListener(SWT.MouseExit, new Listener() { - @Override - public void handleEvent(Event e) { - System.out.println("exit: " + e); - } - }); - button.addListener(SWT.MouseDown, new Listener() { - @Override - public void handleEvent(Event e) { - System.out.println("Mouse Down (button: " + e.button + " x: " + e.x + " y: " + e.y + ")"); - } - }); + button.addListener(SWT.MouseEnter, e -> System.out.println("enter: " + e)); + button.addListener(SWT.MouseExit, e -> System.out.println("exit: " + e)); + button.addListener(SWT.MouseDown, e -> System.out.println("Mouse Down (button: " + e.button + " x: " + e.x + " y: " + e.y + ")")); final Point pt = display.map(shell, null, 50, 50); new Thread() { Event event; diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/FactoryCreateActionTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/FactoryCreateActionTest.java index 09356db92d..3b65409434 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/FactoryCreateActionTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/FactoryCreateActionTest.java @@ -40,8 +40,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -1438,22 +1436,14 @@ public void test_generate_creationParameters_parent_usingDialog() throws Excepti ComponentInfo button = panel.getChildrenComponents().get(0); // animate UI final IAction createAction = getCreateFactoryAction(button); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - createAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Create factory").bot(); - shell.textWithLabel("&Class:").setText("StaticFactory"); - { - SWTBotTreeItem treeItem = shell.tree().expandNode("Invocations", "setSelected(boolean)"); - treeItem.uncheck(); - } - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> createAction.run(), bot -> { + SWTBot shell = bot.shell("Create factory").bot(); + shell.textWithLabel("&Class:").setText("StaticFactory"); + { + SWTBotTreeItem treeItem = shell.tree().expandNode("Invocations", "setSelected(boolean)"); + treeItem.uncheck(); } + shell.button("OK").click(); }); // verify m_getSource_ignoreSpacesCheck = true; diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/ObjectsLabelProviderTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/ObjectsLabelProviderTest.java index 2496acb147..8ad32b0491 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/ObjectsLabelProviderTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/ObjectsLabelProviderTest.java @@ -63,18 +63,8 @@ public void test_default() throws Exception { @Test public void test_decorateImageText() throws Exception { TestObjectInfo theObject = new MyObjectInfo(); - theObject.addBroadcastListener(new ObjectInfoPresentationDecorateIcon() { - @Override - public void invoke(ObjectInfo object, ImageDescriptor[] icon) throws Exception { - icon[0] = new DecorationOverlayIcon(icon[0], DOWN_ICON, IDecoration.BOTTOM_RIGHT); - } - }); - theObject.addBroadcastListener(new ObjectInfoPresentationDecorateText() { - @Override - public void invoke(ObjectInfo object, String[] text) throws Exception { - text[0] = "A: " + text[0] + " :B"; - } - }); + theObject.addBroadcastListener((ObjectInfoPresentationDecorateIcon) (object, icon) -> icon[0] = new DecorationOverlayIcon(icon[0], DOWN_ICON, IDecoration.BOTTOM_RIGHT)); + theObject.addBroadcastListener((ObjectInfoPresentationDecorateText) (object, text) -> text[0] = "A: " + text[0] + " :B"); // do checks assertNotSame(DEF_ICON, ObjectInfo.getImageDescriptor(theObject)); assertEquals("A: " + DEF_TEXT + " :B", ObjectInfo.getText(theObject)); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/RenameConvertSupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/RenameConvertSupportTest.java index 7398778371..539db906a8 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/RenameConvertSupportTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/util/RenameConvertSupportTest.java @@ -31,8 +31,6 @@ import static org.mockito.Mockito.mock; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.util.List; @@ -177,17 +175,9 @@ public void test_animateUI_openDialog() throws Exception { "}"); final ComponentInfo button = getJavaInfoByName("button"); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - RenameConvertSupport.rename(List.of(button)); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Rename/convert").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> RenameConvertSupport.rename(List.of(button)), bot -> { + SWTBot shell = bot.shell("Rename/convert").bot(); + shell.button("Cancel").click(); }); waitEventLoop(10); } @@ -209,21 +199,13 @@ public void test_animateUI_setName() throws Exception { final IAction renameAction = getRenameAction(button); assertNotNull(renameAction); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - renameAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Rename/convert").bot(); - { - SWTBotText nameField = shell.text("button"); - nameField.setText("myButton"); - } - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> renameAction.run(), bot -> { + SWTBot shell = bot.shell("Rename/convert").bot(); + { + SWTBotText nameField = shell.text("button"); + nameField.setText("myButton"); } + shell.button("OK").click(); }); waitEventLoop(10); assertEditor( @@ -252,21 +234,13 @@ public void test_animateUI_toField() throws Exception { final IAction renameAction = getRenameAction(button); assertNotNull(renameAction); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - renameAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Rename/convert").bot(); - { - SWTBotToolbarButton item = shell.toolbarRadioButtonWithTooltip("Be field"); - item.click(); - } - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> renameAction.run(), bot -> { + SWTBot shell = bot.shell("Rename/convert").bot(); + { + SWTBotToolbarButton item = shell.toolbarRadioButtonWithTooltip("Be field"); + item.click(); } + shell.button("OK").click(); }); waitEventLoop(10); assertEditor( @@ -302,24 +276,16 @@ public void test_animateUI_setName_lazy() throws Exception { final IAction renameAction = getRenameAction(button); assertNotNull(renameAction); // animate - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - renameAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Rename/convert").bot(); - { - SWTBotText nameField = shell.text("button"); - nameField.setText("myButton"); - } - // "lazy" can not be converted to local/field - assertFalse(shell.toolbarRadioButtonWithTooltip("Be local").isEnabled()); - assertFalse(shell.toolbarRadioButtonWithTooltip("Be field").isEnabled()); - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> renameAction.run(), bot -> { + SWTBot shell = bot.shell("Rename/convert").bot(); + { + SWTBotText nameField = shell.text("button"); + nameField.setText("myButton"); } + // "lazy" can not be converted to local/field + assertFalse(shell.toolbarRadioButtonWithTooltip("Be local").isEnabled()); + assertFalse(shell.toolbarRadioButtonWithTooltip("Be field").isEnabled()); + shell.button("OK").click(); }); waitEventLoop(10); assertEditor( diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/variables/AbstractNamedTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/variables/AbstractNamedTest.java index 3027b04077..da9c1e52d6 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/variables/AbstractNamedTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/variables/AbstractNamedTest.java @@ -31,8 +31,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -228,17 +226,9 @@ public void test_variableProperty() throws Exception { } // duplicate name - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - setTextEditorText(variableProperty, "button_2"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Variable").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> setTextEditorText(variableProperty, "button_2"), bot -> { + SWTBot shell = bot.shell("Variable").bot(); + shell.button("OK").click(); }); // no changes { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/EditableSupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/EditableSupportTest.java index f943c45901..da5ffe3508 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/EditableSupportTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/EditableSupportTest.java @@ -35,10 +35,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -934,17 +931,7 @@ public void test_renameConflict_cancel() throws Exception { new JavaInfo[][]{new JavaInfo[]{frame}, new JavaInfo[]{frame}}); } // dispose shell, so cancel dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - editableSource.renameKey("frame.name", "frame.title"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - bot.shell("Confirm").close(); - } - }); + new UiContext().executeAndCheck(() -> editableSource.renameKey("frame.name", "frame.title"), bot -> bot.shell("Confirm").close()); // no changes expected { assertStringSet(editableSource.getKeys(), new String[]{"frame.title", "frame.name"}); @@ -977,17 +964,7 @@ public void test_renameConflict_keep() throws Exception { IEditableSupport editableSupport = support.getEditable(); final IEditableSource editableSource = editableSupport.getEditableSources().get(0); // yes, keep existing value - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - editableSource.renameKey("frame.name", "frame.title"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - bot.shell("Confirm").bot().button("Yes, keep existing value").click(); - } - }); + new UiContext().executeAndCheck(() -> editableSource.renameKey("frame.name", "frame.title"), bot -> bot.shell("Confirm").bot().button("Yes, keep existing value").click()); { assertStringSet(editableSource.getKeys(), new String[]{"frame.title"}); assertEquals("title", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title")); @@ -1018,17 +995,7 @@ public void test_renameConflict_useSourceValue() throws Exception { IEditableSupport editableSupport = support.getEditable(); final IEditableSource editableSource = editableSupport.getEditableSources().get(0); // no, use value of renaming key - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - editableSource.renameKey("frame.name", "frame.title"); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - bot.shell("Confirm").bot().button("No, use value of renaming key").click(); - } - }); + new UiContext().executeAndCheck(() -> editableSource.renameKey("frame.name", "frame.title"), bot -> bot.shell("Confirm").bot().button("No, use value of renaming key").click()); { assertStringSet(editableSource.getKeys(), new String[]{"frame.title"}); assertEquals("name", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title")); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/AbstractNlsUiTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/AbstractNlsUiTest.java index 62b84bd563..713129eb72 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/AbstractNlsUiTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/AbstractNlsUiTest.java @@ -23,8 +23,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; import org.apache.commons.lang3.function.FailableBiConsumer; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; @@ -79,17 +77,7 @@ protected final void openDialogNLS(String packageName, String initialSource, openDesign(unit); // click on "Externalize strings" item UiContext context = new UiContext(); - context.executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - m_dialogItem.click(); - } - }, new FailableConsumer () { - @Override - public void accept(SWTBot bot) throws Exception { - consumer.accept(context, bot); - } - }); + context.executeAndCheck(() -> m_dialogItem.click(), bot -> consumer.accept(context, bot)); } //////////////////////////////////////////////////////////////////////////// diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/ContributionItemTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/ContributionItemTest.java index 26eb3eecc4..d998f73211 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/ContributionItemTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/ContributionItemTest.java @@ -17,11 +17,9 @@ import org.eclipse.wb.internal.core.nls.model.LocaleInfo; import org.eclipse.wb.tests.gef.UiContext; -import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu; -import org.apache.commons.lang3.function.FailableBiConsumer; import org.junit.jupiter.api.Test; import java.util.List; @@ -102,12 +100,6 @@ public void test_defaultPackage() throws Exception { " setTitle('My JFrame');", " }", "}"); - openDialogNLS("", initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - // click "OK" - bot.shell("Can't Externalize").bot().button("OK").click(); - } - }); + openDialogNLS("", initialSource, (context, bot) -> bot.shell("Can't Externalize").bot().button("OK").click()); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NewSourceDialogTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NewSourceDialogTest.java index 65878ae9b9..e64a82ee4b 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NewSourceDialogTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NewSourceDialogTest.java @@ -27,8 +27,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -56,22 +54,14 @@ public void test_openDialog() throws Exception { "}"); final NewSourceDialog newSourceDialog = new NewSourceDialog(null, frame); // - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - newSourceDialog.open(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - SWTBot shell = bot.shell("New source").bot(); - assertTrue(shell.radio("Classic Eclipse messages class").isEnabled()); - assertTrue(shell.radio("Modern Eclipse messages class").isEnabled()); - assertTrue(shell.radio("Direct ResourceBundle usage").isEnabled()); - assertTrue(shell.radio("ResourceBundle in field").isEnabled()); - // close dialog - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> newSourceDialog.open(), bot -> { + SWTBot shell = bot.shell("New source").bot(); + assertTrue(shell.radio("Classic Eclipse messages class").isEnabled()); + assertTrue(shell.radio("Modern Eclipse messages class").isEnabled()); + assertTrue(shell.radio("Direct ResourceBundle usage").isEnabled()); + assertTrue(shell.radio("ResourceBundle in field").isEnabled()); + // close dialog + shell.button("Cancel").click(); }); } @@ -89,61 +79,53 @@ public void test_DirectSource() throws Exception { "}"); final NewSourceDialog newSourceDialog = new NewSourceDialog(null, frame); // - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - newSourceDialog.open(); + new UiContext().executeAndCheck(() -> newSourceDialog.open(), bot -> { + SWTBot shell = bot.shell("New source").bot(); + SWTBotButton okButton = shell.button("OK"); + shell.radio("Direct ResourceBundle usage").click(); + { + SWTBotStyledText styledText = shell.styledText(); + assertEquals( + "button.setText( ResourceBundle.getBundle(\"full.bundle.name\").getString(\"some.key\") );", + styledText.getText()); + } + Widget widget = shell.getFinder().findControls(withText("Property file location and name")).getFirst(); + SWTBot group = new SWTBot(widget); + // source folder + { + SWTBotText sourceFolderText = group.textWithLabel("Source folder: "); + assertEquals("TestProject/src", sourceFolderText.getText()); + // set bad folder - "OK" button disabled + sourceFolderText.setText("no-such-folder"); + assertFalse(okButton.isEnabled()); + // restore good folder - "OK" button enabled + sourceFolderText.setText("TestProject/src"); + assertTrue(okButton.isEnabled()); + } + // package + { + SWTBotText packageText = group.textWithLabel("Package:"); + assertEquals("test", packageText.getText()); + // set bad - "OK" button disabled + packageText.setText("no-such-package"); + assertFalse(okButton.isEnabled()); + // restore good - "OK" button enabled + packageText.setText("test"); + assertTrue(okButton.isEnabled()); } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - SWTBot shell = bot.shell("New source").bot(); - SWTBotButton okButton = shell.button("OK"); - shell.radio("Direct ResourceBundle usage").click(); - { - SWTBotStyledText styledText = shell.styledText(); - assertEquals( - "button.setText( ResourceBundle.getBundle(\"full.bundle.name\").getString(\"some.key\") );", - styledText.getText()); - } - Widget widget = shell.getFinder().findControls(withText("Property file location and name")).getFirst(); - SWTBot group = new SWTBot(widget); - // source folder - { - SWTBotText sourceFolderText = group.textWithLabel("Source folder: "); - assertEquals("TestProject/src", sourceFolderText.getText()); - // set bad folder - "OK" button disabled - sourceFolderText.setText("no-such-folder"); - assertFalse(okButton.isEnabled()); - // restore good folder - "OK" button enabled - sourceFolderText.setText("TestProject/src"); - assertTrue(okButton.isEnabled()); - } - // package - { - SWTBotText packageText = group.textWithLabel("Package:"); - assertEquals("test", packageText.getText()); - // set bad - "OK" button disabled - packageText.setText("no-such-package"); - assertFalse(okButton.isEnabled()); - // restore good - "OK" button enabled - packageText.setText("test"); - assertTrue(okButton.isEnabled()); - } - // properties file - { - SWTBotText fileText = group.textWithLabel("Property file name:"); - assertEquals("messages.properties", fileText.getText()); - // set bad - "OK" button disabled - fileText.setText("bad-file-name"); - assertFalse(okButton.isEnabled()); - // restore good - "OK" button enabled - fileText.setText("messages.properties"); - assertTrue(okButton.isEnabled()); - } - // close dialog - okButton.click(); + // properties file + { + SWTBotText fileText = group.textWithLabel("Property file name:"); + assertEquals("messages.properties", fileText.getText()); + // set bad - "OK" button disabled + fileText.setText("bad-file-name"); + assertFalse(okButton.isEnabled()); + // restore good - "OK" button enabled + fileText.setText("messages.properties"); + assertTrue(okButton.isEnabled()); } + // close dialog + okButton.click(); }); // result /*System.out.println(newSourceDialog.getNewSourceDescription()); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NlsDialogTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NlsDialogTest.java index df43954b6d..12c5e32722 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NlsDialogTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/NlsDialogTest.java @@ -13,13 +13,11 @@ package org.eclipse.wb.tests.designer.core.nls.ui; import org.eclipse.wb.internal.core.nls.ui.NlsDialog; -import org.eclipse.wb.tests.gef.UiContext; import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTabItem; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; -import org.apache.commons.lang3.function.FailableBiConsumer; import org.junit.jupiter.api.Test; /** @@ -41,14 +39,11 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - SWTBotTabItem properties = shell.tabItem("Properties"); - assertTrue(properties.isActive()); - assertItems(shell, "Properties"); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + SWTBotTabItem properties = shell.tabItem("Properties"); + assertTrue(properties.isActive()); + assertItems(shell, "Properties"); }); } @@ -69,31 +64,28 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "test.messages2", "Properties"); - SWTBotTabItem messagesTab = shell.tabItem("test.messages"); - assertFalse(messagesTab.isActive()); - SWTBotTabItem messages2Tab = shell.tabItem("test.messages2"); - assertFalse(messages2Tab.isActive()); - SWTBotTabItem properties = shell.tabItem("Properties"); - assertTrue(properties.isActive()); - // check possible sources: 0 - { - messagesTab.activate(); - SWTBotTable table = shell.tableWithLabel("Strings:"); - assertColumns(table, "Key", "(default)"); - assertItems(table, new String[] { "frame.title", "My JFrame" }); - } - // check possible sources: 1 - { - messages2Tab.activate(); - SWTBotTable table = shell.tableWithLabel("Strings:"); - assertColumns(table, "Key", "(default)"); - assertItems(table, new String[] { "frame.name", "My name" }); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "test.messages2", "Properties"); + SWTBotTabItem messagesTab = shell.tabItem("test.messages"); + assertFalse(messagesTab.isActive()); + SWTBotTabItem messages2Tab = shell.tabItem("test.messages2"); + assertFalse(messages2Tab.isActive()); + SWTBotTabItem properties = shell.tabItem("Properties"); + assertTrue(properties.isActive()); + // check possible sources: 0 + { + messagesTab.activate(); + SWTBotTable table = shell.tableWithLabel("Strings:"); + assertColumns(table, "Key", "(default)"); + assertItems(table, new String[] { "frame.title", "My JFrame" }); + } + // check possible sources: 1 + { + messages2Tab.activate(); + SWTBotTable table = shell.tableWithLabel("Strings:"); + assertColumns(table, "Key", "(default)"); + assertItems(table, new String[] { "frame.name", "My name" }); } }); } @@ -113,20 +105,17 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - SWTBotTabItem messagesTab = shell.tabItem("test.messages"); - assertTrue(messagesTab.isActive()); - // check source - SWTBotTable table = shell.tableWithLabel("Strings:"); - assertColumns(table, "Key", "(default)", "it"); - assertItems(table, - new String[] { "frame.name", "My name", "" }, - new String[] { "frame.title", "My JFrame", "My JFrame IT" }); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + SWTBotTabItem messagesTab = shell.tabItem("test.messages"); + assertTrue(messagesTab.isActive()); + // check source + SWTBotTable table = shell.tableWithLabel("Strings:"); + assertColumns(table, "Key", "(default)", "it"); + assertItems(table, + new String[] { "frame.name", "My name", "" }, + new String[] { "frame.title", "My JFrame", "My JFrame IT" }); }); } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/PropertiesCompositeTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/PropertiesCompositeTest.java index f5912a8f66..ee27ee9eb8 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/PropertiesCompositeTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/PropertiesCompositeTest.java @@ -18,7 +18,6 @@ import org.eclipse.wb.internal.core.nls.ui.PropertiesComposite; import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils; import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; -import org.eclipse.wb.tests.gef.UiContext; import org.eclipse.wb.tests.utils.SWTBotEditableSource; import static org.eclipse.swtbot.swt.finder.matchers.WidgetOfType.widgetOfType; @@ -32,7 +31,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.apache.commons.lang3.function.FailableBiConsumer; import org.junit.jupiter.api.Test; /** @@ -54,13 +52,10 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "Properties"); - assertEquals(0, shell.list().itemCount()); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "Properties"); + assertEquals(0, shell.list().itemCount()); }); } @@ -81,19 +76,16 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "test.messages2", "Properties"); - shell.tabItem("Properties").activate(); - SWTBotList sourcesList = shell.list(); - // - assertItems( - sourcesList, - "test.messages (Direct ResourceBundle usage)", - "test.messages2 (Direct ResourceBundle usage)"); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "test.messages2", "Properties"); + shell.tabItem("Properties").activate(); + SWTBotList sourcesList = shell.list(); + // + assertItems( + sourcesList, + "test.messages (Direct ResourceBundle usage)", + "test.messages2 (Direct ResourceBundle usage)"); }); } @@ -112,16 +104,13 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - shell.tabItem("Properties").activate(); - SWTBotList sourcesList = shell.list(); - // - assertItems(sourcesList, "test.messages (Direct ResourceBundle usage)"); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + shell.tabItem("Properties").activate(); + SWTBotList sourcesList = shell.list(); + // + assertItems(sourcesList, "test.messages (Direct ResourceBundle usage)"); }); } @@ -142,99 +131,96 @@ public Test() { } } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - shell.tabItem("Properties").activate(); - // sources list - SWTBotList sourcesList = shell.list(); - // properties tree - SWTBotTree propertiesTree = shell.tree(); - // "Externalize" button - SWTBotButton externalizeButton = shell.button("Externalize"); - // check content on properties tree - { - assertNotNull( - getItem(propertiesTree, "(javax.swing.JFrame)", "title: My JFrame")); - assertNotNull( - getItem( - propertiesTree, - "(javax.swing.JFrame)", - "getContentPane()", - "button", - "text: New button")); - assertNull( - getItem( - propertiesTree, - "(javax.swing.JFrame)", "getContentPane()", "textField")); - } - // prepare TreeItem's - SWTBotTreeItem buttonItem = getItem( - propertiesTree, - "(javax.swing.JFrame)", "getContentPane()", "button"); - SWTBotTreeItem buttonTextItem = getItem(buttonItem, "text: New button"); - // set checked "button" item - { - // check initial states - assertFalse(externalizeButton.isEnabled()); - assertTrue(buttonItem.isGrayed()); - assertFalse(buttonItem.isChecked()); - assertFalse(buttonTextItem.isChecked()); - // check "button" item - buttonItem.check(); - // check state - assertTrue(buttonItem.isChecked()); - assertTrue(buttonTextItem.isChecked()); - assertTrue(externalizeButton.isEnabled()); - } - // clear selection in sources - "Externalize" button should be disabled - { - assertTrue(externalizeButton.isEnabled()); - UIThreadRunnable.syncExec(() -> { - sourcesList.widget.deselectAll(); - sourcesList.widget.notifyListeners(SWT.Selection, null); - }); - assertFalse(externalizeButton.isEnabled()); - } - // select sole source - "Externalize" button should be enabled - { - sourcesList.select(0); - assertTrue(externalizeButton.isEnabled()); - } - // check "&Enable all" - { - shell.button("&Enable all").click(); - assertTrue(buttonTextItem.isChecked()); - } - // check "D&isable all" - { - shell.button("D&isable all").click(); - assertFalse(buttonTextItem.isChecked()); - } - // do externalize - { - buttonItem.check(); - shell.button("E&xternalize").click(); - // items for "button" and its "text" property should be removed - assertNull( - getItem( - propertiesTree, - "(javax.swing.JFrame)", - "getContentPane()", - "button", - "text: New button")); - assertNull( - getItem( - propertiesTree, - "(javax.swing.JFrame)", "getContentPane()", "button")); - assertNull( - getItem(propertiesTree, "(javax.swing.JFrame)", "getContentPane()")); - // check IEditableSource - SWTBotEditableSource editableSource = getEditableSource(shell); - assertEquals("New button", editableSource.getValue(LocaleInfo.DEFAULT, "Test.button.text")); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + shell.tabItem("Properties").activate(); + // sources list + SWTBotList sourcesList = shell.list(); + // properties tree + SWTBotTree propertiesTree = shell.tree(); + // "Externalize" button + SWTBotButton externalizeButton = shell.button("Externalize"); + // check content on properties tree + { + assertNotNull( + getItem(propertiesTree, "(javax.swing.JFrame)", "title: My JFrame")); + assertNotNull( + getItem( + propertiesTree, + "(javax.swing.JFrame)", + "getContentPane()", + "button", + "text: New button")); + assertNull( + getItem( + propertiesTree, + "(javax.swing.JFrame)", "getContentPane()", "textField")); + } + // prepare TreeItem's + SWTBotTreeItem buttonItem = getItem( + propertiesTree, + "(javax.swing.JFrame)", "getContentPane()", "button"); + SWTBotTreeItem buttonTextItem = getItem(buttonItem, "text: New button"); + // set checked "button" item + { + // check initial states + assertFalse(externalizeButton.isEnabled()); + assertTrue(buttonItem.isGrayed()); + assertFalse(buttonItem.isChecked()); + assertFalse(buttonTextItem.isChecked()); + // check "button" item + buttonItem.check(); + // check state + assertTrue(buttonItem.isChecked()); + assertTrue(buttonTextItem.isChecked()); + assertTrue(externalizeButton.isEnabled()); + } + // clear selection in sources - "Externalize" button should be disabled + { + assertTrue(externalizeButton.isEnabled()); + UIThreadRunnable.syncExec(() -> { + sourcesList.widget.deselectAll(); + sourcesList.widget.notifyListeners(SWT.Selection, null); + }); + assertFalse(externalizeButton.isEnabled()); + } + // select sole source - "Externalize" button should be enabled + { + sourcesList.select(0); + assertTrue(externalizeButton.isEnabled()); + } + // check "&Enable all" + { + shell.button("&Enable all").click(); + assertTrue(buttonTextItem.isChecked()); + } + // check "D&isable all" + { + shell.button("D&isable all").click(); + assertFalse(buttonTextItem.isChecked()); + } + // do externalize + { + buttonItem.check(); + shell.button("E&xternalize").click(); + // items for "button" and its "text" property should be removed + assertNull( + getItem( + propertiesTree, + "(javax.swing.JFrame)", + "getContentPane()", + "button", + "text: New button")); + assertNull( + getItem( + propertiesTree, + "(javax.swing.JFrame)", "getContentPane()", "button")); + assertNull( + getItem(propertiesTree, "(javax.swing.JFrame)", "getContentPane()")); + // check IEditableSource + SWTBotEditableSource editableSource = getEditableSource(shell); + assertEquals("New button", editableSource.getValue(LocaleInfo.DEFAULT, "Test.button.text")); } }); } @@ -255,17 +241,14 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "Properties"); - SWTBotList sourcesList = shell.list(); - assertEquals(0, sourcesList.itemCount()); - // - shell.button("&New...").click(); - bot.shell("New source").bot().button("Cancel").click(); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "Properties"); + SWTBotList sourcesList = shell.list(); + assertEquals(0, sourcesList.itemCount()); + // + shell.button("&New...").click(); + bot.shell("New source").bot().button("Cancel").click(); }); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/SourceCompositeTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/SourceCompositeTest.java index 432f93602f..dfb391cefb 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/SourceCompositeTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/nls/ui/SourceCompositeTest.java @@ -21,7 +21,6 @@ import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; import org.eclipse.wb.internal.core.utils.ui.UiUtils.ITableTooltipProvider; import org.eclipse.wb.tests.gef.EventSender; -import org.eclipse.wb.tests.gef.UiContext; import org.eclipse.wb.tests.utils.SWTBotCTableCombo; import org.eclipse.wb.tests.utils.SWTBotEditableSource; @@ -47,8 +46,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.apache.commons.lang3.function.FailableBiConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.io.Closeable; @@ -81,36 +78,33 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - // check items - SWTBotTable table = shell.table(); - assertItems( - table, - new String[] { "frame.name", "My name" }, - new String[] { "frame.title", "My JFrame" }); - // - try (SWTBotTableTooltipProvider provider = getTableToolTipProvider(shell)) { - // not first column - { - Control control = provider.createTooltipControl(table.getTableItem(1), 1); - assertNull(control); - } - // no components - { - Control control = provider.createTooltipControl(table.getTableItem(0), 0); - assertNull(control); - } - // one component - { - Control control = provider.createTooltipControl(table.getTableItem(1), 0); - assertNotNull(control); - assertTrue(provider.getChildren().length > 0); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + // check items + SWTBotTable table = shell.table(); + assertItems( + table, + new String[] { "frame.name", "My name" }, + new String[] { "frame.title", "My JFrame" }); + // + try (SWTBotTableTooltipProvider provider = getTableToolTipProvider(shell)) { + // not first column + { + Control control = provider.createTooltipControl(table.getTableItem(1), 1); + assertNull(control); + } + // no components + { + Control control = provider.createTooltipControl(table.getTableItem(0), 0); + assertNull(control); + } + // one component + { + Control control = provider.createTooltipControl(table.getTableItem(1), 0); + assertNotNull(control); + assertTrue(provider.getChildren().length > 0); } } }); @@ -138,55 +132,42 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - SWTBotTable table = shell.table(); - table.getTableItem(0).click(2); - // Workaround to make sure the context menu for the 2nd column is opened - SWTBotRootMenu tableMenu = new SWTBotRootMenu(UIThreadRunnable.syncExec(() -> { - Menu menu = table.widget.getMenu(); - menu.setVisible(true); - return menu; - })); - final SWTBotMenu removeLocaleItem = tableMenu.menu("Remove locale..."); - // don't confirm, no changes expected - { - context.execute(new FailableRunnable() { - @Override - public void run() { - removeLocaleItem.click(); - } - }); - bot.waitUntil(waitForShell(withText("Confirm"))); - bot.shell("Confirm").bot().button("Cancel").click(); - // check items - assertItems( - table, - new String[] { "frame.name", "My name", "My name IT" }, - new String[] { "frame.title", "My JFrame", "My JFrame IT" }); - } - // confirm - { - context.execute(new FailableRunnable() { - @Override - public void run() { - removeLocaleItem.click(); - } - }); - bot.waitUntil(waitForShell(withText("Confirm"))); - bot.shell("Confirm").bot().button("OK").click(); - // check items - assertItems( - table, - new String[] { "frame.name", "My name" }, - new String[] { "frame.title", "My JFrame" }); - } - shell.button("OK").click(); + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + SWTBotTable table = shell.table(); + table.getTableItem(0).click(2); + // Workaround to make sure the context menu for the 2nd column is opened + SWTBotRootMenu tableMenu = new SWTBotRootMenu(UIThreadRunnable.syncExec(() -> { + Menu menu = table.widget.getMenu(); + menu.setVisible(true); + return menu; + })); + final SWTBotMenu removeLocaleItem = tableMenu.menu("Remove locale..."); + // don't confirm, no changes expected + { + context.execute(() -> removeLocaleItem.click()); + bot.waitUntil(waitForShell(withText("Confirm"))); + bot.shell("Confirm").bot().button("Cancel").click(); + // check items + assertItems( + table, + new String[] { "frame.name", "My name", "My name IT" }, + new String[] { "frame.title", "My JFrame", "My JFrame IT" }); + } + // confirm + { + context.execute(() -> removeLocaleItem.click()); + bot.waitUntil(waitForShell(withText("Confirm"))); + bot.shell("Confirm").bot().button("OK").click(); + // check items + assertItems( + table, + new String[] { "frame.name", "My name" }, + new String[] { "frame.title", "My JFrame" }); } + shell.button("OK").click(); }); // 'it' properties should be deleted assertFalse(getFileSrc("test/messages_it.properties").exists()); @@ -204,40 +185,27 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - SWTBotTable table = shell.table(); - SWTBotRootMenu tableMenu = table.getTableItem(0).contextMenu(); - final SWTBotMenu internalizeItem = tableMenu.contextMenu("Internalize key..."); - // don't confirm, no changes expected - { - context.execute(new FailableRunnable() { - @Override - public void run() { - internalizeItem.click(); - } - }); - bot.shell("Confirm").bot().button("Cancel").click(); - // check items - assertItems(table, new String[] { "frame.title", "My JFrame" }); - } - // confirm - { - context.execute(new FailableRunnable() { - @Override - public void run() { - internalizeItem.click(); - } - }); - bot.shell("Confirm").bot().button("OK").click(); - // check items - assertItems(table /* , */); - shell.button("OK").click(); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + SWTBotTable table = shell.table(); + SWTBotRootMenu tableMenu = table.getTableItem(0).contextMenu(); + final SWTBotMenu internalizeItem = tableMenu.contextMenu("Internalize key..."); + // don't confirm, no changes expected + { + context.execute(() -> internalizeItem.click()); + bot.shell("Confirm").bot().button("Cancel").click(); + // check items + assertItems(table, new String[] { "frame.title", "My JFrame" }); + } + // confirm + { + context.execute(() -> internalizeItem.click()); + bot.shell("Confirm").bot().button("OK").click(); + // check items + assertItems(table /* , */); + shell.button("OK").click(); } }); // check source @@ -263,41 +231,33 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - SWTBotTable table = shell.table(); - SWTBotRootMenu tableMenu = table.getTableItem(0).click().contextMenu(); - final SWTBotMenu addLocaleItem = tableMenu.menu("Add locale..."); - // - context.execute(new FailableRunnable() { - @Override - public void run() { - addLocaleItem.click(); - } - }); - { - SWTBot shell2 = bot.shell("Choose Locale").bot(); - // select 'it' language - SWTBotCTableCombo languagesCombo = getLanguageCombo(shell2); - for (int i = 0; i < languagesCombo.getItemCount(); i++) { - String item = languagesCombo.getItem(i); - if (item.startsWith("it - ")) { - languagesCombo.select(i); - break; - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + SWTBotTable table = shell.table(); + SWTBotRootMenu tableMenu = table.getTableItem(0).click().contextMenu(); + final SWTBotMenu addLocaleItem = tableMenu.menu("Add locale..."); + // + context.execute(() -> addLocaleItem.click()); + { + SWTBot shell2 = bot.shell("Choose Locale").bot(); + // select 'it' language + SWTBotCTableCombo languagesCombo = getLanguageCombo(shell2); + for (int i = 0; i < languagesCombo.getItemCount(); i++) { + String item = languagesCombo.getItem(i); + if (item.startsWith("it - ")) { + languagesCombo.select(i); + break; } - // click "OK" - shell2.button("OK").click(); } - // check items - assertColumns(table, "Key", "(default)", "it"); - assertItems(table, new String[] { "frame.title", "My JFrame", "My JFrame" }); - shell.button("OK").click(); + // click "OK" + shell2.button("OK").click(); } + // check items + assertColumns(table, "Key", "(default)", "it"); + assertItems(table, new String[] { "frame.title", "My JFrame", "My JFrame" }); + shell.button("OK").click(); }); // we should have new locale - 'it' assertTrue(getFileSrc("test/messages_it.properties").exists()); @@ -315,18 +275,10 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - context.execute(new FailableRunnable() { - @Override - public void run() { - shell.button("New locale...").click(); - } - }); - bot.shell("Choose Locale").bot().button("Cancel").click(); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + context.execute(() -> shell.button("New locale...").click()); + bot.shell("Choose Locale").bot().button("Cancel").click(); }); } @@ -348,81 +300,78 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - // - SWTBotEditableSource editableSource = getEditableSource(shell); - SWTBotTable table = shell.table(); - // check initial items + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + // + SWTBotEditableSource editableSource = getEditableSource(shell); + SWTBotTable table = shell.table(); + // check initial items + { + assertColumns(table, "Key", "(default)", "it"); + assertItems(table, new String[] { "frame.title", "My JFrame", "" }); + } + // click to activate cell editor + { + // click on value to start edit + table.click(0, 1); + // send new text and CR { - assertColumns(table, "Key", "(default)", "it"); - assertItems(table, new String[] { "frame.title", "My JFrame", "" }); + SWTBotText text = shell.text(); + text.setText("New title"); + closeCellEditor(shell); + waitEventLoop(10); } - // click to activate cell editor + } + // check after edit + { + assertTrue(editableSource.getKeys().contains("frame.title")); + assertEquals("New title", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title")); + // + assertItems(table, new String[] { "frame.title", "New title", "" }); + } + // rename key + { + table.click(0, 0); { - // click on value to start edit - table.click(0, 1); - // send new text and CR - { - SWTBotText text = shell.text(); - text.setText("New title"); - closeCellEditor(shell); - waitEventLoop(10); - } + SWTBotText text = shell.text(); + text.setText("frame.title2"); + closeCellEditor(shell); + waitEventLoop(10); } - // check after edit + // check { - assertTrue(editableSource.getKeys().contains("frame.title")); - assertEquals("New title", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title")); + assertFalse(editableSource.getKeys().contains("frame.title")); + assertTrue(editableSource.getKeys().contains("frame.title2")); + assertEquals("New title", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title2")); // - assertItems(table, new String[] { "frame.title", "New title", "" }); + assertItems(table, new String[] { "frame.title2", "New title", "" }); } - // rename key + } + // update 'it' + { + LocaleInfo localeInfo = new LocaleInfo(Locale.ITALIAN); + assertNull(editableSource.getValue(localeInfo, "frame.title2")); + // modify { - table.click(0, 0); - { - SWTBotText text = shell.text(); - text.setText("frame.title2"); - closeCellEditor(shell); - waitEventLoop(10); - } - // check - { - assertFalse(editableSource.getKeys().contains("frame.title")); - assertTrue(editableSource.getKeys().contains("frame.title2")); - assertEquals("New title", editableSource.getValue(LocaleInfo.DEFAULT, "frame.title2")); - // - assertItems(table, new String[] { "frame.title2", "New title", "" }); - } + table.click(0, 2); + SWTBotText text = shell.text(); + text.setText("title IT"); + closeCellEditor(shell); + waitEventLoop(10); } - // update 'it' + // check { - LocaleInfo localeInfo = new LocaleInfo(Locale.ITALIAN); - assertNull(editableSource.getValue(localeInfo, "frame.title2")); - // modify - { - table.click(0, 2); - SWTBotText text = shell.text(); - text.setText("title IT"); - closeCellEditor(shell); - waitEventLoop(10); - } - // check - { - assertEquals("title IT", editableSource.getValue(localeInfo, "frame.title2")); - assertItems( - table, - new String[] { "frame.title2", "New title", "title IT" }); - } - shell.button("OK").click(); + assertEquals("title IT", editableSource.getValue(localeInfo, "frame.title2")); + assertItems( + table, + new String[] { "frame.title2", "New title", "title IT" }); } - // wait UI - //waitEventLoop(5000); + shell.button("OK").click(); } + // wait UI + //waitEventLoop(5000); }); } @@ -439,34 +388,31 @@ public Test() { setName("My name"); } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - // - SWTBotEditableSource editableSource = getEditableSource(shell); - SWTBotTable table = shell.table(); - // check initial items - { - assertColumns(table, "Key", "(default)"); - assertItems(table, new String[] { "frame.title", "My JFrame" }); - } - // externalize "name" - { - GenericProperty nameProperty = - (GenericProperty) m_contentJavaInfo.getPropertyByTitle("name"); - editableSource.externalize(new StringPropertyInfo(nameProperty), true); - } - // check items - { - assertColumns(table, "Key", "(default)"); - assertItems( - table, - new String[] { "frame.title", "My JFrame" }, - new String[] { "Test.this.name", "My name" }); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + // + SWTBotEditableSource editableSource = getEditableSource(shell); + SWTBotTable table = shell.table(); + // check initial items + { + assertColumns(table, "Key", "(default)"); + assertItems(table, new String[] { "frame.title", "My JFrame" }); + } + // externalize "name" + { + GenericProperty nameProperty = + (GenericProperty) m_contentJavaInfo.getPropertyByTitle("name"); + editableSource.externalize(new StringPropertyInfo(nameProperty), true); + } + // check items + { + assertColumns(table, "Key", "(default)"); + assertItems( + table, + new String[] { "frame.title", "My JFrame" }, + new String[] { "Test.this.name", "My name" }); } }); } @@ -486,31 +432,28 @@ public Test() { setName(ResourceBundle.getBundle("test.messages").getString("frame.name")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - // - final SWTBotEditableSource editableSource = getEditableSource(shell); - SWTBotTable table = shell.table(); - // check initial items - { - assertColumns(table, "Key", "(default)"); - assertItems( - table, - new String[] { "frame.name", "My name" }, - new String[] { "frame.title", "My JFrame" }); - } - // rename "frame.name" -> "frame.title" - editableSource.renameKey("frame.name", "frame.title"); - bot.shell("Confirm").bot().button("Yes, keep existing value").click(); - // check items - { - assertColumns(table, "Key", "(default)"); - assertItems(table, new String[] { "frame.title", "My JFrame" }); - } + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + // + final SWTBotEditableSource editableSource = getEditableSource(shell); + SWTBotTable table = shell.table(); + // check initial items + { + assertColumns(table, "Key", "(default)"); + assertItems( + table, + new String[] { "frame.name", "My name" }, + new String[] { "frame.title", "My JFrame" }); + } + // rename "frame.name" -> "frame.title" + editableSource.renameKey("frame.name", "frame.title"); + bot.shell("Confirm").bot().button("Yes, keep existing value").click(); + // check items + { + assertColumns(table, "Key", "(default)"); + assertItems(table, new String[] { "frame.title", "My JFrame" }); } }); } @@ -529,28 +472,25 @@ public Test() { setTitle(ResourceBundle.getBundle("test.messages").getString("frame.title")); //$NON-NLS-1$ //$NON-NLS-2$ } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - assertTrue(shell.tabItem("test.messages").isActive()); - // - //waitEventLoop(5000); - SWTBotTable table = shell.table(); - // check initial items - assertItems( - table, - new String[] { "frame.name", "My name" }, - new String[] { "frame.title", "My JFrame" }); - // check "Show strings only for current form" - { - SWTBotCheckBox onlyFormButton = shell.checkBox("Show strings only for current form"); - onlyFormButton.click(); - } - // only 'frame.title' expected - assertItems(table, new String[] { "frame.title", "My JFrame" }); + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + assertTrue(shell.tabItem("test.messages").isActive()); + // + //waitEventLoop(5000); + SWTBotTable table = shell.table(); + // check initial items + assertItems( + table, + new String[] { "frame.name", "My name" }, + new String[] { "frame.title", "My JFrame" }); + // check "Show strings only for current form" + { + SWTBotCheckBox onlyFormButton = shell.checkBox("Show strings only for current form"); + onlyFormButton.click(); } + // only 'frame.title' expected + assertItems(table, new String[] { "frame.title", "My JFrame" }); }); } @@ -570,76 +510,73 @@ public class Test extends JFrame { public Test() { } }"""); - openDialogNLS(initialSource, new FailableBiConsumer() { - @Override - public void accept(UiContext context, SWTBot bot) throws InterruptedException { - SWTBot shell = bot.shell("Externalize strings").bot(); - assertItems(shell, "test.messages", "Properties"); - // No externalizable strings - assertFalse(shell.tabItem("test.messages").isActive()); - shell.tabItem("test.messages").activate(); - SWTBotTable table = shell.table(); - // check initial items + openDialogNLS(initialSource, (context, bot) -> { + SWTBot shell = bot.shell("Externalize strings").bot(); + assertItems(shell, "test.messages", "Properties"); + // No externalizable strings + assertFalse(shell.tabItem("test.messages").isActive()); + shell.tabItem("test.messages").activate(); + SWTBotTable table = shell.table(); + // check initial items + assertItems( + table, + new String[] { "key.1", "1 1", "1 2" }, + new String[] { "key.2", "2 1", "2 2" }); + // check next column + { + // activate editor at (1, 0) + table.click(0, 1); + // navigate next column - (1, 2) + shell.text().traverse(Traverse.TAB_NEXT); + // set text + SWTBotText text = shell.text(); + text.setText("a b"); + closeCellEditor(shell); + waitEventLoop(10); + // check assertItems( table, - new String[] { "key.1", "1 1", "1 2" }, + new String[] { "key.1", "1 1", "a b" }, new String[] { "key.2", "2 1", "2 2" }); - // check next column - { - // activate editor at (1, 0) - table.click(0, 1); - // navigate next column - (1, 2) - shell.text().traverse(Traverse.TAB_NEXT); - // set text - SWTBotText text = shell.text(); - text.setText("a b"); - closeCellEditor(shell); - waitEventLoop(10); - // check - assertItems( - table, - new String[] { "key.1", "1 1", "a b" }, - new String[] { "key.2", "2 1", "2 2" }); - } - // check next row - { - // activate editor at (2, 0) - table.click(0, 2); - // navigate next row - (2, 2) - keyDown(shell.text(), SWT.ARROW_DOWN, (char)0); - waitEventLoop(10); - // set text - SWTBotText text = shell.text(); - text.setText("b b"); - closeCellEditor(shell); - waitEventLoop(10); - // check - assertItems( - table, - new String[] { "key.1", "1 1", "a b" }, - new String[] { "key.2", "2 1", "b b" }); - } - // prev column/row - { - // activate editor at (2, 1) - table.click(1, 2); - // prev column - shell.text().traverse(Traverse.TAB_PREVIOUS); - waitEventLoop(10); - shell.text().setText("b a"); - // prev row - keyDown(shell.text(), SWT.ARROW_UP, (char)0); - waitEventLoop(10); - SWTBotText text = shell.text(); - text.setText("a a"); - closeCellEditor(shell); - // check - waitEventLoop(10); - assertItems( - table, - new String[] { "key.1", "a a", "a b" }, - new String[] { "key.2", "b a", "b b" }); - } + } + // check next row + { + // activate editor at (2, 0) + table.click(0, 2); + // navigate next row - (2, 2) + keyDown(shell.text(), SWT.ARROW_DOWN, (char)0); + waitEventLoop(10); + // set text + SWTBotText text = shell.text(); + text.setText("b b"); + closeCellEditor(shell); + waitEventLoop(10); + // check + assertItems( + table, + new String[] { "key.1", "1 1", "a b" }, + new String[] { "key.2", "2 1", "b b" }); + } + // prev column/row + { + // activate editor at (2, 1) + table.click(1, 2); + // prev column + shell.text().traverse(Traverse.TAB_PREVIOUS); + waitEventLoop(10); + shell.text().setText("b a"); + // prev row + keyDown(shell.text(), SWT.ARROW_UP, (char)0); + waitEventLoop(10); + SWTBotText text = shell.text(); + text.setText("a a"); + closeCellEditor(shell); + // check + waitEventLoop(10); + assertItems( + table, + new String[] { "key.1", "a a", "a b" }, + new String[] { "key.2", "b a", "b b" }); } }); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ChooseComponentEntryInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ChooseComponentEntryInfoTest.java index fec9585e8f..4694295cd4 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ChooseComponentEntryInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ChooseComponentEntryInfoTest.java @@ -31,8 +31,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.util.concurrent.atomic.AtomicBoolean; @@ -116,17 +114,9 @@ public Shell getShell() { CreationTool creationTool; { final CreationTool[] tools = new CreationTool[1]; - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - tools[0] = (CreationTool) entry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Open type").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> tools[0] = (CreationTool) entry.createTool(), bot -> { + SWTBot shell = bot.shell("Open type").bot(); + shell.button("Cancel").click(); }); creationTool = tools[0]; } @@ -175,17 +165,7 @@ public void addCommand(Command command) { CreationTool creationTool; { final CreationTool[] tools = new CreationTool[1]; - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - tools[0] = (CreationTool) entry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "JButton", "OK"); - } - }); + new UiContext().executeAndCheck(() -> tools[0] = (CreationTool) entry.createTool(), bot -> animateOpenTypeSelection(bot, "JButton", "OK")); creationTool = tools[0]; } // check tool @@ -260,17 +240,9 @@ public void reparse() { // create tool { final CreationTool[] tools = new CreationTool[1]; - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - tools[0] = (CreationTool) entry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "MyClass", "OK"); - bot.shell("Unable to load component").bot().button("Yes").click(); - } + new UiContext().executeAndCheck(() -> tools[0] = (CreationTool) entry.createTool(), bot -> { + animateOpenTypeSelection(bot, "MyClass", "OK"); + bot.shell("Unable to load component").bot().button("Yes").click(); }); } } finally { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ComponentEntryInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ComponentEntryInfoTest.java index a91a2bf54c..42d0c8bcfe 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ComponentEntryInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/ComponentEntryInfoTest.java @@ -52,8 +52,6 @@ import static org.assertj.core.data.MapEntry.entry; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; @@ -528,18 +526,12 @@ public Shell getShell() { // do initialize assertTrue(componentEntry.initialize(null, m_lastParseInfo)); // create tool - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - CreationTool creationTool = (CreationTool) componentEntry.createTool(); - assertNull(creationTool); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Error").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> { + CreationTool creationTool = (CreationTool) componentEntry.createTool(); + assertNull(creationTool); + }, bot -> { + SWTBot shell = bot.shell("Error").bot(); + shell.button("OK").click(); }); } @@ -1107,29 +1099,23 @@ public void test_typeParameters_chooseType() throws Exception { CreationTool creationTool; { final AtomicReference creationToolResult = new AtomicReference<>(); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - CreationTool result = (CreationTool) componentEntry.createTool(); - creationToolResult.set(result); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Generic component creation").bot(); - // initial type - SWTBotText textWidget = shell.textWithLabel("Row type:"); - assertEquals("java.lang.Object", textWidget.getText()); - // animate "..." button - { - shell.button("...").click(); - animateOpenTypeSelection(bot, "java.lang.String", "OK"); - } - // chosen type - assertEquals("java.lang.String", textWidget.getText()); - // OK - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> { + CreationTool result = (CreationTool) componentEntry.createTool(); + creationToolResult.set(result); + }, bot -> { + SWTBot shell = bot.shell("Generic component creation").bot(); + // initial type + SWTBotText textWidget = shell.textWithLabel("Row type:"); + assertEquals("java.lang.Object", textWidget.getText()); + // animate "..." button + { + shell.button("...").click(); + animateOpenTypeSelection(bot, "java.lang.String", "OK"); } + // chosen type + assertEquals("java.lang.String", textWidget.getText()); + // OK + shell.button("OK").click(); }); creationTool = creationToolResult.get(); assertNotNull(creationTool); @@ -1160,29 +1146,23 @@ public void test_typeParameters_cancel() throws Exception { CreationTool creationTool; { final AtomicReference creationToolResult = new AtomicReference<>(); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - CreationTool result = (CreationTool) componentEntry.createTool(); - creationToolResult.set(result); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Generic component creation").bot(); - // initial type - SWTBotText textWidget = shell.textWithLabel("Row type:"); - assertEquals("java.lang.Object", textWidget.getText()); - // animate "..." button - { - shell.button("...").click(); - animateOpenTypeSelection(bot, "java.lang.String", "Cancel"); - } - // no changes - assertEquals("java.lang.Object", textWidget.getText()); - // cancel - shell.button("Cancel").click(); + new UiContext().executeAndCheck(() -> { + CreationTool result = (CreationTool) componentEntry.createTool(); + creationToolResult.set(result); + }, bot -> { + SWTBot shell = bot.shell("Generic component creation").bot(); + // initial type + SWTBotText textWidget = shell.textWithLabel("Row type:"); + assertEquals("java.lang.Object", textWidget.getText()); + // animate "..." button + { + shell.button("...").click(); + animateOpenTypeSelection(bot, "java.lang.String", "Cancel"); } + // no changes + assertEquals("java.lang.Object", textWidget.getText()); + // cancel + shell.button("Cancel").click(); }); creationTool = creationToolResult.get(); } @@ -1203,24 +1183,16 @@ public void test_typeParameters_chooseBadType() throws Exception { componentEntry = prepare_typeParameters(line); } // animate createTool() - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - componentEntry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Generic component creation").bot(); - // animate "..." button - { - shell.button("...").click(); - animateOpenTypeSelection(bot, "java.lang.String", "OK"); - bot.shell("Error").bot().button("OK").click(); - } - // Cancel - shell.button("Cancel").click(); + new UiContext().executeAndCheck(() -> componentEntry.createTool(), bot -> { + SWTBot shell = bot.shell("Generic component creation").bot(); + // animate "..." button + { + shell.button("...").click(); + animateOpenTypeSelection(bot, "java.lang.String", "OK"); + bot.shell("Error").bot().button("OK").click(); } + // Cancel + shell.button("Cancel").click(); }); } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/InstanceFactoryEntryInfoTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/InstanceFactoryEntryInfoTest.java index 887219489b..8cf4c6e55a 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/InstanceFactoryEntryInfoTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/InstanceFactoryEntryInfoTest.java @@ -26,8 +26,6 @@ import org.eclipse.swtbot.swt.finder.SWTBot; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.util.List; @@ -257,20 +255,12 @@ public void test_createTool_multiSelect() throws Exception { InstanceFactoryInfo instanceFactory; { final CreationTool[] tools = new CreationTool[1]; - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - tools[0] = (CreationTool) entry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Select factory").bot(); - SWTBotTable table = shell.table(); - table.select(1); - // click OK - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> tools[0] = (CreationTool) entry.createTool(), bot -> { + SWTBot shell = bot.shell("Select factory").bot(); + SWTBotTable table = shell.table(); + table.select(1); + // click OK + shell.button("OK").click(); }); creationTool = tools[0]; instanceFactory = getTestInstanceFactories().get(1); @@ -331,17 +321,9 @@ public void test_createTool_multiCancel() throws Exception { CreationTool creationTool; { final CreationTool[] tools = new CreationTool[1]; - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - tools[0] = (CreationTool) entry.createTool(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Select factory").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> tools[0] = (CreationTool) entry.createTool(), bot -> { + SWTBot shell = bot.shell("Select factory").bot(); + shell.button("Cancel").click(); }); creationTool = tools[0]; } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/PaletteManagerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/PaletteManagerTest.java index 4c4c2e320d..8a932dc982 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/PaletteManagerTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/palette/PaletteManagerTest.java @@ -562,14 +562,11 @@ public void test_customPalette_project_4() throws Exception { PaletteInfo palette; { final boolean[] exceptionHappened = new boolean[1]; - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - exceptionHappened[0] = true; - assertEquals(IStatus.ERROR, status.getSeverity()); - assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); - assertEquals(IStatus.ERROR, status.getCode()); - } + ILogListener logListener = (status, plugin) -> { + exceptionHappened[0] = true; + assertEquals(IStatus.ERROR, status.getSeverity()); + assertEquals(DesignerPlugin.PLUGIN_ID, status.getPlugin()); + assertEquals(IStatus.ERROR, status.getCode()); }; // ILog log = DesignerPlugin.getDefault().getLog(); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/ComponentsPropertiesPageTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/ComponentsPropertiesPageTest.java index 1974792d18..40b8657ce3 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/ComponentsPropertiesPageTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/ComponentsPropertiesPageTest.java @@ -55,12 +55,7 @@ public void _test_exit() throws Exception { public static class CategoryProvider2 implements PropertyCategoryProviderProvider { @Override public PropertyCategoryProvider get(List objects) { - return new PropertyCategoryProvider() { - @Override - public PropertyCategory getCategory(Property property) { - return PropertyCategory.NORMAL; - } - }; + return property -> PropertyCategory.NORMAL; } } diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java index e1d38e83c9..db03a4a7ea 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/DesignerEditorTestCase.java @@ -62,8 +62,6 @@ import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.ide.IDE; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -153,18 +151,10 @@ protected static void assertEquals(Dimension dimension, int width, int height) { protected final void openDesign(IWizard wizard, IPackageFragment packageFragment, String fileName) throws Exception { new UiContext().executeAndCheck( - new FailableRunnable<>() { - @Override - public void run() { - TestUtils.runWizard(wizard, new StructuredSelection(packageFragment)); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell(wizard.getWindowTitle()).bot(); - shell.textWithLabel("Name:").setText(fileName); - shell.button("Finish").click(); - } + () -> TestUtils.runWizard(wizard, new StructuredSelection(packageFragment)), bot -> { + SWTBot shell = bot.shell(wizard.getWindowTitle()).bot(); + shell.textWithLabel("Name:").setText(fileName); + shell.button("Finish").click(); }); ICompilationUnit cu = packageFragment.getCompilationUnit(fileName + ".java"); openDesign(cu); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/UndoManagerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/UndoManagerTest.java index 555fd897e9..cf2ea44f1f 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/UndoManagerTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/editor/UndoManagerTest.java @@ -49,8 +49,6 @@ import org.eclipse.ui.part.FileEditorInput; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -557,17 +555,9 @@ public Test() { new ArrayList<>(), new BodyDeclarationTarget(typeDeclaration, false)); // do commit changes - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - m_lastEditor.commitChanges(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Read-only File Encountered").bot(); - shell.button(buttonId).click(); - } + new UiContext().executeAndCheck(() -> m_lastEditor.commitChanges(), bot -> { + SWTBot shell = bot.shell("Read-only File Encountered").bot(); + shell.button(buttonId).click(); }); // waitEventLoop(0); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/rcp/RcpWizardsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/rcp/RcpWizardsTest.java index 21f54700a8..05bea703b7 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/rcp/RcpWizardsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/rcp/model/rcp/RcpWizardsTest.java @@ -27,8 +27,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.ui.part.ViewPart; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -98,20 +96,12 @@ public void test_ViewPart_notPDE() throws Exception { } private void animate_ViewPart() throws Exception { - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - TestUtils.runWizard(new ViewPartWizard(), new StructuredSelection(m_packageFragment)); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBotShell botShell = bot.shell("New Eclipse RCP ViewPart"); - SWTBot shell = botShell.bot(); - shell.textWithLabel("Name:").setText("MyViewPart"); - shell.button("Finish").click(); - bot.waitUntil(Conditions.shellCloses(botShell)); - } + new UiContext().executeAndCheck(() -> TestUtils.runWizard(new ViewPartWizard(), new StructuredSelection(m_packageFragment)), bot -> { + SWTBotShell botShell = bot.shell("New Eclipse RCP ViewPart"); + SWTBot shell = botShell.bot(); + shell.textWithLabel("Name:").setText("MyViewPart"); + shell.button("Finish").click(); + bot.waitUntil(Conditions.shellCloses(botShell)); }); } @@ -143,20 +133,12 @@ public void test_EditorPart_notPDE() throws Exception { } private void animate_EditorPart() throws Exception { - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - TestUtils.runWizard(new EditorPartWizard(), new StructuredSelection(m_packageFragment)); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBotShell botShell = bot.shell("New Eclipse RCP EditorPart"); - SWTBot shell = botShell.bot(); - shell.textWithLabel("Name:").setText("MyEditorPart"); - shell.button("Finish").click(); - bot.waitUntil(Conditions.shellCloses(botShell)); - } + new UiContext().executeAndCheck(() -> TestUtils.runWizard(new EditorPartWizard(), new StructuredSelection(m_packageFragment)), bot -> { + SWTBotShell botShell = bot.shell("New Eclipse RCP EditorPart"); + SWTBot shell = botShell.bot(); + shell.textWithLabel("Name:").setText("MyEditorPart"); + shell.button("Finish").click(); + bot.waitUntil(Conditions.shellCloses(botShell)); }); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ConvertersTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ConvertersTest.java index 7409798056..5d45907027 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ConvertersTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ConvertersTest.java @@ -81,14 +81,11 @@ public void test_ColorConverter() throws Exception { "java.awt.SystemColor.textHighlight", converter.toJavaSource(null, java.awt.SystemColor.textHighlight)); // - EventQueue.invokeAndWait(new Runnable() { - @Override - public void run() { - try { - UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } catch (Throwable e) { - e.printStackTrace(); - } + EventQueue.invokeAndWait(() -> { + try { + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + } catch (Throwable e) { + e.printStackTrace(); } }); assertEquals( diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/CustomizeTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/CustomizeTest.java index 411fab0f94..81dca4ec1f 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/CustomizeTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/CustomizeTest.java @@ -22,8 +22,6 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; /** @@ -132,17 +130,9 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Customize").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + shell.button("OK").click(); }); // check for isDesignTime() { @@ -220,17 +210,9 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Customize").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + shell.button("OK").click(); }); // check no changes assertEditor(""" @@ -303,17 +285,9 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Customize").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + shell.button("OK").click(); }); // check no changes assertEditor(""" @@ -386,17 +360,9 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Customize").bot(); - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + shell.button("OK").click(); }); // check no changes assertEditor(""" @@ -427,22 +393,14 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Customize").bot(); - // change properties - Object object = button.getObject(); - Object customizer = ReflectionUtils.getFieldObject(object, "customizer"); - ReflectionUtils.invokeMethod(customizer, "doBeanChanges()"); - // commit changes - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + // change properties + Object object = button.getObject(); + Object customizer = ReflectionUtils.getFieldObject(object, "customizer"); + ReflectionUtils.invokeMethod(customizer, "doBeanChanges()"); + // commit changes + shell.button("OK").click(); }); // check source assertEditor(""" @@ -484,21 +442,13 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Customize").bot(); - // change properties - Object customizer = ReflectionUtils.getFieldObject(buttonObject, "customizer"); - ReflectionUtils.invokeMethod(customizer, "doBeanChanges()"); - // cancel changes - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + // change properties + Object customizer = ReflectionUtils.getFieldObject(buttonObject, "customizer"); + ReflectionUtils.invokeMethod(customizer, "doBeanChanges()"); + // cancel changes + shell.button("Cancel").click(); }); // check source assertEditor(""" @@ -684,30 +634,22 @@ public Test() { final IAction action = findChildAction(manager, "&Customize..."); assertNotNull(action); // open customize dialog - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) throws Exception { - SWTBot shell = bot.shell("Customize").bot(); - // change properties - Object object = button.getObject(); - ReflectionUtils.invokeMethod(object, "setTitle(java.lang.String)", "test"); - ReflectionUtils.invokeMethod(object, "setFreeze(boolean)", true); - // fire property changes - Object customizer = ReflectionUtils.getFieldObject(object, "customizer"); - ReflectionUtils.invokeMethod( - customizer, - "firePropertyChange(java.lang.String,java.lang.Object,java.lang.Object)", - "title", - null, - "test"); - // press "OK" button - shell.button("OK").click(); - } + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Customize").bot(); + // change properties + Object object = button.getObject(); + ReflectionUtils.invokeMethod(object, "setTitle(java.lang.String)", "test"); + ReflectionUtils.invokeMethod(object, "setFreeze(boolean)", true); + // fire property changes + Object customizer = ReflectionUtils.getFieldObject(object, "customizer"); + ReflectionUtils.invokeMethod( + customizer, + "firePropertyChange(java.lang.String,java.lang.Object,java.lang.Object)", + "title", + null, + "test"); + // press "OK" button + shell.button("OK").click(); }); // check source assertEditor(""" diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ActionGefTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ActionGefTest.java index 3dd6fce420..ee4b9b88d8 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ActionGefTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ActionGefTest.java @@ -27,10 +27,7 @@ import org.eclipse.wb.tests.gef.UiContext; import org.eclipse.gef.Tool; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import javax.swing.JButton; @@ -252,20 +249,12 @@ public Test() { waitEventLoop(100); JToolBarInfo toolBar = (JToolBarInfo) panel.getChildrenComponents().get(0); // load "action" tool - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - ActionExternalEntryInfo entry = new ActionExternalEntryInfo(); - entry.initialize(m_viewerCanvas, panel); - Tool tool = entry.createTool(); - m_viewerCanvas.getEditDomain().setActiveTool(tool); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "ExternalAction", "OK"); - } - }); + new UiContext().executeAndCheck(() -> { + ActionExternalEntryInfo entry = new ActionExternalEntryInfo(); + entry.initialize(m_viewerCanvas, panel); + Tool tool = entry.createTool(); + m_viewerCanvas.getEditDomain().setActiveTool(tool); + }, bot -> animateOpenTypeSelection(bot, "ExternalAction", "OK")); // drop new "action" on "toolBar"... canvas.target(toolBar).in(10, 5).move(); canvas.click(); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ButtonGroupTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ButtonGroupTest.java index 4a019760bd..cd2b57390d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ButtonGroupTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/bean/ButtonGroupTest.java @@ -26,8 +26,6 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.util.List; @@ -567,17 +565,7 @@ public Test() { ComponentInfo button = panel.getChildrenComponents().get(0); // set new ButtonGroup final IAction newGroupAction = getButtonGroupAction("New custom...", button); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - newGroupAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "MyButtonGroup", "OK"); - } - }); + new UiContext().executeAndCheck(() -> newGroupAction.run(), bot -> animateOpenTypeSelection(bot, "MyButtonGroup", "OK")); assertEditor(""" public class Test extends JPanel { private final MyButtonGroup myButtonGroup = new MyButtonGroup(); @@ -610,17 +598,7 @@ public Test() { ComponentInfo button = panel.getChildrenComponents().get(0); // set new ButtonGroup final IAction newGroupAction = getButtonGroupAction("New custom...", button); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - newGroupAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "java.lang.Object", "OK"); - } - }); + new UiContext().executeAndCheck(() -> newGroupAction.run(), bot -> animateOpenTypeSelection(bot, "java.lang.Object", "OK")); assertEditor(""" public class Test extends JPanel { public Test() { @@ -651,17 +629,9 @@ public Test() { ComponentInfo button = panel.getChildrenComponents().get(0); // set new ButtonGroup final IAction newGroupAction = getButtonGroupAction("New custom...", button); - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - newGroupAction.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Open type").bot(); - shell.button("Cancel").click(); - } + new UiContext().executeAndCheck(() -> newGroupAction.run(), bot -> { + SWTBot shell = bot.shell("Open type").bot(); + shell.button("Cancel").click(); }); assertEditor(""" public class Test extends JPanel { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/JSplitPaneTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/JSplitPaneTest.java index 5455d60bd5..209aa01ba6 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/JSplitPaneTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/JSplitPaneTest.java @@ -396,12 +396,7 @@ class Test extends JPanel { // { ComponentInfo split = getJavaInfoByName("split"); - doCopyPaste(split, new PasteProcedure() { - @Override - public void run(ComponentInfo copy) throws Exception { - ((FlowLayoutInfo) panel.getLayout()).add(copy, null); - } - }); + doCopyPaste(split, copy -> ((FlowLayoutInfo) panel.getLayout()).add(copy, null)); } assertEditor(""" class Test extends JPanel { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/SwingLiveManagerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/SwingLiveManagerTest.java index df354abf15..a9efafcfe3 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/SwingLiveManagerTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/component/SwingLiveManagerTest.java @@ -166,14 +166,11 @@ public Test() { // ask "live" first time { ILog log = DesignerPlugin.getDefault().getLog(); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - assertEquals(IStatus.ERROR, status.getSeverity()); - Throwable exception = status.getException(); - Assertions.assertThat(exception).isExactlyInstanceOf(IllegalStateException.class); - assertEquals("Problem in constructor", exception.getMessage()); - } + ILogListener logListener = (status, plugin) -> { + assertEquals(IStatus.ERROR, status.getSeverity()); + Throwable exception = status.getException(); + Assertions.assertThat(exception).isExactlyInstanceOf(IllegalStateException.class); + assertEquals("Problem in constructor", exception.getMessage()); }; // temporary intercept logging try { @@ -202,12 +199,7 @@ public void logging(IStatus status, String plugin) { // second request for some component class does not cause any exception, we use cached result { ILog log = DesignerPlugin.getDefault().getLog(); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - fail(); - } - }; + ILogListener logListener = (status, plugin) -> fail(); // temporary intercept logging try { log.addLogListener(logListener); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/LayoutManagersTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/LayoutManagersTest.java index 5152b5556f..f442ed46bd 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/LayoutManagersTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/LayoutManagersTest.java @@ -709,12 +709,9 @@ public Test() { }"""); // set logger for adding layouts final StringBuffer buffer = new StringBuffer(); - panel.addBroadcastListener(new ObjectInfoChildAddAfter() { - @Override - public void invoke(ObjectInfo parent, ObjectInfo child) throws Exception { - if (parent == panel && child instanceof LayoutInfo newLayout) { - buffer.append("layout added: " + newLayout.getDescription().getComponentClass().getName()); - } + panel.addBroadcastListener((ObjectInfoChildAddAfter) (parent, child) -> { + if (parent == panel && child instanceof LayoutInfo newLayout) { + buffer.append("layout added: " + newLayout.getDescription().getComponentClass().getName()); } }); // set GridLayout diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/MigLayout/MigLayoutConstraintsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/MigLayout/MigLayoutConstraintsTest.java index fe4a98d719..a54d49e789 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/MigLayout/MigLayoutConstraintsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/MigLayout/MigLayoutConstraintsTest.java @@ -38,8 +38,6 @@ import net.miginfocom.layout.LC; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.Test; import java.awt.Container; @@ -936,23 +934,15 @@ public Test() { assertEquals("", constraints.getString()); // open dialog, but cancel { - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Cell properties").bot(); - { - SWTBotText text = shell.textWithLabel("Specification:"); - text.setText("width 100px"); - } - // changes applied into "constraints" - assertEquals("width 100px", constraints.getString()); - shell.button("Cancel").click(); + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Cell properties").bot(); + { + SWTBotText text = shell.textWithLabel("Specification:"); + text.setText("width 100px"); } + // changes applied into "constraints" + assertEquals("width 100px", constraints.getString()); + shell.button("Cancel").click(); }); // changes of "constraints" rolled back assertEquals("", constraints.getString()); @@ -967,21 +957,13 @@ public Test() { } waitEventLoop(5); // open dialog, commit changes - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() { - action.run(); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Cell properties").bot(); - { - SWTBotText text = shell.textWithLabel("Specification:"); - text.setText("width 100px"); - } - shell.button("OK").click(); + new UiContext().executeAndCheck(() -> action.run(), bot -> { + SWTBot shell = bot.shell("Cell properties").bot(); + { + SWTBotText text = shell.textWithLabel("Specification:"); + text.setText("width 100px"); } + shell.button("OK").click(); }); assertEditor(""" public class Test extends JPanel { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/property/BorderPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/property/BorderPropertyEditorTest.java index 943325211e..8a4ced8f2b 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/property/BorderPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/property/BorderPropertyEditorTest.java @@ -105,12 +105,7 @@ public Test() { ((IClipboardSourceProvider) propertyEditor).getClipboardSource(borderProperty)); } // do copy/paste - doCopyPaste(button, new PasteProcedure() { - @Override - public void run(ComponentInfo copy) throws Exception { - ((FlowLayoutInfo) panel.getLayout()).add(copy, null); - } - }); + doCopyPaste(button, copy -> ((FlowLayoutInfo) panel.getLayout()).add(copy, null)); assertEditor(""" public class Test extends JPanel { public Test() { 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 bb819ccf02..1e5079b7c7 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 @@ -48,10 +48,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -675,17 +672,7 @@ public Test() { { String expectedSource = m_lastEditor.getSource().replace("new ContentProvider", "new ArrayContentProvider"); // open dialog and animate it - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - openPropertyDialog(property); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - animateOpenTypeSelection(bot, "ArrayContentPro", "OK"); - } - }); + new UiContext().executeAndCheck(() -> openPropertyDialog(property), bot -> animateOpenTypeSelection(bot, "ArrayContentPro", "OK")); // check source assertEditor(expectedSource, m_lastEditor); } 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 9f6936662f..ce9c46b207 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 @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.wb.tests.designer.swt.model.layouts; -import org.eclipse.wb.core.model.JavaInfo; import org.eclipse.wb.core.model.ObjectInfoUtils; import org.eclipse.wb.core.model.association.InvocationChildAssociation; import org.eclipse.wb.core.model.broadcast.JavaInfoSetObjectAfter; @@ -47,8 +46,6 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swtbot.swt.finder.SWTBot; -import org.apache.commons.lang3.function.FailableConsumer; -import org.apache.commons.lang3.function.FailableRunnable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -189,13 +186,10 @@ public Test() { // listen for AbsoluteLayoutInfo setObject() during refresh { final boolean[] absoluteLayout_objectSet = new boolean[1]; - shell.addBroadcastListener(new JavaInfoSetObjectAfter() { - @Override - public void invoke(JavaInfo target, Object o) throws Exception { - if (target == absoluteLayout) { - assertNull(o); - absoluteLayout_objectSet[0] = true; - } + shell.addBroadcastListener((JavaInfoSetObjectAfter) (target, o) -> { + if (target == absoluteLayout) { + assertNull(o); + absoluteLayout_objectSet[0] = true; } }); // do refresh @@ -266,19 +260,13 @@ public Test() { }"""); refresh(); // set RowLayout for "inner" - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - CompositeInfo inner = getJavaInfoByName("inner"); - LayoutInfo rowLayout = createJavaInfo("org.eclipse.swt.layout.RowLayout"); - inner.setLayout(rowLayout); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Confirm").bot(); - shell.button("No, keep 'null' layout").click(); - } + new UiContext().executeAndCheck(() -> { + CompositeInfo inner = getJavaInfoByName("inner"); + LayoutInfo rowLayout = createJavaInfo("org.eclipse.swt.layout.RowLayout"); + inner.setLayout(rowLayout); + }, bot -> { + SWTBot shell = bot.shell("Confirm").bot(); + shell.button("No, keep 'null' layout").click(); }); assertEditor(""" public class Test extends Shell { @@ -309,19 +297,13 @@ public Test() { }"""); refresh(); // set RowLayout for "inner" - new UiContext().executeAndCheck(new FailableRunnable<>() { - @Override - public void run() throws Exception { - CompositeInfo inner = getJavaInfoByName("inner"); - LayoutInfo rowLayout = createJavaInfo("org.eclipse.swt.layout.RowLayout"); - inner.setLayout(rowLayout); - } - }, new FailableConsumer<>() { - @Override - public void accept(SWTBot bot) { - SWTBot shell = bot.shell("Confirm").bot(); - shell.button("Yes, use FormLayout").click(); - } + new UiContext().executeAndCheck(() -> { + CompositeInfo inner = getJavaInfoByName("inner"); + LayoutInfo rowLayout = createJavaInfo("org.eclipse.swt.layout.RowLayout"); + inner.setLayout(rowLayout); + }, bot -> { + SWTBot shell = bot.shell("Confirm").bot(); + shell.button("Yes, use FormLayout").click(); }); assertEditor(""" public class Test extends Shell { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/LiveComponentsManagerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/LiveComponentsManagerTest.java index 974e114613..95607bcee8 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/LiveComponentsManagerTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/LiveComponentsManagerTest.java @@ -245,14 +245,11 @@ public Test() { }"""); // add log listener for exception validation ILog log = DesignerPlugin.getDefault().getLog(); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - assertEquals(IStatus.ERROR, status.getSeverity()); - Throwable exception = status.getException(); - Assertions.assertThat(exception).isExactlyInstanceOf(IllegalStateException.class); - assertEquals("Problem in getClientArea()", exception.getMessage()); - } + ILogListener logListener = (status, plugin) -> { + assertEquals(IStatus.ERROR, status.getSeverity()); + Throwable exception = status.getException(); + Assertions.assertThat(exception).isExactlyInstanceOf(IllegalStateException.class); + assertEquals("Problem in getClientArea()", exception.getMessage()); }; // temporary intercept logging try { diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/tests/DesignerTestCase.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/tests/DesignerTestCase.java index 1647e78b74..becb4412b0 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/tests/DesignerTestCase.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/tests/DesignerTestCase.java @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.ILogListener; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.internal.corext.util.OpenTypeHistory; import org.eclipse.jface.action.Action; @@ -187,12 +186,7 @@ private void clearInstanceFields(Class clazz) throws Exception { // //////////////////////////////////////////////////////////////////////////// private int m_numberOfExceptionsDuringThisEditorSession = 0; - private final ILogListener m_logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - m_numberOfExceptionsDuringThisEditorSession++; - } - }; + private final ILogListener m_logListener = (status, plugin) -> m_numberOfExceptionsDuringThisEditorSession++; /** * Adds listener for log. diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/draw2d/FigureTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/draw2d/FigureTest.java index 0bbc578629..5dc704ae65 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/draw2d/FigureTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/draw2d/FigureTest.java @@ -36,7 +36,6 @@ import org.assertj.core.util.Lists; import org.junit.jupiter.api.Test; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.List; @@ -752,10 +751,7 @@ public void test_add_remove_FigureListener() throws Exception { // check init state of listener for new Figure assertFalse(testFigure.getListeners(FigureListener.class).hasNext()); // - FigureListener listener1 = new FigureListener() { - @Override - public void figureMoved(IFigure source) { - } + FigureListener listener1 = source -> { }; testFigure.addFigureListener(listener1); // @@ -765,10 +761,7 @@ public void figureMoved(IFigure source) { assertEquals(1, list.size()); assertSame(listener1, list.get(0)); // - FigureListener listener2 = new FigureListener() { - @Override - public void figureMoved(IFigure source) { - } + FigureListener listener2 = source -> { }; testFigure.addFigureListener(listener2); // @@ -797,12 +790,7 @@ public void figureMoved(IFigure source) { public void test_invoke_FigureListener() throws Exception { final TestLogger actualLogger = new TestLogger(); // - FigureListener listener = new FigureListener() { - @Override - public void figureMoved(IFigure source) { - actualLogger.log("figureMoved(" + source + ")"); - } - }; + FigureListener listener = source -> actualLogger.log("figureMoved(" + source + ")"); // TestLogger expectedLogger = new TestLogger(); // @@ -812,12 +800,7 @@ public String toString() { return "__testFigure_"; } }; - PropertyChangeListener listener1 = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - actualLogger.log("figureReparent(" + event.getOldValue() + ", " + event.getNewValue() + ")"); - } - }; + PropertyChangeListener listener1 = event -> actualLogger.log("figureReparent(" + event.getOldValue() + ", " + event.getNewValue() + ")"); // // check not invoke during addFigureListener() testFigure.addFigureListener(listener); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/CreationToolCursorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/CreationToolCursorTest.java index bf72cf0fd7..a369309da8 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/CreationToolCursorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/CreationToolCursorTest.java @@ -18,7 +18,6 @@ import org.eclipse.draw2d.Cursors; import org.eclipse.gef.EditPart; import org.eclipse.gef.SharedCursors; -import org.eclipse.gef.Tool; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreationFactory; import org.eclipse.gef.requests.SimpleFactory; @@ -414,12 +413,7 @@ public void test_work_updateCursors_Accept_Click_Again_Activate_SelectionTool() m_actualLogger.assertEquals(expectedLogger); } // - m_defaultToolProvider = new IDefaultToolProvider() { - @Override - public Tool getDefaultTool() { - return new SelectionTool(); - } - }; + m_defaultToolProvider = SelectionTool::new; // click to "ShellEditPart" { m_sender.click(60, 60, 1); @@ -455,12 +449,7 @@ public void test_work_updateCursors_Accept_Click_Again_Activate_CreationTool() t } // m_tool = new CreationTool(m_tool.getFactory()); - m_defaultToolProvider = new IDefaultToolProvider() { - @Override - public Tool getDefaultTool() { - return m_tool; - } - }; + m_defaultToolProvider = () -> m_tool; // click to "ShellEditPart" { m_sender.click(60, 60, 1); diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/utils/SWTBotExternalizeDropDownButton.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/utils/SWTBotExternalizeDropDownButton.java index e901c13307..a6fb922d2d 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/utils/SWTBotExternalizeDropDownButton.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/utils/SWTBotExternalizeDropDownButton.java @@ -44,12 +44,9 @@ public SWTBotRootMenu externalizeMenu() throws WidgetNotFoundException { // Set-up Menu[] menu = new Menu[1]; - Listener l = new Listener() { - @Override - public void handleEvent(Event event) { - if (event.widget instanceof Menu m) { - menu[0] = m; - } + Listener l = event -> { + if (event.widget instanceof Menu m) { + menu[0] = m; } }; // Open menu