Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2016-09-13 19:10:45 +0000
committerAlexander Kurtakov2016-09-21 08:01:49 +0000
commit806829c269af091f858f3f4f7be3f6212583d81c (patch)
tree43cad8715c075a89780b2f54c9d3decb7e064106 /bundles
parentab52d77e78d5e8b024a9f036eaccfa04f45dc165 (diff)
downloadeclipse.platform.swt-806829c269af091f858f3f4f7be3f6212583d81c.tar.gz
eclipse.platform.swt-806829c269af091f858f3f4f7be3f6212583d81c.tar.xz
eclipse.platform.swt-806829c269af091f858f3f4f7be3f6212583d81c.zip
Bug 441116 - [api] Create functional interface to use Lambda expressions
for selection events based on SelectionListener Change-Id: I304cb659fa1abb10fd17d6d0abe655b1004603a2 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
index 3c570b2b89..cc897a4f61 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
@@ -7,10 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 441116
*******************************************************************************/
package org.eclipse.swt.events;
+import java.util.function.*;
+
import org.eclipse.swt.internal.*;
/**
@@ -60,6 +63,41 @@ public void widgetSelected(SelectionEvent e);
*/
public void widgetDefaultSelected(SelectionEvent e);
+
+
+/**
+ * Static helper method to create a selection listener for the
+ * {@link #widgetSelected(SelectionEvent e)}) method with a lambda expression.
+ *
+ * @param c the consumer of the event
+ * @return SelectionListener
+ * @since 3.106
+ */
+public static SelectionListener widgetSelectedAdapter(Consumer<SelectionEvent> c) {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ c.accept(e);
+ }
+ };
}
+/**
+ * Static helper method to create a selection listener for the
+ * {@link #widgetDefaultSelected(SelectionEvent e)}) method with a lambda expression.
+ *
+ * @param c the consumer of the event
+ * @return SelectionListener
+ * @since 3.106
+*/
+public static SelectionListener widgetDefaultSelectedAdapter(Consumer<SelectionEvent> c) {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
+}

Back to the top