diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-27 17:44:19 +0200 |
---|---|---|
committer | Pekka Maanpää <pekkamaa@vaadin.com> | 2017-10-27 18:44:19 +0300 |
commit | fb6e81221bd1b5ab0b81a3ee6c82e4286df57264 (patch) | |
tree | 4add58d9872688a1a72d8cfc15fd0dd0d47dc7b4 | |
parent | 01c93a6aef27ef562267d7966c6386ecaa6c1f6b (diff) | |
download | vaadin-framework-fb6e81221bd1b5ab0b81a3ee6c82e4286df57264.tar.gz vaadin-framework-fb6e81221bd1b5ab0b81a3ee6c82e4286df57264.zip |
Use lambda with Handlers (#10229)
Also improve naming by replacing one-letter variable names.
75 files changed, 734 insertions, 1351 deletions
diff --git a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java index af0ca05b65..1608183348 100644 --- a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java @@ -26,7 +26,6 @@ import java.util.logging.Logger; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.RunAsyncCallback; @@ -708,18 +707,16 @@ public class ApplicationConfiguration implements EntryPoint { PointerEventSupport.init(); if (LogConfiguration.loggingIsEnabled()) { - GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { - - @Override - public void onUncaughtException(Throwable e) { - /* - * If the debug window is not enabled (?debug), this will - * not show anything to normal users. "a1 is not an object" - * style errors helps nobody, especially end user. It does - * not work tells just as much. - */ - getLogger().log(Level.SEVERE, e.getMessage(), e); - } + GWT.setUncaughtExceptionHandler(throwable -> { + + /* + * If the debug window is not enabled (?debug), this will not + * show anything to normal users. "a1 is not an object" style + * errors helps nobody, especially end user. It does not work + * tells just as much. + */ + getLogger().log(Level.SEVERE, throwable.getMessage(), + throwable); }); if (isProductionMode()) { diff --git a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java index 40cc6a5d28..3ebd1c16ef 100644 --- a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java +++ b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java @@ -30,8 +30,6 @@ import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Element; import com.vaadin.client.communication.JavaScriptMethodInvocation; import com.vaadin.client.communication.ServerRpcQueue; -import com.vaadin.client.communication.StateChangeEvent; -import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.layout.ElementResizeListener; import com.vaadin.shared.JavaScriptConnectorState; import com.vaadin.shared.communication.MethodInvocation; @@ -70,12 +68,7 @@ public class JavaScriptConnectorHelper { private int processedResponseId = -1; public void init() { - connector.addStateChangeHandler(new StateChangeHandler() { - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - processStateChanges(); - } - }); + connector.addStateChangeHandler(event -> processStateChanges()); } /** diff --git a/client/src/main/java/com/vaadin/client/SimpleTree.java b/client/src/main/java/com/vaadin/client/SimpleTree.java index 9d2f9dee5c..1c15b8251b 100644 --- a/client/src/main/java/com/vaadin/client/SimpleTree.java +++ b/client/src/main/java/com/vaadin/client/SimpleTree.java @@ -25,7 +25,6 @@ import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.TextAlign; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DoubleClickEvent; import com.google.gwt.event.dom.client.DoubleClickHandler; import com.google.gwt.event.dom.client.HasDoubleClickHandlers; @@ -77,27 +76,22 @@ public class SimpleTree extends ComplexPanel implements HasDoubleClickHandlers { style.setDisplay(Display.NONE); getElement().appendChild(children); - addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (event.getNativeEvent().getEventTarget().cast() == handle) { - if (children.getStyle().getDisplay() - .intern() == Display.NONE.getCssName()) { - open(event.getNativeEvent().getAltKey()); - } else { - close(); - } - - } else if (event.getNativeEvent().getEventTarget() - .cast() == text) { - select(event); + addDomHandler(event -> { + if (event.getNativeEvent().getEventTarget().cast() == handle) { + if (children.getStyle().getDisplay().intern() == Display.NONE + .getCssName()) { + open(event.getNativeEvent().getAltKey()); + } else { + close(); } + + } else if (event.getNativeEvent().getEventTarget().cast() == text) { + select(event); } }, ClickEvent.getType()); } protected void select(ClickEvent event) { - } public void close() { @@ -178,13 +172,9 @@ public class SimpleTree extends ComplexPanel implements HasDoubleClickHandlers { DoubleClickHandler handler) { if (textDoubleClickHandlerManager == null) { textDoubleClickHandlerManager = new HandlerManager(this); - addDomHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - if (event.getNativeEvent().getEventTarget() - .cast() == text) { - textDoubleClickHandlerManager.fireEvent(event); - } + addDomHandler(event -> { + if (event.getNativeEvent().getEventTarget().cast() == text) { + textDoubleClickHandlerManager.fireEvent(event); } }, DoubleClickEvent.getType()); } diff --git a/client/src/main/java/com/vaadin/client/VUIDLBrowser.java b/client/src/main/java/com/vaadin/client/VUIDLBrowser.java index eaf0503fa0..5ddd186516 100644 --- a/client/src/main/java/com/vaadin/client/VUIDLBrowser.java +++ b/client/src/main/java/com/vaadin/client/VUIDLBrowser.java @@ -27,7 +27,6 @@ import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ui.UnknownComponentConnector; @@ -103,12 +102,7 @@ public class VUIDLBrowser extends SimpleTree { protected StateChangeItem() { setTitle(HELP); - addDomHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - deHiglight(); - } - }, MouseOutEvent.getType()); + addDomHandler(event -> deHiglight(), MouseOutEvent.getType()); } @Override diff --git a/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java index d7a811371b..4e7cbef43f 100644 --- a/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java @@ -25,7 +25,6 @@ import com.google.gwt.user.client.Window.Location; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedHandler; import com.vaadin.client.ResourceLoader; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; @@ -151,23 +150,17 @@ public class AtmospherePushConnection implements PushConnection { this.connection = connection; connection.addHandler(ApplicationStoppedEvent.TYPE, - new ApplicationStoppedHandler() { + event -> { + if (state == State.DISCONNECT_PENDING + || state == State.DISCONNECTED) { + return; + } - @Override - public void onApplicationStopped( - ApplicationStoppedEvent event) { - if (state == State.DISCONNECT_PENDING - || state == State.DISCONNECTED) { - return; + disconnect(new Command() { + @Override + public void execute() { } - - disconnect(new Command() { - @Override - public void execute() { - } - }); - - } + }); }); config = createConfig(); String debugParameter = Location.getParameter("debug"); diff --git a/client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java b/client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java index 2b815a419e..a16f5c63d4 100644 --- a/client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java +++ b/client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java @@ -26,7 +26,6 @@ import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.Timer; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedHandler; import com.vaadin.client.WidgetUtil; import com.vaadin.client.communication.AtmospherePushConnection.AtmosphereResponse; import com.vaadin.shared.ui.ui.UIState.ReconnectDialogConfigurationState; @@ -94,19 +93,14 @@ public class DefaultConnectionStateHandler implements ConnectionStateHandler { this.connection = connection; connection.addHandler(ApplicationStoppedEvent.TYPE, - new ApplicationStoppedHandler() { - @Override - public void onApplicationStopped( - ApplicationStoppedEvent event) { - if (isReconnecting()) { - giveUp(); - } - if (scheduledReconnect != null - && scheduledReconnect.isRunning()) { - scheduledReconnect.cancel(); - } + event -> { + if (isReconnecting()) { + giveUp(); + } + if (scheduledReconnect != null + && scheduledReconnect.isRunning()) { + scheduledReconnect.cancel(); } - }); // Allow dialog to cache needed resources to make them available when we diff --git a/client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java b/client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java index 4026796e0d..fe58e5f47e 100644 --- a/client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java +++ b/client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java @@ -21,7 +21,6 @@ import com.google.gwt.dom.client.BodyElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; @@ -80,12 +79,9 @@ public class DefaultReconnectDialog extends VOverlay // Click to refresh after giving up if (!reconnecting) { - clickHandler = addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - // refresh - WidgetUtil.redirect(null); - } + clickHandler = addDomHandler(event -> { + // refresh + WidgetUtil.redirect(null); }, ClickEvent.getType()); } else { if (clickHandler != null) { diff --git a/client/src/main/java/com/vaadin/client/communication/Heartbeat.java b/client/src/main/java/com/vaadin/client/communication/Heartbeat.java index 57b5f3d689..f9839a8480 100644 --- a/client/src/main/java/com/vaadin/client/communication/Heartbeat.java +++ b/client/src/main/java/com/vaadin/client/communication/Heartbeat.java @@ -24,7 +24,6 @@ import com.google.gwt.http.client.RequestException; import com.google.gwt.http.client.Response; import com.google.gwt.user.client.Timer; import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.util.SharedUtil; @@ -72,14 +71,7 @@ public class Heartbeat { connection.addHandler( ApplicationConnection.ApplicationStoppedEvent.TYPE, - new ApplicationConnection.ApplicationStoppedHandler() { - - @Override - public void onApplicationStopped( - ApplicationStoppedEvent event) { - setInterval(-1); - } - }); + event -> setInterval(-1)); } /** diff --git a/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java b/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java index 88a85cb764..12becea657 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java @@ -23,11 +23,8 @@ import java.util.Set; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Style.TextDecoration; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Label; @@ -124,31 +121,20 @@ public class AnalyzeLayoutsPanel extends FlowPanel { Highlight.show(parentConnector, "yellow"); } - errorDetails.addMouseOverHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - Highlight.hideAll(); - Highlight.show(parentConnector, "yellow"); - Highlight.show(connector); - errorDetails.getElement().getStyle() - .setTextDecoration(TextDecoration.UNDERLINE); - } - }); - errorDetails.addMouseOutHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - Highlight.hideAll(); - errorDetails.getElement().getStyle() - .setTextDecoration(TextDecoration.NONE); - } + errorDetails.addMouseOverHandler(event -> { + Highlight.hideAll(); + Highlight.show(parentConnector, "yellow"); + Highlight.show(connector); + errorDetails.getElement().getStyle() + .setTextDecoration(TextDecoration.UNDERLINE); }); - errorDetails.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - fireSelectEvent(connector); - } + errorDetails.addMouseOutHandler(event -> { + Highlight.hideAll(); + errorDetails.getElement().getStyle() + .setTextDecoration(TextDecoration.NONE); }); - + errorDetails + .addClickHandler(event -> fireSelectEvent(connector)); } Highlight.show(connector); @@ -174,30 +160,21 @@ public class AnalyzeLayoutsPanel extends FlowPanel { final SimpleTree errorNode = new SimpleTree( connector.getClass().getSimpleName() + " id: " + pid); - errorNode.addDomHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - Highlight.showOnly(connector); - ((Widget) event.getSource()).getElement().getStyle() - .setTextDecoration(TextDecoration.UNDERLINE); - } + errorNode.addDomHandler(event -> { + Highlight.showOnly(connector); + ((Widget) event.getSource()).getElement().getStyle() + .setTextDecoration(TextDecoration.UNDERLINE); }, MouseOverEvent.getType()); - errorNode.addDomHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - Highlight.hideAll(); - ((Widget) event.getSource()).getElement().getStyle() - .setTextDecoration(TextDecoration.NONE); - } + errorNode.addDomHandler(event -> { + Highlight.hideAll(); + ((Widget) event.getSource()).getElement().getStyle() + .setTextDecoration(TextDecoration.NONE); }, MouseOutEvent.getType()); - errorNode.addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (event.getNativeEvent().getEventTarget().cast() == errorNode - .getElement().getChild(1).cast()) { - fireSelectEvent(connector); - } + errorNode.addDomHandler(event -> { + if (event.getNativeEvent().getEventTarget().cast() == errorNode + .getElement().getChild(1).cast()) { + fireSelectEvent(connector); } }, ClickEvent.getType()); diff --git a/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java b/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java index 1172704ba0..28d9001b44 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java @@ -19,9 +19,6 @@ import java.util.ArrayList; import java.util.List; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.DoubleClickEvent; -import com.google.gwt.event.dom.client.DoubleClickHandler; import com.google.gwt.event.dom.client.HasDoubleClickHandlers; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HasWidgets; @@ -104,12 +101,9 @@ public class HierarchyPanel extends FlowPanel { if (children == null || children.isEmpty()) { // Leaf node, just add a label Label label = new Label(connectorString); - label.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - Highlight.showOnly(connector); - showServerDebugInfo(connector); - } + label.addClickHandler(event -> { + Highlight.showOnly(connector); + showServerDebugInfo(connector); }); widget = label; } else { @@ -132,12 +126,7 @@ public class HierarchyPanel extends FlowPanel { if (widget instanceof HasDoubleClickHandlers) { HasDoubleClickHandlers has = (HasDoubleClickHandlers) widget; - has.addDoubleClickHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - fireSelectEvent(connector); - } - }); + has.addDoubleClickHandler(event -> fireSelectEvent(connector)); } return widget; diff --git a/client/src/main/java/com/vaadin/client/debug/internal/HierarchySection.java b/client/src/main/java/com/vaadin/client/debug/internal/HierarchySection.java index 326eff5bbd..0a56e8e761 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/HierarchySection.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/HierarchySection.java @@ -16,12 +16,9 @@ package com.vaadin.client.debug.internal; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlowPanel; @@ -132,50 +129,29 @@ public class HierarchySection implements Section { public HierarchySection() { controls.add(showHierarchy); showHierarchy.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - showHierarchy.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - showHierarchy(); - } - }); + showHierarchy.addClickHandler(event -> showHierarchy()); controls.add(find); find.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - find.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - toggleFind(inspectComponent); - } - }); + find.addClickHandler(event -> toggleFind(inspectComponent)); controls.add(analyze); analyze.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - analyze.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - stopFind(); - analyzeLayouts(); - } + analyze.addClickHandler(event -> { + stopFind(); + analyzeLayouts(); }); controls.add(generateWS); generateWS.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - generateWS.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - generateWidgetset(); - } - }); + generateWS.addClickHandler(event -> generateWidgetset()); controls.add(generateDesign); generateDesign.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - generateDesign.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - content.setWidget(new HTML( - "Select a layout or component to generate the declarative design")); - toggleFind(showComponentDesign); - } + generateDesign.addClickHandler(event -> { + content.setWidget(new HTML( + "Select a layout or component to generate the declarative design")); + toggleFind(showComponentDesign); }); hierarchyPanel.addListener( @@ -321,76 +297,70 @@ public class HierarchySection implements Section { content.setWidget(infoPanel); } - private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { - - @Override - public void onPreviewNativeEvent(NativePreviewEvent event) { - - if (event.getTypeInt() == Event.ONKEYDOWN && event.getNativeEvent() - .getKeyCode() == KeyCodes.KEY_ESCAPE) { - stopFind(); - Highlight.hideAll(); + private final NativePreviewHandler highlightModeHandler = event -> { + if (event.getTypeInt() == Event.ONKEYDOWN + && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { + stopFind(); + Highlight.hideAll(); + return; + } + if (event.getTypeInt() == Event.ONMOUSEMOVE) { + Highlight.hideAll(); + Element eventTarget = WidgetUtil.getElementFromPoint( + event.getNativeEvent().getClientX(), + event.getNativeEvent().getClientY()); + + if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { + // Do not prevent using debug window controls + infoPanel.clear(); return; } - if (event.getTypeInt() == Event.ONMOUSEMOVE) { - Highlight.hideAll(); - Element eventTarget = WidgetUtil.getElementFromPoint( - event.getNativeEvent().getClientX(), - event.getNativeEvent().getClientY()); - - if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { - // Do not prevent using debug window controls - infoPanel.clear(); - return; - } - for (ApplicationConnection a : ApplicationConfiguration - .getRunningApplications()) { - ComponentConnector connector = Util.getConnectorForElement( - a, a.getUIConnector().getWidget(), eventTarget); - if (connector == null) { - connector = Util.getConnectorForElement(a, - RootPanel.get(), eventTarget); - } - if (connector != null) { - activeFindHandler.onHover(connector); - event.cancel(); - event.consume(); - event.getNativeEvent().stopPropagation(); - return; - } + for (ApplicationConnection a : ApplicationConfiguration + .getRunningApplications()) { + ComponentConnector connector = Util.getConnectorForElement(a, + a.getUIConnector().getWidget(), eventTarget); + if (connector == null) { + connector = Util.getConnectorForElement(a, RootPanel.get(), + eventTarget); } - // Not over any connector - activeFindHandler.onHover(null); - } - if (event.getTypeInt() == Event.ONCLICK) { - Highlight.hideAll(); - event.cancel(); - event.consume(); - event.getNativeEvent().stopPropagation(); - Element eventTarget = WidgetUtil.getElementFromPoint( - event.getNativeEvent().getClientX(), - event.getNativeEvent().getClientY()); - for (ApplicationConnection a : ApplicationConfiguration - .getRunningApplications()) { - ComponentConnector connector = Util.getConnectorForElement( - a, a.getUIConnector().getWidget(), eventTarget); - if (connector == null) { - connector = Util.getConnectorForElement(a, - RootPanel.get(), eventTarget); - } - - if (connector != null) { - activeFindHandler.onSelected(connector); - return; - } + if (connector != null) { + activeFindHandler.onHover(connector); + event.cancel(); + event.consume(); + event.getNativeEvent().stopPropagation(); + return; } - // Click on something else -> stop find operation - stopFind(); } - event.cancel(); + // Not over any connector + activeFindHandler.onHover(null); } + if (event.getTypeInt() == Event.ONCLICK) { + Highlight.hideAll(); + event.cancel(); + event.consume(); + event.getNativeEvent().stopPropagation(); + Element eventTarget = WidgetUtil.getElementFromPoint( + event.getNativeEvent().getClientX(), + event.getNativeEvent().getClientY()); + for (ApplicationConnection a : ApplicationConfiguration + .getRunningApplications()) { + ComponentConnector connector = Util.getConnectorForElement(a, + a.getUIConnector().getWidget(), eventTarget); + if (connector == null) { + connector = Util.getConnectorForElement(a, RootPanel.get(), + eventTarget); + } + if (connector != null) { + activeFindHandler.onSelected(connector); + return; + } + } + // Click on something else -> stop find operation + stopFind(); + } + event.cancel(); }; } diff --git a/client/src/main/java/com/vaadin/client/debug/internal/LogSection.java b/client/src/main/java/com/vaadin/client/debug/internal/LogSection.java index a31cc12067..1c62b0a4bf 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/LogSection.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/LogSection.java @@ -22,8 +22,6 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.logging.client.HtmlLogFormatter; import com.google.gwt.storage.client.Storage; import com.google.gwt.user.client.DOM; @@ -125,49 +123,30 @@ public class LogSection implements Section { // clear log button controls.add(clear); clear.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - clear.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - clear(); - } - }); + clear.addClickHandler(event -> clear()); // reset timer button controls.add(reset); reset.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - reset.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - resetTimer(); - } - }); + reset.addClickHandler(event -> resetTimer()); // scroll lock toggle controls.add(scroll); scroll.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - scroll.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - toggleScrollLock(); - } - }); + scroll.addClickHandler(event -> toggleScrollLock()); // select message if row is clicked - content.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - Element el = Element - .as(event.getNativeEvent().getEventTarget()); - while (!el.getClassName() - .contains(VDebugWindow.STYLENAME + "-message")) { - if (el == contentElement) { - // clicked something else - return; - } - el = el.getParentElement(); + content.addClickHandler(event -> { + Element el = Element.as(event.getNativeEvent().getEventTarget()); + while (!el.getClassName() + .contains(VDebugWindow.STYLENAME + "-message")) { + if (el == contentElement) { + // clicked something else + return; } - selectText(el); + el = el.getParentElement(); } + selectText(el); }); // Add handler to the root logger diff --git a/client/src/main/java/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/main/java/com/vaadin/client/debug/internal/TestBenchSection.java index e838c417ba..172bfcdeef 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/TestBenchSection.java @@ -19,8 +19,6 @@ import java.util.HashMap; import java.util.Map; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.MouseOutEvent; import com.google.gwt.event.dom.client.MouseOutHandler; @@ -110,21 +108,11 @@ public class TestBenchSection implements Section { controls.add(find); find.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - find.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - toggleFind(); - } - }); + find.addClickHandler(event -> toggleFind()); controls.add(clear); clear.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - clear.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - clearResults(); - } - }); + clear.addClickHandler(event -> clearResults()); content.setStylePrimaryName(VDebugWindow.STYLENAME + "-testbench"); content.add(selectorPanel); diff --git a/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java b/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java index bfb4ca04ff..ad93e15092 100644 --- a/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java +++ b/client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java @@ -197,28 +197,15 @@ public final class VDebugWindow extends VOverlay { // add controls TODO move these controls.add(menu); - menu.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - menuPopup.showRelativeTo(menu); - } - }); + menu.addClickHandler(event -> menuPopup.showRelativeTo(menu)); controls.add(minimize); - minimize.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - toggleMinimized(); - writeStoredState(); - } + minimize.addClickHandler(event -> { + toggleMinimized(); + writeStoredState(); }); controls.add(close); - close.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - close(); - } - }); + close.addClickHandler(event -> close()); Style s = content.getElement().getStyle(); s.setOverflow(Overflow.AUTO); diff --git a/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java b/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java index b4b21ea9e5..271d0ae112 100644 --- a/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java +++ b/client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java @@ -29,10 +29,6 @@ import com.google.gwt.dom.client.Style.TextAlign; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.dom.client.Style.WhiteSpace; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import com.vaadin.client.FastStringMap; @@ -167,18 +163,8 @@ public abstract class ConnectorBundleLoader { private void notice(String productName) { if (notice == null) { notice = new HTML(); - notice.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - notice.removeFromParent(); - } - }); - notice.addTouchStartHandler(new TouchStartHandler() { - @Override - public void onTouchStart(TouchStartEvent event) { - notice.removeFromParent(); - } - }); + notice.addClickHandler(event -> notice.removeFromParent()); + notice.addTouchStartHandler(event -> notice.removeFromParent()); } String msg = notice.getText().trim(); msg += msg.isEmpty() ? "Using Evaluation License of: " : ", "; diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractClickEventHandler.java b/client/src/main/java/com/vaadin/client/ui/AbstractClickEventHandler.java index d0d109bc74..0931c3c8f5 100644 --- a/client/src/main/java/com/vaadin/client/ui/AbstractClickEventHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/AbstractClickEventHandler.java @@ -29,7 +29,6 @@ import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewHandler; import com.vaadin.client.ComponentConnector; import com.vaadin.client.VConsole; @@ -63,24 +62,20 @@ public abstract class AbstractClickEventHandler implements MouseDownHandler, * Previews events after a mousedown to detect where the following mouseup * hits. */ - private final NativePreviewHandler mouseUpPreviewHandler = new NativePreviewHandler() { - - @Override - public void onPreviewNativeEvent(NativePreviewEvent event) { - if (event.getTypeInt() == Event.ONMOUSEUP) { - mouseUpEventPreviewRegistration.removeHandler(); - - // Event's reported target not always correct if event - // capture is in use - Element elementUnderMouse = WidgetUtil - .getElementUnderMouse(event.getNativeEvent()); - if (lastMouseDownTarget != null - && elementUnderMouse == lastMouseDownTarget) { - mouseUpPreviewMatched = true; - } else { - VConsole.log("Ignoring mouseup from " + elementUnderMouse - + " when mousedown was on " + lastMouseDownTarget); - } + private final NativePreviewHandler mouseUpPreviewHandler = event -> { + if (event.getTypeInt() == Event.ONMOUSEUP) { + mouseUpEventPreviewRegistration.removeHandler(); + + // Event's reported target not always correct if event + // capture is in use + Element elementUnderMouse = WidgetUtil + .getElementUnderMouse(event.getNativeEvent()); + if (lastMouseDownTarget != null + && elementUnderMouse == lastMouseDownTarget) { + mouseUpPreviewMatched = true; + } else { + VConsole.log("Ignoring mouseup from " + elementUnderMouse + + " when mousedown was on " + lastMouseDownTarget); } } }; diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java index 083ab3290a..76f72b6043 100644 --- a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java @@ -21,13 +21,10 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; import com.google.gwt.dom.client.Touch; import com.google.gwt.event.dom.client.ContextMenuEvent; -import com.google.gwt.event.dom.client.ContextMenuHandler; import com.google.gwt.event.dom.client.TouchEndEvent; -import com.google.gwt.event.dom.client.TouchEndHandler; import com.google.gwt.event.dom.client.TouchMoveEvent; import com.google.gwt.event.dom.client.TouchMoveHandler; import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Focusable; @@ -109,19 +106,15 @@ public abstract class AbstractComponentConnector extends AbstractConnector void handleContextClickListenerChange() { if (contextHandler == null && hasEventListener(EventId.CONTEXT_CLICK)) { contextHandler = getWidget() - .addDomHandler(new ContextMenuHandler() { - @Override - public void onContextMenu(ContextMenuEvent event) { - final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder - .buildMouseEventDetails( - event.getNativeEvent(), - getWidget().getElement()); - - event.preventDefault(); - event.stopPropagation(); - sendContextClickEvent(mouseEventDetails, - event.getNativeEvent().getEventTarget()); - } + .addDomHandler(event -> { + final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder + .buildMouseEventDetails(event.getNativeEvent(), + getWidget().getElement()); + + event.preventDefault(); + event.stopPropagation(); + sendContextClickEvent(mouseEventDetails, + event.getNativeEvent().getEventTarget()); }, ContextMenuEvent.getType()); // if the widget has a contextclick listener, add touch support as @@ -178,60 +171,55 @@ public abstract class AbstractComponentConnector extends AbstractConnector * @since 7.6 */ protected void registerTouchHandlers() { - touchStartHandler = getWidget().addDomHandler(new TouchStartHandler() { - - @Override - public void onTouchStart(final TouchStartEvent event) { - if (longTouchTimer != null && longTouchTimer.isRunning()) { - return; - } - - // Prevent selection for the element while pending long tap. - WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), - false); + touchStartHandler = getWidget().addDomHandler(event -> { + if (longTouchTimer != null && longTouchTimer.isRunning()) { + return; + } - if (BrowserInfo.get().isAndroid()) { - // Android fires ContextMenu events automatically. - return; - } + // Prevent selection for the element while pending long tap. + WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), + false); - /* - * we need to build mouseEventDetails eagerly - the event won't - * be guaranteed to be around when the timer executes. At least - * this was the case with iOS devices. - */ + if (BrowserInfo.get().isAndroid()) { + // Android fires ContextMenu events automatically. + return; + } - final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder - .buildMouseEventDetails(event.getNativeEvent(), - getWidget().getElement()); + /* + * we need to build mouseEventDetails eagerly - the event won't + * be guaranteed to be around when the timer executes. At least + * this was the case with iOS devices. + */ - final EventTarget eventTarget = event.getNativeEvent() - .getEventTarget(); + final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder + .buildMouseEventDetails(event.getNativeEvent(), + getWidget().getElement()); - longTouchTimer = new Timer() { + final EventTarget eventTarget = event.getNativeEvent() + .getEventTarget(); - @Override - public void run() { - // we're handling this event, our parent components - // don't need to bother with it anymore. - cancelParentTouchTimers(); - // The default context click - // implementation only provides the - // mouse coordinates relative to root - // element of widget. + longTouchTimer = new Timer() { - sendContextClickEvent(mouseEventDetails, eventTarget); - preventNextTouchEnd = true; - } - }; + @Override + public void run() { + // we're handling this event, our parent components + // don't need to bother with it anymore. + cancelParentTouchTimers(); + // The default context click + // implementation only provides the + // mouse coordinates relative to root + // element of widget. - Touch touch = event.getChangedTouches().get(0); - touchStartX = touch.getClientX(); - touchStartY = touch.getClientY(); + sendContextClickEvent(mouseEventDetails, eventTarget); + preventNextTouchEnd = true; + } + }; - longTouchTimer.schedule(TOUCH_CONTEXT_MENU_TIMEOUT); + Touch touch = event.getChangedTouches().get(0); + touchStartX = touch.getClientX(); + touchStartY = touch.getClientY(); - } + longTouchTimer.schedule(TOUCH_CONTEXT_MENU_TIMEOUT); }, TouchStartEvent.getType()); touchMoveHandler = getWidget().addDomHandler(new TouchMoveHandler() { @@ -272,17 +260,13 @@ public abstract class AbstractComponentConnector extends AbstractConnector } }, TouchMoveEvent.getType()); - touchEndHandler = getWidget().addDomHandler(new TouchEndHandler() { - - @Override - public void onTouchEnd(TouchEndEvent event) { - // cancel the timer so the event doesn't fire - cancelTouchTimer(); + touchEndHandler = getWidget().addDomHandler(event -> { + // cancel the timer so the event doesn't fire + cancelTouchTimer(); - if (preventNextTouchEnd) { - event.preventDefault(); - preventNextTouchEnd = false; - } + if (preventNextTouchEnd) { + event.preventDefault(); + preventNextTouchEnd = false; } }, TouchEndEvent.getType()); } diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java index 62bc4e28f8..f29e7544a6 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java @@ -28,7 +28,6 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.FocusEvent; @@ -125,43 +124,6 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> private static final String CN_OUTSIDE_RANGE = "outside-range"; - /** - * Represents a click handler for when a user selects a value by using the - * mouse - */ - private ClickHandler dayClickHandler = new ClickHandler() { - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt - * .event.dom.client.ClickEvent) - */ - @Override - public void onClick(ClickEvent event) { - if (!isEnabled() || isReadonly()) { - return; - } - - Date newDate = ((Day) event.getSource()).getDate(); - if (!isDateInsideRange(newDate, - getResolution(VAbstractCalendarPanel.this::isDay))) { - return; - } - if (newDate.getMonth() != displayedMonth.getMonth() - || newDate.getYear() != displayedMonth.getYear()) { - // If an off-month date was clicked, we must change the - // displayed month and re-render the calendar (#8931) - displayedMonth.setMonth(newDate.getMonth()); - displayedMonth.setYear(newDate.getYear()); - renderCalendar(); - } - focusDay(newDate); - selectFocused(); - onSubmit(); - } - }; - private VEventButton prevYear; private VEventButton nextYear; @@ -202,6 +164,33 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> private boolean initialRenderDone = false; + /** + * Represents a click handler for when a user selects a value by using the + * mouse + */ + private ClickHandler dayClickHandler = event -> { + if (!isEnabled() || isReadonly()) { + return; + } + + Date newDate = ((Day) event.getSource()).getDate(); + if (!isDateInsideRange(newDate, + getResolution(VAbstractCalendarPanel.this::isDay))) { + return; + } + if (newDate.getMonth() != displayedMonth.getMonth() + || newDate.getYear() != displayedMonth.getYear()) { + // If an off-month date was clicked, we must change the + // displayed month and re-render the calendar (#8931) + displayedMonth.setMonth(newDate.getMonth()); + displayedMonth.setYear(newDate.getYear()); + renderCalendar(); + } + focusDay(newDate); + selectFocused(); + onSubmit(); + }; + public VAbstractCalendarPanel() { getElement().setId(DOM.createUniqueId()); setStyleName(VDateField.CLASSNAME + "-calendarpanel"); diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java b/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java index 0ca3693286..67ac878552 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java @@ -26,9 +26,7 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.i18n.client.DateTimeFormat; @@ -104,19 +102,13 @@ public abstract class VAbstractPopupCalendar<PANEL extends VAbstractCalendarPane calendarToggle.setText(""); calendarToggle.addClickHandler(this); - calendarToggle.addDomHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - cursorOverCalendarToggleButton = true; - } - }, MouseOverEvent.getType()); + calendarToggle.addDomHandler( + event -> cursorOverCalendarToggleButton = true, + MouseOverEvent.getType()); - calendarToggle.addDomHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - cursorOverCalendarToggleButton = false; - } - }, MouseOutEvent.getType()); + calendarToggle.addDomHandler( + event -> cursorOverCalendarToggleButton = false, + MouseOutEvent.getType()); // -2 instead of -1 to avoid FocusWidget.onAttach to reset it calendarToggle.getElement().setTabIndex(-2); diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractSplitPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractSplitPanel.java index e2863c449c..a883480df2 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractSplitPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractSplitPanel.java @@ -25,13 +25,9 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.TouchCancelEvent; -import com.google.gwt.event.dom.client.TouchCancelHandler; import com.google.gwt.event.dom.client.TouchEndEvent; -import com.google.gwt.event.dom.client.TouchEndHandler; import com.google.gwt.event.dom.client.TouchMoveEvent; -import com.google.gwt.event.dom.client.TouchMoveHandler; import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.user.client.DOM; @@ -140,36 +136,24 @@ public abstract class VAbstractSplitPanel extends ComplexPanel { makeScrollable(); - addDomHandler(new TouchCancelHandler() { - @Override - public void onTouchCancel(TouchCancelEvent event) { - // TODO When does this actually happen?? - VConsole.log("TOUCH CANCEL"); - } + addDomHandler(event -> { + // TODO When does this actually happen?? + VConsole.log("TOUCH CANCEL"); }, TouchCancelEvent.getType()); - addDomHandler(new TouchStartHandler() { - @Override - public void onTouchStart(TouchStartEvent event) { - Node target = event.getTouches().get(0).getTarget().cast(); - if (splitter.isOrHasChild(target)) { - onMouseDown(Event.as(event.getNativeEvent())); - } + addDomHandler(event -> { + Node target = event.getTouches().get(0).getTarget().cast(); + if (splitter.isOrHasChild(target)) { + onMouseDown(Event.as(event.getNativeEvent())); } }, TouchStartEvent.getType()); - addDomHandler(new TouchMoveHandler() { - @Override - public void onTouchMove(TouchMoveEvent event) { - if (resizing) { - onMouseMove(Event.as(event.getNativeEvent())); - } + addDomHandler(event -> { + if (resizing) { + onMouseMove(Event.as(event.getNativeEvent())); } }, TouchMoveEvent.getType()); - addDomHandler(new TouchEndHandler() { - @Override - public void onTouchEnd(TouchEndEvent event) { - if (resizing) { - onMouseUp(Event.as(event.getNativeEvent())); - } + addDomHandler(event -> { + if (resizing) { + onMouseUp(Event.as(event.getNativeEvent())); } }, TouchEndEvent.getType()); diff --git a/client/src/main/java/com/vaadin/client/ui/VCheckBox.java b/client/src/main/java/com/vaadin/client/ui/VCheckBox.java index 18140c203d..fe565e8b02 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCheckBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VCheckBox.java @@ -17,8 +17,6 @@ package com.vaadin.client.ui; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.vaadin.client.ApplicationConnection; @@ -60,12 +58,7 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isFirefox()) { // Webkit and Firefox do not focus non-text input elements on click // (#3944) - addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - setFocus(true); - } - }); + addClickHandler(event -> setFocus(true)); } } diff --git a/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java b/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java index a957690526..d393b1c3ce 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java +++ b/client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java @@ -106,8 +106,9 @@ public class VCheckBoxGroup extends FocusableFlowPanelComposite */ public JsonObject getItem(Element element) { return optionsToItems.entrySet().stream() - .filter(e -> e.getKey().getElement().isOrHasChild(element)) - .map(e -> e.getValue()).findFirst().orElse(null); + .filter(entry -> entry.getKey().getElement() + .isOrHasChild(element)) + .map(entry -> entry.getValue()).findFirst().orElse(null); } private void remove(Widget widget) { diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index df134c4505..14bddb43fe 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -2048,12 +2048,9 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, ClickEvent.getType()); selectedItemIcon.addDomHandler(VComboBox.this, MouseDownEvent.getType()); - selectedItemIcon.addDomHandler(new LoadHandler() { - @Override - public void onLoad(LoadEvent event) { - afterSelectedItemIconChange(); - } - }, LoadEvent.getType()); + selectedItemIcon.addDomHandler( + event -> afterSelectedItemIconChange(), + LoadEvent.getType()); panel.insert(selectedItemIcon, 0); afterSelectedItemIconChange(); } diff --git a/client/src/main/java/com/vaadin/client/ui/VDateField.java b/client/src/main/java/com/vaadin/client/ui/VDateField.java index b4780955f9..be56fd99ee 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateField.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateField.java @@ -270,8 +270,8 @@ public abstract class VDateField<R extends Enum<R>> extends FlowPanel public void sendBufferedValues() { rpc.update(bufferedDateString, bufferedResolutions.entrySet().stream().collect(Collectors - .toMap(e -> e.getKey().name(), - e -> e.getValue()))); + .toMap(entry -> entry.getKey().name(), + entry -> entry.getValue()))); bufferedDateString = null; bufferedResolutions.clear(); } diff --git a/client/src/main/java/com/vaadin/client/ui/VDateTimeCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VDateTimeCalendarPanel.java index 8f27c920cc..5e9732e091 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateTimeCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateTimeCalendarPanel.java @@ -20,8 +20,6 @@ import java.util.Date; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyDownEvent; -import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.ListBox; @@ -179,17 +177,12 @@ public class VDateTimeCalendarPanel updateTimes(); ListBox lastDropDown = getLastDropDown(); - lastDropDown.addKeyDownHandler(new KeyDownHandler() { - @Override - public void onKeyDown(KeyDownEvent event) { - boolean shiftKey = event.getNativeEvent().getShiftKey(); - if (shiftKey) { - return; - } else { - int nativeKeyCode = event.getNativeKeyCode(); - if (nativeKeyCode == KeyCodes.KEY_TAB) { - onTabOut(event); - } + lastDropDown.addKeyDownHandler(event -> { + boolean shiftKey = event.getNativeEvent().getShiftKey(); + if (!shiftKey) { + int nativeKeyCode = event.getNativeKeyCode(); + if (nativeKeyCode == KeyCodes.KEY_TAB) { + onTabOut(event); } } }); diff --git a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java index abf6bd9164..43c455f386 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -26,11 +26,8 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.MouseDownEvent; -import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.event.dom.client.MouseUpEvent; -import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; @@ -86,47 +83,33 @@ public class VDragAndDropWrapper extends VCustomComponent hookHtml5Events(getElement()); setStyleName(CLASSNAME); - addDomHandler(new MouseDownHandler() { - - @Override - public void onMouseDown(final MouseDownEvent event) { - if (getConnector().isEnabled() - && event.getNativeEvent() - .getButton() == Event.BUTTON_LEFT - && startDrag(event.getNativeEvent())) { - event.preventDefault(); // prevent text selection - startX = event.getClientX(); - startY = event.getClientY(); - } + addDomHandler(event -> { + if (getConnector().isEnabled() + && event.getNativeEvent().getButton() == Event.BUTTON_LEFT + && startDrag(event.getNativeEvent())) { + event.preventDefault(); // prevent text selection + startX = event.getClientX(); + startY = event.getClientY(); } }, MouseDownEvent.getType()); - addDomHandler(new MouseUpHandler() { - - @Override - public void onMouseUp(final MouseUpEvent event) { - final int deltaX = Math.abs(event.getClientX() - startX); - final int deltaY = Math.abs(event.getClientY() - startY); - if ((deltaX + deltaY) < MIN_PX_DELTA) { - Element clickedElement = WidgetUtil.getElementFromPoint( - event.getClientX(), event.getClientY()); - clickedElement.focus(); - } + addDomHandler(event -> { + final int deltaX = Math.abs(event.getClientX() - startX); + final int deltaY = Math.abs(event.getClientY() - startY); + if ((deltaX + deltaY) < MIN_PX_DELTA) { + Element clickedElement = WidgetUtil.getElementFromPoint( + event.getClientX(), event.getClientY()); + clickedElement.focus(); } - }, MouseUpEvent.getType()); - addDomHandler(new TouchStartHandler() { - - @Override - public void onTouchStart(TouchStartEvent event) { - if (getConnector().isEnabled() - && startDrag(event.getNativeEvent())) { - /* - * Don't let e.g. panel start scrolling. - */ - event.stopPropagation(); - } + addDomHandler(event -> { + if (getConnector().isEnabled() + && startDrag(event.getNativeEvent())) { + /* + * Don't let e.g. panel start scrolling. + */ + event.stopPropagation(); } }, TouchStartEvent.getType()); @@ -226,18 +209,14 @@ public class VDragAndDropWrapper extends VCustomComponent private boolean uploading; - private final ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() { - - @Override - public void onReadyStateChange(XMLHttpRequest xhr) { - if (xhr.getReadyState() == XMLHttpRequest.DONE) { - // #19616 Notify the upload handler that the request is complete - // and let it poll the server for changes. - uploadHandler.uploadDone(); - uploading = false; - startNextUpload(); - xhr.clearOnReadyStateChange(); - } + private final ReadyStateChangeHandler readyStateChangeHandler = xhr -> { + if (xhr.getReadyState() == XMLHttpRequest.DONE) { + // #19616 Notify the upload handler that the request is complete + // and let it poll the server for changes. + uploadHandler.uploadDone(); + uploading = false; + startNextUpload(); + xhr.clearOnReadyStateChange(); } }; private Timer dragleavetimer; diff --git a/client/src/main/java/com/vaadin/client/ui/VPopupView.java b/client/src/main/java/com/vaadin/client/ui/VPopupView.java index 8185bb06cd..959458132e 100644 --- a/client/src/main/java/com/vaadin/client/ui/VPopupView.java +++ b/client/src/main/java/com/vaadin/client/ui/VPopupView.java @@ -22,11 +22,8 @@ import java.util.Set; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; -import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.event.shared.HandlerRegistration; @@ -93,15 +90,12 @@ public class VPopupView extends HTML popup.setWidget(loading); // When we click to open the popup... - addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (isEnabled()) { - preparePopup(popup); - showPopup(popup); - center(); - fireEvent(new VisibilityChangeEvent(true)); - } + addClickHandler(event -> { + if (isEnabled()) { + preparePopup(popup); + showPopup(popup); + center(); + fireEvent(new VisibilityChangeEvent(true)); } }); @@ -249,13 +243,11 @@ public class VPopupView extends HTML // Delegate popup keyboard events to the relevant handler. The // events do not propagate automatically because the popup is // directly attached to the RootPanel. - addDomHandler(new KeyDownHandler() { - @Override - public void onKeyDown(KeyDownEvent event) { - if (shortcutActionHandler != null) { - shortcutActionHandler.handleKeyboardEvent( - Event.as(event.getNativeEvent())); - } + addDomHandler(event -> { + if (shortcutActionHandler != null) { + shortcutActionHandler + .handleKeyboardEvent( + Event.as(event.getNativeEvent())); } }, KeyDownEvent.getType()); } diff --git a/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java b/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java index 4f0bed52ed..a382758409 100644 --- a/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java +++ b/client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java @@ -121,8 +121,8 @@ public class VRadioButtonGroup extends FocusableFlowPanelComposite private Optional<JsonObject> tryGetItem(Element element) { return optionsToItems.entrySet().stream() - .filter(e -> e.getKey().getElement().equals(element)) - .map(e -> e.getValue()).findFirst(); + .filter(entry -> entry.getKey().getElement().equals(element)) + .map(entry -> entry.getValue()).findFirst(); } private void remove(Widget widget) { diff --git a/client/src/main/java/com/vaadin/client/ui/VTwinColSelect.java b/client/src/main/java/com/vaadin/client/ui/VTwinColSelect.java index d744e289dd..4797aab311 100644 --- a/client/src/main/java/com/vaadin/client/ui/VTwinColSelect.java +++ b/client/src/main/java/com/vaadin/client/ui/VTwinColSelect.java @@ -362,14 +362,16 @@ public class VTwinColSelect extends Composite implements MultiSelectWidget, Set<String> movedItems = moveSelectedItems(optionsListBox, selectionsListBox); selectionChangeListeners - .forEach(e -> e.accept(movedItems, Collections.emptySet())); + .forEach(listener -> listener.accept(movedItems, + Collections.emptySet())); } private void moveSelectedItemsRightToLeft() { Set<String> movedItems = moveSelectedItems(selectionsListBox, optionsListBox); selectionChangeListeners - .forEach(e -> e.accept(Collections.emptySet(), movedItems)); + .forEach(listener -> listener.accept(Collections.emptySet(), + movedItems)); } private static Set<String> moveSelectedItems(ListBox source, diff --git a/client/src/main/java/com/vaadin/client/ui/VUpload.java b/client/src/main/java/com/vaadin/client/ui/VUpload.java index ef66f07467..11e9c24a14 100644 --- a/client/src/main/java/com/vaadin/client/ui/VUpload.java +++ b/client/src/main/java/com/vaadin/client/ui/VUpload.java @@ -23,8 +23,6 @@ import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.FormElement; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; @@ -143,15 +141,12 @@ public class VUpload extends SimplePanel { panel.add(maxfilesize); panel.add(fu); submitButton = new VButton(); - submitButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (isImmediateMode()) { - // fire click on upload (e.g. focused button and hit space) - fireNativeClick(fu.getElement()); - } else { - submit(); - } + submitButton.addClickHandler(event -> { + if (isImmediateMode()) { + // fire click on upload (e.g. focused button and hit space) + fireNativeClick(fu.getElement()); + } else { + submit(); } }); panel.add(submitButton); diff --git a/client/src/main/java/com/vaadin/client/ui/VWindow.java b/client/src/main/java/com/vaadin/client/ui/VWindow.java index b27c803b75..6b32278734 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -48,7 +48,6 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Widget; @@ -434,35 +433,29 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, // Handlers to Prevent tab to leave the window // and backspace to cause browser navigation - topEventBlocker = new NativePreviewHandler() { - @Override - public void onPreviewNativeEvent(NativePreviewEvent event) { - NativeEvent nativeEvent = event.getNativeEvent(); - if (nativeEvent.getEventTarget().cast() == topTabStop - && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB - && nativeEvent.getShiftKey()) { - nativeEvent.preventDefault(); - } - if (nativeEvent.getEventTarget().cast() == topTabStop - && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) { - nativeEvent.preventDefault(); - } + topEventBlocker = event -> { + NativeEvent nativeEvent = event.getNativeEvent(); + if (nativeEvent.getEventTarget().cast() == topTabStop + && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB + && nativeEvent.getShiftKey()) { + nativeEvent.preventDefault(); + } + if (nativeEvent.getEventTarget().cast() == topTabStop + && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) { + nativeEvent.preventDefault(); } }; - bottomEventBlocker = new NativePreviewHandler() { - @Override - public void onPreviewNativeEvent(NativePreviewEvent event) { - NativeEvent nativeEvent = event.getNativeEvent(); - if (nativeEvent.getEventTarget().cast() == bottomTabStop - && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB - && !nativeEvent.getShiftKey()) { - nativeEvent.preventDefault(); - } - if (nativeEvent.getEventTarget().cast() == bottomTabStop - && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) { - nativeEvent.preventDefault(); - } + bottomEventBlocker = event -> { + NativeEvent nativeEvent = event.getNativeEvent(); + if (nativeEvent.getEventTarget().cast() == bottomTabStop + && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB + && !nativeEvent.getShiftKey()) { + nativeEvent.preventDefault(); + } + if (nativeEvent.getEventTarget().cast() == bottomTabStop + && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) { + nativeEvent.preventDefault(); } }; } diff --git a/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index 6f603fe392..8f6e802f74 100644 --- a/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -58,24 +58,20 @@ public class AbsoluteLayoutConnector extends AbstractComponentContainerConnector } }; - private StateChangeHandler childStateChangeHandler = new StateChangeHandler() { - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - ComponentConnector child = (ComponentConnector) stateChangeEvent - .getConnector(); - List<String> childStyles = child.getState().styles; - if (childStyles == null) { - getWidget().setWidgetWrapperStyleNames(child.getWidget(), - (String[]) null); - } else { - getWidget().setWidgetWrapperStyleNames(child.getWidget(), - childStyles.toArray(new String[childStyles.size()])); - } + private StateChangeHandler childStateChangeHandler = event -> { + ComponentConnector child = (ComponentConnector) event.getConnector(); + List<String> childStyles = child.getState().styles; + if (childStyles == null) { + getWidget().setWidgetWrapperStyleNames(child.getWidget(), + (String[]) null); + } else { + getWidget().setWidgetWrapperStyleNames(child.getWidget(), + childStyles.toArray(new String[childStyles.size()])); + } - if (stateChangeEvent.hasPropertyChanged("height") - || stateChangeEvent.hasPropertyChanged("width")) { - setChildWidgetPosition(child); - } + if (event.hasPropertyChanged("height") + || event.hasPropertyChanged("width")) { + setChildWidgetPosition(child); } }; diff --git a/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java b/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java index 55e17c325f..e7cff4c3eb 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java @@ -104,49 +104,44 @@ public class DragAndDropHandler { } }; - private final NativePreviewHandler dragPreviewHandler = new NativePreviewHandler() { - - @Override - public void onPreviewNativeEvent(NativePreviewEvent event) { - if (dragging) { - final int typeInt = event.getTypeInt(); - switch (typeInt) { - case Event.ONMOUSEMOVE: - case Event.ONTOUCHMOVE: - callback.onDragUpdate(Event.as(event.getNativeEvent())); - break; - case Event.ONKEYDOWN: - // End drag if ESC is pressed - int keyCode = event.getNativeEvent().getKeyCode(); - if (keyCode == KeyCodes.KEY_ESCAPE) { - cancelDrag(event); - } - break; - case Event.ONTOUCHCANCEL: + private final NativePreviewHandler dragPreviewHandler = event -> { + if (dragging) { + final int typeInt = event.getTypeInt(); + switch (typeInt) { + case Event.ONMOUSEMOVE: + case Event.ONTOUCHMOVE: + callback.onDragUpdate(Event.as(event.getNativeEvent())); + break; + case Event.ONKEYDOWN: + // End drag if ESC is pressed + int keyCode = event.getNativeEvent().getKeyCode(); + if (keyCode == KeyCodes.KEY_ESCAPE) { cancelDrag(event); - break; - case Event.ONTOUCHEND: - case Event.ONMOUSEUP: - callback.onDragUpdate(Event.as(event.getNativeEvent())); - callback.onDrop(); - stopDrag(); - break; - case Event.ONCLICK: - break; - default: - break; } - } else { + break; + case Event.ONTOUCHCANCEL: + cancelDrag(event); + break; + case Event.ONTOUCHEND: + case Event.ONMOUSEUP: + callback.onDragUpdate(Event.as(event.getNativeEvent())); + callback.onDrop(); stopDrag(); + break; + case Event.ONCLICK: + break; + default: + break; } - - // Kill events - as long as this thing is active, we don't want to - // let any event through. - event.getNativeEvent().stopPropagation(); - event.getNativeEvent().preventDefault(); - event.cancel(); + } else { + stopDrag(); } + // Kill events - as long as this thing is active, we don't want to + // let any event through. + event.getNativeEvent().stopPropagation(); + event.getNativeEvent().preventDefault(); + event.cancel(); }; /** diff --git a/client/src/main/java/com/vaadin/client/ui/image/ImageConnector.java b/client/src/main/java/com/vaadin/client/ui/image/ImageConnector.java index c544232d80..6acdb8ba8f 100644 --- a/client/src/main/java/com/vaadin/client/ui/image/ImageConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/image/ImageConnector.java @@ -17,7 +17,6 @@ package com.vaadin.client.ui.image; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.LoadEvent; -import com.google.gwt.event.dom.client.LoadHandler; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.ClickEventHandler; @@ -34,14 +33,10 @@ public class ImageConnector extends AbstractComponentConnector { @Override protected void init() { super.init(); - getWidget().addHandler(new LoadHandler() { - - @Override - public void onLoad(LoadEvent event) { - getLayoutManager().setNeedsMeasure(ImageConnector.this); - } - - }, LoadEvent.getType()); + getWidget().addHandler( + event -> getLayoutManager() + .setNeedsMeasure(ImageConnector.this), + LoadEvent.getType()); } @Override diff --git a/client/src/main/java/com/vaadin/client/ui/loginform/LoginFormConnector.java b/client/src/main/java/com/vaadin/client/ui/loginform/LoginFormConnector.java index 27cb297a57..7bffa75e5f 100644 --- a/client/src/main/java/com/vaadin/client/ui/loginform/LoginFormConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/loginform/LoginFormConnector.java @@ -18,14 +18,11 @@ package com.vaadin.client.ui.loginform; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.FocusWidget; -import com.google.gwt.user.client.ui.FormPanel; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.communication.StateChangeEvent; @@ -61,15 +58,10 @@ public class LoginFormConnector super.init(); loginFormRpc = getRpcProxy(LoginFormRpc.class); - getWidget().addSubmitCompleteHandler( - new FormPanel.SubmitCompleteHandler() { - @Override - public void onSubmitComplete( - FormPanel.SubmitCompleteEvent event) { - valuesChanged(); - loginFormRpc.submitCompleted(); - } - }); + getWidget().addSubmitCompleteHandler(event -> { + valuesChanged(); + loginFormRpc.submitCompleted(); + }); } @Override @@ -153,12 +145,7 @@ public class LoginFormConnector } private void addSubmitButtonClickHandler(FocusWidget button) { - button.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - login(); - } - }); + button.addClickHandler(event -> login()); } private void valuesChanged() { diff --git a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 29634b983f..d24a3cc331 100644 --- a/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -73,25 +73,22 @@ public abstract class AbstractOrderedLayoutConnector } }; - private StateChangeHandler childStateChangeHandler = new StateChangeHandler() { - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - // Child state has changed, update stuff it hasn't already been done - updateInternalState(); + private StateChangeHandler childStateChangeHandler = event -> { + // Child state has changed, update stuff it hasn't already been done + updateInternalState(); - /* - * Some changes must always be done after each child's own state - * change handler has been run because it might have changed some - * styles that are overridden here. - */ - ServerConnector child = stateChangeEvent.getConnector(); - if (child instanceof ComponentConnector) { - ComponentConnector component = (ComponentConnector) child; - Slot slot = getWidget().getSlot(component.getWidget()); + /* + * Some changes must always be done after each child's own state change + * handler has been run because it might have changed some styles that + * are overridden here. + */ + ServerConnector child = event.getConnector(); + if (child instanceof ComponentConnector) { + ComponentConnector component = (ComponentConnector) child; + Slot slot = getWidget().getSlot(component.getWidget()); - slot.setRelativeWidth(component.isRelativeWidth()); - slot.setRelativeHeight(component.isRelativeHeight()); - } + slot.setRelativeWidth(component.isRelativeWidth()); + slot.setRelativeHeight(component.isRelativeHeight()); } }; diff --git a/client/src/main/java/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java b/client/src/main/java/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java index 0e117a81c0..77a69874fb 100644 --- a/client/src/main/java/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java @@ -15,8 +15,6 @@ */ package com.vaadin.client.ui.richtextarea; -import com.google.gwt.event.dom.client.BlurEvent; -import com.google.gwt.event.dom.client.BlurHandler; import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.ConnectorFocusAndBlurHandler; @@ -48,12 +46,7 @@ public class RichTextAreaConnector extends AbstractFieldConnector @Override protected void init() { - getWidget().addBlurHandler(new BlurHandler() { - @Override - public void onBlur(BlurEvent event) { - flush(); - } - }); + getWidget().addBlurHandler(event -> flush()); getWidget().addInputHandler( () -> valueChangeHandler.scheduleValueChange()); diff --git a/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java index 86cf5adf98..0dd4e38e2c 100644 --- a/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -35,7 +35,6 @@ import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.VAbstractSplitPanel; -import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler; import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.ComponentStateUtil; @@ -52,27 +51,21 @@ public abstract class AbstractSplitPanelConnector extends // TODO Remove getWidget().client = getConnection(); - getWidget().addHandler(new SplitterMoveHandler() { - - @Override - public void splitterMoved(SplitterMoveEvent event) { - String position = getWidget().getSplitterPosition(); - float pos = 0; - if (position.indexOf("%") > 0) { - // Send % values as a fraction to avoid that the splitter - // "jumps" when server responds with the integer pct value - // (e.g. dragged 16.6% -> should not jump to 17%) - pos = Float.valueOf( - position.substring(0, position.length() - 1)); - } else { - pos = Integer.parseInt( - position.substring(0, position.length() - 2)); - } - - getRpcProxy(AbstractSplitPanelRpc.class) - .setSplitterPosition(pos); + getWidget().addHandler(event -> { + String position = getWidget().getSplitterPosition(); + float pos = 0; + if (position.indexOf("%") > 0) { + // Send % values as a fraction to avoid that the splitter + // "jumps" when server responds with the integer pct value + // (e.g. dragged 16.6% -> should not jump to 17%) + pos = Float + .valueOf(position.substring(0, position.length() - 1)); + } else { + pos = Integer + .parseInt(position.substring(0, position.length() - 2)); } + getRpcProxy(AbstractSplitPanelRpc.class).setSplitterPosition(pos); }, SplitterMoveEvent.TYPE); } diff --git a/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java b/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java index 35055a746e..fe288b626b 100644 --- a/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java @@ -36,11 +36,8 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.StyleInjector; import com.google.gwt.event.dom.client.KeyDownEvent; -import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; -import com.google.gwt.event.logical.shared.ResizeEvent; -import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; @@ -122,35 +119,28 @@ public class UIConnector extends AbstractSingleComponentContainerConnector */ private String currentLocation; - private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() { - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - // TODO Should use a more specific handler that only reacts to - // size changes - onChildSizeChange(); - } + private final StateChangeHandler childStateChangeHandler = event -> { + // TODO Should use a more specific handler that only reacts to + // size changes + onChildSizeChange(); }; - private WindowOrderHandler windowOrderHandler = new WindowOrderHandler() { - - @Override - public void onWindowOrderChange(WindowOrderEvent event) { - VWindow[] windows = event.getWindows(); - Map<Integer, Connector> orders = new HashMap<>(); - boolean hasEventListener = hasEventListener(EventId.WINDOW_ORDER); - for (VWindow window : windows) { - Connector connector = Util.findConnectorFor(window); - orders.put(window.getWindowOrder(), connector); - if (connector instanceof AbstractConnector - && ((AbstractConnector) connector) - .hasEventListener(EventId.WINDOW_ORDER)) { - hasEventListener = true; - } - } - if (hasEventListener) { - getRpcProxy(WindowOrderRpc.class).windowOrderChanged(orders); + private WindowOrderHandler windowOrderHandler = event -> { + VWindow[] windows = event.getWindows(); + Map<Integer, Connector> orders = new HashMap<>(); + boolean hasEventListener = hasEventListener(EventId.WINDOW_ORDER); + for (VWindow window : windows) { + Connector connector = Util.findConnectorFor(window); + orders.put(window.getWindowOrder(), connector); + if (connector instanceof AbstractConnector + && ((AbstractConnector) connector) + .hasEventListener(EventId.WINDOW_ORDER)) { + hasEventListener = true; } } + if (hasEventListener) { + getRpcProxy(WindowOrderRpc.class).windowOrderChanged(orders); + } }; @Override @@ -214,14 +204,11 @@ public class UIConnector extends AbstractSingleComponentContainerConnector }-*/; }); - getWidget().addResizeHandler(new ResizeHandler() { - @Override - public void onResize(ResizeEvent event) { - getRpcProxy(UIServerRpc.class).resize(event.getWidth(), - event.getHeight(), Window.getClientWidth(), - Window.getClientHeight()); - getConnection().getServerRpcQueue().flush(); - } + getWidget().addResizeHandler(event -> { + getRpcProxy(UIServerRpc.class).resize(event.getWidth(), + event.getHeight(), Window.getClientWidth(), + Window.getClientHeight()); + getConnection().getServerRpcQueue().flush(); }); getWidget().addScrollHandler(new ScrollHandler() { private int lastSentScrollTop = Integer.MAX_VALUE; @@ -524,22 +511,18 @@ public class UIConnector extends AbstractSingleComponentContainerConnector shortcutContextWidget = RootPanel.get(); // document body } - shortcutContextWidget.addDomHandler(new KeyDownHandler() { - @Override - public void onKeyDown(KeyDownEvent event) { - if (VWindow.isModalWindowOpen()) { - return; - } - if (getWidget().actionHandler != null) { - Element target = Element - .as(event.getNativeEvent().getEventTarget()); - if (target == Document.get().getBody() - || getWidget().getElement().isOrHasChild(target)) { - // Only react to body and elements inside the UI - getWidget().actionHandler.handleKeyboardEvent( - (Event) event.getNativeEvent().cast()); - } - + shortcutContextWidget.addDomHandler(event -> { + if (VWindow.isModalWindowOpen()) { + return; + } + if (getWidget().actionHandler != null) { + Element target = Element + .as(event.getNativeEvent().getEventTarget()); + if (target == Document.get().getBody() + || getWidget().getElement().isOrHasChild(target)) { + // Only react to body and elements inside the UI + getWidget().actionHandler.handleKeyboardEvent( + (Event) event.getNativeEvent().cast()); } } }, KeyDownEvent.getType()); diff --git a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java index 5b5c4a60e4..9c784ae23c 100644 --- a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java @@ -16,8 +16,6 @@ package com.vaadin.client.ui.upload; -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; @@ -48,13 +46,10 @@ public class UploadConnector extends AbstractComponentConnector protected void init() { super.init(); - getWidget().fu.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - if (hasEventListener(EventId.CHANGE)) { - getRpcProxy(UploadServerRpc.class) - .change(getWidget().fu.getFilename()); - } + getWidget().fu.addChangeHandler(event -> { + if (hasEventListener(EventId.CHANGE)) { + getRpcProxy(UploadServerRpc.class) + .change(getWidget().fu.getFilename()); } }); } diff --git a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java index a425da2231..6be292c5a7 100644 --- a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java +++ b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java @@ -435,12 +435,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { } // must be a field because Java insists. offsetSizeTemporaryScrollHandler = addScrollHandler( - new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - setOffsetSizeNow(px); - } - }); + event -> setOffsetSizeNow(px)); setScrollPos(0); } else { setOffsetSizeNow(px); @@ -523,12 +518,9 @@ public abstract class ScrollbarBundle implements DeferredWorker { if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) { if (scrollInProgress == null) { // Only used for tracking that there is "workPending" - scrollInProgress = addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - scrollInProgress.removeHandler(); - scrollInProgress = null; - } + scrollInProgress = addScrollHandler(event -> { + scrollInProgress.removeHandler(); + scrollInProgress = null; }); } if (isInvisibleScrollbar) { @@ -662,12 +654,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { scrollSizeTemporaryScrollHandler.removeHandler(); } scrollSizeTemporaryScrollHandler = addScrollHandler( - new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - setScrollSizeNow(px); - } - }); + event -> setScrollSizeNow(px)); } setScrollPos(0); if (!delayedSizeSet) { diff --git a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java index ebf806bbbd..c9b4f0dac1 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java @@ -487,30 +487,27 @@ public class MultiSelectionRenderer<T> /** The registration info for {@link #scrollPreviewHandler} */ private HandlerRegistration handlerRegistration; - private final NativePreviewHandler scrollPreviewHandler = new NativePreviewHandler() { - @Override - public void onPreviewNativeEvent(final NativePreviewEvent event) { - if (autoScroller == null) { - stop(); - return; - } + private final NativePreviewHandler scrollPreviewHandler = event -> { + if (autoScroller == null) { + stop(); + return; + } - final NativeEvent nativeEvent = event.getNativeEvent(); - int pageY = 0; - int pageX = 0; - switch (event.getTypeInt()) { - case Event.ONMOUSEMOVE: - case Event.ONTOUCHMOVE: - pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent); - pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent); - autoScroller.updatePointerCoords(pageX, pageY); - break; - case Event.ONMOUSEUP: - case Event.ONTOUCHEND: - case Event.ONTOUCHCANCEL: - stop(); - break; - } + final NativeEvent nativeEvent = event.getNativeEvent(); + int pageY = 0; + int pageX = 0; + switch (event.getTypeInt()) { + case Event.ONMOUSEMOVE: + case Event.ONTOUCHMOVE: + pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent); + pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent); + autoScroller.updatePointerCoords(pageX, pageY); + break; + case Event.ONMOUSEUP: + case Event.ONTOUCHEND: + case Event.ONTOUCHCANCEL: + stop(); + break; } }; diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index e134d01d9b..11604db9b8 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -49,7 +49,6 @@ import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.dom.client.Touch; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; @@ -62,8 +61,6 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.touch.client.Point; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.Event.NativePreviewEvent; -import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.CheckBox; @@ -98,7 +95,6 @@ import com.vaadin.client.widget.escalator.EscalatorUpdater; import com.vaadin.client.widget.escalator.FlyweightCell; import com.vaadin.client.widget.escalator.Row; import com.vaadin.client.widget.escalator.RowContainer; -import com.vaadin.client.widget.escalator.RowVisibilityChangeEvent; import com.vaadin.client.widget.escalator.RowVisibilityChangeHandler; import com.vaadin.client.widget.escalator.ScrollbarBundle.Direction; import com.vaadin.client.widget.escalator.Spacer; @@ -1458,22 +1454,16 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, public Editor() { saveButton = new Button(); saveButton.setText(GridConstants.DEFAULT_SAVE_CAPTION); - saveButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - save(); - FocusUtil.setFocus(grid, true); - } + saveButton.addClickHandler(event -> { + save(); + FocusUtil.setFocus(grid, true); }); cancelButton = new Button(); cancelButton.setText(GridConstants.DEFAULT_CANCEL_CAPTION); - cancelButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - cancel(); - FocusUtil.setFocus(grid, true); - } + cancelButton.addClickHandler(event -> { + cancel(); + FocusUtil.setFocus(grid, true); }); } @@ -1613,13 +1603,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, if (escalator.getVisibleRowRange().contains(rowIndex)) { show(rowIndex, columnIndexDOM); } else { - vScrollHandler = grid.addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - if (escalator.getVisibleRowRange().contains(rowIndex)) { - show(rowIndex, columnIndexDOM); - vScrollHandler.removeHandler(); - } + vScrollHandler = grid.addScrollHandler(event -> { + if (escalator.getVisibleRowRange().contains(rowIndex)) { + show(rowIndex, columnIndexDOM); + vScrollHandler.removeHandler(); } }); grid.scrollToRow(rowIndex, @@ -1829,12 +1816,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, TableRowElement tr = grid.getEscalator().getBody() .getRowElement(rowIndex); - hScrollHandler = grid.addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - updateHorizontalScrollPosition(); - updateVerticalScrollPosition(); - } + hScrollHandler = grid.addScrollHandler(event -> { + updateHorizontalScrollPosition(); + updateVerticalScrollPosition(); }); gridElement.appendChild(editorOverlay); @@ -3781,15 +3765,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, */ private static class Sidebar extends Composite implements HasEnabled { - private final ClickHandler openCloseButtonHandler = new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - if (!isOpen()) { - open(); - } else { - close(); - } + private final ClickHandler openCloseButtonHandler = event -> { + if (!isOpen()) { + open(); + } else { + close(); } }; @@ -3872,13 +3852,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, } } }; - KeyDownHandler keyDownHandler = new KeyDownHandler() { - - @Override - public void onKeyDown(KeyDownEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { - close(); - } + KeyDownHandler keyDownHandler = event -> { + if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { + close(); } }; openCloseButton.addDomHandler(keyDownHandler, @@ -4542,18 +4518,12 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, // mouse was released on top of the dragged cell if (columnSortPreventRegistration == null) { columnSortPreventRegistration = Event - .addNativePreviewHandler(new NativePreviewHandler() { - - @Override - public void onPreviewNativeEvent( - NativePreviewEvent event) { - if (event.getTypeInt() == Event.ONCLICK) { - event.cancel(); - event.getNativeEvent().preventDefault(); - columnSortPreventRegistration - .removeHandler(); - columnSortPreventRegistration = null; - } + .addNativePreviewHandler(event -> { + if (event.getTypeInt() == Event.ONCLICK) { + event.cancel(); + event.getNativeEvent().preventDefault(); + columnSortPreventRegistration.removeHandler(); + columnSortPreventRegistration = null; } }); } @@ -6156,23 +6126,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, escalator.getBody().setSpacerUpdater(gridSpacerUpdater); - escalator.addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - fireEvent(new ScrollEvent()); - } - }); + escalator.addScrollHandler(event -> fireEvent(new ScrollEvent())); escalator.addRowVisibilityChangeHandler( - new RowVisibilityChangeHandler() { - @Override - public void onRowVisibilityChange( - RowVisibilityChangeEvent event) { - if (dataSource != null && dataSource.size() != 0) { - dataSource.ensureAvailability( - event.getFirstVisibleRow(), - event.getVisibleRowCount()); - } + event -> { + if (dataSource != null && dataSource.size() != 0) { + dataSource.ensureAvailability( + event.getFirstVisibleRow(), + event.getVisibleRowCount()); } }); @@ -6193,18 +6154,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, BrowserEvents.MOUSEDOWN, BrowserEvents.CLICK)); // Make ENTER and SHIFT+ENTER in the header perform sorting - addHeaderKeyUpHandler(new HeaderKeyUpHandler() { - @Override - public void onKeyUp(GridKeyUpEvent event) { - if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) { - return; - } - if (getHeader().getRow(event.getFocusedCell().getRowIndex()) - .isDefault()) { - // Only sort for enter on the default header - sorter.sort(event.getFocusedCell().getColumn(), - event.isShiftKeyDown()); - } + addHeaderKeyUpHandler(event -> { + if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) { + return; + } + if (getHeader().getRow(event.getFocusedCell().getRowIndex()) + .isDefault()) { + // Only sort for enter on the default header + sorter.sort(event.getFocusedCell().getColumn(), + event.isShiftKeyDown()); } }); diff --git a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java index f3e7c237a8..7719f0502a 100644 --- a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java +++ b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java @@ -176,7 +176,6 @@ public abstract class DeclarativeTestBaseBase<T extends Component> { @Override public void close() throws SecurityException { - } }; diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java index 61da7255ff..a7253b7229 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java @@ -462,10 +462,9 @@ public class GridElement extends AbstractComponentElement { Optional<WebElement> toggleButton = getDriver() .findElement(By.className("v-grid-sidebar-content")) .findElements(By.className("column-hiding-toggle")).stream() - .filter(e -> e.getText().equals(toggleCaption)) - .findAny(); + .filter(element -> element.getText().equals(toggleCaption)).findAny(); if (toggleButton.isPresent()) { - toggleButton.ifPresent(e -> e.click()); + toggleButton.ifPresent(element -> element.click()); } else { throw new IllegalArgumentException( "No column hiding toggle with caption '" + toggleCaption diff --git a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java index 6193b4d5ee..4941994e73 100644 --- a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java +++ b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java @@ -16,50 +16,43 @@ package com.vaadin.tests.application; -import java.io.IOException; import java.io.PrintWriter; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Link; import com.vaadin.v7.shared.ui.progressindicator.ProgressIndicatorServerRpc; import com.vaadin.v7.ui.ProgressIndicator; public class NavigateWithOngoingXHR extends AbstractReindeerTestUI { - private final RequestHandler slowRequestHandler = new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - if ("/slowRequestHandler".equals(request.getPathInfo())) { - // Make the navigation request last longer to keep the - // communication error visible - // System.out.println("Got slow content request"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + private final RequestHandler slowRequestHandler = (session, request, + response) -> { + if ("/slowRequestHandler".equals(request.getPathInfo())) { + // Make the navigation request last longer to keep the + // communication error visible + // System.out.println("Got slow content request"); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } - if (request.getParameter("download") != null) { - response.setHeader("Content-Disposition", "attachment"); - } + if (request.getParameter("download") != null) { + response.setHeader("Content-Disposition", "attachment"); + } - response.setContentType("text/plain"); - PrintWriter writer = response.getWriter(); - writer.println("Loaded slowly"); - writer.close(); + response.setContentType("text/plain"); + PrintWriter writer = response.getWriter(); + writer.println("Loaded slowly"); + writer.close(); - // System.out.println("Finished slow content request"); + // System.out.println("Finished slow content request"); - return true; - } - return false; + return true; } + return false; }; @Override diff --git a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java index d100108c3c..5b9db4ea9c 100644 --- a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java +++ b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java @@ -15,17 +15,12 @@ */ package com.vaadin.tests.applicationservlet; -import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import com.vaadin.server.ConnectorIdGenerationEvent; import com.vaadin.server.ConnectorIdGenerator; -import com.vaadin.server.RequestHandler; import com.vaadin.server.ServiceInitEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinServiceInitListener; -import com.vaadin.server.VaadinSession; public class TestingServiceInitListener implements VaadinServiceInitListener { @@ -37,14 +32,9 @@ public class TestingServiceInitListener implements VaadinServiceInitListener { public void serviceInit(ServiceInitEvent event) { initCount.incrementAndGet(); - event.addRequestHandler(new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - requestCount.incrementAndGet(); - return false; - } + event.addRequestHandler((session, request, response) -> { + requestCount.incrementAndGet(); + return false; }); event.addConnectorIdGenerator(new ConnectorIdGenerator() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java index 679ad6f18d..2f8cdae641 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java @@ -24,12 +24,9 @@ public class ResponseWritingErrorHandling extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - ErrorHandler errorHandler = new ErrorHandler() { - @Override - public void error(com.vaadin.server.ErrorEvent event) { - String message = event.getThrowable().getMessage(); - log(message); - } + ErrorHandler errorHandler = event -> { + String message = event.getThrowable().getMessage(); + log(message); }; Button button = new Button("Throw in beforeClientResponse") { diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java index 49745d96ca..94fd1b98e5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.abstractfield; import java.util.Date; -import com.vaadin.server.ErrorEvent; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.UserError; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.ui.ComboBox; @@ -34,12 +32,7 @@ public class TextFieldConversions extends AbstractComponentDataBindingTest { tf = new TextField("TextField"); addComponent(tf); - tf.setErrorHandler(new ErrorHandler() { - - @Override - public void error(ErrorEvent event) { - tf.setComponentError(new UserError("Invalid value")); - } - }); + tf.setErrorHandler( + event -> tf.setComponentError(new UserError("Invalid value"))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java index 95af0ad435..99ee908173 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java @@ -1,7 +1,6 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; -import com.vaadin.v7.ui.AbstractSelect.NewItemHandler; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.TextArea; @@ -16,13 +15,10 @@ public class NewItemsESCPress extends TestBase { final ComboBox box = new ComboBox("New items are allowed"); box.setNewItemsAllowed(true); - box.setNewItemHandler(new NewItemHandler() { - @Override - public void addNewItem(String newItemCaption) { - String value = addedItems.getValue(); - addedItems.setValue(value + newItemCaption + "\n"); - box.addItem(newItemCaption); - } + box.setNewItemHandler(newItemCaption -> { + String value = addedItems.getValue(); + addedItems.setValue(value + newItemCaption + "\n"); + box.addItem(newItemCaption); }); box.setImmediate(true); addComponent(box); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java index 4c779c33f0..0d947c1dc7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import java.lang.reflect.InvocationTargetException; import com.vaadin.event.ListenerMethod.MethodException; -import com.vaadin.server.ErrorEvent; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.ServerRpcManager.RpcInvocationException; import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.TestBase; @@ -118,25 +116,21 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { protected void setErrorHandler(boolean enabled) { if (enabled) { - VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() { - - @Override - public void error(ErrorEvent event) { - Throwable t = event.getThrowable(); - if (t instanceof RpcInvocationException) { + VaadinSession.getCurrent().setErrorHandler(event -> { + Throwable t = event.getThrowable(); + if (t instanceof RpcInvocationException) { + t = t.getCause(); + if (t instanceof InvocationTargetException) { t = t.getCause(); - if (t instanceof InvocationTargetException) { + if (t instanceof MethodException) { t = t.getCause(); - if (t instanceof MethodException) { - t = t.getCause(); - if (t instanceof CacheUpdateException) { - Table table = ((CacheUpdateException) t) - .getTable(); - table.removeAllItems(); - Notification.show( - "Problem updating table. Please try again later", - Notification.Type.ERROR_MESSAGE); - } + if (t instanceof CacheUpdateException) { + Table table = ((CacheUpdateException) t) + .getTable(); + table.removeAllItems(); + Notification.show( + "Problem updating table. Please try again later", + Notification.Type.ERROR_MESSAGE); } } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java index 6fa8511b0a..7c4a31bf05 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java @@ -4,9 +4,7 @@ import java.util.LinkedHashMap; import com.vaadin.server.Resource; import com.vaadin.tests.components.AbstractComponentContainerTest; -import com.vaadin.ui.Component; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.CloseHandler; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.TabSheet.Tab; @@ -42,23 +40,14 @@ public class TabSheetTest<T extends TabSheet> extends @Override public void execute(T c, Boolean value, Object data) { if (value) { - c.setCloseHandler(new CloseHandler() { - @Override - public void onTabClose(TabSheet tabsheet, Component c) { - tabClosed(tabsheet, tabsheet.getTab(c)); - tabsheet.removeComponent(c); - } - + c.setCloseHandler((tabsheet, comp) -> { + tabClosed(tabsheet, tabsheet.getTab(comp)); + tabsheet.removeComponent(comp); }); } else { - c.setCloseHandler(new CloseHandler() { - @Override - public void onTabClose(TabSheet tabsheet, Component c) { - tabsheet.removeComponent(c); - } - }); + c.setCloseHandler( + (tabsheet, comp) -> tabsheet.removeComponent(comp)); } - } }; private Command<T, Boolean> setSelectedTabListener = new Command<T, Boolean>() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java index 76573d1f81..c57578824a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java @@ -1,6 +1,5 @@ package com.vaadin.tests.components.ui; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Label; @@ -9,14 +8,9 @@ public class UIInitException extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - setErrorHandler(new ErrorHandler() { - @Override - public void error(com.vaadin.server.ErrorEvent event) { - addComponent(new Label("An exception occurred: " - + event.getThrowable().getMessage())); - - } - }); + setErrorHandler( + event -> addComponent(new Label("An exception occurred: " + + event.getThrowable().getMessage()))); throw new RuntimeException("Catch me if you can"); } diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java b/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java index 06027bf820..4ffb0c2466 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java @@ -182,7 +182,6 @@ public class DDTest1 extends TestBase { copyChildren(source, target, childId); } } - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java index 15c5196abd..38b8ba8859 100644 --- a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java +++ b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java @@ -38,15 +38,8 @@ public class ErrorHandlers extends AbstractReindeerTestUI { final VerticalLayout layoutWithErrorHandler = new VerticalLayout( runtimeExceptionOnClick(new Button("Error handler on parent"))); - ErrorHandler e = new ErrorHandler() { - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - layoutWithErrorHandler.addComponent( - new Label("Layout error: " + getErrorMessage(event))); - } - - }; + ErrorHandler e = event -> layoutWithErrorHandler.addComponent( + new Label("Layout error: " + getErrorMessage(event))); layoutWithErrorHandler.setErrorHandler(e); layoutWithErrorHandler.addComponent(notificationErrorHandler( npeOnClick(new Button("Error handler on button and parent")))); diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java index a24278de3f..e9e0b99ecf 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java @@ -1,7 +1,6 @@ package com.vaadin.tests.minitutorials.v7a1; import java.awt.image.BufferedImage; -import java.io.IOException; import javax.imageio.ImageIO; @@ -9,36 +8,30 @@ import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; import com.vaadin.server.Resource; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Image; public class DynamicImageUI extends AbstractReindeerTestUI { public static final String IMAGE_URL = "myimage.png"; - private final RequestHandler requestHandler = new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - if (("/" + IMAGE_URL).equals(request.getPathInfo())) { - // Create an image, draw the "text" parameter to it and output - // it to the browser. - String text = request.getParameter("text"); - BufferedImage bi = new BufferedImage(100, 30, - BufferedImage.TYPE_3BYTE_BGR); - bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), - 10, 20); - response.setContentType("image/png"); - ImageIO.write(bi, "png", response.getOutputStream()); + private final RequestHandler requestHandler = (session, request, + response) -> { + if (("/" + IMAGE_URL).equals(request.getPathInfo())) { + // Create an image, draw the "text" parameter to it and output + // it to the browser. + String text = request.getParameter("text"); + BufferedImage bi = new BufferedImage(100, 30, + BufferedImage.TYPE_3BYTE_BGR); + bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), 10, + 20); + response.setContentType("image/png"); + ImageIO.write(bi, "png", response.getOutputStream()); - return true; - } - // If the URL did not match our image URL, let the other request - // handlers handle it - return false; + return true; } + // If the URL did not match our image URL, let the other request + // handlers handle it + return false; }; @Override diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java index 49ec4da0b2..985ede4aa7 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java @@ -2,8 +2,6 @@ package com.vaadin.tests.minitutorials.v7a2; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.PushButton; @@ -26,12 +24,8 @@ public class MyPickerWidget extends ComplexPanel { add(textBox, getElement()); add(button, getElement()); - button.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - Window.alert("Calendar picker not yet supported!"); - } - }); + button.addClickHandler( + event -> Window.alert("Calendar picker not yet supported!")); } public void setButtonText(String buttonText, boolean adjustSpace) { diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java index 92f073aad4..82b922db37 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java @@ -4,13 +4,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; import com.vaadin.shared.communication.PushMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.v7.data.util.AbstractInMemoryContainer; import com.vaadin.v7.data.util.BeanContainer; @@ -24,23 +22,16 @@ public class PushErrorHandling extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { getPushConfiguration().setPushMode(PushMode.AUTOMATIC); - VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() { - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - addComponent(new Label( - "An error! " + event.getThrowable().getMessage())); - System.err.println( - "An error! " + event.getThrowable().getMessage()); - } + VaadinSession.getCurrent().setErrorHandler(event -> { + addComponent( + new Label( + "An error! " + event.getThrowable().getMessage())); + System.err + .println("An error! " + event.getThrowable().getMessage()); }); - final Button button = new Button("Click for NPE!", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ((String) null).length(); // Null-pointer exception - } + final Button button = new Button("Click for NPE!", event -> { + ((String) null).length(); // Null-pointer exception }); button.setId("npeButton"); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java index ad5a13e744..9d735ad2e2 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java @@ -39,7 +39,6 @@ import com.vaadin.v7.ui.DateField; import com.vaadin.v7.ui.TextArea; import com.vaadin.v7.ui.TextField; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent; -import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClick; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClickHandler; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectEvent; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectHandler; @@ -625,13 +624,9 @@ public class CalendarTest extends GridLayout implements View { } }); - calendarComponent.setHandler(new EventClickHandler() { - - @Override - public void eventClick(EventClick event) { - showEventPopup(event.getCalendarEvent(), false); - } - }); + calendarComponent + .setHandler((EventClickHandler) + event -> showEventPopup(event.getCalendarEvent(), false)); calendarComponent.setHandler(new BasicDateClickHandler() { @@ -644,13 +639,9 @@ public class CalendarTest extends GridLayout implements View { } }); - calendarComponent.setHandler(new RangeSelectHandler() { - - @Override - public void rangeSelect(RangeSelectEvent event) { - handleRangeSelect(event); - } - }); + calendarComponent + .setHandler( + (RangeSelectHandler) event -> handleRangeSelect(event)); } private ComboBox createTimeZoneSelect() { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java index ab300a9e81..4a4bb58488 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java @@ -19,11 +19,8 @@ import java.util.Arrays; import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; @@ -63,14 +60,10 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector private IntegerBox endHeight = new IntegerBox(); private final Button terrorizeButton = new Button("Terrorize", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - terrorize(startWidth.getValue(), endWidth.getValue(), - startHeight.getValue(), endHeight.getValue(), - 1000); - } - }); + (ClickHandler) event -> terrorize(startWidth.getValue(), + endWidth.getValue(), startHeight.getValue(), + endHeight.getValue(), + 1000)); private HandlerRegistration historyHandlerRegistration; @@ -98,12 +91,9 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector // Emulate button click from enter on any of the text boxes for (IntegerBox box : Arrays.asList(startWidth, endWidth, startHeight, endHeight)) { - box.addKeyUpHandler(new KeyUpHandler() { - @Override - public void onKeyUp(KeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - terrorizeButton.click(); - } + box.addKeyUpHandler(event -> { + if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { + terrorizeButton.click(); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java index a212dcedfe..203e813a80 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java @@ -2,7 +2,6 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -41,47 +40,35 @@ public class RunOverflowFixConnector overflowY.addStyleName("third-scrollbar"); Button runFix = new Button("Click to runWebkitOverflowAutoFix", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - overflow.getElement().getStyle() - .setOverflow(Style.Overflow.SCROLL); - WidgetUtil.runWebkitOverflowAutoFix( - overflow.getElement()); - - overflowX.getElement().getStyle() - .setOverflowX(Style.Overflow.HIDDEN); - WidgetUtil.runWebkitOverflowAutoFix( - overflowX.getElement()); - - overflowY.getElement().getStyle() - .setOverflowY(Style.Overflow.HIDDEN); - WidgetUtil.runWebkitOverflowAutoFix( - overflowY.getElement()); - } + (ClickHandler) event -> { + overflow.getElement().getStyle() + .setOverflow(Style.Overflow.SCROLL); + WidgetUtil.runWebkitOverflowAutoFix(overflow.getElement()); + + overflowX.getElement().getStyle() + .setOverflowX(Style.Overflow.HIDDEN); + WidgetUtil.runWebkitOverflowAutoFix(overflowX.getElement()); + + overflowY.getElement().getStyle() + .setOverflowY(Style.Overflow.HIDDEN); + WidgetUtil.runWebkitOverflowAutoFix(overflowY.getElement()); }); runFix.addStyleName("run-button-one"); getWidget().add(runFix); Button runFix2 = new Button("Click to runWebkitOverflowAutoFix 2", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - overflow.getElement().getStyle() - .setOverflow(Style.Overflow.VISIBLE); - WidgetUtil.runWebkitOverflowAutoFix( - overflow.getElement()); - - overflowX.getElement().getStyle() - .setOverflowX(Style.Overflow.SCROLL); - WidgetUtil.runWebkitOverflowAutoFix( - overflowX.getElement()); - - overflowY.getElement().getStyle() - .setOverflowY(Style.Overflow.AUTO); - WidgetUtil.runWebkitOverflowAutoFix( - overflowY.getElement()); - } + (ClickHandler) event -> { + overflow.getElement().getStyle() + .setOverflow(Style.Overflow.VISIBLE); + WidgetUtil.runWebkitOverflowAutoFix(overflow.getElement()); + + overflowX.getElement().getStyle() + .setOverflowX(Style.Overflow.SCROLL); + WidgetUtil.runWebkitOverflowAutoFix(overflowX.getElement()); + + overflowY.getElement().getStyle() + .setOverflowY(Style.Overflow.AUTO); + WidgetUtil.runWebkitOverflowAutoFix(overflowY.getElement()); }); runFix2.addStyleName("run-button-two"); getWidget().add(runFix2); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java index 17d27feed2..07eba9accc 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java @@ -22,7 +22,6 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.BorderStyle; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.WidgetUtil; @@ -43,12 +42,7 @@ public class WidgetUtilTestWidget extends Widget { root.addClassName("v-widget-util-test"); setElement(root); - addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - showSizes(); - } - }, ClickEvent.getType()); + addDomHandler(event -> showSizes(), ClickEvent.getType()); } public void construct(boolean inline) { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java index bb3b09aedf..1c626ba73d 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java @@ -19,8 +19,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.google.gwt.core.shared.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.VButton; import com.vaadin.shared.ui.Connect; @@ -60,13 +58,8 @@ public class CsrfButtonConnector extends AbstractComponentConnector { getWidget().getElement().setId(ID); getWidget().setText(csrfTokenInfo()); - getWidget().addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - getWidget().setText(csrfTokenInfo()); - } - }); + getWidget() + .addClickHandler(event -> getWidget().setText(csrfTokenInfo())); } private String csrfTokenInfo() { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java index 030fbe8110..336d48ccdf 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java @@ -16,7 +16,6 @@ package com.vaadin.tests.widgetset.client.extension; import com.google.gwt.event.dom.client.ContextMenuEvent; -import com.google.gwt.event.dom.client.ContextMenuHandler; import com.vaadin.client.ServerConnector; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.ui.AbstractComponentConnector; @@ -32,13 +31,9 @@ public class BrowserContextMenuExtensionConnector @Override protected void extend(ServerConnector target) { - getParent().getWidget().addDomHandler(new ContextMenuHandler() { - - @Override - public void onContextMenu(ContextMenuEvent event) { - // Stop context click events from propagating. - event.stopPropagation(); - } + getParent().getWidget().addDomHandler(event -> { + // Stop context click events from propagating. + event.stopPropagation(); }, ContextMenuEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java index b5e1e824eb..f7f385e154 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java @@ -18,8 +18,6 @@ package com.vaadin.tests.widgetset.client.grid; import java.util.ArrayList; import java.util.List; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Button; import com.vaadin.client.data.DataChangeHandler; import com.vaadin.client.data.DataSource; @@ -110,13 +108,7 @@ public class GridCellFocusOnResetSizeWidget final MyDataSource dataSource = new MyDataSource(); grid.setDataSource(dataSource); Button widget = new Button("Change Container Size"); - widget.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - dataSource.changeSize(); - } - }); + widget.addClickHandler(event -> dataSource.changeSize()); addNorth(grid, 400); addNorth(widget, 50); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java index 478ac51fde..4a06cb9914 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java @@ -19,8 +19,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.google.gwt.core.shared.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DialogBox; @@ -66,14 +64,7 @@ public class GwtRpcButtonConnector extends AbstractComponentConnector { log("GwtRpcButtonTestConnector init"); getWidget().setText("Click me"); - getWidget().addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - doRPC(); - } - - }); + getWidget().addClickHandler(event -> doRPC()); } /** diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java index aee16c334d..4a099fa3ff 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java @@ -1,7 +1,5 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a2; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.annotations.OnStateChange; @@ -18,16 +16,12 @@ public class MyComponentConnector extends AbstractComponentConnector { this); public MyComponentConnector() { - getWidget().addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - - final MouseEventDetails mouseDetails = MouseEventDetailsBuilder - .buildMouseEventDetails(event.getNativeEvent(), - getWidget().getElement()); + getWidget().addClickHandler(event -> { + final MouseEventDetails mouseDetails = MouseEventDetailsBuilder + .buildMouseEventDetails(event.getNativeEvent(), + getWidget().getElement()); - rpc.clicked(mouseDetails); - } + rpc.clicked(mouseDetails); }); registerRpc(MyComponentClientRpc.class, new MyComponentClientRpc() { @Override diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java index 3ac0db54fa..b093917cf9 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java @@ -1,7 +1,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a3; import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; @@ -22,14 +21,11 @@ public class CapsLockWarningConnector extends AbstractExtensionConnector { warning.setOwner(passwordWidget); warning.add(new HTML("Caps Lock is enabled!")); - passwordWidget.addDomHandler(new KeyPressHandler() { - @Override - public void onKeyPress(KeyPressEvent event) { - if (isEnabled() && isCapsLockOn(event)) { - warning.showRelativeTo(passwordWidget); - } else { - warning.hide(); - } + passwordWidget.addDomHandler(event -> { + if (isEnabled() && isCapsLockOn(event)) { + warning.showRelativeTo(passwordWidget); + } else { + warning.hide(); } }, KeyPressEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java index cbe12b57a2..15e703e9b2 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java @@ -17,8 +17,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a3; import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.RootPanel; @@ -38,14 +36,11 @@ public class ClientSideModule implements EntryPoint { vp.add(button); RootPanel.get().add(vp); - button.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if ("GWT User".equals(nameField.getText())) { - Window.alert("User OK"); - } else { - Window.alert("Unauthorized user"); - } + button.addClickHandler(event -> { + if ("GWT User".equals(nameField.getText())) { + Window.alert("User OK"); + } else { + Window.alert("Unauthorized user"); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java index d8d1f43c32..a2091f1d0c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java @@ -1,7 +1,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7b1; import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; @@ -25,18 +24,15 @@ public class CapsLockWarningWithRpcConnector warning.setOwner(passwordWidget); warning.add(new HTML("Caps Lock is enabled!")); - passwordWidget.addDomHandler(new KeyPressHandler() { - @Override - public void onKeyPress(KeyPressEvent event) { - if (isEnabled() && isCapsLockOn(event)) { - warning.showRelativeTo(passwordWidget); - rpc.isCapsLockEnabled(true); // Added to send message to the - // server - } else { - warning.hide(); - rpc.isCapsLockEnabled(false); // Added to send message to - // the server - } + passwordWidget.addDomHandler(event -> { + if (isEnabled() && isCapsLockOn(event)) { + warning.showRelativeTo(passwordWidget); + // Added to send message to the server + rpc.isCapsLockEnabled(true); + } else { + warning.hide(); + // Added to send message to the server + rpc.isCapsLockEnabled(false); } }, KeyPressEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java index d41df99886..0fb967610c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java @@ -27,7 +27,6 @@ import java.util.logging.Logger; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuHandler; @@ -79,8 +78,6 @@ import com.vaadin.v7.client.widget.grid.events.GridKeyUpEvent; import com.vaadin.v7.client.widget.grid.events.HeaderKeyDownHandler; import com.vaadin.v7.client.widget.grid.events.HeaderKeyPressHandler; import com.vaadin.v7.client.widget.grid.events.HeaderKeyUpHandler; -import com.vaadin.v7.client.widget.grid.events.ScrollEvent; -import com.vaadin.v7.client.widget.grid.events.ScrollHandler; import com.vaadin.v7.client.widget.grid.selection.SelectionModel; import com.vaadin.v7.client.widget.grid.selection.SelectionModel.None; import com.vaadin.v7.client.widgets.Grid; @@ -450,14 +447,10 @@ public class GridBasicClientFeaturesWidget if (scrollHandler != null) { return; } - scrollHandler = grid.addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - @SuppressWarnings("hiding") - final Grid<?> grid = (Grid<?>) event.getSource(); - label.setText("scrollTop: " + grid.getScrollTop() - + ", scrollLeft: " + grid.getScrollLeft()); - } + scrollHandler = grid.addScrollHandler(event -> { + final Grid<?> grid = (Grid<?>) event.getSource(); + label.setText("scrollTop: " + grid.getScrollTop() + + ", scrollLeft: " + grid.getScrollLeft()); }); } }, listenersPath); @@ -526,26 +519,22 @@ public class GridBasicClientFeaturesWidget addMenuCommand("Add context menu listener", new ScheduledCommand() { HandlerRegistration handler = null; - ContextMenuHandler contextMenuHandler = new ContextMenuHandler() { - - @Override - public void onContextMenu(ContextMenuEvent event) { - event.preventDefault(); - final String location; - EventCellReference<?> cellRef = grid.getEventCell(); - if (cellRef.isHeader()) { - location = "header"; - } else if (cellRef.isBody()) { - location = "body"; - } else if (cellRef.isFooter()) { - location = "footer"; - } else { - location = "somewhere"; - } - - getLogger().info("Prevented opening a context menu in grid " - + location); + ContextMenuHandler contextMenuHandler = event -> { + event.preventDefault(); + final String location; + EventCellReference<?> cellRef = grid.getEventCell(); + if (cellRef.isHeader()) { + location = "header"; + } else if (cellRef.isBody()) { + location = "body"; + } else if (cellRef.isFooter()) { + location = "footer"; + } else { + location = "somewhere"; } + + getLogger().info( + "Prevented opening a context menu in grid " + location); }; @Override @@ -913,13 +902,7 @@ public class GridBasicClientFeaturesWidget @Override public void execute() { final Button button = new Button("Button Header"); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); grid.getHeaderRow(0).getCell(column).setWidget(button); } }, "Component", "Columns", "Column " + i, "Header Type"); @@ -942,13 +925,7 @@ public class GridBasicClientFeaturesWidget @Override public void execute() { final Button button = new Button("Button Footer"); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); grid.getFooterRow(0).getCell(column).setWidget(button); } }, "Component", "Columns", "Column " + i, "Footer Type"); @@ -1459,12 +1436,8 @@ public class GridBasicClientFeaturesWidget final Label label = new Label("Row: " + rowIndex + "."); Button button = new Button("Button", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - label.setText("clicked"); - } - }); + (ClickHandler) event -> label + .setText("clicked")); panel.add(label); panel.add(button); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java index a651da1a44..d243573d7c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java @@ -22,8 +22,6 @@ import java.util.List; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.Button; @@ -280,13 +278,7 @@ public class GridClientColumnRendererConnector @Override public Button createWidget() { final Button button = new Button(""); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); return button; } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index 07e8b9389f..294026f06e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -256,7 +256,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { @Test public void testDisabled() { List<String> optionsCssClasses = getSelect().getOptionElements() - .stream().map(event -> event.getAttribute("class")) + .stream().map(element -> element.getAttribute("class")) .collect(Collectors.toList()); for (int i = 0; i < optionsCssClasses.size(); i++) { String cssClassList = optionsCssClasses.get(i); diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java index 365d1cd7ad..af6abf5a24 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java @@ -236,7 +236,7 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { Select select = new Select( getListSelect().findElement(By.tagName("select"))); return select.getAllSelectedOptions().stream() - .map(event -> event.getText()) + .map(element -> element.getText()) .collect(Collectors.toList()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java index 7695564970..e2c60b9506 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java @@ -22,16 +22,16 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class TreeBasicFeaturesTest extends MultiBrowserTest { private static final Predicate<TestBenchElement> THEME_RESOURCE = - e -> e.isElementPresent(By.tagName("img")) - && e.findElement(By.tagName("img")).getAttribute("src") + element -> element.isElementPresent(By.tagName("img")) + && element.findElement(By.tagName("img")).getAttribute("src") .contains("bullet.png"); private static final Predicate<TestBenchElement> VAADIN_ICON = - e -> e.isElementPresent(By.className("v-icon")) && e - .findElement(By.className("v-icon")).getAttribute("class") + element -> element.isElementPresent(By.className("v-icon")) + && element.findElement(By.className("v-icon")).getAttribute("class") .contains("Vaadin-Icons"); private static final Predicate<TestBenchElement> CLASS_RESOURCE = - e -> e.isElementPresent(By.tagName("img")) - && e.findElement(By.tagName("img")).getAttribute("src") + element -> element.isElementPresent(By.tagName("img")) + && element.findElement(By.tagName("img")).getAttribute("src") .contains("m.gif"); @Before |