diff options
author | Lars Vogel | 2016-11-25 18:08:35 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2016-11-28 09:49:40 +0000 |
commit | 158a75ff825054aebb7e9ab680f904eb63500db9 (patch) | |
tree | de34506e75118fba33d565deb3f073db1f405869 /examples | |
parent | 2d160e510e8521c426d131db934a899927b4cccb (diff) | |
download | eclipse.platform.swt-158a75ff825054aebb7e9ab680f904eb63500db9.tar.gz eclipse.platform.swt-158a75ff825054aebb7e9ab680f904eb63500db9.tar.xz eclipse.platform.swt-158a75ff825054aebb7e9ab680f904eb63500db9.zip |
Bug 508155 - Update SWT Snippets FocusListener with lambda expressions
Change-Id: I69f45a131c8b8db3ac6ed1cf3d68b61bf66ea1f9
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'examples')
3 files changed, 15 insertions, 35 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet334.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet334.java index a67ce702ab..e4fa5b918d 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet334.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet334.java @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Lars Vogel <Lars.Vogel@vogella.com> - Bug 507339 + * Lars Vogel <Lars.Vogel@vogella.com> - Bug 507339, 508155 *******************************************************************************/ package org.eclipse.swt.snippets; @@ -20,6 +20,7 @@ package org.eclipse.swt.snippets; * @since 3.6 */ +import static org.eclipse.swt.events.FocusListener.*; import static org.eclipse.swt.events.KeyListener.*; import org.eclipse.swt.*; @@ -64,16 +65,8 @@ public static void main(String[] arg) { // key listener enables traversal out) canvas.addKeyListener(keyPressedAdapter(e-> {})); - canvas.addFocusListener(new FocusAdapter() { - @Override - public void focusGained(FocusEvent e) { - canvas.redraw(); - } - @Override - public void focusLost(FocusEvent e) { - canvas.redraw(); - } - }); + canvas.addFocusListener(focusGainedAdapter(event-> canvas.redraw())); + canvas.addFocusListener(focusLostAdapter(event-> canvas.redraw())); canvas.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java index e9673156c0..eba4f7f202 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@vogella.com> - Bug 508155 *******************************************************************************/ package org.eclipse.swt.snippets; @@ -18,8 +19,10 @@ package org.eclipse.swt.snippets; * * @since 3.6 */ + +import static org.eclipse.swt.events.FocusListener.*; + import org.eclipse.swt.*; -import org.eclipse.swt.events.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; @@ -67,16 +70,9 @@ public static void main(String[] args) { canvas.traverse(traversal, event); } }); - canvas.addFocusListener(new FocusListener() { - @Override - public void focusLost(FocusEvent e) { - canvas.redraw(); - } - @Override - public void focusGained(FocusEvent e) { - canvas.redraw(); - } - }); + canvas.addFocusListener(focusLostAdapter(e->canvas.redraw())); + canvas.addFocusListener(focusGainedAdapter(e->canvas.redraw())); + Text text2 = new Text(composite, SWT.SINGLE); Button button = new Button(childShell, SWT.PUSH); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java index 399c1e68f2..ee2d39bba1 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Lars Vogel <Lars.Vogel@vogella.com> - Bug 507185 + * Lars Vogel <Lars.Vogel@vogella.com> - Bug 507185, 508155 *******************************************************************************/ package org.eclipse.swt.snippets; @@ -20,6 +20,7 @@ package org.eclipse.swt.snippets; * http://www.eclipse.org/swt/snippets/ */ +import static org.eclipse.swt.events.FocusListener.*; import static org.eclipse.swt.events.KeyListener.*; import org.eclipse.swt.*; @@ -87,12 +88,7 @@ public static void main(String[] args) { } })); // close the text editor when the user tabs away - text.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - text.dispose(); - } - }); + text.addFocusListener(focusLostAdapter(event-> text.dispose())); editor.setEditor(text); text.setFocus(); } @@ -131,12 +127,7 @@ public static void main(String[] args) { } })); // close the text editor when the user clicks away - text.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - text.dispose(); - } - }); + text.addFocusListener(focusLostAdapter(event-> text.dispose())); editor.setEditor(text); text.setFocus(); } |