Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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