Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-16 15:55:35 +0000
committerAlexander Kurtakov2017-08-16 18:15:38 +0000
commit8e2a55127f5c83fa4aa93d5601bfc307b1669276 (patch)
treeb3e555973750284f5ede83d01015ae8194692e09 /bundles/org.eclipse.swt/Eclipse SWT Browser
parent98870ecbd1255ec61abddc2e93c347a133199bfc (diff)
downloadeclipse.platform.swt-8e2a55127f5c83fa4aa93d5601bfc307b1669276.tar.gz
eclipse.platform.swt-8e2a55127f5c83fa4aa93d5601bfc307b1669276.tar.xz
eclipse.platform.swt-8e2a55127f5c83fa4aa93d5601bfc307b1669276.zip
Bug 521024 - [api] Provide helpers to use lambda expressions for Browser
listeners Add helper methods. Change-Id: I373cf73c439b0c68e3c8602bc3a99fcbe3a4338a Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Browser')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationAdapter.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationListener.java41
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressAdapter.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressListener.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowAdapter.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowListener.java40
6 files changed, 131 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationAdapter.java
index e306d56fbb..89d2f51246 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationAdapter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2016 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,11 @@ package org.eclipse.swt.browser;
* extend this class and override only the methods which they are
* interested in.
* </p>
+ * <p>
+ * An alternative to this class are the static helper methods in
+ * {@link LocationListener},
+ * which accept a lambda expression or a method reference that implements the event consumer.
+ * </p>
*
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationListener.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationListener.java
index 348fec171f..3d9591e6e1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/LocationListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.swt.browser;
-import org.eclipse.swt.internal.SWTEventListener;
+import java.util.function.*;
+
+import org.eclipse.swt.internal.*;
/**
* This listener interface may be implemented in order to receive
@@ -19,6 +21,7 @@ import org.eclipse.swt.internal.SWTEventListener;
*
* @see Browser#addLocationListener(LocationListener)
* @see Browser#removeLocationListener(LocationListener)
+ * @see LocationAdapter
*
* @since 3.0
*/
@@ -62,4 +65,38 @@ public void changing(LocationEvent event);
*/
public void changed(LocationEvent event);
+/**
+ * Static helper method to create a <code>LocationListener</code> for the
+ * {@link #changing(LocationEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static LocationListener changingAdapter(Consumer<LocationEvent> c) {
+ return new LocationAdapter() {
+ @Override
+ public void changing(LocationEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
+/**
+ * Static helper method to create a <code>LocationListener</code> for the
+ * {@link #changed(LocationEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static LocationListener changedAdapter(Consumer<LocationEvent> c) {
+ return new LocationAdapter() {
+ @Override
+ public void changed(LocationEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressAdapter.java
index 1cfd6ae678..f770ea0a86 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressAdapter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressAdapter.java
@@ -18,6 +18,11 @@ package org.eclipse.swt.browser;
* extend this class and override only the methods which they are
* interested in.
* </p>
+ * <p>
+ * An alternative to this class are the static helper methods in
+ * {@link ProgressListener},
+ * which accept a lambda expression or a method reference that implements the event consumer.
+ * </p>
*
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressListener.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressListener.java
index 18615170d5..ec1e75547b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/ProgressListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.swt.browser;
-import org.eclipse.swt.internal.SWTEventListener;
+import java.util.function.*;
+
+import org.eclipse.swt.internal.*;
/**
* This listener interface may be implemented in order to receive
@@ -60,4 +62,38 @@ public void changed(ProgressEvent event);
* @since 3.0
*/
public void completed(ProgressEvent event);
+
+/**
+ * Static helper method to create a <code>ProgressListener</code> for the
+ * {@link #changed(ProgressEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static ProgressListener changedAdapter(Consumer<ProgressEvent> c) {
+ return new ProgressAdapter() {
+ @Override
+ public void changed(ProgressEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
+/**
+ * Static helper method to create a <code>ProgressListener</code> for the
+ * {@link #completed(ProgressEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static ProgressListener completedAdapter(Consumer<ProgressEvent> c) {
+ return new ProgressAdapter() {
+ @Override
+ public void completed(ProgressEvent e) {
+ c.accept(e);
+ }
+ };
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowAdapter.java
index 7886aca05a..d4e70b32b3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowAdapter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2016 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,10 @@ package org.eclipse.swt.browser;
* extend this class and override only the methods which they are
* interested in.
* </p>
+ * An alternative to this class are the static helper methods in
+ * {@link VisibilityWindowListener},
+ * which accept a lambda expression or a method reference that implements the event consumer.
+ * </p>
*
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowListener.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowListener.java
index 711a8c91d6..c9e528d142 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/VisibilityWindowListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.swt.browser;
-import org.eclipse.swt.internal.SWTEventListener;
+import java.util.function.*;
+
+import org.eclipse.swt.internal.*;
/**
* This listener interface may be implemented in order to receive
@@ -88,4 +90,38 @@ public void hide(WindowEvent event);
*/
public void show(WindowEvent event);
+/**
+ * Static helper method to create a <code>VisibilityWindowListener</code> for thehide
+ * {@link #hide(WindowEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static VisibilityWindowListener hideAdapter(Consumer<WindowEvent> c) {
+ return new VisibilityWindowAdapter() {
+ @Override
+ public void hide(WindowEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
+/**
+ * Static helper method to create a <code>VisibilityWindowListener</code> for the
+ * {@link #show(WindowEvent e)}) method, given a lambda expression or a method reference.
+ *
+ * @param c the consumer of the event
+ * @return LocationListener
+ * @since 3.107
+ */
+public static VisibilityWindowListener showAdapter(Consumer<WindowEvent> c) {
+ return new VisibilityWindowAdapter() {
+ @Override
+ public void show(WindowEvent e) {
+ c.accept(e);
+ }
+ };
+}
+
}

Back to the top