diff options
author | David Weiser | 2016-12-12 15:33:23 +0000 |
---|---|---|
committer | David Weiser | 2016-12-13 10:49:02 +0000 |
commit | a51e9b60a4d6f1ce13e48f0c284d6c283baa073b (patch) | |
tree | 0a9eefbcdf6f479d3c215a8a313523076be774de /examples | |
parent | c2aae3dd4e11c36d90967cb919a7eda79e2c6474 (diff) | |
download | eclipse.platform.swt-a51e9b60a4d6f1ce13e48f0c284d6c283baa073b.tar.gz eclipse.platform.swt-a51e9b60a4d6f1ce13e48f0c284d6c283baa073b.tar.xz eclipse.platform.swt-a51e9b60a4d6f1ce13e48f0c284d6c283baa073b.zip |
Bug 509086 - Use SelectionListener lambda helper methods in
org.eclipse.swt.examples
* Changes SelectionListener to lambda method in
org.eclipse.swt.examples.accessibility
Change-Id: Ib516a5c7b7ef7f053469e830134dba4136f6b7d6
Signed-off-by: David Weiser <david.weiser@vogella.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleTableExample.java | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleTableExample.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleTableExample.java index 4d885ce022..fa0c1364fa 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleTableExample.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleTableExample.java @@ -10,12 +10,21 @@ *******************************************************************************/ package org.eclipse.swt.examples.accessibility; -import java.util.*; +import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; -import org.eclipse.swt.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; /** * This example shows how to use AccessibleTableListener and @@ -72,66 +81,51 @@ public class AccessibleTableExample { btnGroup.setLayout(new FillLayout(SWT.VERTICAL)); Button btn = new Button(btnGroup, SWT.PUSH); btn.setText("Add rows"); - btn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int currSize = table1.getItemCount(); - int colCount = table1.getColumnCount(); - CTableItem item = new CTableItem(table1, SWT.NONE); - String[] cells = new String[colCount]; + btn.addSelectionListener(widgetSelectedAdapter(e -> { + int currSize = table1.getItemCount(); + int colCount = table1.getColumnCount(); + CTableItem item = new CTableItem(table1, SWT.NONE); + String[] cells = new String[colCount]; - for (int i = 0; i < colCount; i++) { - cells[i] = "C" + i + "R" + currSize; - } - item.setText(cells); + for (int i = 0; i < colCount; i++) { + cells[i] = "C" + i + "R" + currSize; } - }); + item.setText(cells); + })); btn = new Button(btnGroup, SWT.PUSH); btn.setText("Remove rows"); - btn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int currSize = table1.getItemCount(); - if (currSize > 0) { - table1.remove(currSize - 1); - } + btn.addSelectionListener(widgetSelectedAdapter(e -> { + int currSize = table1.getItemCount(); + if (currSize > 0) { + table1.remove(currSize - 1); } - }); + })); btn = new Button(btnGroup, SWT.PUSH); btn.setText("Remove selected rows"); - btn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - CTableItem[] selectedItems = table1.getSelection(); - for (CTableItem selectedItem : selectedItems) { - selectedItem.dispose(); - } + btn.addSelectionListener(widgetSelectedAdapter(e -> { + CTableItem[] selectedItems = table1.getSelection(); + for (CTableItem selectedItem : selectedItems) { + selectedItem.dispose(); } - }); + })); btn = new Button(btnGroup, SWT.PUSH); btn.setText("Add column"); - btn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int currSize = table1.getColumnCount(); - CTableColumn item = new CTableColumn(table1, SWT.NONE); - item.setText("Col " + currSize); - item.setWidth(50); - } - }); + btn.addSelectionListener(widgetSelectedAdapter(e -> { + int currSize = table1.getColumnCount(); + CTableColumn item = new CTableColumn(table1, SWT.NONE); + item.setText("Col " + currSize); + item.setWidth(50); + })); btn = new Button(btnGroup, SWT.PUSH); btn.setText("Remove last column"); - btn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int colCount = table1.getColumnCount(); - if (colCount > 0) { - CTableColumn column = table1.getColumn(colCount - 1); - column.dispose(); - } + btn.addSelectionListener(widgetSelectedAdapter(e -> { + int colCount = table1.getColumnCount(); + if (colCount > 0) { + CTableColumn column = table1.getColumn(colCount - 1); + column.dispose(); } - }); + })); new Label(group, SWT.NONE).setText("CTable used as a list"); |