Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-10 07:15:50 +0000
committerAlexander Kurtakov2017-08-10 07:15:50 +0000
commita6ea6a1498989e3e2c7bef97b2099bb1ee718619 (patch)
tree579fc82629cd0d6a12bdb9f1d662fc3ba7aad31c /examples/org.eclipse.swt.snippets/src/org
parentfe4627a9d6e65c5ba9046b8ea50e9aacd64eb7a3 (diff)
downloadeclipse.platform.swt-a6ea6a1498989e3e2c7bef97b2099bb1ee718619.tar.gz
eclipse.platform.swt-a6ea6a1498989e3e2c7bef97b2099bb1ee718619.tar.xz
eclipse.platform.swt-a6ea6a1498989e3e2c7bef97b2099bb1ee718619.zip
Bug 512342 - [api] Provide helper methods to use lambda expressions for
ControlListener Use the new helper methods through out the swt codebase. Change-Id: Ide620b5e33829fd7aaa772f78427aa0e69bca094 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'examples/org.eclipse.swt.snippets/src/org')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java13
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java11
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet77.java59
3 files changed, 37 insertions, 46 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java
index 6a60d6ed97..60132839c3 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -52,13 +52,10 @@ public static void main(String[] args) {
scrollComposite.setContent(parent);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
- scrollComposite.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Rectangle r = scrollComposite.getClientArea();
- scrollComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT));
- }
- });
+ scrollComposite.addControlListener(ControlListener.controlResizedAdapter(e -> {
+ Rectangle r = scrollComposite.getClientArea();
+ scrollComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT));
+ }));
shell.open();
while (!shell.isDisposed()) {
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java
index 1f6b2547f4..2f31442164 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -49,12 +49,9 @@ public static void main(String[] args) {
GLData data = new GLData();
data.doubleBuffer = true;
final GLCanvas canvas = new GLCanvas(shell, SWT.NO_BACKGROUND, data);
- canvas.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- resize(canvas);
- }
- });
+ canvas.addControlListener(ControlListener.controlResizedAdapter(e -> {
+ resize(canvas);
+ }));
init(canvas);
new Runnable() {
@Override
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet77.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet77.java
index 6556847fbd..a4d8463fcb 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet77.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet77.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -41,37 +41,34 @@ public static void main(String[] args) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] {"item 0" + i, "item 1"+i});
}
- comp.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Rectangle area = comp.getClientArea();
- Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- ScrollBar vBar = table.getVerticalBar();
- int width = area.width - table.computeTrim(0,0,0,0).width - vBar.getSize().x;
- if (size.y > area.height + table.getHeaderHeight()) {
- // Subtract the scrollbar width from the total column width
- // if a vertical scrollbar will be required
- Point vBarSize = vBar.getSize();
- width -= vBarSize.x;
- }
- Point oldSize = table.getSize();
- if (oldSize.x > area.width) {
- // table is getting smaller so make the columns
- // smaller first and then resize the table to
- // match the client area width
- column1.setWidth(width/3);
- column2.setWidth(width - column1.getWidth());
- table.setSize(area.width, area.height);
- } else {
- // table is getting bigger so make the table
- // bigger first and then make the columns wider
- // to match the client area width
- table.setSize(area.width, area.height);
- column1.setWidth(width/3);
- column2.setWidth(width - column1.getWidth());
- }
+ comp.addControlListener(ControlListener.controlResizedAdapter(e -> {
+ Rectangle area = comp.getClientArea();
+ Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ ScrollBar vBar = table.getVerticalBar();
+ int width = area.width - table.computeTrim(0, 0, 0, 0).width - vBar.getSize().x;
+ if (size.y > area.height + table.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = vBar.getSize();
+ width -= vBarSize.x;
}
- });
+ Point oldSize = table.getSize();
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ column1.setWidth(width / 3);
+ column2.setWidth(width - column1.getWidth());
+ table.setSize(area.width, area.height);
+ } else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ table.setSize(area.width, area.height);
+ column1.setWidth(width / 3);
+ column2.setWidth(width - column1.getWidth());
+ }
+ }));
shell.open();
while (!shell.isDisposed()) {

Back to the top