diff options
17 files changed, 127 insertions, 192 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java index 42cd17bcd0..36eb0c76c9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -74,12 +74,7 @@ public AnimatedProgress(Composite parent, int style) { } showBorder = (style & SWT.BORDER) != 0; - addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - redraw(); - } - }); + addControlListener(ControlListener.controlResizedAdapter(e -> redraw())); addPaintListener(e -> paint(e)); addDisposeListener(e -> stop()); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java index 3bbd223cb0..f78bbd60be 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -58,15 +58,10 @@ public PopupList(Shell parent, int style) { shell.addListener(SWT.Deactivate, e -> shell.setVisible (false)); // resize shell when list resizes - shell.addControlListener(new ControlListener() { - @Override - public void controlMoved(ControlEvent e){} - @Override - public void controlResized(ControlEvent e){ - Rectangle shellSize = shell.getClientArea(); - list.setSize(shellSize.width, shellSize.height); - } - }); + shell.addControlListener(ControlListener.controlResizedAdapter(e -> { + Rectangle shellSize = shell.getClientArea(); + list.setSize(shellSize.width, shellSize.height); + })); // return list selection on Mouse Up or Carriage Return list.addMouseListener(new MouseListener() { diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java index 2f90c64ee2..f30c836431 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java @@ -27,8 +27,7 @@ import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.browser.VisibilityWindowListener; import org.eclipse.swt.browser.WindowEvent; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -188,12 +187,7 @@ class BrowserTab extends Tab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e-> setExampleWidgetSize ())); /* * Add a selection listener to the tabFolder to bring up a diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CanvasTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CanvasTab.java index e5efc996e5..a2407f12f5 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CanvasTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CanvasTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -14,8 +14,7 @@ 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.ControlListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; @@ -136,14 +135,12 @@ class CanvasTab extends Tab { Point extent = gc.textExtent(canvasString); gc.drawString(canvasString, cx + (size.x - extent.x) / 2, cy - extent.y + (size.y - 10) / 2, true); }); - canvas.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent event) { - Point size = canvas.getSize (); - maxX = size.x * 3 / 2; maxY = size.y * 3 / 2; - resizeScrollBars (); - } - }); + canvas.addControlListener(ControlListener.controlResizedAdapter(e -> { + Point size = canvas.getSize(); + maxX = size.x * 3 / 2; + maxY = size.y * 3 / 2; + resizeScrollBars(); + })); ScrollBar bar = canvas.getHorizontalBar(); if (bar != null) { hookListeners (bar); @@ -200,12 +197,7 @@ class CanvasTab extends Tab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ComboTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ComboTab.java index 9b71ffbb21..6c86e52b34 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ComboTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ComboTab.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 @@ -11,10 +11,16 @@ package org.eclipse.swt.examples.controlexample; -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Widget; class ComboTab extends Tab { @@ -92,12 +98,7 @@ class ComboTab extends Tab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java index 1ddaf306d6..465136130f 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SashTab.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 @@ -10,14 +10,20 @@ *******************************************************************************/ package org.eclipse.swt.examples.controlexample; - import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.events.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Sash; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Widget; class SashTab extends Tab { /* Example widgets and groups that contain them */ @@ -117,12 +123,7 @@ class SashTab extends Tab { layout (); } })); - sashComp.addControlListener (new ControlAdapter () { - @Override - public void controlResized (ControlEvent event) { - resized (); - } - }); + sashComp.addControlListener (ControlListener.controlResizedAdapter(e -> resized ())); } /** diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java index 3d457bb36f..445ee6f9dc 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/SpinnerTab.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 @@ -13,10 +13,16 @@ package org.eclipse.swt.examples.controlexample; import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +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.Group; +import org.eclipse.swt.widgets.Spinner; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Widget; class SpinnerTab extends RangeTab { @@ -166,12 +172,7 @@ class SpinnerTab extends RangeTab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } 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 673f773e2c..a5ddef0493 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -24,8 +24,7 @@ import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.TextChangeListener; 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.ControlListener; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; @@ -296,12 +295,7 @@ class StyledTextTab extends ScrollableTab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TextTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TextTab.java index f2ce80320e..7079618eef 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TextTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TextTab.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 @@ -11,10 +11,16 @@ package org.eclipse.swt.examples.controlexample; -import org.eclipse.swt.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +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.Group; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Widget; class TextTab extends ScrollableTab { /* Example widgets and groups that contain them */ @@ -124,12 +130,7 @@ class TextTab extends ScrollableTab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } 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 a25256703c..71306d0ba4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -14,8 +14,7 @@ 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.ControlListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -101,12 +100,7 @@ class ToolTipTab extends Tab { * its preferred size, and then resizes the shell, we * recalculate the preferred size correctly. */ - tabFolderPage.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - setExampleWidgetSize (); - } - }); + tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize ())); return tabFolderPage; } diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/helloworld/HelloWorld3.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/helloworld/HelloWorld3.java index 9ceea4f7dc..5e3803b4d2 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/helloworld/HelloWorld3.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/helloworld/HelloWorld3.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 @@ -10,12 +10,14 @@ *******************************************************************************/ package org.eclipse.swt.examples.helloworld; - -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.events.*; import java.util.ResourceBundle; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + /* * This example builds on HelloWorld2 and demonstrates how to resize the * Label when the Shell resizes using a Listener mechanism. @@ -37,12 +39,7 @@ public Shell open (Display display) { final Label label = new Label (shell, SWT.CENTER); label.setText (resHello.getString("Hello_world")); label.pack(); - shell.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - label.setBounds (shell.getClientArea ()); - } - }); + shell.addControlListener(ControlListener.controlResizedAdapter(e -> label.setBounds (shell.getClientArea ()))); shell.pack(); shell.open (); return shell; diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java index 3a595c8286..7feb5d6f13 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java @@ -24,8 +24,8 @@ import org.eclipse.swt.SWTError; import org.eclipse.swt.SWTException; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseListener; @@ -203,12 +203,7 @@ public class ImageAnalyzer { shell.setText(bundle.getString("Image_analyzer")); // Hook resize and dispose listeners. - shell.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent event) { - resizeShell(event); - } - }); + shell.addControlListener(ControlListener.controlResizedAdapter(e-> resizeShell(e))); shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) { diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java index 3cdb40d3aa..64efa8f7ad 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/paint/PaintSurface.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -12,8 +12,7 @@ package org.eclipse.swt.examples.paint; import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Color; @@ -157,12 +156,7 @@ public class PaintSurface { event.x, event.y, event.width, event.height); } }); - paintCanvas.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent event) { - handleResize(); - } - }); + paintCanvas.addControlListener(ControlListener.controlResizedAdapter(e -> handleResize())); /* Set up the paint canvas scroll bars */ ScrollBar horizontal = paintCanvas.getHorizontalBar(); diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java index 40346b6fdf..1a7b25e15d 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java @@ -29,8 +29,8 @@ import org.eclipse.swt.custom.PaintObjectEvent; import org.eclipse.swt.custom.ST; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.MenuAdapter; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.ModifyEvent; @@ -856,12 +856,7 @@ public class TextEditor { item.setPreferredSize(size); item.setSize(size); } - coolBar.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent event) { - handleResize(event); - } - }); + coolBar.addControlListener(ControlListener.controlResizedAdapter(event -> handleResize(event))); } void disposeRanges(StyleRange[] ranges) { @@ -1135,12 +1130,7 @@ public class TextEditor { } } }); - shell.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent event) { - handleResize(event); - } - }); + shell.addControlListener(ControlListener.controlResizedAdapter(event -> handleResize(event))); } Image loadImage(Display display, String fileName) { 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()) { |