Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2017-03-29 05:26:57 -0400
committerAlexander Kurtakov2017-03-30 07:20:13 -0400
commit421056971ab86c3fe5f5ba7b4494de4335069b2c (patch)
tree67e9005bc66c08108670742f16c4d6e40ea2646d
parentb515cd1fa98fe02aacaf2d2e1a49b77ad4ed5aff (diff)
downloadeclipse.platform.swt-421056971ab86c3fe5f5ba7b4494de4335069b2c.tar.gz
eclipse.platform.swt-421056971ab86c3fe5f5ba7b4494de4335069b2c.tar.xz
eclipse.platform.swt-421056971ab86c3fe5f5ba7b4494de4335069b2c.zip
Bug 509086 - Use lambda helper methods in org.eclipse.swt.examples -
Part 3 Removes also unused imports Change-Id: Iccfd0e997249e4582661f37aecc539e14cfbebd9 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java104
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java107
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java9
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolTipTab.java25
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java109
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/TextTool.java22
6 files changed, 123 insertions, 253 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
index 7da872a3df..673f773e2c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import java.io.IOException;
import java.io.InputStream;
@@ -24,8 +26,6 @@ import org.eclipse.swt.custom.TextChangedEvent;
import org.eclipse.swt.custom.TextChangingEvent;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -212,63 +212,57 @@ class StyledTextTab extends ScrollableTab {
label.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
yellowButton = new Button (styledTextStyleGroup, SWT.PUSH);
yellowButton.setImage (yellowImage);
- SelectionListener styleListener = new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- Point sel = styledText.getSelectionRange();
- if ((sel == null) || (sel.y == 0)) return;
- StyleRange style;
- for (int i = sel.x; i<sel.x+sel.y; i++) {
- StyleRange range = styledText.getStyleRangeAtOffset(i);
- if (range != null && e.widget != resetButton) {
- style = (StyleRange)range.clone();
- style.start = i;
- style.length = 1;
- } else {
- style = new StyleRange(i, 1, null, null, SWT.NORMAL);
- }
- if (e.widget == boldButton) {
- style.fontStyle ^= SWT.BOLD;
- } else if (e.widget == italicButton) {
- style.fontStyle ^= SWT.ITALIC;
- } else if (e.widget == underlineButton) {
- style.underline = !style.underline;
- } else if (e.widget == strikeoutButton) {
- style.strikeout = !style.strikeout;
- }
- styledText.setStyleRange(style);
+ SelectionListener styleListener = widgetSelectedAdapter(e -> {
+ Point sel = styledText.getSelectionRange();
+ if ((sel == null) || (sel.y == 0)) return;
+ StyleRange style;
+ for (int i = sel.x; i<sel.x+sel.y; i++) {
+ StyleRange range = styledText.getStyleRangeAtOffset(i);
+ if (range != null && e.widget != resetButton) {
+ style = (StyleRange)range.clone();
+ style.start = i;
+ style.length = 1;
+ } else {
+ style = new StyleRange(i, 1, null, null, SWT.NORMAL);
}
- styledText.setSelectionRange(sel.x + sel.y, 0);
- }
- };
- SelectionListener colorListener = new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent e) {
- Point sel = styledText.getSelectionRange();
- if ((sel == null) || (sel.y == 0)) return;
- Color fg = null, bg = null;
- if (e.widget == redButton) {
- fg = display.getSystemColor (SWT.COLOR_RED);
- } else if (e.widget == yellowButton) {
- bg = display.getSystemColor (SWT.COLOR_YELLOW);
+ if (e.widget == boldButton) {
+ style.fontStyle ^= SWT.BOLD;
+ } else if (e.widget == italicButton) {
+ style.fontStyle ^= SWT.ITALIC;
+ } else if (e.widget == underlineButton) {
+ style.underline = !style.underline;
+ } else if (e.widget == strikeoutButton) {
+ style.strikeout = !style.strikeout;
}
- StyleRange style;
- for (int i = sel.x; i<sel.x+sel.y; i++) {
- StyleRange range = styledText.getStyleRangeAtOffset(i);
- if (range != null) {
- style = (StyleRange)range.clone();
- style.start = i;
- style.length = 1;
- if (fg != null) style.foreground = style.foreground != null ? null : fg;
- if (bg != null) style.background = style.background != null ? null : bg;
- } else {
- style = new StyleRange (i, 1, fg, bg, SWT.NORMAL);
- }
- styledText.setStyleRange(style);
+ styledText.setStyleRange(style);
+ }
+ styledText.setSelectionRange(sel.x + sel.y, 0);
+ });
+ SelectionListener colorListener = widgetSelectedAdapter(e -> {
+ Point sel = styledText.getSelectionRange();
+ if ((sel == null) || (sel.y == 0)) return;
+ Color fg = null, bg = null;
+ if (e.widget == redButton) {
+ fg = display.getSystemColor (SWT.COLOR_RED);
+ } else if (e.widget == yellowButton) {
+ bg = display.getSystemColor (SWT.COLOR_YELLOW);
+ }
+ StyleRange style;
+ for (int i = sel.x; i<sel.x+sel.y; i++) {
+ StyleRange range = styledText.getStyleRangeAtOffset(i);
+ if (range != null) {
+ style = (StyleRange)range.clone();
+ style.start = i;
+ style.length = 1;
+ if (fg != null) style.foreground = style.foreground != null ? null : fg;
+ if (bg != null) style.background = style.background != null ? null : bg;
+ } else {
+ style = new StyleRange (i, 1, fg, bg, SWT.NORMAL);
}
- styledText.setSelectionRange(sel.x + sel.y, 0);
+ styledText.setStyleRange(style);
}
- };
+ styledText.setSelectionRange(sel.x + sel.y, 0);
+ });
resetButton.addSelectionListener(styleListener);
boldButton.addSelectionListener(styleListener);
italicButton.addSelectionListener(styleListener);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
index e962a13db5..61e40977d2 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -265,54 +265,14 @@ class TableTab extends ScrollableTab {
subImagesButton.setText (ControlExample.getResourceString("Sub_Images"));
/* Add the listeners */
- linesVisibleButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetLinesVisible ();
- }
- });
- multipleColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
- headerVisibleButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetHeaderVisible ();
- }
- });
- sortIndicatorButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetSortIndicator ();
- }
- });
- moveableColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setColumnsMoveable ();
- }
- });
- resizableColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setColumnsResizable ();
- }
- });
- headerImagesButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
- subImagesButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
+ linesVisibleButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetLinesVisible ()));
+ multipleColumns.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
+ headerVisibleButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetHeaderVisible ()));
+ sortIndicatorButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetSortIndicator ()));
+ moveableColumns.addSelectionListener (widgetSelectedAdapter(event -> setColumnsMoveable ()));
+ resizableColumns.addSelectionListener (widgetSelectedAdapter(event -> setColumnsResizable ()));
+ headerImagesButton.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
+ subImagesButton.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
}
/**
@@ -395,13 +355,10 @@ class TableTab extends ScrollableTab {
packColumnsButton = new Button (sizeGroup, SWT.PUSH);
packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns"));
- packColumnsButton.addSelectionListener(new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- packColumns ();
- setExampleWidgetSize ();
- }
- });
+ packColumnsButton.addSelectionListener(widgetSelectedAdapter(event -> {
+ packColumns ();
+ setExampleWidgetSize ();
+ }));
}
/**
@@ -745,22 +702,19 @@ class TableTab extends ScrollableTab {
for (int i = 0; i < columns.length; i++) {
TableColumn column = columns[i];
if (i == 0) table1.setSortColumn(column);
- SelectionListener listener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int sortDirection = SWT.DOWN;
- if (e.widget == table1.getSortColumn()) {
- /* If the sort column hasn't changed, cycle down -> up -> none. */
- switch (table1.getSortDirection ()) {
- case SWT.DOWN: sortDirection = SWT.UP; break;
- case SWT.UP: sortDirection = SWT.NONE; break;
- }
- } else {
- table1.setSortColumn((TableColumn)e.widget);
+ SelectionListener listener = widgetSelectedAdapter(e -> {
+ int sortDirection = SWT.DOWN;
+ if (e.widget == table1.getSortColumn()) {
+ /* If the sort column hasn't changed, cycle down -> up -> none. */
+ switch (table1.getSortDirection ()) {
+ case SWT.DOWN: sortDirection = SWT.UP; break;
+ case SWT.UP: sortDirection = SWT.NONE; break;
}
- table1.setSortDirection (sortDirection);
+ } else {
+ table1.setSortColumn((TableColumn)e.widget);
}
- };
+ table1.setSortDirection (sortDirection);
+ });
column.addSelectionListener(listener);
column.setData("SortListener", listener); //$NON-NLS-1$
}
@@ -785,12 +739,9 @@ class TableTab extends ScrollableTab {
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText("getItem(Point) on mouse coordinates");
menuMouseCoords = table1.toControl(new Point(event.x, event.y));
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + table1.getItem(menuMouseCoords));
- eventConsole.append ("\n");
- }
- });
+ item.addSelectionListener(widgetSelectedAdapter(e -> {
+ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + table1.getItem(menuMouseCoords));
+ eventConsole.append ("\n");
+ }));
}
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java
index 3dac1c503b..7f9be02e8a 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java
@@ -11,6 +11,8 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -236,12 +238,7 @@ class ToolBarTab extends Tab {
comboChildButton.setText (ControlExample.getResourceString("Combo_child"));
/* Add the listeners */
- comboChildButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
+ comboChildButton.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
}
/**
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolTipTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolTipTab.java
index ab47da1855..a25256703c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolTipTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolTipTab.java
@@ -11,11 +11,11 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -63,12 +63,7 @@ class ToolTipTab extends Tab {
toolTipGroup.setText ("ToolTip");
visibleButton = new Button(toolTipGroup, SWT.CHECK);
visibleButton.setText(ControlExample.getResourceString("Visible"));
- visibleButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setExampleWidgetVisibility ();
- }
- });
+ visibleButton.addSelectionListener (widgetSelectedAdapter(event -> setExampleWidgetVisibility ()));
}
/**
@@ -158,18 +153,8 @@ class ToolTipTab extends Tab {
showInTrayButton.setEnabled(tray != null);
/* Add the listeners */
- autoHideButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setExampleWidgetAutoHide ();
- }
- });
- showInTrayButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- showExampleWidgetInTray ();
- }
- });
+ autoHideButton.addSelectionListener (widgetSelectedAdapter(event -> setExampleWidgetAutoHide ()));
+ showInTrayButton.addSelectionListener (widgetSelectedAdapter(event -> showExampleWidgetInTray ()));
shell.addDisposeListener(event -> disposeTrayItem());
/* Set the default state */
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
index 6fd29a076f..542ae8e908 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
@@ -11,9 +11,9 @@
package org.eclipse.swt.examples.controlexample;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -232,54 +232,14 @@ class TreeTab extends ScrollableTab {
subImagesButton.setText (ControlExample.getResourceString("Sub_Images"));
/* Add the listeners */
- linesVisibleButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetLinesVisible ();
- }
- });
- multipleColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
- headerVisibleButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetHeaderVisible ();
- }
- });
- sortIndicatorButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setWidgetSortIndicator ();
- }
- });
- moveableColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setColumnsMoveable ();
- }
- });
- resizableColumns.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- setColumnsResizable ();
- }
- });
- headerImagesButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
- subImagesButton.addSelectionListener (new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- recreateExampleWidgets ();
- }
- });
+ linesVisibleButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetLinesVisible ()));
+ multipleColumns.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
+ headerVisibleButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetHeaderVisible ()));
+ sortIndicatorButton.addSelectionListener (widgetSelectedAdapter(event -> setWidgetSortIndicator ()));
+ moveableColumns.addSelectionListener (widgetSelectedAdapter(event -> setColumnsMoveable ()));
+ resizableColumns.addSelectionListener (widgetSelectedAdapter(event -> setColumnsResizable ()));
+ headerImagesButton.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
+ subImagesButton.addSelectionListener (widgetSelectedAdapter(event -> recreateExampleWidgets ()));
}
/**
@@ -426,14 +386,11 @@ class TreeTab extends ScrollableTab {
packColumnsButton = new Button (sizeGroup, SWT.PUSH);
packColumnsButton.setText (ControlExample.getResourceString("Pack_Columns"));
- packColumnsButton.addSelectionListener(new SelectionAdapter () {
- @Override
- public void widgetSelected (SelectionEvent event) {
- packColumns (tree1);
- packColumns (tree2);
- setExampleWidgetSize ();
- }
- });
+ packColumnsButton.addSelectionListener(widgetSelectedAdapter(event -> {
+ packColumns (tree1);
+ packColumns (tree2);
+ setExampleWidgetSize ();
+ }));
}
/**
@@ -769,22 +726,19 @@ class TreeTab extends ScrollableTab {
for (int i = 0; i < columns.length; i++) {
TreeColumn column = columns[i];
if (i == 0) tree.setSortColumn(column);
- SelectionListener listener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int sortDirection = SWT.DOWN;
- if (e.widget == tree.getSortColumn()) {
- /* If the sort column hasn't changed, cycle down -> up -> none. */
- switch (tree.getSortDirection ()) {
- case SWT.DOWN: sortDirection = SWT.UP; break;
- case SWT.UP: sortDirection = SWT.NONE; break;
- }
- } else {
- tree.setSortColumn((TreeColumn)e.widget);
+ SelectionListener listener = widgetSelectedAdapter(e -> {
+ int sortDirection = SWT.DOWN;
+ if (e.widget == tree.getSortColumn()) {
+ /* If the sort column hasn't changed, cycle down -> up -> none. */
+ switch (tree.getSortDirection ()) {
+ case SWT.DOWN: sortDirection = SWT.UP; break;
+ case SWT.UP: sortDirection = SWT.NONE; break;
}
- tree.setSortDirection (sortDirection);
+ } else {
+ tree.setSortColumn((TreeColumn)e.widget);
}
- };
+ tree.setSortDirection (sortDirection);
+ });
column.addSelectionListener(listener);
column.setData("SortListener", listener); //$NON-NLS-1$
}
@@ -813,12 +767,9 @@ class TreeTab extends ScrollableTab {
item.setText("getItem(Point) on mouse coordinates");
final Tree t = (Tree) event.widget;
menuMouseCoords = t.toControl(new Point(event.x, event.y));
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords));
- eventConsole.append ("\n");
- }
- });
+ item.addSelectionListener(widgetSelectedAdapter(e -> {
+ eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords));
+ eventConsole.append ("\n");
+ }));
}
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/TextTool.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/TextTool.java
index 2bf75e2b7e..de1c7c1ae2 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/TextTool.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/TextTool.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.examples.paint;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -119,21 +119,13 @@ public class TextTool extends BasicPaintSession implements PaintTool {
Button ok = new Button(buttons, SWT.PUSH);
ok.setText(PaintExample.getResourceString("OK"));
ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- ok.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- drawText = field.getText();
- dialog.dispose();
- }
- });
+ ok.addSelectionListener(widgetSelectedAdapter(e -> {
+ drawText = field.getText();
+ dialog.dispose();
+ }));
Button cancel = new Button(buttons, SWT.PUSH);
cancel.setText(PaintExample.getResourceString("Cancel"));
- cancel.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- dialog.dispose();
- }
- });
+ cancel.addSelectionListener(widgetSelectedAdapter(e -> dialog.dispose()));
dialog.setDefaultButton(ok);
dialog.pack();
dialog.open();

Back to the top