summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-27 17:44:19 +0200
committerPekka Maanpää <pekkamaa@vaadin.com>2017-10-27 18:44:19 +0300
commitfb6e81221bd1b5ab0b81a3ee6c82e4286df57264 (patch)
tree4add58d9872688a1a72d8cfc15fd0dd0d47dc7b4 /client
parent01c93a6aef27ef562267d7966c6386ecaa6c1f6b (diff)
downloadvaadin-framework-fb6e81221bd1b5ab0b81a3ee6c82e4286df57264.tar.gz
vaadin-framework-fb6e81221bd1b5ab0b81a3ee6c82e4286df57264.zip
Use lambda with Handlers (#10229)
Also improve naming by replacing one-letter variable names.
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ApplicationConfiguration.java23
-rw-r--r--client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java9
-rw-r--r--client/src/main/java/com/vaadin/client/SimpleTree.java36
-rw-r--r--client/src/main/java/com/vaadin/client/VUIDLBrowser.java8
-rw-r--r--client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java25
-rw-r--r--client/src/main/java/com/vaadin/client/communication/DefaultConnectionStateHandler.java20
-rw-r--r--client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java10
-rw-r--r--client/src/main/java/com/vaadin/client/communication/Heartbeat.java10
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java71
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/HierarchyPanel.java19
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/HierarchySection.java162
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/LogSection.java45
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/TestBenchSection.java16
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java23
-rw-r--r--client/src/main/java/com/vaadin/client/metadata/ConnectorBundleLoader.java18
-rw-r--r--client/src/main/java/com/vaadin/client/ui/AbstractClickEventHandler.java33
-rw-r--r--client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java124
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java65
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java20
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAbstractSplitPanel.java42
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VCheckBox.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java5
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VComboBox.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VDateField.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VDateTimeCalendarPanel.java19
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java79
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VPopupView.java30
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VTwinColSelect.java6
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VUpload.java17
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VWindow.java47
-rw-r--r--client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java30
-rw-r--r--client/src/main/java/com/vaadin/client/ui/dd/DragAndDropHandler.java69
-rw-r--r--client/src/main/java/com/vaadin/client/ui/image/ImageConnector.java13
-rw-r--r--client/src/main/java/com/vaadin/client/ui/loginform/LoginFormConnector.java23
-rw-r--r--client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java31
-rw-r--r--client/src/main/java/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java33
-rw-r--r--client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java87
-rw-r--r--client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java13
-rw-r--r--client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java23
-rw-r--r--client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java43
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java126
43 files changed, 549 insertions, 959 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());
}
});