diff options
538 files changed, 4776 insertions, 10755 deletions
diff --git a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java index 2f64602557..5b0cd97206 100644 --- a/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/main/java/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java @@ -60,21 +60,11 @@ public class ConnectorBundle { static final String OLD_RENDERER_CONNECTOR_NAME = "com.vaadin.v7.client.connectors.AbstractRendererConnector"; - public static final Comparator<JClassType> jClassComparator = new Comparator<JClassType>() { - @Override - public int compare(JClassType o1, JClassType o2) { - return o1.getQualifiedSourceName() - .compareTo(o2.getQualifiedSourceName()); - } - }; + public static final Comparator<JClassType> jClassComparator = (o1, o2) -> o1 + .getQualifiedSourceName().compareTo(o2.getQualifiedSourceName()); - public static final Comparator<JMethod> jMethodComparator = new Comparator<JMethod>() { - @Override - public int compare(JMethod o1, JMethod o2) { - return o1.getReadableDeclaration() - .compareTo(o2.getReadableDeclaration()); - } - }; + public static final Comparator<JMethod> jMethodComparator = (o1, o2) -> o1 + .getReadableDeclaration().compareTo(o2.getReadableDeclaration()); private final String name; private final ConnectorBundle previousBundle; @@ -85,12 +75,7 @@ public class ConnectorBundle { private final Set<JType> needsSerializeSupport = new HashSet<>(); private final Map<JType, GeneratedSerializer> serializers = new TreeMap<>( - new Comparator<JType>() { - @Override - public int compare(JType o1, JType o2) { - return o1.toString().compareTo(o2.toString()); - } - }); + (o1, o2) -> o1.toString().compareTo(o2.toString())); private final Map<JClassType, Map<JMethod, Set<MethodAttribute>>> methodAttributes = new TreeMap<>( jClassComparator); diff --git a/client-compiler/src/main/java/com/vaadin/tools/WidgetsetCompiler.java b/client-compiler/src/main/java/com/vaadin/tools/WidgetsetCompiler.java index 7e43c0850f..20bcc8714e 100755 --- a/client-compiler/src/main/java/com/vaadin/tools/WidgetsetCompiler.java +++ b/client-compiler/src/main/java/com/vaadin/tools/WidgetsetCompiler.java @@ -60,28 +60,25 @@ public class WidgetsetCompiler { // thread and cannot be changed in JRE 1.5 (see // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197) - Runnable runCompiler = new Runnable() { - @Override - public void run() { - try { - // GWTCompiler.main(args); - // avoid warnings + Runnable runCompiler = () -> { + try { + // GWTCompiler.main(args); + // avoid warnings - String wsname = args[args.length - 1]; + String wsname = args[args.length - 1]; - // TODO expecting this is launched via eclipse WTP - // project - System.out.println( - "Updating GWT module description file..."); - WidgetSetBuilder.updateWidgetSet(wsname); - System.out.println("Done."); + // TODO expecting this is launched via eclipse WTP + // project + System.out + .println("Updating GWT module description file..."); + WidgetSetBuilder.updateWidgetSet(wsname); + System.out.println("Done."); - System.out.println("Starting GWT compiler"); - com.google.gwt.dev.Compiler.main(args); - } catch (Throwable thr) { - getLogger().log(Level.SEVERE, - "Widgetset compilation failed", thr); - } + System.out.println("Starting GWT compiler"); + com.google.gwt.dev.Compiler.main(args); + } catch (Throwable thr) { + getLogger().log(Level.SEVERE, + "Widgetset compilation failed", thr); } }; Thread runThread = new Thread(runCompiler); diff --git a/client/src/main/java/com/vaadin/client/ApplicationConnection.java b/client/src/main/java/com/vaadin/client/ApplicationConnection.java index 3cd2590311..718941916b 100644 --- a/client/src/main/java/com/vaadin/client/ApplicationConnection.java +++ b/client/src/main/java/com/vaadin/client/ApplicationConnection.java @@ -460,12 +460,8 @@ public class ApplicationConnection implements HasHandlers { // correct place in the DOM if (!tooltipInitialized) { tooltipInitialized = true; - ApplicationConfiguration.runWhenDependenciesLoaded(new Command() { - @Override - public void execute() { - getVTooltip().initializeAssistiveTooltips(); - } - }); + ApplicationConfiguration.runWhenDependenciesLoaded( + () -> getVTooltip().initializeAssistiveTooltips()); } } diff --git a/client/src/main/java/com/vaadin/client/Profiler.java b/client/src/main/java/com/vaadin/client/Profiler.java index e9e75a6922..d1ba1443a6 100644 --- a/client/src/main/java/com/vaadin/client/Profiler.java +++ b/client/src/main/java/com/vaadin/client/Profiler.java @@ -19,7 +19,6 @@ package com.vaadin.client; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -538,12 +537,8 @@ public class Profiler { rootNode.sumUpTotals(totals); List<Node> totalList = new ArrayList<>(totals.values()); - Collections.sort(totalList, new Comparator<Node>() { - @Override - public int compare(Node o1, Node o2) { - return (int) (o2.getTimeSpent() - o1.getTimeSpent()); - } - }); + Collections.sort(totalList, + (o1, o2) -> (int) (o2.getTimeSpent() - o1.getTimeSpent())); if (getConsumer() != null) { getConsumer().addProfilerData(stack.getFirst(), totalList); diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java index 3841592704..09ef5a3c6a 100644 --- a/client/src/main/java/com/vaadin/client/WidgetUtil.java +++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java @@ -37,7 +37,6 @@ import com.google.gwt.dom.client.Touch; import com.google.gwt.event.dom.client.KeyEvent; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; -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.EventListener; @@ -425,14 +424,8 @@ public class WidgetUtil { * with overflow auto */ public static void runWebkitOverflowAutoFixDeferred(final Element elem) { - Scheduler.get().scheduleDeferred(new Command() { - - @Override - public void execute() { - WidgetUtil.runWebkitOverflowAutoFix(elem); - } - }); - + Scheduler.get().scheduleDeferred( + () -> WidgetUtil.runWebkitOverflowAutoFix(elem)); } /** @@ -464,60 +457,54 @@ public class WidgetUtil { final int scrollleft = elem.getScrollLeft(); elem.getStyle().setProperty("overflow", "hidden"); - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - // Dough, Safari scroll auto means actually just a moped - elem.getStyle().setProperty("overflow", originalOverflow); - if (!originalOverflowX.isEmpty()) { - elem.getStyle().setProperty("overflowX", - originalOverflowX); - } - if (!originalOverflowY.isEmpty()) { - elem.getStyle().setProperty("overflowY", - originalOverflowY); - } + Scheduler.get().scheduleDeferred(() -> { + // Dough, Safari scroll auto means actually just a moped + elem.getStyle().setProperty("overflow", originalOverflow); + if (!originalOverflowX.isEmpty()) { + elem.getStyle().setProperty("overflowX", originalOverflowX); + } + if (!originalOverflowY.isEmpty()) { + elem.getStyle().setProperty("overflowY", originalOverflowY); + } - if (scrolltop > 0 || elem.getScrollTop() > 0) { - int scrollvalue = scrolltop; - if (scrollvalue == 0) { - // mysterious are the ways of webkits scrollbar - // handling. In some cases webkit reports bad (0) - // scrolltop before hiding the element temporary, - // sometimes after. - scrollvalue = elem.getScrollTop(); - } - // fix another bug where scrollbar remains in wrong - // position - elem.setScrollTop(scrollvalue - 1); - elem.setScrollTop(scrollvalue); + if (scrolltop > 0 || elem.getScrollTop() > 0) { + int scrollvalue = scrolltop; + if (scrollvalue == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit reports bad (0) + // scrolltop before hiding the element temporary, + // sometimes after. + scrollvalue = elem.getScrollTop(); } + // fix another bug where scrollbar remains in wrong + // position + elem.setScrollTop(scrollvalue - 1); + elem.setScrollTop(scrollvalue); + } - // fix for #6940 : Table horizontal scroll sometimes not - // updated when collapsing/expanding columns - // Also appeared in Safari 5.1 with webkit 534 (#7667) - if ((BrowserInfo.get().isChrome() || (BrowserInfo.get() - .isSafariOrIOS() - && BrowserInfo.get().getWebkitVersion() >= 534)) - && (scrollleft > 0 || elem.getScrollLeft() > 0)) { - int scrollvalue = scrollleft; - - if (scrollvalue == 0) { - // mysterious are the ways of webkits scrollbar - // handling. In some cases webkit may report a bad - // (0) scrollleft before hiding the element - // temporary, sometimes after. - scrollvalue = elem.getScrollLeft(); - } - // fix another bug where scrollbar remains in wrong - // position - elem.setScrollLeft(scrollvalue - 1); - elem.setScrollLeft(scrollvalue); + // fix for #6940 : Table horizontal scroll sometimes not + // updated when collapsing/expanding columns + // Also appeared in Safari 5.1 with webkit 534 (#7667) + if ((BrowserInfo.get().isChrome() + || (BrowserInfo.get().isSafariOrIOS() + && BrowserInfo.get().getWebkitVersion() >= 534)) + && (scrollleft > 0 || elem.getScrollLeft() > 0)) { + int scrollvalue = scrollleft; + + if (scrollvalue == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit may report a bad + // (0) scrollleft before hiding the element + // temporary, sometimes after. + scrollvalue = elem.getScrollLeft(); } + // fix another bug where scrollbar remains in wrong + // position + elem.setScrollLeft(scrollvalue - 1); + elem.setScrollLeft(scrollvalue); } }); } - } public static void alert(String string) { 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 4e7cbef43f..1a65fd8d8d 100644 --- a/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java @@ -156,10 +156,7 @@ public class AtmospherePushConnection implements PushConnection { return; } - disconnect(new Command() { - @Override - public void execute() { - } + disconnect(() -> { }); }); config = createConfig(); @@ -182,17 +179,8 @@ public class AtmospherePushConnection implements PushConnection { url = ApplicationConstants.APP_PROTOCOL_PREFIX + ApplicationConstants.PUSH_PATH; } - runWhenAtmosphereLoaded(new Command() { - @Override - public void execute() { - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - connect(); - } - }); - } - }); + runWhenAtmosphereLoaded( + () -> Scheduler.get().scheduleDeferred(() -> connect())); } private void connect() { diff --git a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java index 6fea01af69..50f98bf5f7 100644 --- a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -247,12 +247,7 @@ public class MessageHandler { .getApplicationState() == ApplicationState.INITIALIZING) { // Application is starting up for the first time connection.setApplicationRunning(true); - connection.executeWhenCSSLoaded(new Command() { - @Override - public void execute() { - handleJSON(json); - } - }); + connection.executeWhenCSSLoaded(() -> handleJSON(json)); } else { getLogger().warning( "Ignored received message because application has already been stopped"); diff --git a/client/src/main/java/com/vaadin/client/communication/MessageSender.java b/client/src/main/java/com/vaadin/client/communication/MessageSender.java index 07855902fb..735668bd5a 100644 --- a/client/src/main/java/com/vaadin/client/communication/MessageSender.java +++ b/client/src/main/java/com/vaadin/client/communication/MessageSender.java @@ -19,7 +19,6 @@ import java.util.logging.Logger; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; -import com.google.gwt.user.client.Command; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection.RequestStartingEvent; @@ -199,26 +198,23 @@ public class MessageSender { push = GWT.create(PushConnection.class); push.init(connection, pushState); } else if (!enabled && push != null && push.isActive()) { - push.disconnect(new Command() { - @Override - public void execute() { - push = null; - /* - * If push has been enabled again while we were waiting for - * the old connection to disconnect, now is the right time - * to open a new connection - */ - if (pushState.mode.isEnabled()) { - setPushEnabled(true); - } - - /* - * Send anything that was enqueued while we waited for the - * connection to close - */ - if (getServerRpcQueue().isFlushPending()) { - getServerRpcQueue().flush(); - } + push.disconnect(() -> { + push = null; + /* + * If push has been enabled again while we were waiting for the + * old connection to disconnect, now is the right time to open a + * new connection + */ + if (pushState.mode.isEnabled()) { + setPushEnabled(true); + } + + /* + * Send anything that was enqueued while we waited for the + * connection to close + */ + if (getServerRpcQueue().isFlushPending()) { + getServerRpcQueue().flush(); } }); } @@ -250,21 +246,18 @@ public class MessageSender { } // deferring to avoid flickering - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - if (!connection.isApplicationRunning() || !(hasActiveRequest() - || getServerRpcQueue().isFlushPending())) { - getLoadingIndicator().hide(); - - // If on Liferay and session expiration management is in - // use, extend session duration on each request. - // Doing it here rather than before the request to improve - // responsiveness. - // Postponed until the end of the next request if other - // requests still pending. - extendLiferaySession(); - } + Scheduler.get().scheduleDeferred(() -> { + if (!connection.isApplicationRunning() || !(hasActiveRequest() + || getServerRpcQueue().isFlushPending())) { + getLoadingIndicator().hide(); + + // If on Liferay and session expiration management is in + // use, extend session duration on each request. + // Doing it here rather than before the request to improve + // responsiveness. + // Postponed until the end of the next request if other + // requests still pending. + extendLiferaySession(); } }); connection.fireEvent(new ResponseHandlingEndedEvent(connection)); diff --git a/client/src/main/java/com/vaadin/client/communication/XhrConnection.java b/client/src/main/java/com/vaadin/client/communication/XhrConnection.java index 859b3c3024..cc15c00cc2 100644 --- a/client/src/main/java/com/vaadin/client/communication/XhrConnection.java +++ b/client/src/main/java/com/vaadin/client/communication/XhrConnection.java @@ -24,8 +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.google.gwt.user.client.Window; -import com.google.gwt.user.client.Window.ClosingEvent; -import com.google.gwt.user.client.Window.ClosingHandler; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection.CommunicationHandler; import com.vaadin.client.ApplicationConnection.RequestStartingEvent; @@ -63,12 +61,8 @@ public class XhrConnection { private boolean webkitMaybeIgnoringRequests = false; public XhrConnection() { - Window.addWindowClosingHandler(new ClosingHandler() { - @Override - public void onWindowClosing(ClosingEvent event) { - webkitMaybeIgnoringRequests = true; - } - }); + Window.addWindowClosingHandler( + event -> webkitMaybeIgnoringRequests = true); } /** 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 172bfcdeef..62ae9c458a 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 @@ -26,7 +26,6 @@ import com.google.gwt.event.dom.client.MouseOverEvent; import com.google.gwt.event.dom.client.MouseOverHandler; 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; @@ -193,60 +192,54 @@ public class TestBenchSection implements Section { content.add(w); } - 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 + || event.getTypeInt() == Event.ONCLICK) { + Element eventTarget = WidgetUtil.getElementFromPoint( + event.getNativeEvent().getClientX(), + event.getNativeEvent().getClientY()); + if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { + if (isFindMode() && event.getTypeInt() == Event.ONCLICK) { + stopFind(); + event.cancel(); + } return; } - if (event.getTypeInt() == Event.ONMOUSEMOVE - || event.getTypeInt() == Event.ONCLICK) { - Element eventTarget = WidgetUtil.getElementFromPoint( - event.getNativeEvent().getClientX(), - event.getNativeEvent().getClientY()); - if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { - if (isFindMode() && event.getTypeInt() == Event.ONCLICK) { - stopFind(); - event.cancel(); - } - return; - } - // make sure that not finding the highlight element only - Highlight.hideAll(); - - eventTarget = WidgetUtil.getElementFromPoint( - event.getNativeEvent().getClientX(), - event.getNativeEvent().getClientY()); - ComponentConnector connector = findConnector(eventTarget); - - if (event.getTypeInt() == Event.ONMOUSEMOVE) { - if (connector != null) { - Highlight.showOnly(connector); - event.cancel(); - event.consume(); - event.getNativeEvent().stopPropagation(); - return; - } - } else if (event.getTypeInt() == Event.ONCLICK) { + // make sure that not finding the highlight element only + Highlight.hideAll(); + + eventTarget = WidgetUtil.getElementFromPoint( + event.getNativeEvent().getClientX(), + event.getNativeEvent().getClientY()); + ComponentConnector connector = findConnector(eventTarget); + + if (event.getTypeInt() == Event.ONMOUSEMOVE) { + if (connector != null) { + Highlight.showOnly(connector); event.cancel(); event.consume(); event.getNativeEvent().stopPropagation(); - if (connector != null) { - Highlight.showOnly(connector); - pickSelector(connector, eventTarget); - return; - } + return; + } + } else if (event.getTypeInt() == Event.ONCLICK) { + event.cancel(); + event.consume(); + event.getNativeEvent().stopPropagation(); + if (connector != null) { + Highlight.showOnly(connector); + pickSelector(connector, eventTarget); + return; } } - event.cancel(); } - + event.cancel(); }; private ComponentConnector findConnector(Element element) { 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 ad93e15092..70d4f7a154 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 @@ -27,7 +27,6 @@ import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Cursor; import com.google.gwt.dom.client.Style.Overflow; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownHandler; @@ -520,12 +519,9 @@ public final class VDebugWindow extends VOverlay { */ public void addSection(final Section section) { Button b = section.getTabButton(); - b.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - activateSection(section); - writeStoredState(); - } + b.addClickHandler(event -> { + activateSection(section); + writeStoredState(); }); b.setStylePrimaryName(STYLENAME_TAB); tabs.add(b); @@ -792,17 +788,14 @@ public final class VDebugWindow extends VOverlay { FlowPanel size = new FlowPanel(); content.add(size); - final ClickHandler sizeHandler = new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - for (int i = 0; i < sizes.length; i++) { - Button b = sizes[i]; - if (b == event.getSource()) { - setSize(i); - } + final ClickHandler sizeHandler = event -> { + for (int i = 0; i < sizes.length; i++) { + Button b = sizes[i]; + if (b == event.getSource()) { + setSize(i); } - hide(); } + hide(); }; for (int i = 0; i < sizes.length; i++) { Button b = sizes[i]; @@ -813,17 +806,14 @@ public final class VDebugWindow extends VOverlay { FlowPanel mode = new FlowPanel(); content.add(mode); - final ClickHandler modeHandler = new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - for (int i = 0; i < modes.length; i++) { - Button b = modes[i]; - if (b == event.getSource()) { - setDevMode(i); - } + final ClickHandler modeHandler = event -> { + for (int i = 0; i < modes.length; i++) { + Button b = modes[i]; + if (b == event.getSource()) { + setDevMode(i); } - hide(); } + hide(); }; modes[getDevMode()].setActive(true); for (Button b : modes) { @@ -833,13 +823,10 @@ public final class VDebugWindow extends VOverlay { Button reset = new DebugButton(Icon.RESET, "Restore defaults.", " Reset"); - reset.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - resetStoredState(); - readStoredState(); - hide(); - } + reset.addClickHandler(event -> { + resetStoredState(); + readStoredState(); + hide(); }); content.add(reset); } diff --git a/client/src/main/java/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java b/client/src/main/java/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java index 4381caddd0..05f7bf9c30 100644 --- a/client/src/main/java/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java @@ -38,12 +38,7 @@ public class JavaScriptManagerConnector extends AbstractExtensionConnector { @Override protected void init() { - registerRpc(ExecuteJavaScriptRpc.class, new ExecuteJavaScriptRpc() { - @Override - public void executeJavaScript(String script) { - eval(script); - } - }); + registerRpc(ExecuteJavaScriptRpc.class, script -> eval(script)); } @Override diff --git a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java index 133d195f48..02bfa95e14 100644 --- a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; -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.ui.HasWidgets; @@ -136,15 +135,12 @@ public class ShortcutActionHandler { */ client.flushActiveConnector(); - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - if (finalTarget != null) { - client.updateVariable(paintableId, "actiontarget", - finalTarget, false); - } - client.updateVariable(paintableId, "action", a.getKey(), true); + Scheduler.get().scheduleDeferred(() -> { + if (finalTarget != null) { + client.updateVariable(paintableId, "actiontarget", finalTarget, + false); } + client.updateVariable(paintableId, "action", a.getKey(), true); }); } diff --git a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java index e6aabd1af1..bf159f17f0 100644 --- a/client/src/main/java/com/vaadin/client/ui/VContextMenu.java +++ b/client/src/main/java/com/vaadin/client/ui/VContextMenu.java @@ -43,7 +43,6 @@ import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; 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.Window; import com.google.gwt.user.client.ui.MenuBar; @@ -137,45 +136,38 @@ public class VContextMenu extends VOverlay implements SubPartAware { // reset height (if it has been previously set explicitly) setHeight(""); - setPopupPositionAndShow(new PositionCallback() { - @Override - public void setPosition(int offsetWidth, int offsetHeight) { - // mac FF gets bad width due GWT popups overflow hacks, - // re-determine width - offsetWidth = menu.getOffsetWidth(); - int left = VContextMenu.this.left; - int top = VContextMenu.this.top; - if (offsetWidth + left > Window.getClientWidth()) { - left = left - offsetWidth; - if (left < 0) { - left = 0; - } - } - if (offsetHeight + top > Window.getClientHeight()) { - top = Math.max(0, Window.getClientHeight() - offsetHeight); - } - if (top == 0) { - setHeight(Window.getClientHeight() + "px"); + setPopupPositionAndShow((offsetWidth, offsetHeight) -> { + // mac FF gets bad width due GWT popups overflow hacks, + // re-determine width + offsetWidth = menu.getOffsetWidth(); + int menuLeft = VContextMenu.this.left; + int menuTop = VContextMenu.this.top; + if (offsetWidth + menuLeft > Window.getClientWidth()) { + menuLeft = menuLeft - offsetWidth; + if (menuLeft < 0) { + menuLeft = 0; } - setPopupPosition(left, top); - - /* - * Move keyboard focus to menu, deferring the focus setting so - * the focus is certainly moved to the menu in all browser after - * the positioning has been done. - */ - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - // Focus the menu. - menu.setFocus(true); - - // Unselect previously selected items - menu.selectItem(null); - } - }); - } + if (offsetHeight + menuTop > Window.getClientHeight()) { + menuTop = Math.max(0, Window.getClientHeight() - offsetHeight); + } + if (menuTop == 0) { + setHeight(Window.getClientHeight() + "px"); + } + setPopupPosition(menuLeft, menuTop); + + /* + * Move keyboard focus to menu, deferring the focus setting so the + * focus is certainly moved to the menu in all browser after the + * positioning has been done. + */ + Scheduler.get().scheduleDeferred(() -> { + // Focus the menu. + menu.setFocus(true); + + // Unselect previously selected items + menu.selectItem(null); + }); }); } diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomField.java b/client/src/main/java/com/vaadin/client/ui/VCustomField.java index 2d5039fcd8..11ecfd88b0 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCustomField.java +++ b/client/src/main/java/com/vaadin/client/ui/VCustomField.java @@ -47,13 +47,7 @@ public class VCustomField extends VCustomComponent implements Focusable { */ public void setFocusDelegate( final com.google.gwt.user.client.ui.Focusable focusDelegate) { - this.focusDelegate = new Focusable() { - @Override - public void focus() { - focusDelegate.setFocus(true); - } - }; - + this.focusDelegate = () -> focusDelegate.setFocus(true); } } 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 43c455f386..3c088236c6 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -28,7 +28,6 @@ import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.TouchStartEvent; -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.Timer; @@ -46,7 +45,6 @@ import com.vaadin.client.ValueMap; import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.dd.DDUtil; import com.vaadin.client.ui.dd.VAbstractDropHandler; -import com.vaadin.client.ui.dd.VAcceptCallback; import com.vaadin.client.ui.dd.VDragAndDropManager; import com.vaadin.client.ui.dd.VDragEvent; import com.vaadin.client.ui.dd.VDropHandler; @@ -223,30 +221,23 @@ public class VDragAndDropWrapper extends VCustomComponent /** For internal use only. May be removed or replaced in the future. */ public void startNextUpload() { - Scheduler.get().scheduleDeferred(new Command() { - - @Override - public void execute() { - if (!uploading) { - if (!fileIds.isEmpty()) { - - uploading = true; - final Integer fileId = fileIds.remove(0); - VHtml5File file = files.remove(0); - final String receiverUrl = client.translateVaadinUri( - fileIdToReceiver.remove(fileId.toString())); - ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR - .create(); - extendedXHR - .setOnReadyStateChange(readyStateChangeHandler); - extendedXHR.open("POST", receiverUrl); - extendedXHR.postFile(file); - } + Scheduler.get().scheduleDeferred(() -> { + if (!uploading) { + if (!fileIds.isEmpty()) { + + uploading = true; + final Integer fileId = fileIds.remove(0); + VHtml5File file = files.remove(0); + final String receiverUrl = client.translateVaadinUri( + fileIdToReceiver.remove(fileId.toString())); + ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR + .create(); + extendedXHR.setOnReadyStateChange(readyStateChangeHandler); + extendedXHR.open("POST", receiverUrl); + extendedXHR.postFile(file); } - } }); - } public boolean html5DragStart(VHtml5DragEvent event) { @@ -511,13 +502,7 @@ public class VDragAndDropWrapper extends VCustomComponent boolean detailsChanged = updateDropDetails(drag); if (detailsChanged) { currentlyValid = false; - validate(new VAcceptCallback() { - - @Override - public void accepted(VDragEvent event) { - dragAccepted(drag); - } - }, drag); + validate(event -> dragAccepted(drag), drag); } } diff --git a/client/src/main/java/com/vaadin/client/ui/VRichTextArea.java b/client/src/main/java/com/vaadin/client/ui/VRichTextArea.java index a4d8147f81..2c655c40cf 100644 --- a/client/src/main/java/com/vaadin/client/ui/VRichTextArea.java +++ b/client/src/main/java/com/vaadin/client/ui/VRichTextArea.java @@ -259,12 +259,9 @@ public class VRichTextArea extends Composite implements Field, KeyPressHandler, @Override public void onKeyPress(KeyPressEvent event) { if (maxLength >= 0) { - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - if (rta.getHTML().length() > maxLength) { - rta.setHTML(rta.getHTML().substring(0, maxLength)); - } + Scheduler.get().scheduleDeferred(() -> { + if (rta.getHTML().length() > maxLength) { + rta.setHTML(rta.getHTML().substring(0, maxLength)); } }); } diff --git a/client/src/main/java/com/vaadin/client/ui/VSlider.java b/client/src/main/java/com/vaadin/client/ui/VSlider.java index ec4167f9fa..fe4950bfdb 100644 --- a/client/src/main/java/com/vaadin/client/ui/VSlider.java +++ b/client/src/main/java/com/vaadin/client/ui/VSlider.java @@ -231,12 +231,9 @@ public class VSlider extends SimpleFocusablePanel if (!isVertical()) { // Draw handle with a delay to allow base to gain maximum width - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - buildHandle(); - setValue(value, false); - } + Scheduler.get().scheduleDeferred(() -> { + buildHandle(); + setValue(value, false); }); } else { buildHandle(); diff --git a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java index e7da389113..e3e55f97ef 100644 --- a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java @@ -1347,15 +1347,9 @@ public class VTabsheet extends VTabsheetBase */ final Style style = scroller.getStyle(); style.setProperty("whiteSpace", "normal"); - Scheduler.get().scheduleDeferred(new Command() { - - @Override - public void execute() { - style.setProperty("whiteSpace", ""); - } - }); + Scheduler.get().scheduleDeferred( + () -> style.setProperty("whiteSpace", "")); } - } /** For internal use only. May be removed or replaced in the future. */ 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 11e9c24a14..a808f76a7e 100644 --- a/client/src/main/java/com/vaadin/client/ui/VUpload.java +++ b/client/src/main/java/com/vaadin/client/ui/VUpload.java @@ -23,7 +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.user.client.Command; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.FileUpload; @@ -253,35 +252,32 @@ public class VUpload extends SimplePanel { */ private void onSubmitComplete() { /* Needs to be run dereferred to avoid various browser issues. */ - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - if (submitted) { - if (client != null) { - if (t != null) { - t.cancel(); - } - VConsole.log("VUpload:Submit complete"); - if (isAttached()) { - // no need to call poll() if component is already - // detached #8728 - ((UploadConnector) ConnectorMap.get(client) - .getConnector(VUpload.this)) - .getRpcProxy(UploadServerRpc.class) - .poll(); - } + Scheduler.get().scheduleDeferred(() -> { + if (submitted) { + if (client != null) { + if (t != null) { + t.cancel(); + } + VConsole.log("VUpload:Submit complete"); + if (isAttached()) { + // no need to call poll() if component is already + // detached #8728 + ((UploadConnector) ConnectorMap.get(client) + .getConnector(VUpload.this)) + .getRpcProxy(UploadServerRpc.class) + .poll(); } + } - rebuildPanel(); + rebuildPanel(); - submitted = false; - enableUpload(); - if (!isAttached()) { - /* - * Upload is complete when upload is already abandoned. - */ - cleanTargetFrame(); - } + submitted = false; + enableUpload(); + if (!isAttached()) { + /* + * Upload is complete when upload is already abandoned. + */ + cleanTargetFrame(); } } }); 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 6b32278734..e7618ed59b 100644 --- a/client/src/main/java/com/vaadin/client/ui/VWindow.java +++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java @@ -21,7 +21,6 @@ import static com.vaadin.client.WidgetUtil.isFocusedElementEditable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.List; import com.google.gwt.aria.client.Id; @@ -45,7 +44,6 @@ import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.shared.HandlerManager; 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.NativePreviewHandler; @@ -522,13 +520,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, public static void deferOrdering() { if (!orderingDefered) { orderingDefered = true; - Scheduler.get().scheduleFinally(new Command() { - - @Override - public void execute() { - doServerSideOrdering(); - VNotification.bringNotificationsToFront(); - } + Scheduler.get().scheduleFinally(() -> { + doServerSideOrdering(); + VNotification.bringNotificationsToFront(); }); } } @@ -536,26 +530,24 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, private static void doServerSideOrdering() { orderingDefered = false; VWindow[] array = windowOrder.toArray(new VWindow[windowOrder.size()]); - Arrays.sort(array, new Comparator<VWindow>() { - - @Override - public int compare(VWindow o1, VWindow o2) { - /* - * Order by modality, then by bringtofront sequence. - */ - - if (o1.vaadinModality && !o2.vaadinModality) { - return 1; - } else if (!o1.vaadinModality && o2.vaadinModality) { - return -1; - } else if (o1.bringToFrontSequence > o2.bringToFrontSequence) { - return 1; - } else if (o1.bringToFrontSequence < o2.bringToFrontSequence) { - return -1; - } else { - return 0; - } + Arrays.sort(array, (o1, o2) -> { + + /* + * Order by modality, then by bringtofront sequence. + */ + if (o1.vaadinModality && !o2.vaadinModality) { + return 1; + } + if (!o1.vaadinModality && o2.vaadinModality) { + return -1; + } + if (o1.bringToFrontSequence > o2.bringToFrontSequence) { + return 1; + } + if (o1.bringToFrontSequence < o2.bringToFrontSequence) { + return -1; } + return 0; }); for (VWindow w : array) { if (w.bringToFrontSequence != -1 || w.vaadinModality) { diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VAbstractDropHandler.java b/client/src/main/java/com/vaadin/client/ui/dd/VAbstractDropHandler.java index 89d33881ff..f7903e615e 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VAbstractDropHandler.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VAbstractDropHandler.java @@ -96,12 +96,7 @@ public abstract class VAbstractDropHandler implements VDropHandler { */ @Override public void dragEnter(final VDragEvent drag) { - validate(new VAcceptCallback() { - @Override - public void accepted(VDragEvent event) { - dragAccepted(drag); - } - }, drag); + validate(event -> dragAccepted(drag), drag); } /** @@ -116,12 +111,8 @@ public abstract class VAbstractDropHandler implements VDropHandler { protected abstract void dragAccepted(VDragEvent drag); protected void validate(final VAcceptCallback cb, final VDragEvent event) { - Command checkCriteria = new Command() { - @Override - public void execute() { - acceptCriteria.accept(event, criterioUIDL, cb); - } - }; + Command checkCriteria = () -> acceptCriteria.accept(event, criterioUIDL, + cb); VDragAndDropManager.get().executeWhenReady(checkCriteria); } @@ -139,15 +130,10 @@ public abstract class VAbstractDropHandler implements VDropHandler { return true; } else { validated = false; - acceptCriteria.accept(drag, criterioUIDL, new VAcceptCallback() { - @Override - public void accepted(VDragEvent event) { - validated = true; - } - }); + acceptCriteria.accept(drag, criterioUIDL, + event -> validated = true); return validated; } - } /** diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VAcceptCriterion.java b/client/src/main/java/com/vaadin/client/ui/dd/VAcceptCriterion.java index f1fe4fb409..956b10c8d8 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VAcceptCriterion.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VAcceptCriterion.java @@ -39,12 +39,9 @@ public abstract class VAcceptCriterion { public void accept(final VDragEvent drag, UIDL configuration, final VAcceptCallback callback) { if (needsServerSideCheck(drag, configuration)) { - VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { - @Override - public void handleResponse(boolean accepted, UIDL response) { - if (accepted) { - callback.accepted(drag); - } + VDragEventServerCallback acceptCallback = (accepted, response) -> { + if (accepted) { + callback.accepted(drag); } }; VDragAndDropManager.get().visitServer(acceptCallback); @@ -54,7 +51,6 @@ public abstract class VAcceptCriterion { callback.accepted(drag); } } - } protected abstract boolean accept(VDragEvent drag, UIDL configuration); diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java index 40817c5d32..16f9420adf 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java @@ -47,20 +47,16 @@ public class VLazyInitItemIdentifiers extends VAcceptCriterion { } } else { - VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { - - @Override - public void handleResponse(boolean accepted, UIDL response) { - hashSet = new HashSet<>(); - String[] stringArrayAttribute = response - .getStringArrayAttribute("allowedIds"); - for (String attribute : stringArrayAttribute) { - hashSet.add(attribute); - } - loaded = true; - if (accepted) { - callback.accepted(drag); - } + VDragEventServerCallback acceptCallback = (accepted, response) -> { + hashSet = new HashSet<>(); + String[] stringArrayAttribute = response + .getStringArrayAttribute("allowedIds"); + for (String attribute : stringArrayAttribute) { + hashSet.add(attribute); + } + loaded = true; + if (accepted) { + callback.accepted(drag); } }; diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VNot.java b/client/src/main/java/com/vaadin/client/ui/dd/VNot.java index ffa0b25aff..d919541b8e 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VNot.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VNot.java @@ -46,12 +46,7 @@ public final class VNot extends VAcceptCriterion { b1 = false; - VAcceptCallback accept1cb = new VAcceptCallback() { - @Override - public void accepted(VDragEvent event) { - b1 = true; - } - }; + VAcceptCallback accept1cb = event -> b1 = true; crit1.accept(drag, configuration.getChildUIDL(0), accept1cb); if (!b1) { diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VServerAccept.java b/client/src/main/java/com/vaadin/client/ui/dd/VServerAccept.java index 69bb013e5c..24a8ae0f58 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VServerAccept.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VServerAccept.java @@ -32,12 +32,9 @@ public final class VServerAccept extends VAcceptCriterion { public void accept(final VDragEvent drag, UIDL configuration, final VAcceptCallback callback) { - VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { - @Override - public void handleResponse(boolean accepted, UIDL response) { - if (accepted) { - callback.accepted(drag); - } + VDragEventServerCallback acceptCallback = (accepted, response) -> { + if (accepted) { + callback.accepted(drag); } }; VDragAndDropManager.get().visitServer(acceptCallback); diff --git a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java index 4b9f9a1bd5..802d4a7396 100644 --- a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java @@ -123,12 +123,7 @@ public class MenuBarConnector extends AbstractComponentConnector if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with the // item's id-number - cmd = new Command() { - @Override - public void execute() { - widget.hostReference.onMenuClick(itemId); - } - }; + cmd = () -> widget.hostReference.onMenuClick(itemId); } } diff --git a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetConnector.java b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetConnector.java index 1c2841fd20..bc3c412f09 100644 --- a/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/tabsheet/TabsheetConnector.java @@ -34,21 +34,18 @@ public class TabsheetConnector extends TabsheetBaseConnector implements SimpleManagedLayout, MayScrollChildren { public TabsheetConnector() { - registerRpc(TabsheetClientRpc.class, new TabsheetClientRpc() { - @Override - public void revertToSharedStateSelection() { - for (int i = 0; i < getState().tabs.size(); ++i) { - final String key = getState().tabs.get(i).key; - final boolean selected = key.equals(getState().selected); - if (selected) { - getWidget().waitingForResponse = false; - getWidget().setActiveTabIndex(i); - getWidget().selectTab(i); - break; - } + registerRpc(TabsheetClientRpc.class, () -> { + for (int i = 0; i < getState().tabs.size(); ++i) { + final String key = getState().tabs.get(i).key; + final boolean selected = key.equals(getState().selected); + if (selected) { + getWidget().waitingForResponse = false; + getWidget().setActiveTabIndex(i); + getWidget().selectTab(i); + break; } - renderContent(); } + renderContent(); }); } 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 835c924d47..ad7a192d14 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 @@ -39,7 +39,6 @@ import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; 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.History; @@ -172,23 +171,20 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getWidget().getElement().setScrollLeft(scrollLeft); } }); - registerRpc(UIClientRpc.class, new UIClientRpc() { - @Override - public void uiClosed(final boolean sessionExpired) { - Scheduler.get().scheduleDeferred(() -> { - // Only notify user if we're still running and not e.g. - // navigating away (#12298) - if (getConnection().isApplicationRunning()) { - if (sessionExpired) { - getConnection().showSessionExpiredError(null); - } else { - getState().enabled = false; - updateEnabledState(getState().enabled); - } - getConnection().setApplicationRunning(false); + registerRpc(UIClientRpc.class, sessionExpired -> { + Scheduler.get().scheduleDeferred(() -> { + // Only notify user if we're still running and not e.g. + // navigating away (#12298) + if (getConnection().isApplicationRunning()) { + if (sessionExpired) { + getConnection().showSessionExpiredError(null); + } else { + getState().enabled = false; + updateEnabledState(getState().enabled); } - }); - } + getConnection().setApplicationRunning(false); + } + }); }); registerRpc(DebugWindowClientRpc.class, new DebugWindowClientRpc() { @@ -297,12 +293,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - VUI.goTo(url); - } - }); + Scheduler.get().scheduleDeferred(() -> VUI.goTo(url)); } else if ("_self".equals(target)) { // This window is closing (for sure). Only other opens are // relevant in this change. See #3558, #2144 @@ -365,38 +356,34 @@ public class UIConnector extends AbstractSingleComponentContainerConnector if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - ComponentConnector connector = (ComponentConnector) uidl - .getPaintableAttribute("focused", getConnection()); - - if (connector == null) { - // Do not try to focus invisible components which not - // present in UIDL - return; - } + Scheduler.get().scheduleDeferred(() -> { + ComponentConnector connector = (ComponentConnector) uidl + .getPaintableAttribute("focused", getConnection()); + + if (connector == null) { + // Do not try to focus invisible components which not + // present in UIDL + return; + } - final Widget toBeFocused = connector.getWidget(); - /* - * Two types of Widgets can be focused, either implementing - * GWT Focusable of a thinner Vaadin specific Focusable - * interface. - */ - if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { - final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; - toBeFocusedWidget.setFocus(true); - } else if (toBeFocused instanceof Focusable) { - ((Focusable) toBeFocused).focus(); - } else { - getLogger().severe( - "Server is trying to set focus to the widget of connector " - + Util.getConnectorString(connector) - + " but it is not focusable. The widget should implement either " - + com.google.gwt.user.client.ui.Focusable.class - .getName() - + " or " + Focusable.class.getName()); - } + final Widget toBeFocused = connector.getWidget(); + /* + * Two types of Widgets can be focused, either implementing GWT + * Focusable of a thinner Vaadin specific Focusable interface. + */ + if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { + final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; + toBeFocusedWidget.setFocus(true); + } else if (toBeFocused instanceof Focusable) { + ((Focusable) toBeFocused).focus(); + } else { + getLogger().severe( + "Server is trying to set focus to the widget of connector " + + Util.getConnectorString(connector) + + " but it is not focusable. The widget should implement either " + + com.google.gwt.user.client.ui.Focusable.class + .getName() + + " or " + Focusable.class.getName()); } }); } @@ -757,12 +744,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector return; } - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - componentConnector.getWidget().getElement().scrollIntoView(); - } - }); + Scheduler.get().scheduleDeferred(() -> componentConnector.getWidget() + .getElement().scrollIntoView()); } @Override 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 92945427f5..49aeae6a39 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 @@ -34,12 +34,7 @@ public class UploadConnector extends AbstractComponentConnector implements Paintable { public UploadConnector() { - registerRpc(UploadClientRpc.class, new UploadClientRpc() { - @Override - public void submitUpload() { - getWidget().submit(); - } - }); + registerRpc(UploadClientRpc.class, () -> getWidget().submit()); } @Override diff --git a/client/src/main/java/com/vaadin/client/widget/escalator/FlyweightRow.java b/client/src/main/java/com/vaadin/client/widget/escalator/FlyweightRow.java index 996741ddc5..4ab1676af2 100644 --- a/client/src/main/java/com/vaadin/client/widget/escalator/FlyweightRow.java +++ b/client/src/main/java/com/vaadin/client/widget/escalator/FlyweightRow.java @@ -240,13 +240,9 @@ public class FlyweightRow implements Row { assertSetup(); assert offset >= 0 && offset + numberOfCells <= cells .size() : "Invalid range of cells"; - return new Iterable<FlyweightCell>() { - @Override - public Iterator<FlyweightCell> iterator() { - return CellIterator.attached( + return () -> CellIterator + .attached( cells.subList(offset, offset + numberOfCells)); - } - }; } /** @@ -269,13 +265,9 @@ public class FlyweightRow implements Row { assertSetup(); assert offset >= 0 && offset + numberOfCells <= cells .size() : "Invalid range of cells"; - return new Iterable<FlyweightCell>() { - @Override - public Iterator<FlyweightCell> iterator() { - return CellIterator.unattached( + return () -> CellIterator + .unattached( cells.subList(offset, offset + numberOfCells)); - } - }; } /** diff --git a/client/src/main/java/com/vaadin/client/widget/grid/AutoScroller.java b/client/src/main/java/com/vaadin/client/widget/grid/AutoScroller.java index 6ff77a2c88..db9af545fc 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/AutoScroller.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/AutoScroller.java @@ -380,39 +380,6 @@ public class AutoScroller { } } - /** - * This handler makes sure that pointer movements are handled. - * <p> - * Essentially, a native preview handler is registered (so that selection - * gestures can happen outside of the selection column). The handler itself - * makes sure that it's detached when the pointer is "lifted". - */ - private final NativePreviewHandler scrollPreviewHandler = new NativePreviewHandler() { - @Override - public void onPreviewNativeEvent(final NativePreviewEvent 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; - } - } - }; /** The registration info for {@link #scrollPreviewHandler} */ private HandlerRegistration handlerRegistration; @@ -442,6 +409,37 @@ public class AutoScroller { private AutoScrollerCallback callback; /** + * This handler makes sure that pointer movements are handled. + * <p> + * Essentially, a native preview handler is registered (so that selection + * gestures can happen outside of the selection column). The handler itself + * makes sure that it's detached when the pointer is "lifted". + */ + 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; + } + }; + + /** * Creates a new instance for scrolling the given grid. * * @param grid diff --git a/client/src/main/java/com/vaadin/client/widget/grid/DetailsGenerator.java b/client/src/main/java/com/vaadin/client/widget/grid/DetailsGenerator.java index 23e2c5aee5..c5f483ca96 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/DetailsGenerator.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/DetailsGenerator.java @@ -26,12 +26,7 @@ import com.google.gwt.user.client.ui.Widget; public interface DetailsGenerator { /** A details generator that provides no details. */ - public static final DetailsGenerator NULL = new DetailsGenerator() { - @Override - public Widget getDetails(int rowIndex) { - return null; - } - }; + public static final DetailsGenerator NULL = rowIndex -> null; /** * This method is called for whenever a new details row needs to be diff --git a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java index d5f3e24528..fe95399e7c 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListSorter.java @@ -133,45 +133,36 @@ public class ListSorter<T> { "Grid " + grid + " data source is not a ListDataSource!"); } - ((ListDataSource<T>) ds).sort(new Comparator<T>() { - - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public int compare(T a, T b) { - - for (SortOrder o : order) { - - Grid.Column column = o.getColumn(); - Comparator cmp = ListSorter.this.comparators.get(column); - int result = 0; - Object valueA = column.getValue(a); - Object valueB = column.getValue(b); - if (cmp != null) { - result = cmp.compare(valueA, valueB); - } else { - if (!(valueA instanceof Comparable)) { - throw new IllegalStateException("Column " + column - + " has no assigned comparator and value " - + valueA + " isn't naturally comparable"); - } - result = ((Comparable) valueA).compareTo(valueB); - } - - if (result != 0) { - return o.getDirection() == SortDirection.ASCENDING - ? result - : -result; + ((ListDataSource<T>) ds).sort((a, b) -> { + for (SortOrder o : order) { + Grid.Column column = o.getColumn(); + Comparator cmp = comparators.get(column); + int result = 0; + Object valueA = column.getValue(a); + Object valueB = column.getValue(b); + if (cmp != null) { + result = cmp.compare(valueA, valueB); + } else { + if (!(valueA instanceof Comparable)) { + throw new IllegalStateException("Column " + column + + " has no assigned comparator and value " + + valueA + " isn't naturally comparable"); } + result = ((Comparable) valueA).compareTo(valueB); } - if (!order.isEmpty()) { - return order.get(0) - .getDirection() == SortDirection.ASCENDING - ? a.hashCode() - b.hashCode() - : b.hashCode() - a.hashCode(); + if (result != 0) { + return o.getDirection() == SortDirection.ASCENDING ? result + : -result; } - return a.hashCode() - b.hashCode(); } + + if (!order.isEmpty()) { + return order.get(0).getDirection() == SortDirection.ASCENDING + ? a.hashCode() - b.hashCode() + : b.hashCode() - a.hashCode(); + } + return a.hashCode() - b.hashCode(); }); } } diff --git a/client/src/main/java/com/vaadin/client/widget/grid/selection/SpaceSelectHandler.java b/client/src/main/java/com/vaadin/client/widget/grid/selection/SpaceSelectHandler.java index b8a1ae4e5b..59c78b313d 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/selection/SpaceSelectHandler.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/selection/SpaceSelectHandler.java @@ -17,12 +17,8 @@ package com.vaadin.client.widget.grid.selection; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.shared.HandlerRegistration; -import com.vaadin.client.widget.grid.DataAvailableEvent; -import com.vaadin.client.widget.grid.DataAvailableHandler; import com.vaadin.client.widget.grid.events.BodyKeyDownHandler; -import com.vaadin.client.widget.grid.events.BodyKeyUpHandler; import com.vaadin.client.widget.grid.events.GridKeyDownEvent; -import com.vaadin.client.widget.grid.events.GridKeyUpEvent; import com.vaadin.client.widgets.Grid; import com.vaadin.shared.ui.grid.ScrollDestination; @@ -60,17 +56,12 @@ public class SpaceSelectHandler<T> { } scrollHandler = grid - .addDataAvailableHandler(new DataAvailableHandler() { - - @Override - public void onDataAvailable( - DataAvailableEvent dataAvailableEvent) { - if (dataAvailableEvent.getAvailableRows() - .contains(rowIndex)) { - setSelected(grid, rowIndex); - scrollHandler.removeHandler(); - scrollHandler = null; - } + .addDataAvailableHandler(dataAvailableEvent -> { + if (dataAvailableEvent.getAvailableRows() + .contains(rowIndex)) { + setSelected(grid, rowIndex); + scrollHandler.removeHandler(); + scrollHandler = null; } }); grid.scrollToRow(rowIndex, ScrollDestination.ANY); @@ -104,13 +95,9 @@ public class SpaceSelectHandler<T> { this.grid = grid; spaceDownHandler = grid .addBodyKeyDownHandler(new SpaceKeyDownHandler()); - spaceUpHandler = grid.addBodyKeyUpHandler(new BodyKeyUpHandler() { - - @Override - public void onKeyUp(GridKeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_SPACE) { - spaceDown = false; - } + spaceUpHandler = grid.addBodyKeyUpHandler(event -> { + if (event.getNativeKeyCode() == KeyCodes.KEY_SPACE) { + spaceDown = false; } }); } diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index f53ea4fdd8..f54cecad6d 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -5868,12 +5868,9 @@ public class Escalator extends Widget private void setupScrollbars(final Element root) { - ScrollHandler scrollHandler = new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - scroller.onScroll(); - fireEvent(new ScrollEvent()); - } + ScrollHandler scrollHandler = event -> { + scroller.onScroll(); + fireEvent(new ScrollEvent()); }; int scrollbarThickness = WidgetUtil.getNativeScrollbarSize(); diff --git a/client/src/main/java/com/vaadin/client/widgets/Overlay.java b/client/src/main/java/com/vaadin/client/widgets/Overlay.java index 1ec7456f93..965924c376 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Overlay.java +++ b/client/src/main/java/com/vaadin/client/widgets/Overlay.java @@ -238,12 +238,7 @@ public class Overlay extends PopupPanel { if (left < 0) { // Would move left of screen, shrink to fit in window setOuterWidthThroughWidget(windowRight - windowLeft); - runOnClose.add(new Command() { - @Override - public void execute() { - getWidget().setWidth(""); - } - }); + runOnClose.add(() -> getWidget().setWidth("")); left = 0; } } @@ -259,12 +254,7 @@ public class Overlay extends PopupPanel { if (top < 0) { // Would move above screen, shrink to fit in window setOuterHeightThroughWidget(windowBottom - windowTop); - runOnClose.add(new Command() { - @Override - public void execute() { - getWidget().setHeight(""); - } - }); + runOnClose.add(() -> getWidget().setHeight("")); top = 0; } } diff --git a/client/src/test/java/com/vaadin/client/ui/grid/ListDataSourceTest.java b/client/src/test/java/com/vaadin/client/ui/grid/ListDataSourceTest.java index 7d9bf530ce..93a5be4de0 100644 --- a/client/src/test/java/com/vaadin/client/ui/grid/ListDataSourceTest.java +++ b/client/src/test/java/com/vaadin/client/ui/grid/ListDataSourceTest.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; -import java.util.Comparator; import org.easymock.EasyMock; import org.junit.Test; @@ -178,12 +177,7 @@ public class ListDataSourceTest { // TODO Should be simplified to sort(). No point in providing these // trivial comparators. - ds.sort(new Comparator<Integer>() { - @Override - public int compare(Integer o1, Integer o2) { - return o1.compareTo(o2); - } - }); + ds.sort((o1, o2) -> o1.compareTo(o2)); assertTrue(Arrays.equals(ds.asList().toArray(), new Integer[] { 1, 2, 3, 3, 4 })); diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/SerializationTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/SerializationTest.java index b59d7a4aa7..d976e2c50c 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/SerializationTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/SerializationTest.java @@ -25,7 +25,6 @@ public class SerializationTest { } }); } - } @Test diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java index 8ee154a56e..24c55fce2b 100644 --- a/server/src/main/java/com/vaadin/ui/TreeGrid.java +++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java @@ -121,36 +121,27 @@ public class TreeGrid<T> extends Grid<T> HierarchicalDataCommunicator<T> dataCommunicator) { super(propertySet, dataCommunicator); - registerRpc(new NodeCollapseRpc() { - @Override - public void setNodeCollapsed(String rowKey, int rowIndex, - boolean collapse, boolean userOriginated) { - T item = getDataCommunicator().getKeyMapper().get(rowKey); - if (collapse && getDataCommunicator().isExpanded(item)) { - getDataCommunicator().doCollapse(item, - Optional.of(rowIndex)); - fireCollapseEvent( - getDataCommunicator().getKeyMapper().get(rowKey), - userOriginated); - } else if (!collapse - && !getDataCommunicator().isExpanded(item)) { - getDataCommunicator().doExpand(item, Optional.of(rowIndex)); - fireExpandEvent( - getDataCommunicator().getKeyMapper().get(rowKey), - userOriginated); - } + registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse, + userOriginated) -> { + T item = getDataCommunicator().getKeyMapper().get(rowKey); + if (collapse && getDataCommunicator().isExpanded(item)) { + getDataCommunicator().doCollapse(item, Optional.of(rowIndex)); + fireCollapseEvent( + getDataCommunicator().getKeyMapper().get(rowKey), + userOriginated); + } else if (!collapse && !getDataCommunicator().isExpanded(item)) { + getDataCommunicator().doExpand(item, Optional.of(rowIndex)); + fireExpandEvent( + getDataCommunicator().getKeyMapper().get(rowKey), + userOriginated); } }); - registerRpc(new FocusParentRpc() { - @Override - public void focusParent(String rowKey, int cellIndex) { - Integer parentIndex = getDataCommunicator().getParentIndex( - getDataCommunicator().getKeyMapper().get(rowKey)); - if (parentIndex != null) { - getRpcProxy(FocusRpc.class).focusCell(parentIndex, - cellIndex); - } + registerRpc((FocusParentRpc) (rowKey, cellIndex) -> { + Integer parentIndex = getDataCommunicator().getParentIndex( + getDataCommunicator().getKeyMapper().get(rowKey)); + if (parentIndex != null) { + getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex); } }); } diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java index 13adb68817..0fb1e8e3a3 100644 --- a/server/src/main/java/com/vaadin/ui/UI.java +++ b/server/src/main/java/com/vaadin/ui/UI.java @@ -260,18 +260,14 @@ public abstract class UI extends AbstractSingleComponentContainer } }; - private WindowOrderRpc windowOrderRpc = new WindowOrderRpc() { - - @Override - public void windowOrderChanged(Map<Integer, Connector> windowOrders) { - Map<Integer, Window> orders = new LinkedHashMap<>(); - for (Entry<Integer, Connector> entry : windowOrders.entrySet()) { - if (entry.getValue() instanceof Window) { - orders.put(entry.getKey(), (Window) entry.getValue()); - } + private WindowOrderRpc windowOrderRpc = windowOrders -> { + Map<Integer, Window> orders = new LinkedHashMap<>(); + for (Entry<Integer, Connector> entry : windowOrders.entrySet()) { + if (entry.getValue() instanceof Window) { + orders.put(entry.getKey(), (Window) entry.getValue()); } - fireWindowOrder(orders); } + fireWindowOrder(orders); }; /** @@ -518,18 +514,15 @@ public abstract class UI extends AbstractSingleComponentContainer // on. getPushConfiguration().setPushMode(PushMode.DISABLED); - new Thread(new Runnable() { - @Override - public void run() { - // This intentionally does disconnect without locking - // the VaadinSession to avoid deadlocks where the server - // uses a lock for the websocket connection - - // See https://dev.vaadin.com/ticket/18436 - // The underlying problem is - // https://dev.vaadin.com/ticket/16919 - setPushConnection(null); - } + new Thread(() -> { + // This intentionally does disconnect without locking + // the VaadinSession to avoid deadlocks where the server + // uses a lock for the websocket connection + + // See https://dev.vaadin.com/ticket/18436 + // The underlying problem is + // https://dev.vaadin.com/ticket/16919 + setPushConnection(null); }).start(); } this.session = session; diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java index bc92a755a4..c07d17d41f 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java @@ -30,20 +30,15 @@ import com.vaadin.ui.AbstractField; */ public class ColorPickerGradient extends AbstractField<Color> { - private ColorPickerGradientServerRpc rpc = new ColorPickerGradientServerRpc() { - - @Override - public void select(int cursorX, int cursorY) { - setValue(converter.calculate(cursorX, cursorY), true); - } - }; - /** The converter. */ private Coordinates2Color converter; /** The foreground color. */ private Color color; + private ColorPickerGradientServerRpc rpc = (cursorX, + cursorY) -> setValue(converter.calculate(cursorX, cursorY), true); + private ColorPickerGradient() { registerRpc(rpc); // width and height must be set here instead of in theme, otherwise diff --git a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java index 6ded996687..617fe6be63 100644 --- a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java +++ b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java @@ -30,8 +30,6 @@ import org.junit.Test; import org.mockito.Mockito; import com.vaadin.server.DefaultDeploymentConfiguration; -import com.vaadin.server.ErrorEvent; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.MockServletConfig; import com.vaadin.server.UIClassSelectionEvent; @@ -121,12 +119,7 @@ public class ServletUIInitHandlerTest { } }; - ui.setErrorHandler(new ErrorHandler() { - @Override - public void error(ErrorEvent event) { - errorHandlerCalls.incrementAndGet(); - } - }); + ui.setErrorHandler(event -> errorHandlerCalls.incrementAndGet()); CommunicationMock mock = new CommunicationMock(ui); VaadinRequest initRequest = mock.createInitRequest(); diff --git a/server/src/test/java/com/vaadin/ui/UITest.java b/server/src/test/java/com/vaadin/ui/UITest.java index 886dd38087..ff9062ea0a 100644 --- a/server/src/test/java/com/vaadin/ui/UITest.java +++ b/server/src/test/java/com/vaadin/ui/UITest.java @@ -87,41 +87,35 @@ public class UITest { final ConcurrentLinkedQueue<Exception> exceptions = new ConcurrentLinkedQueue<Exception>(); // Simulates the websocket close thread - Runnable websocketClose = new Runnable() { - @Override - public void run() { - externalLock.lock(); - // Wait for disconnect thread to lock VaadinSession - websocketReachedCheckpoint.countDown(); - try { - uiDisconnectReachedCheckpoint.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - exceptions.add(e); - return; - } - uiSession.lock(); - externalLock.unlock(); + Runnable websocketClose = () -> { + externalLock.lock(); + // Wait for disconnect thread to lock VaadinSession + websocketReachedCheckpoint.countDown(); + try { + uiDisconnectReachedCheckpoint.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + exceptions.add(e); + return; } + uiSession.lock(); + externalLock.unlock(); }; - Runnable disconnectPushFromUI = new Runnable() { - @Override - public void run() { - uiSession.lock(); - // Wait for websocket thread to lock external lock - uiDisconnectReachedCheckpoint.countDown(); - try { - websocketReachedCheckpoint.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - exceptions.add(e); - return; - } - - ui.setSession(null); - uiSession.unlock(); + Runnable disconnectPushFromUI = () -> { + uiSession.lock(); + // Wait for websocket thread to lock external lock + uiDisconnectReachedCheckpoint.countDown(); + try { + websocketReachedCheckpoint.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + exceptions.add(e); + return; } + + ui.setSession(null); + uiSession.unlock(); }; Thread websocketThread = new Thread(websocketClose); diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java index a7253b7229..79b84780ac 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridElement.java @@ -496,35 +496,29 @@ public class GridElement extends AbstractComponentElement { * @return an iterable of all the data rows in the grid. */ public Iterable<GridRowElement> getRows() { - return new Iterable<GridElement.GridRowElement>() { + return () -> new Iterator<GridElement.GridRowElement>() { + int nextIndex = 0; + + @Override + public GridRowElement next() { + return getRow(nextIndex++); + } + @Override - public Iterator<GridRowElement> iterator() { - return new Iterator<GridElement.GridRowElement>() { - int nextIndex = 0; - - @Override - public GridRowElement next() { - return getRow(nextIndex++); - } - - @Override - public boolean hasNext() { - try { - getRow(nextIndex); - return true; - } catch (Exception e) { - return false; - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException( - "remove not supported"); - } - - }; + public boolean hasNext() { + try { + getRow(nextIndex); + return true; + } catch (Exception e) { + return false; + } } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove not supported"); + } + }; } } diff --git a/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java index a5c2d87295..8139f7a94c 100644 --- a/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -47,7 +47,6 @@ import com.vaadin.server.LegacyApplication; import com.vaadin.server.LegacyVaadinServlet; import com.vaadin.server.ServiceException; import com.vaadin.server.SystemMessages; -import com.vaadin.server.SystemMessagesInfo; import com.vaadin.server.SystemMessagesProvider; import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UICreateEvent; @@ -452,22 +451,16 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { deploymentConfiguration); final SystemMessagesProvider provider = service .getSystemMessagesProvider(); - service.setSystemMessagesProvider(new SystemMessagesProvider() { - - @Override - public SystemMessages getSystemMessages( - SystemMessagesInfo systemMessagesInfo) { - if (systemMessagesInfo.getRequest() == null) { - return provider.getSystemMessages(systemMessagesInfo); - } - Object messages = systemMessagesInfo.getRequest() - .getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY); - if (messages instanceof SystemMessages) { - return (SystemMessages) messages; - } + service.setSystemMessagesProvider(systemMessagesInfo -> { + if (systemMessagesInfo.getRequest() == null) { return provider.getSystemMessages(systemMessagesInfo); } - + Object messages = systemMessagesInfo.getRequest() + .getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY); + if (messages instanceof SystemMessages) { + return (SystemMessages) messages; + } + return provider.getSystemMessages(systemMessagesInfo); }); return service; } diff --git a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java index 545ebf8a13..655d67c132 100644 --- a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -17,7 +17,6 @@ package com.vaadin.launcher; import java.io.File; -import java.io.FilenameFilter; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; @@ -257,12 +256,8 @@ public class DevelopmentServerLauncher { server.start(); }); scanner.setReportExistingFilesOnStartup(false); - scanner.setFilenameFilter(new FilenameFilter() { - @Override - public boolean accept(File folder, String name) { - return name.endsWith(".class"); - } - }); + scanner.setFilenameFilter( + (folder, name) -> name.endsWith(".class")); scanner.setScanDirs(classFolders); scanner.start(); diff --git a/uitest/src/main/java/com/vaadin/screenshotbrowser/ScreenshotBrowser.java b/uitest/src/main/java/com/vaadin/screenshotbrowser/ScreenshotBrowser.java index de5eb07077..12d153ae18 100644 --- a/uitest/src/main/java/com/vaadin/screenshotbrowser/ScreenshotBrowser.java +++ b/uitest/src/main/java/com/vaadin/screenshotbrowser/ScreenshotBrowser.java @@ -17,7 +17,6 @@ package com.vaadin.screenshotbrowser; import java.io.File; import java.io.FileInputStream; -import java.io.FilenameFilter; import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -357,12 +356,8 @@ public class ScreenshotBrowser extends UI { private void refreshTableContainer() { File errorsDir = new File(screenshotDir, "errors"); - File[] failures = errorsDir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(".html"); - } - }); + File[] failures = errorsDir + .listFiles((dir, name) -> name.endsWith(".html")); BeanItemContainer<ComparisonFailure> container = new BeanItemContainer<>( ComparisonFailure.class); diff --git a/uitest/src/main/java/com/vaadin/tests/CustomLayoutDemo.java b/uitest/src/main/java/com/vaadin/tests/CustomLayoutDemo.java index b9eaf16271..b88fd93059 100644 --- a/uitest/src/main/java/com/vaadin/tests/CustomLayoutDemo.java +++ b/uitest/src/main/java/com/vaadin/tests/CustomLayoutDemo.java @@ -18,7 +18,6 @@ package com.vaadin.tests; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component.Event; import com.vaadin.ui.Component.Listener; import com.vaadin.ui.CustomLayout; @@ -56,13 +55,7 @@ public class CustomLayoutDemo extends com.vaadin.server.LegacyApplication private final PasswordField loginPwd = new PasswordField("Password"); private final Button loginButton = new Button("Login", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - loginClicked(); - } - }); + event -> loginClicked()); private final Tree menu = new Tree(); diff --git a/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java b/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java index 3f86939378..1be2cd896b 100644 --- a/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java @@ -2,7 +2,6 @@ package com.vaadin.tests; import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.v7.ui.AbstractSelect; @@ -53,12 +52,7 @@ public class FocusingComponents extends CustomComponent { } Button focus = new Button("focus"); - focus.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - f.focus(); - } - }); + focus.addClickListener(event -> f.focus()); lo.addComponent(focus); } diff --git a/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java index db23287d88..86e68ad590 100644 --- a/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java +++ b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java @@ -58,10 +58,7 @@ public class ListenerOrder extends com.vaadin.server.LegacyApplication b1.addClickListener(mutualListener); b1.removeClickListener(b1Listener); // remove non-existing listener - b1.removeClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - } + b1.removeClickListener(event -> { }); // diff --git a/uitest/src/main/java/com/vaadin/tests/NativeWindowing.java b/uitest/src/main/java/com/vaadin/tests/NativeWindowing.java index 615fe7f489..cfbbde98cf 100644 --- a/uitest/src/main/java/com/vaadin/tests/NativeWindowing.java +++ b/uitest/src/main/java/com/vaadin/tests/NativeWindowing.java @@ -38,75 +38,60 @@ public class NativeWindowing extends LegacyApplication { setMainWindow(main); main.addComponent( - new Button("Add new subwindow", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - final Window w = new Window( - "sw " + System.currentTimeMillis(), layout); - main.addWindow(w); - w.setPositionX(100); - w.setPositionY(100); - w.setWidth("200px"); - w.setHeight("200px"); - - w.setWidth("100px"); - w.setHeight("400px"); - - final Button closebutton = new Button( - "Close " + w.getCaption(), - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - main.removeWindow(w); - } - - }); - layout.addComponent(closebutton); - - layout.addComponent(new Label( - "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>", - ContentMode.HTML)); - - } + new Button("Add new subwindow", event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + final Window w = new Window( + "sw " + System.currentTimeMillis(), layout); + main.addWindow(w); + w.setPositionX(100); + w.setPositionY(100); + w.setWidth("200px"); + w.setHeight("200px"); + + w.setWidth("100px"); + w.setHeight("400px"); + + final Button closebutton = new Button( + "Close " + w.getCaption(), + clickEvent -> main.removeWindow(w)); + layout.addComponent(closebutton); + + layout.addComponent(new Label( + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>", + ContentMode.HTML)); })); main.addComponent(new Button( "Open a currently uncreated application level window", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - main.open(new com.vaadin.server.ExternalResource( - new URL(getURL(), - "mainwin-" - + System.currentTimeMillis() - + "/")), - null); - } catch (final MalformedURLException e) { - } + event -> { + try { + main.open(new com.vaadin.server.ExternalResource( + new URL(getURL(), "mainwin-" + + System.currentTimeMillis() + "/")), + null); + } catch (final MalformedURLException e) { } })); diff --git a/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java b/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java index 40353ad83c..f9bc3867bf 100644 --- a/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java @@ -21,7 +21,6 @@ import java.util.List; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -72,37 +71,31 @@ public class OrderedLayoutSwapComponents extends CustomComponent { ol.setId(name.replaceAll(" ", "")); ol.addComponent(new Label(name)); up = new Button("up"); - up.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - int newIndex = order.indexOf(MyComponent.this) - 1; - MyComponent old = order.get(newIndex); - main.replaceComponent(old, MyComponent.this); - order.remove(MyComponent.this); - order.add(newIndex, MyComponent.this); - if (newIndex == 0) { - MyComponent.this.setMode(FIRST); - } else { - MyComponent.this.setMode(69); - } + up.addClickListener(event -> { + int newIndex = order.indexOf(this) - 1; + MyComponent old = order.get(newIndex); + main.replaceComponent(old, this); + order.remove(this); + order.add(newIndex, this); + if (newIndex == 0) { + setMode(FIRST); + } else { + setMode(69); } }); ol.addComponent(up); down = new Button("down"); - down.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - int newIndex = order.indexOf(MyComponent.this) + 1; - MyComponent old = order.get(newIndex); - main.replaceComponent(old, MyComponent.this); - order.remove(MyComponent.this); - order.add(newIndex, MyComponent.this); - if (newIndex == order.size() - 1) { - MyComponent.this.setMode(LAST); - } else { - MyComponent.this.setMode(69); - } + down.addClickListener(event -> { + int newIndex = order.indexOf(MyComponent.this) + 1; + MyComponent old = order.get(newIndex); + main.replaceComponent(old, MyComponent.this); + order.remove(MyComponent.this); + order.add(newIndex, MyComponent.this); + if (newIndex == order.size() - 1) { + MyComponent.this.setMode(LAST); + } else { + MyComponent.this.setMode(69); } }); ol.addComponent(down); diff --git a/uitest/src/main/java/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java b/uitest/src/main/java/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java index 55987c1d4b..ef93520900 100644 --- a/uitest/src/main/java/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java +++ b/uitest/src/main/java/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java @@ -21,8 +21,6 @@ import java.util.Date; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -30,7 +28,7 @@ import com.vaadin.ui.VerticalLayout; public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { private final AbstractOrderedLayout main; - private final AbstractOrderedLayout testContainer; + private final AbstractOrderedLayout testContainer = new VerticalLayout(); private Date startTime; @@ -49,24 +47,11 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { main.addComponent(result); main.addComponent( - new Button("click when rendered", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - endTest(); - } - })); + new Button("click when rendered", event -> endTest())); main.addComponent( new Button("Click for layout repaint (cached components)", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - testContainer.markAsDirty(); - } - })); - - testContainer = new VerticalLayout(); + event -> testContainer.markAsDirty())); for (int i = 0; i < INITIAL_COMPONENTS; i++) { Label l = new Label("foo" + i); diff --git a/uitest/src/main/java/com/vaadin/tests/PerformanceTestSubTreeCaching.java b/uitest/src/main/java/com/vaadin/tests/PerformanceTestSubTreeCaching.java index a959ae2750..67480a3417 100644 --- a/uitest/src/main/java/com/vaadin/tests/PerformanceTestSubTreeCaching.java +++ b/uitest/src/main/java/com/vaadin/tests/PerformanceTestSubTreeCaching.java @@ -20,7 +20,6 @@ import java.util.Date; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -50,21 +49,11 @@ public class PerformanceTestSubTreeCaching extends CustomComponent { setCompositionRoot(main); addInfo(); - Button b = new Button("start test", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - startTest(); - } - }); + Button b = new Button("start test", event -> startTest()); b.setDescription( "Push this button to start test. A test label will be rendered above existing components."); main.addComponent(b); - b = new Button("end test", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - endTest(); - } - }); + b = new Button("end test", event -> endTest()); b.setDescription( "Push this button as soon as test componenet is rendered."); main.addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/ScrollbarStressTest.java b/uitest/src/main/java/com/vaadin/tests/ScrollbarStressTest.java index 9b0d493efb..fe8c33ba9a 100644 --- a/uitest/src/main/java/com/vaadin/tests/ScrollbarStressTest.java +++ b/uitest/src/main/java/com/vaadin/tests/ScrollbarStressTest.java @@ -3,8 +3,6 @@ package com.vaadin.tests; import com.vaadin.server.LegacyApplication; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -72,26 +70,23 @@ public class ScrollbarStressTest extends LegacyApplication { height.addItem("500px"); height.setValue("100%"); - final Button set = new Button("Set", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getTable = testComponent.getValue().equals("Table"); - - if (context.getValue() == "Main window") { - drawInMainWindow(); - } else if (context.getValue() == "Subwindow") { - drawInSubwindow(); - } else if (context.getValue() == "Panel") { - drawInPanel(); - } else if (context.getValue() == "Split Panel") { - drawInSplitPanel(); - } else if (context.getValue() == "TabSheet") { - drawInTabSheet(false); - } else if (context.getValue() == "Accordion") { - drawInTabSheet(true); - } else if (context.getValue() == "ExpandLayout") { - drawInExpandLayout(); - } + final Button set = new Button("Set", event -> { + getTable = testComponent.getValue().equals("Table"); + + if (context.getValue() == "Main window") { + drawInMainWindow(); + } else if (context.getValue() == "Subwindow") { + drawInSubwindow(); + } else if (context.getValue() == "Panel") { + drawInPanel(); + } else if (context.getValue() == "Split Panel") { + drawInSplitPanel(); + } else if (context.getValue() == "TabSheet") { + drawInTabSheet(false); + } else if (context.getValue() == "Accordion") { + drawInTabSheet(true); + } else if (context.getValue() == "ExpandLayout") { + drawInExpandLayout(); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/StressComponentsInTable.java b/uitest/src/main/java/com/vaadin/tests/StressComponentsInTable.java index 229b3352c9..bfebfc6752 100644 --- a/uitest/src/main/java/com/vaadin/tests/StressComponentsInTable.java +++ b/uitest/src/main/java/com/vaadin/tests/StressComponentsInTable.java @@ -20,7 +20,6 @@ import java.util.Date; import java.util.Vector; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -47,16 +46,10 @@ public class StressComponentsInTable extends CustomComponent { for (int j = 0; j < cols; j++) { content.add(rndString()); } - content.add(new Button("b" + i, new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Button b = event.getButton(); - System.out - .println(b.getCaption() + " click: " + new Date()); - System.out.println(b.getUI().getSession()); - - } + content.add(new Button("b" + i, event -> { + Button b = event.getButton(); + System.out.println(b.getCaption() + " click: " + new Date()); + System.out.println(b.getUI().getSession()); })); t.addItem(content.toArray(), "" + i); } diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java index 208f583dc3..80dafb8151 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestBench.java +++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java @@ -27,8 +27,6 @@ import java.util.Set; import com.vaadin.server.ExternalResource; import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Page; -import com.vaadin.server.Page.UriFragmentChangedEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalSplitPanel; @@ -129,71 +127,65 @@ public class TestBench extends com.vaadin.server.LegacyApplication lo.addComponent(menu); mainWindow.getPage().addUriFragmentChangedListener( - new Page.UriFragmentChangedListener() { - @Override - public void uriFragmentChanged( - UriFragmentChangedEvent source) { - String fragment = source.getUriFragment(); - if (fragment != null && !fragment.isEmpty()) { - // try to find a proper test class - - // exact match - for (Object next : menu.getItemIds()) { - if (next instanceof Class) { - Class<?> c = (Class<?>) next; - String string = c.getName(); - if (string.equals(fragment)) { - menu.setValue(c); - mainLayout.setSplitPosition(0); - return; - } + event -> { + String fragment = event.getUriFragment(); + if (fragment != null && !fragment.isEmpty()) { + // try to find a proper test class + + // exact match + for (Object next : menu.getItemIds()) { + if (next instanceof Class) { + Class<?> c = (Class<?>) next; + String string = c.getName(); + if (string.equals(fragment)) { + menu.setValue(c); + mainLayout.setSplitPosition(0); + return; } } + } - // simple name match - for (Object next : menu.getItemIds()) { - if (next instanceof Class) { - Class<?> c = (Class<?>) next; - String string = c.getSimpleName(); - if (string.equals(fragment)) { - menu.setValue(c); - mainLayout.setSplitPosition(0); - return; - } + // simple name match + for (Object next : menu.getItemIds()) { + if (next instanceof Class) { + Class<?> c = (Class<?>) next; + String string = c.getSimpleName(); + if (string.equals(fragment)) { + menu.setValue(c); + mainLayout.setSplitPosition(0); + return; } } - // ticket match - for (Object next : menu.getItemIds()) { - if (next instanceof Class) { - Class<?> c = (Class<?>) next; - String string = c.getSimpleName(); - if (string - .startsWith("Ticket" + fragment)) { - menu.setValue(c); - mainLayout.setSplitPosition(0); - return; - } + } + // ticket match + for (Object next : menu.getItemIds()) { + if (next instanceof Class) { + Class<?> c = (Class<?>) next; + String string = c.getSimpleName(); + if (string.startsWith("Ticket" + fragment)) { + menu.setValue(c); + mainLayout.setSplitPosition(0); + return; } } + } - // just partly match lowercase - for (Object next : menu.getItemIds()) { - if (next instanceof Class) { - Class<?> c = (Class<?>) next; - String string = c.getSimpleName(); - if (string.toLowerCase(Locale.ROOT) - .contains(fragment.toLowerCase( - Locale.ROOT))) { - menu.setValue(c); - mainLayout.setSplitPosition(0); - return; - } + // just partly match lowercase + for (Object next : menu.getItemIds()) { + if (next instanceof Class) { + Class<?> c = (Class<?>) next; + String string = c.getSimpleName(); + if (string.toLowerCase(Locale.ROOT).contains( + fragment.toLowerCase(Locale.ROOT))) { + menu.setValue(c); + mainLayout.setSplitPosition(0); + return; } } - - getMainWindow().showNotification( - "No potential matc for #" + fragment); } + + getMainWindow().showNotification( + "No potential matc for #" + fragment); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/TestComponentAddAndRecursion.java b/uitest/src/main/java/com/vaadin/tests/TestComponentAddAndRecursion.java index 7f9efc23a6..a5267378ef 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestComponentAddAndRecursion.java +++ b/uitest/src/main/java/com/vaadin/tests/TestComponentAddAndRecursion.java @@ -5,7 +5,6 @@ package com.vaadin.tests; import com.vaadin.server.Page; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -50,94 +49,55 @@ public class TestComponentAddAndRecursion extends CustomComponent { p3 = new Panel("p3", p3l); p2l.addComponent(p3); - Button b = new Button("use gridlayout", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - p.setContent(new GridLayout()); - p2.setContent(new GridLayout()); - p3.setContent(new GridLayout()); - } - + Button b = new Button("use gridlayout", event -> { + p.setContent(new GridLayout()); + p2.setContent(new GridLayout()); + p3.setContent(new GridLayout()); }); main.addComponent(b); - b = new Button("use orderedlayout", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - p.setContent(new VerticalLayout()); - p2.setContent(new VerticalLayout()); - p3.setContent(new VerticalLayout()); - } - + b = new Button("use orderedlayout", event -> { + p.setContent(new VerticalLayout()); + p2.setContent(new VerticalLayout()); + p3.setContent(new VerticalLayout()); }); main.addComponent(b); - b = new Button("move B", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - p2l.addComponent(l2); - } - - }); + b = new Button("move B", event -> p2l.addComponent(l2)); main.addComponent(b); - b = new Button("move p", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - p3l.addComponent(p); - } - - }); + b = new Button("move p", event -> p3l.addComponent(p)); main.addComponent(b); - b = new Button("add to both", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Label l = new Label("both"); - pl.addComponent(l); - p2l.addComponent(l); - } - + b = new Button("add to both", event -> { + Label l = new Label("both"); + pl.addComponent(l); + p2l.addComponent(l); }); main.addComponent(b); - b = new Button("recurse", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - try { - p3l.addComponent(p2); - new Notification("ERROR", "This should have failed", - Notification.TYPE_ERROR_MESSAGE) - .show(Page.getCurrent()); - } catch (Exception e) { - new Notification("OK", "threw, as expected", - Notification.TYPE_ERROR_MESSAGE) - .show(Page.getCurrent()); - } + b = new Button("recurse", event -> { + try { + p3l.addComponent(p2); + new Notification("ERROR", "This should have failed", + Notification.TYPE_ERROR_MESSAGE) + .show(Page.getCurrent()); + } catch (Exception e) { + new Notification("OK", "threw, as expected", + Notification.TYPE_ERROR_MESSAGE) + .show(Page.getCurrent()); } - }); main.addComponent(b); - b = new Button("recurse2", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - Panel p = new Panel("dynamic", layout); - layout.addComponent(p2); - try { - p3l.addComponent(p); - new Notification("ERROR", "This should have failed", - Notification.TYPE_ERROR_MESSAGE) - .show(Page.getCurrent()); - } catch (Exception e) { - new Notification("OK", "threw, as expected", - Notification.TYPE_ERROR_MESSAGE) - .show(Page.getCurrent()); - } + b = new Button("recurse2", event -> { + VerticalLayout layout = new VerticalLayout(); + Panel p = new Panel("dynamic", layout); + layout.addComponent(p2); + try { + p3l.addComponent(p); + new Notification("ERROR", "This should have failed", + Notification.TYPE_ERROR_MESSAGE) + .show(Page.getCurrent()); + } catch (Exception e) { + new Notification("OK", "threw, as expected", + Notification.TYPE_ERROR_MESSAGE) + .show(Page.getCurrent()); } - }); main.addComponent(b); /* diff --git a/uitest/src/main/java/com/vaadin/tests/TestContainerChanges.java b/uitest/src/main/java/com/vaadin/tests/TestContainerChanges.java index 9280c48d19..8b40d787d6 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestContainerChanges.java +++ b/uitest/src/main/java/com/vaadin/tests/TestContainerChanges.java @@ -4,14 +4,12 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Container; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.ContainerHierarchicalWrapper; import com.vaadin.v7.data.util.ContainerOrderedWrapper; import com.vaadin.v7.data.util.IndexedContainer; @@ -69,14 +67,8 @@ public class TestContainerChanges extends CustomComponent { tbl2.setSelectable(true); tbl2.setMultiSelect(false); tbl2.setImmediate(true); - tbl2.addListener(new Table.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - System.err - .println("Value now " + event.getProperty().getValue()); - - } - }); + tbl2.addValueChangeListener(event -> System.err + .println("Value now " + event.getProperty().getValue())); tbl2.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); // non-ordered container will get wrapped tbl2.setContainerDataSource(hierarchical); @@ -84,97 +76,35 @@ public class TestContainerChanges extends CustomComponent { VerticalLayout buttons = new VerticalLayout(); v.addComponent(buttons); - Button b = new Button("table.commit()", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tbl.commit(); - } - - }); + Button b = new Button("table.commit()", event -> tbl.commit()); buttons.addComponent(b); b = new Button("indexedcontainer.addItem()", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cont.addItem(new Integer(cnt++)); - } - - }); + event -> cont.addItem(new Integer(cnt++))); buttons.addComponent(b); b = new Button("indexedcontainer.addItem(null)", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cont.addItem(null); - } - - }); + event -> cont.addItem(null)); buttons.addComponent(b); b = new Button("indexedcontainer.removeItem(table.lastItemId()", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cont.removeItem(tbl.lastItemId()); - } - - }); + event -> cont.removeItem(tbl.lastItemId())); buttons.addComponent(b); b = new Button("indexedcontainer.addContainerProperty()", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cont.addContainerProperty("prop" + cnt, String.class, - "#" + cnt++); - } - - }); + event -> cont.addContainerProperty("prop" + cnt, String.class, + "#" + cnt++)); buttons.addComponent(b); - b = new Button("indexedcontainer.clear()", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cont.removeAllItems(); - } - - }); + b = new Button("indexedcontainer.clear()", + event -> cont.removeAllItems()); buttons.addComponent(b); b = new Button("table.setContainerDataSource(indexedcontainer)", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tbl.setContainerDataSource(cont); - } - - }); + event -> tbl.setContainerDataSource(cont)); buttons.addComponent(b); b = new Button("table.setContainerDataSource(orderedwrapper)", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tbl.setContainerDataSource(ordered); - } - - }); + event -> tbl.setContainerDataSource(ordered)); buttons.addComponent(b); b = new Button("table.setContainerDataSource(hierarchicalwrapper)", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tbl.setContainerDataSource(hierarchical); - } - - }); + event -> tbl.setContainerDataSource(hierarchical)); buttons.addComponent(b); VerticalLayout pl = createPanelLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java b/uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java index 9463d3820d..dd4c48b0e4 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java @@ -24,8 +24,6 @@ import com.vaadin.shared.ui.datefield.DateResolution; import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; @@ -39,27 +37,14 @@ public class TestForBasicApplicationLayout extends CustomComponent { private final Button click; private final Button click2; - private final TabSheet tab; + private final TabSheet tab = new TabSheet(); public TestForBasicApplicationLayout() { - click = new Button("Set height -1", new ClickListener() { + click = new Button("Set height -1", event -> tab.setHeight(null)); - @Override - public void buttonClick(ClickEvent event) { - tab.setHeight(null); - } - - }); - - click2 = new Button("Set height 100%", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tab.setHeight(100, TabSheet.UNITS_PERCENTAGE); - } - - }); + click2 = new Button("Set height 100%", + event -> tab.setHeight(100, TabSheet.UNITS_PERCENTAGE)); final HorizontalSplitPanel sp = new HorizontalSplitPanel(); sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); @@ -72,7 +57,6 @@ public class TestForBasicApplicationLayout extends CustomComponent { final Panel p = new Panel("Accordion Panel", pl); p.setSizeFull(); - tab = new TabSheet(); tab.setSizeFull(); VerticalLayout reportLayout = new VerticalLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForChildComponentRendering.java b/uitest/src/main/java/com/vaadin/tests/TestForChildComponentRendering.java index 8c5bc83561..04cac1419f 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForChildComponentRendering.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForChildComponentRendering.java @@ -22,7 +22,6 @@ import java.util.List; import com.vaadin.server.ExternalResource; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; @@ -65,31 +64,15 @@ public class TestForChildComponentRendering extends CustomComponent { se.addItem("valinta1"); se.addItem("Valinta 2"); - Button b = new Button("refresh view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createNewView(); - } - }); + Button b = new Button("refresh view", event -> createNewView()); main.addComponent(b); - b = new Button("reorder view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - randomReorder(); - } - }); + b = new Button("reorder view", event -> randomReorder()); main.addComponent(b); b = new Button("remove randomly one component", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - removeRandomComponent(); - } - }); + event -> removeRandomComponent()); main.addComponent(b); - } public void randomReorder() { diff --git a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java index f5a8f1a72f..52762397cd 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java @@ -17,7 +17,6 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -72,30 +71,21 @@ public class TestForContainerFilterable extends CustomComponent { t.setContainerDataSource(ic); // Handler - filterButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ic.removeAllContainerFilters(); - if (!fooFilter.getValue().isEmpty()) { - ic.addContainerFilter("foo", fooFilter.getValue(), false, - false); - } - if (!barFilter.getValue().isEmpty()) { - ic.addContainerFilter("bar", barFilter.getValue(), true, - true); - } - count.setValue("Rows in table: " + ic.size()); + filterButton.addClickListener(event -> { + ic.removeAllContainerFilters(); + if (!fooFilter.getValue().isEmpty()) { + ic.addContainerFilter("foo", fooFilter.getValue(), false, + false); } + if (!barFilter.getValue().isEmpty()) { + ic.addContainerFilter("bar", barFilter.getValue(), true, true); + } + count.setValue("Rows in table: " + ic.size()); }); // Resetbutton lo.addComponent(new Button("Rebind table datasource", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - t.setContainerDataSource(ic); - } - })); + event -> t.setContainerDataSource(ic))); } private String randomWord() { diff --git a/uitest/src/main/java/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java b/uitest/src/main/java/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java index 8c2d83da30..5991bbca3b 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java @@ -22,7 +22,6 @@ import java.util.List; import com.vaadin.server.ExternalResource; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; @@ -66,31 +65,15 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { main.addComponent(se, 0, 1, 1, 1); - Button b = new Button("refresh view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createNewView(); - } - }); + Button b = new Button("refresh view", event -> createNewView()); main.addComponent(b); - b = new Button("reorder view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - randomReorder(); - } - }); + b = new Button("reorder view", event -> randomReorder()); main.addComponent(b); b = new Button("remove randomly one component", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - removeRandomComponent(); - } - }); + event -> removeRandomComponent()); main.addComponent(b); - } public void randomReorder() { diff --git a/uitest/src/main/java/com/vaadin/tests/TestForNativeWindowing.java b/uitest/src/main/java/com/vaadin/tests/TestForNativeWindowing.java index 77db536053..94407d6387 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForNativeWindowing.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForNativeWindowing.java @@ -38,75 +38,60 @@ public class TestForNativeWindowing extends LegacyApplication { setMainWindow(main); main.addComponent( - new Button("Add new subwindow", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - final Window w = new Window( - "sw " + System.currentTimeMillis(), layout); - main.addWindow(w); - w.setPositionX(100); - w.setPositionY(100); - w.setWidth("200px"); - w.setHeight("200px"); - - w.setWidth("100px"); - w.setHeight("400px"); - - final Button closebutton = new Button( - "Close " + w.getCaption(), - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - main.removeWindow(w); - } - - }); - layout.addComponent(closebutton); - - layout.addComponent(new Label( - "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>" - + "<p>Lorem ipsum dolor sit amet.</p>", - ContentMode.HTML)); - - } + new Button("Add new subwindow", event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + final Window w = new Window( + "sw " + System.currentTimeMillis(), layout); + main.addWindow(w); + w.setPositionX(100); + w.setPositionY(100); + w.setWidth("200px"); + w.setHeight("200px"); + + w.setWidth("100px"); + w.setHeight("400px"); + + final Button closebutton = new Button( + "Close " + w.getCaption(), + clickEvent -> main.removeWindow(w)); + layout.addComponent(closebutton); + + layout.addComponent(new Label( + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>" + + "<p>Lorem ipsum dolor sit amet.</p>", + ContentMode.HTML)); })); main.addComponent(new Button( "Open a currently uncreated application level window", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - main.open(new com.vaadin.server.ExternalResource( - new URL(getURL(), - "mainwin-" - + System.currentTimeMillis() - + "/")), - null); - } catch (final MalformedURLException e) { - } + event -> { + try { + main.open(new com.vaadin.server.ExternalResource( + new URL(getURL(), "mainwin-" + + System.currentTimeMillis() + "/")), + null); + } catch (final MalformedURLException e) { } })); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForPreconfiguredComponents.java b/uitest/src/main/java/com/vaadin/tests/TestForPreconfiguredComponents.java index b8d498ef7c..d5387b8fc9 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForPreconfiguredComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForPreconfiguredComponents.java @@ -17,8 +17,6 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; @@ -93,14 +91,8 @@ public class TestForPreconfiguredComponents extends CustomComponent { "OptionGroup + multiselect manually (configured from select)"); main.addComponent(test); - final Button b = new Button("refresh view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createNewView(); - } - }); + final Button b = new Button("refresh view", event -> createNewView()); main.addComponent(b); - } public static void fillSelect(AbstractSelect s, int items) { @@ -150,12 +142,9 @@ public class TestForPreconfiguredComponents extends CustomComponent { final VerticalLayout statusLayout = new VerticalLayout(); final Panel status = new Panel("Events", statusLayout); final Button clear = new Button("clear event log"); - clear.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - statusLayout.removeAllComponents(); - statusLayout.addComponent(ol2); - } + clear.addClickListener(event -> { + statusLayout.removeAllComponents(); + statusLayout.addComponent(ol2); }); ol2.addComponent(clear); final Button commit = new Button("commit changes"); @@ -167,15 +156,11 @@ public class TestForPreconfiguredComponents extends CustomComponent { ol.addComponent(status); - t.addListener(new Listener() { - @Override - public void componentEvent(Event event) { - statusLayout - .addComponent(new Label(event.getClass().getName())); - // TODO should not use LegacyField.toString() - statusLayout.addComponent( - new Label("selected: " + event.getSource().toString())); - } + t.addListener(event -> { + statusLayout.addComponent(new Label(event.getClass().getName())); + // TODO should not use LegacyField.toString() + statusLayout.addComponent( + new Label("selected: " + event.getSource().toString())); }); return new Panel(ol); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java index 6894eec2e3..bcdfa8781d 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java @@ -30,7 +30,6 @@ import com.vaadin.server.LegacyApplication; import com.vaadin.server.StreamResource; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.LegacyWindow; @@ -80,35 +79,20 @@ public class TestForStyledUpload extends LegacyApplication up.addSucceededListener(this); up.addStartedListener(this); - up.addProgressListener(new Upload.ProgressListener() { + up.addProgressListener((readBytes, contentLenght) -> { + pi.setValue(new Float(readBytes / (float) contentLenght)); - @Override - public void updateProgress(long readBytes, long contentLenght) { - pi.setValue(new Float(readBytes / (float) contentLenght)); - - refreshMemUsage(); - - transferred.setValue( - "Transferred " + readBytes + " of " + contentLenght); - } + refreshMemUsage(); + transferred.setValue( + "Transferred " + readBytes + " of " + contentLenght); }); final Button b = new Button("Update status", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - readState(); - } - }); + event -> readState()); final Button c = new Button("Update status with gc", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - gc(); - } - }); + evenet -> gc()); main.addComponent(up); l = new Label("Idle"); @@ -127,27 +111,15 @@ public class TestForStyledUpload extends LegacyApplication main.addComponent(status); Button cancel = new Button("Cancel current upload"); - cancel.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - buffer.cancel(); - } - }); + cancel.addClickListener(event -> buffer.cancel()); main.addComponent(cancel); final Button restart = new Button("Restart demo application"); - restart.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - TestForStyledUpload.this.close(); - } - }); + restart.addClickListener(event -> TestForStyledUpload.this.close()); main.addComponent(restart); main.addComponent(b); main.addComponent(c); - } public void gc() { diff --git a/uitest/src/main/java/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java b/uitest/src/main/java/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java index bec14f12ef..68c4f8e002 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java @@ -21,7 +21,6 @@ import java.util.Vector; import com.vaadin.server.UserError; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; @@ -117,14 +116,8 @@ public class TestForTablesInitialColumnWidthLogicRendering t.setWidth("200px"); main.addComponent(t); - final Button b = new Button("refresh view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createNewView(); - } - }); + final Button b = new Button("refresh view", event -> createNewView()); main.addComponent(b); - } public static Table getTestTable(int cols, int rows) { @@ -139,14 +132,8 @@ public class TestForTablesInitialColumnWidthLogicRendering for (int j = 0; j < cols; j++) { content.add(rndString()); } - Button button = new Button("b", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - System.out.println("b click"); - - } - }); + Button button = new Button("b", + event -> System.out.println("b click")); button.setDescription("Yep yep"); button.setComponentError(new UserError("Error")); content.add(button); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForTrees.java b/uitest/src/main/java/com/vaadin/tests/TestForTrees.java index c5e8376c0f..338b35912d 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForTrees.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForTrees.java @@ -20,8 +20,6 @@ import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; @@ -100,14 +98,8 @@ public class TestForTrees extends CustomComponent implements Handler { main.addComponent(ol); contextTree = t; - final Button b = new Button("refresh view", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createNewView(); - } - }); + final Button b = new Button("refresh view", event -> createNewView()); main.addComponent(b); - } public Tree createTestTree() { @@ -148,12 +140,9 @@ public class TestForTrees extends CustomComponent implements Handler { statusLayout.setMargin(true); final Panel status = new Panel("Events", statusLayout); final Button clear = new Button("c"); - clear.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - statusLayout.removeAllComponents(); - statusLayout.addComponent(clear); - } + clear.addClickListener(event -> { + statusLayout.removeAllComponents(); + statusLayout.addComponent(clear); }); statusLayout.addComponent(clear); @@ -162,15 +151,11 @@ public class TestForTrees extends CustomComponent implements Handler { ol.addComponent(status); - t.addListener(new Listener() { - @Override - public void componentEvent(Event event) { - statusLayout - .addComponent(new Label(event.getClass().getName())); - // TODO should not use LegacyField.toString() - statusLayout.addComponent( - new Label("selected: " + event.getSource().toString())); - } + t.addListener((Listener) event -> { + statusLayout.addComponent(new Label(event.getClass().getName())); + // TODO should not use LegacyField.toString() + statusLayout.addComponent( + new Label("selected: " + event.getSource().toString())); }); return ol; diff --git a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java index 31dff4e350..8d226a057c 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java @@ -31,7 +31,6 @@ import java.lang.management.MemoryMXBean; import com.vaadin.server.StreamResource; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; @@ -40,12 +39,7 @@ import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FinishedEvent; -import com.vaadin.ui.Upload.StartedEvent; -import com.vaadin.ui.Upload.StartedListener; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.ui.AbstractField; import com.vaadin.v7.ui.ProgressIndicator; import com.vaadin.v7.ui.Select; import com.vaadin.v7.ui.TextField; @@ -106,130 +100,88 @@ public class TestForUpload extends CustomComponent up = new Upload("Upload", buffer); up.setImmediateMode(true); - up.addListener(new Listener() { - private static final long serialVersionUID = -8319074730512324303L; - - @Override - public void componentEvent(Event event) { - // print out all events fired by upload for debug purposes - System.out.println("Upload fired event | " + event); - } - }); - - up.addStartedListener(new StartedListener() { - private static final long serialVersionUID = 5508883803861085154L; - - @Override - public void uploadStarted(StartedEvent event) { - pi.setVisible(true); - pi2.setVisible(true); - l.setValue("Started uploading file " + event.getFilename()); - textFieldValue - .setValue(" TestFields value at the upload start is:" - + textField.getValue()); - } - }); - - up.addFinishedListener(new Upload.FinishedListener() { - private static final long serialVersionUID = -3773034195991947371L; - - @Override - public void uploadFinished(FinishedEvent event) { - pi.setVisible(false); - pi2.setVisible(false); - if (event instanceof Upload.FailedEvent) { - Exception reason = ((Upload.FailedEvent) event).getReason(); - l.setValue( - "Finished with failure ( " + reason + " ), idle"); - } else if (event instanceof Upload.SucceededEvent) { - l.setValue("Finished with succes, idle"); - } else { - l.setValue("Finished with unknow event"); - } - - statusLayout.removeAllComponents(); - final InputStream stream = buffer.getStream(); - if (stream == null) { - statusLayout.addComponent(new Label( - "Upload finished, but output buffer is null")); - } else { - statusLayout.addComponent( - new Label("<b>Name:</b> " + event.getFilename(), - ContentMode.HTML)); - statusLayout.addComponent( - new Label("<b>Mimetype:</b> " + event.getMIMEType(), - ContentMode.HTML)); - statusLayout.addComponent(new Label( - "<b>Size:</b> " + event.getLength() + " bytes.", - ContentMode.HTML)); - - statusLayout.addComponent(new Link( - "Download " + buffer.getFileName(), - new StreamResource(buffer, buffer.getFileName()))); - - statusLayout.setVisible(true); - } - - setBuffer(); - } - }); - - up.addProgressListener(new Upload.ProgressListener() { - - @Override - public void updateProgress(long readBytes, long contentLenght) { - pi2.setValue(new Float(readBytes / (float) contentLenght)); - - refreshMemUsage(); - } - - }); final Button b = new Button("Reed state from upload", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - readState(); - } - }); + event -> readState()); - final Button c = new Button("Force GC", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - gc(); - } - }); + final Button c = new Button("Force GC", event -> gc()); main.addComponent(b); main.addComponent(c); main.addComponent(beSluggish); main.addComponent(throwExecption); main.addComponent(interrupt); - interrupt.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - up.interruptUpload(); - } - }); + interrupt.addClickListener(event -> up.interruptUpload()); uploadBufferSelector = new Select("StreamVariable type"); uploadBufferSelector.setImmediate(true); uploadBufferSelector.addItem("memory"); uploadBufferSelector.setValue("memory"); uploadBufferSelector.addItem("tempfile"); - uploadBufferSelector - .addListener(new AbstractField.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - setBuffer(); - } - }); + uploadBufferSelector.addValueChangeListener(event -> setBuffer()); main.addComponent(uploadBufferSelector); main.addComponent(up); l = new Label("Idle"); main.addComponent(l); + up.addListener((Listener) event -> { + // print out all events fired by upload for debug purposes + System.out.println("Upload fired event | " + event); + }); + + up.addStartedListener(event -> { + pi.setVisible(true); + pi2.setVisible(true); + l.setValue("Started uploading file " + event.getFilename()); + textFieldValue.setValue(" TestFields value at the upload start is:" + + textField.getValue()); + }); + + up.addFinishedListener(event -> { + pi.setVisible(false); + pi2.setVisible(false); + if (event instanceof Upload.FailedEvent) { + Exception reason = ((Upload.FailedEvent) event).getReason(); + l.setValue("Finished with failure ( " + reason + " ), idle"); + } else if (event instanceof Upload.SucceededEvent) { + l.setValue("Finished with succes, idle"); + } else { + l.setValue("Finished with unknow event"); + } + + statusLayout.removeAllComponents(); + final InputStream stream = buffer.getStream(); + if (stream == null) { + statusLayout.addComponent(new Label( + "Upload finished, but output buffer is null")); + } else { + statusLayout.addComponent( + new Label("<b>Name:</b> " + event.getFilename(), + ContentMode.HTML)); + statusLayout.addComponent( + new Label("<b>Mimetype:</b> " + event.getMIMEType(), + ContentMode.HTML)); + statusLayout.addComponent(new Label( + "<b>Size:</b> " + event.getLength() + " bytes.", + ContentMode.HTML)); + + statusLayout.addComponent(new Link( + "Download " + buffer.getFileName(), + new StreamResource(buffer, buffer.getFileName()))); + + statusLayout.setVisible(true); + } + + setBuffer(); + }); + + up.addProgressListener((readBytes, contentLength) -> { + pi2.setValue(new Float(readBytes / (float) contentLength)); + + refreshMemUsage(); + }); + pi.setVisible(false); pi.setPollingInterval(1000); main.addComponent(pi); @@ -246,13 +198,9 @@ public class TestForUpload extends CustomComponent main.addComponent(status); final Button restart = new Button("R"); - restart.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - LegacyWindow window = (LegacyWindow) event.getButton().getUI(); - window.getApplication().close(); - } + restart.addClickListener(event -> { + LegacyWindow window = (LegacyWindow) event.getButton().getUI(); + window.getApplication().close(); }); main.addComponent(restart); diff --git a/uitest/src/main/java/com/vaadin/tests/TestForWindowOpen.java b/uitest/src/main/java/com/vaadin/tests/TestForWindowOpen.java index 72a04523e6..a30fe2f336 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForWindowOpen.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForWindowOpen.java @@ -17,7 +17,6 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; @@ -29,42 +28,16 @@ public class TestForWindowOpen extends CustomComponent { final VerticalLayout main = new VerticalLayout(); setCompositionRoot(main); - main.addComponent( - new Button("Open in this window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().getPage() - .setLocation("http://www.google.com"); - - } - - })); + main.addComponent(new Button("Open in this window", event -> UI + .getCurrent().getPage().setLocation("http://www.google.com"))); main.addComponent(new Button("Open in target \"mytarget\"", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().getPage().open("http://www.google.com", - "mytarget"); - - } - - })); + event -> UI.getCurrent().getPage().open("http://www.google.com", + "mytarget"))); main.addComponent(new Button("Open in target \"secondtarget\"", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().getPage().open("http://www.google.com", - "secondtarget"); - - } - - })); - + event -> UI.getCurrent().getPage().open("http://www.google.com", + "secondtarget"))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/TestForWindowing.java b/uitest/src/main/java/com/vaadin/tests/TestForWindowing.java index 52cf961c85..11de7f3e8a 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestForWindowing.java +++ b/uitest/src/main/java/com/vaadin/tests/TestForWindowing.java @@ -17,8 +17,6 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; @@ -26,8 +24,6 @@ import com.vaadin.ui.Slider; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.AbstractSelect; import com.vaadin.v7.ui.OptionGroup; import com.vaadin.v7.ui.Select; @@ -47,69 +43,57 @@ public class TestForWindowing extends CustomComponent { main.addComponent(asModal); final Button create = new Button("Create a new window", - new ClickListener() { + event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + Window w = new Window("Testing Window", layout); - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - Window w = new Window("Testing Window", layout); + if (asModal.getValue().booleanValue()) { + w.setModal(true); + } - if (asModal.getValue().booleanValue()) { - w.setModal(true); + AbstractSelect s1 = new OptionGroup(); + s1.setCaption("1. Select output format"); + s1.addItem("Excel sheet"); + s1.addItem("CSV plain text"); + s1.setValue("Excel sheet"); + s1.setImmediate(true); + + s2 = new Select(); + s2.addItem("Separate by comma (,)"); + s2.addItem("Separate by colon (:)"); + s2.addItem("Separate by semicolon (;)"); + s2.setEnabled(false); + + s1.addValueChangeListener(valueChangeEvent -> { + String v = (String) valueChangeEvent.getProperty() + .getValue(); + if (v.equals("CSV plain text")) { + s2.setEnabled(true); + } else { + s2.setEnabled(false); } + }); - AbstractSelect s1 = new OptionGroup(); - s1.setCaption("1. Select output format"); - s1.addItem("Excel sheet"); - s1.addItem("CSV plain text"); - s1.setValue("Excel sheet"); - s1.setImmediate(true); - - s2 = new Select(); - s2.addItem("Separate by comma (,)"); - s2.addItem("Separate by colon (:)"); - s2.addItem("Separate by semicolon (;)"); - s2.setEnabled(false); - - s1.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - String v = (String) event.getProperty() - .getValue(); - if (v.equals("CSV plain text")) { - s2.setEnabled(true); - } else { - s2.setEnabled(false); - } - } - - }); - - layout.addComponent(s1); - layout.addComponent(s2); - - Slider s = new Slider(); - s.setCaption("Volume"); - s.setMax(13); - s.setMin(12); - s.setResolution(2); - // s.setOrientation(Slider.ORIENTATION_VERTICAL); - // s.setArrows(false); - - layout.addComponent(s); - - UI.getCurrent().addWindow(w); + layout.addComponent(s1); + layout.addComponent(s2); - } + Slider s = new Slider(); + s.setCaption("Volume"); + s.setMax(13); + s.setMin(12); + s.setResolution(2); + // s.setOrientation(Slider.ORIENTATION_VERTICAL); + // s.setArrows(false); + layout.addComponent(s); + + UI.getCurrent().addWindow(w); }); main.addComponent(create); setCompositionRoot(main); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java b/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java index 73e9e887ad..791bd06697 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java +++ b/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java @@ -17,8 +17,6 @@ package com.vaadin.tests; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.LegacyWindow; @@ -62,17 +60,13 @@ public class TestSetVisibleAndCaching selectPanel(selectedPanel); - buttonNextPanel.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - selectedPanel++; - if (selectedPanel > 2) { - selectedPanel = 0; - } - selectPanel(selectedPanel); + buttonNextPanel.addClickListener(event -> { + selectedPanel++; + if (selectedPanel > 2) { + selectedPanel = 0; } + selectPanel(selectedPanel); }); - } private VerticalLayout wrapInPanelLayout(Component component) { diff --git a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java index 31ecf12927..89b5cbf40c 100644 --- a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java +++ b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java @@ -26,7 +26,6 @@ import com.vaadin.server.LegacyApplication; import com.vaadin.server.ThemeResource; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Embedded; @@ -36,7 +35,6 @@ import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Container; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.shared.ui.combobox.FilteringMode; import com.vaadin.v7.ui.AbstractSelect; @@ -70,35 +68,29 @@ public class TestSizeableIncomponents extends LegacyApplication { select.setWidth("400px"); prev = new Button("<<-|"); - prev.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object cur = select.getValue(); - Testable prev = (Testable) cont.prevItemId(cur); - if (prev == null) { - getMainWindow().showNotification("No more test cases"); - } else { - getMainWindow().showNotification( - "Selected test:" + prev.getTestableName()); - select.setValue(prev); - select.markAsDirty(); - } + prev.addClickListener(event -> { + Object cur = select.getValue(); + Testable prev = (Testable) cont.prevItemId(cur); + if (prev == null) { + getMainWindow().showNotification("No more test cases"); + } else { + getMainWindow().showNotification( + "Selected test:" + prev.getTestableName()); + select.setValue(prev); + select.markAsDirty(); } }); next = new Button("|->>"); - next.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object cur = select.getValue(); - Testable next = (Testable) cont.nextItemId(cur); - if (next == null) { - getMainWindow().showNotification("No more test cases"); - } else { - getMainWindow().showNotification( - "Selected test:" + next.getTestableName()); - select.setValue(next); - select.markAsDirty(); - } + next.addClickListener(event -> { + Object cur = select.getValue(); + Testable next = (Testable) cont.nextItemId(cur); + if (next == null) { + getMainWindow().showNotification("No more test cases"); + } else { + getMainWindow().showNotification( + "Selected test:" + next.getTestableName()); + select.setValue(next); + select.markAsDirty(); } }); @@ -109,21 +101,17 @@ public class TestSizeableIncomponents extends LegacyApplication { main.addComponent(controllers); select.setContainerDataSource(cont); - select.addListener(new ComboBox.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Testable t = (Testable) select.getValue(); - if (t != null) { - testPanelLayout.removeAllComponents(); - try { - Component c = t.getComponent(); - if (c != null) { - testPanelLayout.addComponent(c); - } - } catch (InstantiationException - | IllegalAccessException e) { - e.printStackTrace(); + select.addValueChangeListener(event -> { + Testable t = (Testable) select.getValue(); + if (t != null) { + testPanelLayout.removeAllComponents(); + try { + Component c = t.getComponent(); + if (c != null) { + testPanelLayout.addComponent(c); } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); } } }); diff --git a/uitest/src/main/java/com/vaadin/tests/VaadinClasses.java b/uitest/src/main/java/com/vaadin/tests/VaadinClasses.java index 4b24f08eb0..1208ad5242 100644 --- a/uitest/src/main/java/com/vaadin/tests/VaadinClasses.java +++ b/uitest/src/main/java/com/vaadin/tests/VaadinClasses.java @@ -9,7 +9,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; @@ -94,14 +93,9 @@ public class VaadinClasses { findPackages(juc, basePackage, baseClass, classes); } - Collections.sort(classes, new Comparator<Class<? extends T>>() { + Collections.sort(classes, + (o1, o2) -> o1.getName().compareTo(o2.getName())); - @Override - public int compare(Class<? extends T> o1, Class<? extends T> o2) { - return o1.getName().compareTo(o2.getName()); - } - - }); return classes; } diff --git a/uitest/src/main/java/com/vaadin/tests/application/CommErrorEmulatorServlet.java b/uitest/src/main/java/com/vaadin/tests/application/CommErrorEmulatorServlet.java index 3a8714eec9..294004c555 100644 --- a/uitest/src/main/java/com/vaadin/tests/application/CommErrorEmulatorServlet.java +++ b/uitest/src/main/java/com/vaadin/tests/application/CommErrorEmulatorServlet.java @@ -110,18 +110,15 @@ public class CommErrorEmulatorServlet extends VaadinServlet { "Responding with " + responseCode + " to UIDL requests for " + ui + " for the next " + delay + "s"); - new Thread(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(delay * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Handing UIDL requests normally again"); - - uidlResponseCode.remove(ui); + new Thread(() -> { + try { + Thread.sleep(delay * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); } + System.out.println("Handing UIDL requests normally again"); + + uidlResponseCode.remove(ui); }).start(); } @@ -133,18 +130,14 @@ public class CommErrorEmulatorServlet extends VaadinServlet { + " to heartbeat requests for " + ui + " for the next " + delay + "s"); - new Thread(new Runnable() { - - @Override - public void run() { - try { - Thread.sleep(delay * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Handing heartbeat requests normally again"); - heartbeatResponseCode.remove(ui); + new Thread(() -> { + try { + Thread.sleep(delay * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); } + System.out.println("Handing heartbeat requests normally again"); + heartbeatResponseCode.remove(ui); }).start(); } diff --git a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java index 4941994e73..ecf50d08d0 100644 --- a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java +++ b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java @@ -59,19 +59,16 @@ public class NavigateWithOngoingXHR extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { addComponent(new ProgressIndicator() { { - registerRpc(new ProgressIndicatorServerRpc() { - @Override - public void poll() { - // System.out.println("Pausing poll request"); - try { - // Make the XHR request last longer to make it - // easier to click the link at the right moment. - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // System.out.println("Continuing poll request"); + registerRpc((ProgressIndicatorServerRpc) () -> { + // System.out.println("Pausing poll request"); + try { + // Make the XHR request last longer to make it + // easier to click the link at the right moment. + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); } + // System.out.println("Continuing poll request"); }); setPollingInterval(3000); } diff --git a/uitest/src/main/java/com/vaadin/tests/application/TimingInfoReported.java b/uitest/src/main/java/com/vaadin/tests/application/TimingInfoReported.java index 53b2d63f14..5b2bf910a8 100644 --- a/uitest/src/main/java/com/vaadin/tests/application/TimingInfoReported.java +++ b/uitest/src/main/java/com/vaadin/tests/application/TimingInfoReported.java @@ -18,7 +18,6 @@ package com.vaadin.tests.application; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.JavaScriptFunction; import elemental.json.JsonArray; @@ -31,29 +30,24 @@ public class TimingInfoReported extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { getPage().getJavaScript().addFunction("report", - new JavaScriptFunction() { + arguments -> { + log("Got: " + arguments.toJson()); + JsonArray values = arguments.getArray(0); - @Override - public void call(JsonArray arguments) { - log("Got: " + arguments.toJson()); - JsonArray values = arguments.getArray(0); + if (values.length() != 5) { + log("ERROR: expected 5 values, got " + values.length()); + return; + } - if (values.length() != 5) { - log("ERROR: expected 5 values, got " - + values.length()); + for (int i = 0; i < values.length(); i++) { + if (i < 0 || i > 10000) { + log("ERROR: expected value " + i + + " to be between 0 and 10000, was " + + values.getNumber(i)); return; } - - for (int i = 0; i < values.length(); i++) { - if (i < 0 || i > 10000) { - log("ERROR: expected value " + i - + " to be between 0 and 10000, was " - + values.getNumber(i)); - return; - } - } - log("Timings ok"); } + log("Timings ok"); }); getPage().getJavaScript().execute(reportTimings); Button b = new Button("test request", diff --git a/uitest/src/main/java/com/vaadin/tests/applicationcontext/CloseSession.java b/uitest/src/main/java/com/vaadin/tests/applicationcontext/CloseSession.java index 6a43a69e53..9c4aec7184 100644 --- a/uitest/src/main/java/com/vaadin/tests/applicationcontext/CloseSession.java +++ b/uitest/src/main/java/com/vaadin/tests/applicationcontext/CloseSession.java @@ -100,24 +100,17 @@ public class CloseSession extends AbstractReindeerTestUI { final HttpSession session = ((WrappedHttpSession) VaadinService .getCurrentRequest().getWrappedSession()) .getHttpSession(); - Thread t = new Thread(new Runnable() { - - @Override - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out - .println("Invalidating session from thread " - + session.getId()); - session.invalidate(); - System.out - .println("Invalidated session from thread " - + session.getId()); - + Thread t = new Thread(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); } + System.out.println("Invalidating session from thread " + + session.getId()); + session.invalidate(); + System.out.println("Invalidated session from thread " + + session.getId()); }); t.start(); })); diff --git a/uitest/src/main/java/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java b/uitest/src/main/java/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java index a7edd2c0d0..1104848373 100644 --- a/uitest/src/main/java/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java +++ b/uitest/src/main/java/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java @@ -11,13 +11,7 @@ public abstract class UIRunSafelyThread extends Thread { @Override public void run() { - ui.accessSynchronously(new Runnable() { - - @Override - public void run() { - runSafely(); - } - }); + ui.accessSynchronously(() -> runSafely()); } protected abstract void runSafely(); diff --git a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java index 5b9db4ea9c..7cbd411c81 100644 --- a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java +++ b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java @@ -17,7 +17,6 @@ package com.vaadin.tests.applicationservlet; import java.util.concurrent.atomic.AtomicInteger; -import com.vaadin.server.ConnectorIdGenerationEvent; import com.vaadin.server.ConnectorIdGenerator; import com.vaadin.server.ServiceInitEvent; import com.vaadin.server.VaadinServiceInitListener; @@ -37,13 +36,10 @@ public class TestingServiceInitListener implements VaadinServiceInitListener { return false; }); - event.addConnectorIdGenerator(new ConnectorIdGenerator() { - @Override - public String generateConnectorId( - ConnectorIdGenerationEvent event) { - connectorIdCount.incrementAndGet(); - return ConnectorIdGenerator.generateDefaultConnectorId(event); - } + event.addConnectorIdGenerator(connectorIdGenerationEvent -> { + connectorIdCount.incrementAndGet(); + return ConnectorIdGenerator + .generateDefaultConnectorId(connectorIdGenerationEvent); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/AddRemoveSetStyleNamesTest.java b/uitest/src/main/java/com/vaadin/tests/components/AddRemoveSetStyleNamesTest.java index d2ff9f8900..3c8f13ec1d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AddRemoveSetStyleNamesTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AddRemoveSetStyleNamesTest.java @@ -1,7 +1,6 @@ package com.vaadin.tests.components; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.PopupDateField; public class AddRemoveSetStyleNamesTest extends TestBase { @@ -24,15 +23,11 @@ public class AddRemoveSetStyleNamesTest extends TestBase { popupDateField.setRequiredError("abcd"); addComponent(popupDateField); - listener = new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - String style = (String) event.getButton().getData(); - setComponentsStyle(style, - !popupDateField.getStyleName().contains(style), - event.getButton()); - } + listener = event -> { + String style = (String) event.getButton().getData(); + setComponentsStyle(style, + !popupDateField.getStyleName().contains(style), + event.getButton()); }; button1 = new Button("Add style1", listener); @@ -43,19 +38,15 @@ public class AddRemoveSetStyleNamesTest extends TestBase { button2.setData(style2); addComponent(button2); - button3 = new Button("Set thestyle", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (popupDateField.getStyleName().contains(thestyle)) { - popupDateField.removeStyleName(thestyle); - button3.setCaption("Set thestyle"); - } else { - popupDateField.setStyleName(thestyle); - button1.setCaption("Add style1"); - button2.setCaption("Add style2"); - button3.setCaption("Remove thestyle"); - } + button3 = new Button("Set thestyle", event -> { + if (popupDateField.getStyleName().contains(thestyle)) { + popupDateField.removeStyleName(thestyle); + button3.setCaption("Set thestyle"); + } else { + popupDateField.setStyleName(thestyle); + button1.setCaption("Add style1"); + button2.setCaption("Add style2"); + button3.setCaption("Remove thestyle"); } }); addComponent(button3); diff --git a/uitest/src/main/java/com/vaadin/tests/components/CustomComponentwithUndefinedSize.java b/uitest/src/main/java/com/vaadin/tests/components/CustomComponentwithUndefinedSize.java index 853f2863ef..9f294cba3d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/CustomComponentwithUndefinedSize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/CustomComponentwithUndefinedSize.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; @@ -57,25 +55,20 @@ public class CustomComponentwithUndefinedSize extends TestBase { widePanel.setHeight("200px"); layout.addComponent(widePanel); Button button = new Button("Change panel size", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - switch (step++ % 4) { - case 0: - widePanel.setWidth("200px"); - break; - case 1: - widePanel.setHeight("2000px"); - break; - case 2: - widePanel.setWidth("2000px"); - break; - case 3: - widePanel.setHeight("200px"); - break; - } - + event -> { + switch (step++ % 4) { + case 0: + widePanel.setWidth("200px"); + break; + case 1: + widePanel.setHeight("2000px"); + break; + case 2: + widePanel.setWidth("2000px"); + break; + case 3: + widePanel.setHeight("200px"); + break; } }); panelLayout.addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascade.java b/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascade.java index bcb899c66c..fda4e0844e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascade.java +++ b/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascade.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; @@ -31,35 +29,14 @@ public class DisableEnableCascade extends TestBase { addComponent(outerPanel); enableDisablePanelButton = new Button("Disable panel", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(outerPanel, enableDisablePanelButton); - - } - }); + event -> enableDisable(outerPanel, enableDisablePanelButton)); enableDisableTabSheetButton = new Button("Disable TabSheet", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(innerTabsheet, - enableDisableTabSheetButton); - - } - }); + event -> enableDisable(innerTabsheet, + enableDisableTabSheetButton)); enableDisableButtonButton = new Button("Disable Button", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(button, enableDisableButtonButton); - - } - }); + event -> enableDisable(button, enableDisableButtonButton)); addComponent(enableDisablePanelButton); addComponent(enableDisableTabSheetButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascadeStyles.java b/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascadeStyles.java index 1822cceb80..fdc4c186f4 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascadeStyles.java +++ b/uitest/src/main/java/com/vaadin/tests/components/DisableEnableCascadeStyles.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components; import java.util.Iterator; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.NativeButton; import com.vaadin.ui.Panel; @@ -53,63 +51,38 @@ public class DisableEnableCascadeStyles extends TestBase { addComponent(outerPanel); enableDisablePanelButton = new Button("Disable panel", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(outerPanel, enableDisablePanelButton); - - } - }); + event -> enableDisable(outerPanel, enableDisablePanelButton)); enableDisableTabSheetButton = new Button("Disable TabSheet", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(innerTabsheet, - enableDisableTabSheetButton); - - } - }); + event -> enableDisable(innerTabsheet, + enableDisableTabSheetButton)); enableDisableLayoutButton = new Button("Disable Tab content (Layout)", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - enableDisable(layout, enableDisableLayoutButton); - - } - }); + event -> enableDisable(layout, enableDisableLayoutButton)); enableDisableComponentsButton = new Button("Disable Layout Components", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - for (Iterator<Component> i = layout - .getComponentIterator(); i.hasNext();) { - final Component c = i.next(); - if (c.isEnabled()) { - c.setEnabled(false); - c.setCaption(c.getCaption().replace("enabled", - "disabled")); - } else { - c.setEnabled(true); - c.setCaption(c.getCaption().replace("disabled", - "enabled")); - } - } - if (layout.getComponent(0).isEnabled()) { - enableDisableComponentsButton.setCaption( - enableDisableComponentsButton.getCaption() - .replace("Enable", "Disable")); + event -> { + for (Iterator<Component> i = layout + .getComponentIterator(); i.hasNext();) { + final Component c = i.next(); + if (c.isEnabled()) { + c.setEnabled(false); + c.setCaption(c.getCaption().replace("enabled", + "disabled")); } else { - enableDisableComponentsButton.setCaption( - enableDisableComponentsButton.getCaption() - .replace("Disable", "Enable")); + c.setEnabled(true); + c.setCaption(c.getCaption().replace("disabled", + "enabled")); } } + if (layout.getComponent(0).isEnabled()) { + enableDisableComponentsButton.setCaption( + enableDisableComponentsButton.getCaption() + .replace("Enable", "Disable")); + } else { + enableDisableComponentsButton.setCaption( + enableDisableComponentsButton.getCaption() + .replace("Disable", "Enable")); + } }); addComponent(enableDisablePanelButton); addComponent(enableDisableTabSheetButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java b/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java index e74a7128d5..fa63b82e94 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/FileDownloaderUI.java @@ -39,8 +39,6 @@ import com.vaadin.server.VaadinResponse; import com.vaadin.tests.components.embedded.EmbeddedPdf; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; @@ -106,26 +104,17 @@ public class FileDownloaderUI extends AbstractTestUIWithLog { addComponent(downloadUtf8File); addComponent( - new Button("Remove first download button", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Layout parent = (Layout) firstDownloadComponent - .getParent(); - parent.removeComponent(firstDownloadComponent); - } + new Button("Remove first download button", event -> { + Layout parent = (Layout) firstDownloadComponent.getParent(); + parent.removeComponent(firstDownloadComponent); })); addComponent( new Button("Detach FileDownloader from first download button", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - FileDownloader e = (FileDownloader) firstDownloadComponent - .getExtensions().iterator().next(); - e.remove(); - log("FileDownload detached"); - } + event -> { + FileDownloader e = (FileDownloader) firstDownloadComponent + .getExtensions().iterator().next(); + e.remove(); + log("FileDownload detached"); })); } @@ -152,11 +141,7 @@ public class FileDownloaderUI extends AbstractTestUIWithLog { new FileDownloader(resource).extend(c); if (c instanceof Button) { - ((Button) c).addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - } + ((Button) c).addClickListener(event -> { }); } } catch (Exception e) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java index 7bf144c8d7..b1e5f2ef59 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java @@ -2,9 +2,7 @@ package com.vaadin.tests.components; import java.util.Date; -import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.Button; @@ -21,25 +19,19 @@ import com.vaadin.v7.ui.OptionGroup; public class FocusAndBlurListeners extends TestBase { - private FocusListener focusListener = new FocusListener() { + private VerticalLayout messages = new VerticalLayout(); - @Override - public void focus(FocusEvent event) { - Label msg = new Label(new Date() + " Focused " - + event.getComponent().getCaption()); - messages.addComponentAsFirst(msg); - } + private FocusListener focusListener = event -> { + Label msg = new Label( + new Date() + " Focused " + event.getComponent().getCaption()); + messages.addComponentAsFirst(msg); }; - private BlurListener blurListener = new BlurListener() { - - @Override - public void blur(BlurEvent event) { - Label msg = new Label(new Date() + " Blurred " - + event.getComponent().getCaption()); - messages.addComponentAsFirst(msg); - } + + private BlurListener blurListener = event -> { + Label msg = new Label( + new Date() + " Blurred " + event.getComponent().getCaption()); + messages.addComponentAsFirst(msg); }; - private VerticalLayout messages = new VerticalLayout(); @Override protected void setup() { @@ -78,7 +70,6 @@ public class FocusAndBlurListeners extends TestBase { @Override public void buttonClick(ClickEvent event) { ogm.addItem("newItem" + i++); - } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/FocusFromShortcutAction.java b/uitest/src/main/java/com/vaadin/tests/components/FocusFromShortcutAction.java index 9de40f2210..44f6d93865 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/FocusFromShortcutAction.java +++ b/uitest/src/main/java/com/vaadin/tests/components/FocusFromShortcutAction.java @@ -5,7 +5,6 @@ import java.util.Arrays; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Select; import com.vaadin.v7.ui.TextField; @@ -19,22 +18,12 @@ public class FocusFromShortcutAction extends TestBase { addComponent(select); addComponent(text); - Button focusText = new Button("Focus text", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - text.focus(); - } - }); + Button focusText = new Button("Focus text", event -> text.focus()); focusText.setClickShortcut(KeyCode.T, ModifierKey.ALT); addComponent(focusText); Button focusSelect = new Button("Focus select", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - select.focus(); - } - }); + event -> select.focus()); focusSelect.setClickShortcut(KeyCode.S, ModifierKey.ALT); addComponent(focusSelect); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/HierarchyChangeForRemovedComponentContainers.java b/uitest/src/main/java/com/vaadin/tests/components/HierarchyChangeForRemovedComponentContainers.java index 4a9c46409e..af33bbca95 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/HierarchyChangeForRemovedComponentContainers.java +++ b/uitest/src/main/java/com/vaadin/tests/components/HierarchyChangeForRemovedComponentContainers.java @@ -1,7 +1,6 @@ package com.vaadin.tests.components; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; @@ -26,13 +25,8 @@ public class HierarchyChangeForRemovedComponentContainers extends TestBase { compose(); - addComponent(new Button("Replace layout with button", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - compose2(); - } - })); + addComponent( + new Button("Replace layout with button", event -> compose2())); } private void compose() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/LayoutAttachListenerInfo.java b/uitest/src/main/java/com/vaadin/tests/components/LayoutAttachListenerInfo.java index d1cdc31e7a..a10f700a40 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/LayoutAttachListenerInfo.java +++ b/uitest/src/main/java/com/vaadin/tests/components/LayoutAttachListenerInfo.java @@ -4,15 +4,10 @@ import java.util.Arrays; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HasComponents.ComponentAttachEvent; -import com.vaadin.ui.HasComponents.ComponentAttachListener; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.OptionGroup; public class LayoutAttachListenerInfo extends TestBase { @@ -26,18 +21,13 @@ public class LayoutAttachListenerInfo extends TestBase { Arrays.asList("AbsoluteLayout", "OrderedLayout", "GridLayout")); layouts.select("AbsoluteLayout"); layouts.setImmediate(true); - layouts.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (event.getProperty().getValue().equals("AbsoluteLayout")) { - testAbsoluteLayout(); - } else if (event.getProperty().getValue() - .equals("OrderedLayout")) { - testOrderedLayout(); - } else if (event.getProperty().getValue() - .equals("GridLayout")) { - testGridLayout(); - } + layouts.addValueChangeListener(event -> { + if (event.getProperty().getValue().equals("AbsoluteLayout")) { + testAbsoluteLayout(); + } else if (event.getProperty().getValue().equals("OrderedLayout")) { + testOrderedLayout(); + } else if (event.getProperty().getValue().equals("GridLayout")) { + testGridLayout(); } }); @@ -65,28 +55,19 @@ public class LayoutAttachListenerInfo extends TestBase { final AbsoluteLayout a = new AbsoluteLayout(); a.setWidth("300px"); a.setHeight("300px"); - a.addComponentAttachListener(new ComponentAttachListener() { - @Override - public void componentAttachedToContainer( - ComponentAttachEvent event) { - AbsoluteLayout layout = (AbsoluteLayout) event.getContainer(); - AbsoluteLayout.ComponentPosition position = layout - .getPosition(event.getAttachedComponent()); - - getMainWindow().showNotification( - "Attached to " + position.getCSSString(), - Notification.TYPE_ERROR_MESSAGE); - } + a.addComponentAttachListener(event -> { + AbsoluteLayout layout = (AbsoluteLayout) event.getContainer(); + AbsoluteLayout.ComponentPosition position = layout + .getPosition(event.getAttachedComponent()); + + getMainWindow().showNotification( + "Attached to " + position.getCSSString(), + Notification.TYPE_ERROR_MESSAGE); }); content.addComponent(a); content.addComponent(new Button("Attach label to layout", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - a.addComponent(new Label("X"), "top:50px;left:50px"); - } - })); + event -> a.addComponent(new Label("X"), "top:50px;left:50px"))); } private void testOrderedLayout() { @@ -95,27 +76,17 @@ public class LayoutAttachListenerInfo extends TestBase { final VerticalLayout v = new VerticalLayout(); v.setWidth("300px"); v.setHeight("300px"); - v.addComponentAttachListener(new ComponentAttachListener() { - @Override - public void componentAttachedToContainer( - ComponentAttachEvent event) { - VerticalLayout layout = (VerticalLayout) event.getContainer(); - getMainWindow().showNotification( - "Attached to index " + layout.getComponentIndex( - event.getAttachedComponent()), - Notification.TYPE_ERROR_MESSAGE); - } + v.addComponentAttachListener(event -> { + VerticalLayout layout = (VerticalLayout) event.getContainer(); + getMainWindow().showNotification( + "Attached to index " + layout + .getComponentIndex(event.getAttachedComponent()), + Notification.TYPE_ERROR_MESSAGE); }); content.addComponent(v); content.addComponent(new Button("Attach label to layout", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - v.addComponent(new Label("X")); - - } - })); + event -> v.addComponent(new Label("X")))); } private void testGridLayout() { @@ -125,28 +96,18 @@ public class LayoutAttachListenerInfo extends TestBase { g.setWidth("300px"); g.setHeight("300px"); g.setHideEmptyRowsAndColumns(true); - g.addComponentAttachListener(new ComponentAttachListener() { - @Override - public void componentAttachedToContainer( - ComponentAttachEvent event) { - GridLayout layout = (GridLayout) event.getContainer(); - GridLayout.Area area = layout - .getComponentArea(event.getAttachedComponent()); - getMainWindow().showNotification( - "Attached to " + area.getColumn1() + "," - + area.getRow1(), - Notification.TYPE_ERROR_MESSAGE); - } + g.addComponentAttachListener(event -> { + GridLayout layout = (GridLayout) event.getContainer(); + GridLayout.Area area = layout + .getComponentArea(event.getAttachedComponent()); + getMainWindow().showNotification( + "Attached to " + area.getColumn1() + "," + area.getRow1(), + Notification.TYPE_ERROR_MESSAGE); }); content.addComponent(g); content.addComponent(new Button("Attach label to layout", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - g.addComponent(new Label("X"), 2, 3); - } - })); + event -> g.addComponent(new Label("X"), 2, 3))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayout.java b/uitest/src/main/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayout.java index dcf0f2c1a1..1982a4062e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayout.java @@ -7,7 +7,6 @@ import java.util.concurrent.TimeUnit; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.ProgressBar; @@ -52,12 +51,9 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { Button closeB = new Button( "2. Click to close after the progress is updated"); closeB.setId("closeWindow"); - closeB.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - w2.close(); - w2 = null; - } + closeB.addClickListener(clickEvent -> { + w2.close(); + w2 = null; }); glo.addComponent(closeB); addWindow(w2); @@ -67,26 +63,18 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { }); Button openWin = new Button("3. Finally, Click to open a new Window"); - openWin.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - w = new Window("test"); - w.setWidth("300px"); - w.setHeight("300px"); - w.setContent(new VerticalLayout( - new Label("simple test label component"))); - w.center(); - getUI().addWindow(w); - } + openWin.addClickListener(event -> { + w = new Window("test"); + w.setWidth("300px"); + w.setHeight("300px"); + w.setContent(new VerticalLayout( + new Label("simple test label component"))); + w.center(); + getUI().addWindow(w); }); - Button stopPolling = new Button("Stop polling", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - setPollInterval(-1); - } - }); + Button stopPolling = new Button("Stop polling", + event -> setPollInterval(-1)); layout.addComponents(button, openWin, stopPolling); } @@ -95,12 +83,7 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { @Override public void run() { - getUI().access(new Runnable() { - @Override - public void run() { - updateProgresBar(50); - } - }); + getUI().access(() -> updateProgresBar(50)); } }; ScheduledExecutorService worker = Executors diff --git a/uitest/src/main/java/com/vaadin/tests/components/SaneErrors.java b/uitest/src/main/java/com/vaadin/tests/components/SaneErrors.java index 6ac39310b4..7a7f332d46 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/SaneErrors.java +++ b/uitest/src/main/java/com/vaadin/tests/components/SaneErrors.java @@ -7,8 +7,6 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.RowHeaderMode; @@ -17,14 +15,7 @@ public class SaneErrors extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { final Button b = new Button("Show me my NPE!"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - throwError(); - } - - }); + b.addClickListener(event -> throwError()); /* * Errors from "legacy variable changes" @@ -32,12 +23,7 @@ public class SaneErrors extends AbstractReindeerTestUI { final Table table = new Table(); table.addItem("Show me my NPE!"); table.setRowHeaderMode(RowHeaderMode.ID); - table.addItemClickListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - throwError(); - } - }); + table.addItemClickListener(event -> throwError()); final VerticalLayout content = new VerticalLayout(b, table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java b/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java index 4ddc242377..963b426513 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java +++ b/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java @@ -14,7 +14,6 @@ import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalSplitPanel; @@ -78,19 +77,9 @@ public class TouchScrollables extends TestBase { final Label l = l50; Button button = new Button("Scroll to label 50", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getLayout().getUI().scrollIntoView(l); - } - }); + event -> getLayout().getUI().scrollIntoView(l)); cssLayout.addComponent(button); - button = new Button("Scroll to 100px", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - p.setScrollTop(100); - } - }); + button = new Button("Scroll to 100px", event -> p.setScrollTop(100)); cssLayout.addComponent(button); cssLayout.addComponent(p); return cssLayout; @@ -118,27 +107,20 @@ public class TouchScrollables extends TestBase { final Table table = new Table(); Button button = new Button("Toggle lazyloading"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (table.getCacheRate() == 100) { - table.setCacheRate(2); - table.setPageLength(15); - } else { - table.setCacheRate(100); - table.setHeight("400px"); - } + button.addClickListener(event -> { + if (table.getCacheRate() == 100) { + table.setCacheRate(2); + table.setPageLength(15); + } else { + table.setCacheRate(100); + table.setHeight("400px"); } }); cssLayout.addComponent(button); button = new Button("Toggle selectable"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setSelectable(!table.isSelectable()); - } - }); + button.addClickListener( + event -> table.setSelectable(!table.isSelectable())); cssLayout.addComponent(button); table.addContainerProperty("foo", String.class, "bar"); @@ -162,17 +144,14 @@ public class TouchScrollables extends TestBase { } private Component getSubWindowTest() { - Button b = new Button("Open subwindow", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - Window w = new Window("Subwindow", layout); - w.center(); - w.setHeight("200px"); - layout.addComponent(getBigComponent()); - getMainWindow().addWindow(w); - } + Button b = new Button("Open subwindow", event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + Window w = new Window("Subwindow", layout); + w.center(); + w.setHeight("200px"); + layout.addComponent(getBigComponent()); + getMainWindow().addWindow(w); }); return b; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxes2.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxes2.java index 172d930cb3..890acc2363 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxes2.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxes2.java @@ -81,15 +81,11 @@ public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> { private void createItemStyleGeneratorAction(String category) { LinkedHashMap<String, ItemStyleGenerator> options = new LinkedHashMap<>(); options.put("-", null); - options.put("Bold fives", new ItemStyleGenerator() { - @Override - public String getStyle(ComboBox source, Object itemId) { - if (String.valueOf(itemId).indexOf('5') != -1) { - return "bold"; - } else { - return null; - } + options.put("Bold fives", (source, itemId) -> { + if (String.valueOf(itemId).indexOf('5') != -1) { + return "bold"; } + return null; }); createSelectAction("Item style generator", category, options, "-", itemStyleGeneratorCommand); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboPushTiming.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboPushTiming.java index 564c46c203..1f7d5a1644 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboPushTiming.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboPushTiming.java @@ -64,20 +64,17 @@ public class ComboPushTiming extends TestBase { } private void changeValue(final ComboBox cb) { - executor.execute(new Runnable() { - @Override - public void run() { - VaadinSession.getCurrent().lock(); - try { - cb.setEnabled(true); - cb.setValue("B"); - cb.setEnabled(true); - - // If this isn't sent by push or poll in the background, the - // problem will go away - } finally { - VaadinSession.getCurrent().unlock(); - } + executor.execute(() -> { + VaadinSession.getCurrent().lock(); + try { + cb.setEnabled(true); + cb.setValue("B"); + cb.setEnabled(true); + + // If this isn't sent by push or poll in the background, the + // problem will go away + } finally { + VaadinSession.getCurrent().unlock(); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java index f260f752ce..0d1633c64b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java +++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java @@ -38,12 +38,7 @@ public class DateFieldPopupClosingOnDetach extends AbstractReindeerTestUI { @Override public void run() { - getUI().access(new Runnable() { - @Override - public void run() { - removeComponent(df); - } - }); + getUI().access(() -> removeComponent(df)); } }; new Timer(true).schedule(removeTask, 1000); diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridFastAsyncUpdate.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridFastAsyncUpdate.java index 3f4391d504..8f88e7c5c5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridFastAsyncUpdate.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridFastAsyncUpdate.java @@ -19,35 +19,6 @@ import com.vaadin.ui.VerticalLayout; @Push public class GridFastAsyncUpdate extends AbstractTestUI { - private final Runnable addRowsTask = new Runnable() { - @Override - public void run() { - System.out.println("Logging..."); - try { - Random random = new Random(); - while (!Thread.currentThread().isInterrupted()) { - Thread.sleep(random.nextInt(100)); - - GridFastAsyncUpdate.this.access(() -> { - ++counter; - Item item = new Item(counter, - (Calendar.getInstance().getTimeInMillis() - - loggingStart), - Level.INFO.toString(), "Message"); - items.add(item); - grid.setItems(items); - - if (grid != null && !scrollLock) { - grid.scrollToEnd(); - } - }); - } - } catch (InterruptedException e) { - System.out.println("logging thread interrupted"); - } - } - }; - private int counter; private List<Item> items = new LinkedList<>(); @@ -55,6 +26,32 @@ public class GridFastAsyncUpdate extends AbstractTestUI { private long loggingStart; private volatile boolean scrollLock = false; + private final Runnable addRowsTask = () -> { + System.out.println("Logging..."); + try { + Random random = new Random(); + while (!Thread.currentThread().isInterrupted()) { + Thread.sleep(random.nextInt(100)); + + GridFastAsyncUpdate.this.access(() -> { + ++counter; + Item item = new Item(counter, + (Calendar.getInstance().getTimeInMillis() + - loggingStart), + Level.INFO.toString(), "Message"); + items.add(item); + grid.setItems(items); + + if (grid != null && !scrollLock) { + grid.scrollToEnd(); + } + }); + } + } catch (InterruptedException e) { + System.out.println("logging thread interrupted"); + } + }; + @Override protected void setup(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java index bd57bf43bf..442b112737 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java @@ -33,7 +33,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.AbstractJavaScriptComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HasComponents; import com.vaadin.ui.JavaScriptFunction; @@ -173,12 +172,8 @@ public class BasicJavaScriptComponent extends AbstractReindeerTestUI { addComponent(c); Button removeButton = new Button("Remove component", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - removeComponent(c); - } - }); + event -> removeComponent(c)); + removeButton.setId("RemoveButton"); addComponent(removeButton); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUI.java b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUI.java index 37f5b20b6b..dd88d5fb5b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUI.java @@ -21,8 +21,6 @@ import com.vaadin.shared.ui.JavaScriptComponentState; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.AbstractJavaScriptComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; public class JavaScriptNoLayoutHandlingUI extends AbstractTestUIWithLog { @@ -54,15 +52,8 @@ public class JavaScriptNoLayoutHandlingUI extends AbstractTestUIWithLog { final MyJsComponent myComponent = new MyJsComponent(); myComponent.setId("js"); addComponent(myComponent); - addComponent(new Button("Send update", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - myComponent.getState().aaa++; - } - - })); - + addComponent(new Button("Send update", + event -> myComponent.getState().aaa++)); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.java b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.java index 29c226fd8c..86082a938f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.java +++ b/uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.java @@ -21,7 +21,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.AbstractJavaScriptComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.CssLayout; @@ -42,12 +41,7 @@ public class JavaScriptResizeListener extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { addComponent( - new Button("Change holder size", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - updateHolderSize(); - } - })); + new Button("Change holder size", event -> updateHolderSize())); addComponent(new CheckBox("Listener active") { { addValueChangeListener(event -> resizeJsComponent diff --git a/uitest/src/main/java/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java b/uitest/src/main/java/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java index 61caf9a2f2..c4c5d7c5af 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.label; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; public class HundredPercentWideLabelResize extends TestBase { @@ -26,17 +25,12 @@ public class HundredPercentWideLabelResize extends TestBase { getLayout().addComponent(text); getLayout().addComponent( - new Button("toggle width", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (getLayout().getWidth() == 500) { - getLayout().setWidth("100px"); - } else { - getLayout().setWidth("500px"); - } - + new Button("toggle width", event -> { + if (getLayout().getWidth() == 500) { + getLayout().setWidth("100px"); + } else { + getLayout().setWidth("500px"); } - })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/label/LabelPropertySourceValue.java b/uitest/src/main/java/com/vaadin/tests/components/label/LabelPropertySourceValue.java index 57513e47fc..242355d988 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/label/LabelPropertySourceValue.java +++ b/uitest/src/main/java/com/vaadin/tests/components/label/LabelPropertySourceValue.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.label; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.ui.Label; @@ -16,32 +14,19 @@ public class LabelPropertySourceValue extends AbstractReindeerTestUI { label = new Label("Hello Vaadin user"); addComponent(label); Button button = new Button("Give label a new property data source..."); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ObjectProperty<String> p = new ObjectProperty<>( - "This text should appear on the label after clicking the button."); - - label.setPropertyDataSource(p); - } - }); - addComponent(button); - button = new Button("Remove data source", new ClickListener() { + button.addClickListener(event -> { + ObjectProperty<String> p = new ObjectProperty<>( + "This text should appear on the label after clicking the button."); - @Override - public void buttonClick(ClickEvent event) { - label.setPropertyDataSource(null); - } + label.setPropertyDataSource(p); }); addComponent(button); + button = new Button("Remove data source", + event -> label.setPropertyDataSource(null)); + addComponent(button); - button = new Button("Set label value to 'foo'", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - label.setValue("foo"); - } - }); + button = new Button("Set label value to 'foo'", + event -> label.setValue("foo")); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java b/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java index 2a20b46911..948f25e046 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java +++ b/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.label; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -27,14 +26,11 @@ public class LabelWrapping extends TestBase { final Label longLabel = new Label(longString); Button changeLength = new Button("Change length"); - changeLength.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (longLabel.getValue().equals(longString)) { - longLabel.setValue(""); - } else { - longLabel.setValue(longString); - } + changeLength.addClickListener(event -> { + if (longLabel.getValue().equals(longString)) { + longLabel.setValue(""); + } else { + longLabel.setValue(longString); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/link/LinkInsideDisabledContainer.java b/uitest/src/main/java/com/vaadin/tests/components/link/LinkInsideDisabledContainer.java index 2a040b413f..60730a551f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/link/LinkInsideDisabledContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/link/LinkInsideDisabledContainer.java @@ -40,21 +40,13 @@ public class LinkInsideDisabledContainer extends AbstractTestUIWithLog { layout.addComponent(vlayout); Button toggleLinkButton = new Button("enable/disable link"); - toggleLinkButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - link.setEnabled(!link.isEnabled()); - } - }); + toggleLinkButton + .addClickListener(event -> link.setEnabled(!link.isEnabled())); layout.addComponent(toggleLinkButton); Button toggleContainerButton = new Button("enable/disable container"); - toggleContainerButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - vlayout.setEnabled(!vlayout.isEnabled()); - } - }); + toggleContainerButton.addClickListener( + event -> vlayout.setEnabled(!vlayout.isEnabled())); layout.addComponent(toggleContainerButton); addComponent(layout); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java index 98eab80796..057b33b988 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java +++ b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java @@ -4,7 +4,6 @@ import java.util.Arrays; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.ListSelect; public class ListSelectPrimaryStylename extends TestBase { @@ -17,13 +16,7 @@ public class ListSelectPrimaryStylename extends TestBase { addComponent(list); addComponent(new Button("Change primary stylename", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - list.setPrimaryStyleName("my-second-list"); - } - })); - + event -> list.setPrimaryStyleName("my-second-list"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java b/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java index 034a650eeb..451265367f 100755 --- a/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java +++ b/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.loginform; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; import com.vaadin.ui.LoginForm; -import com.vaadin.ui.LoginForm.LoginEvent; -import com.vaadin.ui.LoginForm.LoginListener; import com.vaadin.ui.UI; public class LoginFormUIInLoginHandler extends TestBase { @@ -12,25 +10,20 @@ public class LoginFormUIInLoginHandler extends TestBase { @Override protected void setup() { LoginForm lf = new LoginForm(); - lf.addLoginListener(new LoginListener() { - - @Override - public void onLogin(LoginEvent event) { - UI r1 = UI.getCurrent(); - if (r1 != null) { - addComponent( - new Label("UI.getCurrent().data: " + r1.getData())); - } else { - addComponent(new Label("UI.getCurrent() is null")); - } - UI r2 = event.getSource().getUI(); - if (r2 != null) { - addComponent(new Label( - "event.getSource().data: " + r2.getData())); - } else { - addComponent( - new Label("event.getSource().getRoot() is null")); - } + lf.addLoginListener(event -> { + UI r1 = UI.getCurrent(); + if (r1 != null) { + addComponent( + new Label("UI.getCurrent().data: " + r1.getData())); + } else { + addComponent(new Label("UI.getCurrent() is null")); + } + UI r2 = event.getSource().getUI(); + if (r2 != null) { + addComponent( + new Label("event.getSource().data: " + r2.getData())); + } else { + addComponent(new Label("event.getSource().getRoot() is null")); } }); addComponent(lf); diff --git a/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java b/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java index cb25163d77..9b43c2cd1b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.loginform; import com.vaadin.server.LegacyApplication; import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.LoginForm; -import com.vaadin.ui.LoginForm.LoginEvent; -import com.vaadin.ui.LoginForm.LoginListener; @SuppressWarnings("serial") public class LoginFormWithMultipleWindows extends LegacyApplication { @@ -21,17 +19,9 @@ public class LoginFormWithMultipleWindows extends LegacyApplication { LoginForm loginForm = new LoginForm(); loginForm.setSizeUndefined(); - loginForm.addLoginListener(new LoginListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void onLogin(LoginEvent event) { - showNotification(event.getLoginParameter("username") + ":" - + event.getLoginParameter("password")); - - } - }); + loginForm.addLoginListener(event -> showNotification( + event.getLoginParameter("username") + ":" + + event.getLoginParameter("password"))); addComponent(loginForm); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/media/AudioTest.java b/uitest/src/main/java/com/vaadin/tests/components/media/AudioTest.java index f81eea8746..b482b7846f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/media/AudioTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/media/AudioTest.java @@ -21,7 +21,6 @@ import com.vaadin.server.Resource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Audio; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; public class AudioTest extends TestBase { @@ -68,13 +67,7 @@ public class AudioTest extends TestBase { event -> audio.setAutoplay(event.getValue())); addComponent(checkBox); - Button b = new Button("Change", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - audio.setSources(s2); - } - }); + Button b = new Button("Change", event -> audio.setSources(s2)); addComponent(b); getLayout().setHeight("400px"); getLayout().setExpandRatio(b, 1.0f); diff --git a/uitest/src/main/java/com/vaadin/tests/components/media/Media.java b/uitest/src/main/java/com/vaadin/tests/components/media/Media.java index aadd98b8ce..a6840fe8ea 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/media/Media.java +++ b/uitest/src/main/java/com/vaadin/tests/components/media/Media.java @@ -21,8 +21,6 @@ import com.vaadin.shared.ui.PreloadMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Audio; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Video; @@ -36,22 +34,8 @@ public class Media extends TestBase { v.setWidth("560px"); v.setHeight("320px"); addComponent(v); - addComponent(new Button("Play video", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - v.play(); - } - - })); - addComponent(new Button("Pause video", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - v.pause(); - } - - })); + addComponent(new Button("Play video", event -> v.play())); + addComponent(new Button("Pause video", event -> v.pause())); final CheckBox loop = new CheckBox("Loop"); loop.addValueChangeListener(event -> v.setLoop(event.getValue())); addComponent(loop); @@ -62,22 +46,8 @@ public class Media extends TestBase { "http://www.sample-videos.com/audio/mp3/crowd-cheering.mp3")); addComponent(a); - addComponent(new Button("Play audio", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - a.play(); - } - - })); - addComponent(new Button("Pause audio", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - a.pause(); - } - - })); + addComponent(new Button("Play audio", event -> a.play())); + addComponent(new Button("Pause audio", event -> a.pause())); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarFocus.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarFocus.java index e8dbd2b75e..c382b8bc78 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarFocus.java +++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarFocus.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.menubar; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.Command; @@ -71,15 +69,8 @@ public class MenuBarFocus extends AbstractReindeerTestUI { } private Button buildButton(final MenuBar bar) { - ClickListener buttonClickListener = new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - bar.focus(); - } - }; - Button focusButton = new Button("Click me to focus the menubar", - buttonClickListener); + event -> bar.focus()); focusButton.setTabIndex(1); return focusButton; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java index ad8e2b05ed..1dd5d22039 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java +++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.menubar; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.MenuItem; @@ -28,13 +27,7 @@ public class MenuBarPrimaryStylenames extends TestBase { addComponent(mainMenu); addComponent(new Button("Change primary stylename", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - mainMenu.setPrimaryStyleName("my-other-menu"); - } - })); - + event -> mainMenu.setPrimaryStyleName("my-other-menu"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java index ece7994232..8cde698af5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java +++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleRemoved.java @@ -4,7 +4,6 @@ import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; import com.vaadin.server.WebBrowser; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.JavaScript; import com.vaadin.ui.MenuBar; @@ -24,21 +23,16 @@ public class MenuItemStyleRemoved extends AbstractReindeerTestUI { second.addItem("second sub-item 2", null, null); addComponent(menuBar); - addButton("Add styles", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - String method = "getElementsByClassName('" + MENUITEM_CLASS - + "')"; - WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); - if (webBrowser.isIE() - && webBrowser.getBrowserMajorVersion() == 8) { - method = "querySelectorAll('." + MENUITEM_CLASS + "')"; - } - JavaScript.getCurrent() - .execute("var x=document." + method + ";" - + " var i; for (i=0; i < x.length; i++)" - + " {x[i].className += ' custom-menu-item'};"); + addButton("Add styles", event -> { + String method = "getElementsByClassName('" + MENUITEM_CLASS + "')"; + WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); + if (webBrowser.isIE() && webBrowser.getBrowserMajorVersion() == 8) { + method = "querySelectorAll('." + MENUITEM_CLASS + "')"; } + JavaScript.getCurrent() + .execute("var x=document." + method + ";" + + " var i; for (i=0; i < x.length; i++)" + + " {x[i].className += ' custom-menu-item'};"); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonClick.java b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonClick.java index e35d7f3105..17a38be166 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonClick.java +++ b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonClick.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.nativebutton; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.NativeButton; @@ -44,21 +43,11 @@ public class NativeButtonClick extends AbstractReindeerTestUI { final Label label2 = new Label("0,0"); Button button1 = new NativeButton("Button1", - new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - label1.setValue( - event.getClientX() + "," + event.getClientY()); - } - }); + event -> label1.setValue( + event.getClientX() + "," + event.getClientY())); Button button2 = new NativeButton("Button2", - new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - label2.setValue( - event.getClientX() + "," + event.getClientY()); - } - }); + event -> label2.setValue( + event.getClientX() + "," + event.getClientY())); HorizontalLayout layout = new HorizontalLayout(); layout.addComponents(button1, button2, label1, label2); diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java index da974a691a..c8b04e5b92 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java +++ b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components.nativebutton; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.NativeButton; public class NativeButtonHtml extends TestBase { @@ -18,13 +16,8 @@ public class NativeButtonHtml extends TestBase { addComponent(b); final NativeButton swapButton = new NativeButton("<i>Swap button<i>"); - swapButton.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - swapButton.setCaptionAsHtml(!swapButton.isCaptionAsHtml()); - } - }); + swapButton.addClickListener(event -> swapButton + .setCaptionAsHtml(!swapButton.isCaptionAsHtml())); addComponent(swapButton); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/notification/ChromeBottomNotification.java b/uitest/src/main/java/com/vaadin/tests/components/notification/ChromeBottomNotification.java index 3cbedceab8..295c7c720e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/notification/ChromeBottomNotification.java +++ b/uitest/src/main/java/com/vaadin/tests/components/notification/ChromeBottomNotification.java @@ -3,20 +3,16 @@ package com.vaadin.tests.components.notification; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.Position; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.Notification; public class ChromeBottomNotification extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addButton("Show notification", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - Notification notification = new Notification("Hello world", - Notification.Type.ERROR_MESSAGE); - notification.setPosition(Position.BOTTOM_CENTER); - notification.show(getPage()); - } + addButton("Show notification", event -> { + Notification notification = new Notification("Hello world", + Notification.Type.ERROR_MESSAGE); + notification.setPosition(Position.BOTTOM_CENTER); + notification.show(getPage()); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/notification/MiddleNotificationPosition.java b/uitest/src/main/java/com/vaadin/tests/components/notification/MiddleNotificationPosition.java index d504eb81b1..c7671e99d5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/notification/MiddleNotificationPosition.java +++ b/uitest/src/main/java/com/vaadin/tests/components/notification/MiddleNotificationPosition.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.Position; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; /** @@ -35,29 +33,21 @@ public class MiddleNotificationPosition extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { Button left = new Button("Show Notification in middle left"); left.addStyleName("show-middle-left"); - left.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification notification = new Notification("Notification"); - notification.setDelayMsec(10000); - notification.setPosition(Position.MIDDLE_LEFT); - notification.show(getUI().getPage()); - } + left.addClickListener(event -> { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(10000); + notification.setPosition(Position.MIDDLE_LEFT); + notification.show(getUI().getPage()); }); addComponent(left); Button right = new Button("Show Notification in middle right"); right.addStyleName("show-middle-right"); - right.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification notification = new Notification("Notification"); - notification.setDelayMsec(10000); - notification.setPosition(Position.MIDDLE_RIGHT); - notification.show(getUI().getPage()); - } + right.addClickListener(event -> { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(10000); + notification.setPosition(Position.MIDDLE_RIGHT); + notification.show(getUI().getPage()); }); addComponent(right); diff --git a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java index f4d0c77428..cfd1cb85e7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.notification; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.ui.Window; @@ -16,13 +15,10 @@ public class NotificationsAndModalWindow extends TestBase { Notification.TYPE_WARNING_MESSAGE); Button b = new Button("Button"); - b.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Window w = new Window("This is a window"); - w.setModal(true); - getMainWindow().addWindow(w); - } + b.addClickListener(event -> { + Window w = new Window("This is a window"); + w.setModal(true); + getMainWindow().addWindow(w); }); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupMultipleValueChange.java b/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupMultipleValueChange.java index d0df54fe23..0c69180251 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupMultipleValueChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupMultipleValueChange.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.optiongroup; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.ui.OptionGroup; public class OptionGroupMultipleValueChange extends TestBase { @@ -32,13 +30,9 @@ public class OptionGroupMultipleValueChange extends TestBase { events.setWidth(null); addComponent(events); - og.addListener(new Property.ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - String s = "ValueChange: " + event.getProperty().getValue(); - events.setValue(events.getValue() + "\n" + s); - } + og.addValueChangeListener(event -> { + String s = "ValueChange: " + event.getProperty().getValue(); + events.setValue(events.getValue() + "\n" + s); }); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java b/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java index d8871dc43e..83b033d1d3 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.optiongroup; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.OptionGroup; /** @@ -40,17 +38,13 @@ public class OptionGroupRetainFocusKeyboardValueChange optiongroup.setItemCaption(3, "C"); optiongroup.setImmediate(true); - optiongroup.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if (optiongroup.isSelected(2)) { - optiongroup.setItemCaption(1, "A+"); - } else if (optiongroup.isSelected(3)) { - optiongroup.removeItem(2); - optiongroup.addItem(2); - optiongroup.setItemCaption(2, "B"); - } + optiongroup.addValueChangeListener(event -> { + if (optiongroup.isSelected(2)) { + optiongroup.setItemCaption(1, "A+"); + } else if (optiongroup.isSelected(3)) { + optiongroup.removeItem(2); + optiongroup.addItem(2); + optiongroup.setItemCaption(2, "B"); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java index 2be125a917..cb02ccfed2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java @@ -6,8 +6,6 @@ import java.util.List; import com.vaadin.annotations.PreserveOnRefresh; import com.vaadin.annotations.Theme; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.server.ThemeResource; import com.vaadin.server.UserError; import com.vaadin.server.VaadinRequest; @@ -17,15 +15,12 @@ import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.AbstractField; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.TextField; @@ -116,42 +111,30 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { header.addComponent(vertical); Button addComponent = new Button("Add Component", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - GridLayout grid = new GridLayout(2, 2); - Button grow = new Button("Grow Me", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (event.getButton() - .getWidth() == -1) { - event.getButton().setHeight("50px"); - event.getButton().setWidth("200px"); - } else { - event.getButton() - .setSizeUndefined(); - } - } - }); - grid.addComponent(new Label("Grid cell 1")); - grid.addComponent(new Label("Grid cell 2")); - grid.addComponent(grow); - grid.addComponent(new Label("Grid cell 4")); - l.addComponent(grid); - // l.addComponent(new TextField("Some field")); - } + event -> { + GridLayout grid = new GridLayout(2, 2); + Button grow = new Button("Grow Me", + event2 -> { + if (event2.getButton().getWidth() == -1) { + event2.getButton().setHeight("50px"); + event2.getButton().setWidth("200px"); + } else { + event2.getButton().setSizeUndefined(); + } + }); + grid.addComponent(new Label("Grid cell 1")); + grid.addComponent(new Label("Grid cell 2")); + grid.addComponent(grow); + grid.addComponent(new Label("Grid cell 4")); + l.addComponent(grid); + // l.addComponent(new TextField("Some field")); }); header.addComponent(addComponent); Button removeComponent = new Button("Remove Component", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Component last = l - .getComponent(l.getComponentCount() - 1); - l.removeComponent(last); - } + event -> { + Component last = l.getComponent(l.getComponentCount() - 1); + l.removeComponent(last); }); header.addComponent(removeComponent); @@ -171,28 +154,22 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { final NativeSelect width = new NativeSelect(null, sizes); width.setImmediate(true); - width.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (width.getValue() != null) { - l.setWidth(width.getValue().toString()); - } else { - l.setWidth(null); - } + width.addValueChangeListener(event -> { + if (width.getValue() != null) { + l.setWidth(width.getValue().toString()); + } else { + l.setWidth(null); } }); layout.addComponent(width); layout.addComponent(new Label("×", ContentMode.HTML)); final NativeSelect height = new NativeSelect(null, sizes); height.setImmediate(true); - height.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (height.getValue() != null) { - l.setHeight(height.getValue().toString()); - } else { - l.setHeight(null); - } + height.addValueChangeListener(event -> { + if (height.getValue() != null) { + l.setHeight(height.getValue().toString()); + } else { + l.setHeight(null); } }); layout.addComponent(height); @@ -229,14 +206,11 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { align.setEnabled(false); align.setNullSelectionAllowed(false); align.select(Alignment.TOP_LEFT); - align.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (target == null) { - return; - } - l.setComponentAlignment(target, (Alignment) align.getValue()); + align.addValueChangeListener(event -> { + if (target == null) { + return; } + l.setComponentAlignment(target, (Alignment) align.getValue()); }); cell.addComponent(align); @@ -261,17 +235,14 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { componentWidth = new NativeSelect(null, sizes); componentWidth.setImmediate(true); componentWidth.setEnabled(false); - componentWidth.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (target == null) { - return; - } - if (componentWidth.getValue() != null) { - target.setWidth(componentWidth.getValue().toString()); - } else { - target.setWidth(null); - } + componentWidth.addValueChangeListener(event -> { + if (target == null) { + return; + } + if (componentWidth.getValue() != null) { + target.setWidth(componentWidth.getValue().toString()); + } else { + target.setWidth(null); } }); component.addComponent(componentWidth); @@ -280,14 +251,11 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { componentHeight = new NativeSelect(null, sizes); componentHeight.setImmediate(true); componentHeight.setEnabled(false); - componentHeight.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (componentHeight.getValue() != null) { - target.setHeight(componentHeight.getValue().toString()); - } else { - target.setHeight(null); - } + componentHeight.addValueChangeListener(event -> { + if (componentHeight.getValue() != null) { + target.setHeight(componentHeight.getValue().toString()); + } else { + target.setHeight(null); } }); component.addComponent(componentHeight); @@ -296,14 +264,11 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { Arrays.asList("Short", "Slightly Longer Caption")); componentCaption.setImmediate(true); componentCaption.setEnabled(false); - componentCaption.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (componentCaption.getValue() != null) { - target.setCaption(componentCaption.getValue().toString()); - } else { - target.setCaption(null); - } + componentCaption.addValueChangeListener(event -> { + if (componentCaption.getValue() != null) { + target.setCaption(componentCaption.getValue().toString()); + } else { + target.setCaption(null); } }); component.addComponent(componentCaption); @@ -313,15 +278,12 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { "../runo/icons/32/document.png")); componentIcon.setImmediate(true); componentIcon.setEnabled(false); - componentIcon.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (componentIcon.getValue() != null) { - target.setIcon(new ThemeResource( - componentIcon.getValue().toString())); - } else { - target.setIcon(null); - } + componentIcon.addValueChangeListener(event -> { + if (componentIcon.getValue() != null) { + target.setIcon( + new ThemeResource(componentIcon.getValue().toString())); + } else { + target.setIcon(null); } }); component.addComponent(componentIcon); @@ -329,12 +291,8 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { componentDescription = new TextField("Description"); componentDescription.setImmediate(true); componentDescription.setEnabled(false); - componentDescription.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - target.setDescription(componentDescription.getValue()); - } - }); + componentDescription.addValueChangeListener(event -> target + .setDescription(componentDescription.getValue())); component.addComponent(componentDescription); componentError = new CheckBox("Error"); @@ -375,64 +333,61 @@ public class BoxLayoutTest extends AbstractReindeerTestUI { l.addComponent(label); l.addComponent(new Button("Component 2")); - l.addLayoutClickListener(new LayoutClickListener() { - @Override - public void layoutClick(LayoutClickEvent event) { - if (event.getChildComponent() == null - || target == event.getChildComponent()) { - if (target != null) { - target.removeStyleName("target"); - } - target = null; - } else if (target != event.getChildComponent()) { - if (target != null) { - target.removeStyleName("target"); - } - target = (AbstractComponent) event.getChildComponent(); - target.addStyleName("target"); + l.addLayoutClickListener(event -> { + if (event.getChildComponent() == null + || target == event.getChildComponent()) { + if (target != null) { + target.removeStyleName("target"); } - componentWidth.setEnabled(target != null); - componentHeight.setEnabled(target != null); - componentCaption.setEnabled(target != null); - componentIcon.setEnabled(target != null); - componentDescription.setEnabled(target != null); - componentError.setEnabled(target != null); - componentRequired.setEnabled( - target != null && target instanceof AbstractField); - align.setEnabled(target != null); - expand.setEnabled(target != null); + target = null; + } else if (target != event.getChildComponent()) { if (target != null) { - if (target.getWidth() > -1) { - componentWidth - .select(new Float(target.getWidth()).intValue() - + target.getWidthUnits().getSymbol()); - } else { - componentWidth.select(null); - } - if (target.getHeight() > -1) { - componentHeight - .select(new Float(target.getHeight()).intValue() - + target.getHeightUnits().getSymbol()); - } else { - componentHeight.select(null); - } - - align.select(l.getComponentAlignment(target)); - expand.setValue(new Boolean(l.getExpandRatio(target) > 0)); - - componentCaption.select(target.getCaption()); - if (target.getIcon() != null) { - componentIcon.select(((ThemeResource) target.getIcon()) - .getResourceId()); - } else { - componentIcon.select(null); - } - componentDescription.setValue(target.getDescription()); - componentError.setValue(target.getComponentError() != null); - if (target instanceof AbstractField) { - componentRequired.setValue( - ((AbstractField<?>) target).isRequired()); - } + target.removeStyleName("target"); + } + target = (AbstractComponent) event.getChildComponent(); + target.addStyleName("target"); + } + componentWidth.setEnabled(target != null); + componentHeight.setEnabled(target != null); + componentCaption.setEnabled(target != null); + componentIcon.setEnabled(target != null); + componentDescription.setEnabled(target != null); + componentError.setEnabled(target != null); + componentRequired.setEnabled( + target != null && target instanceof AbstractField); + align.setEnabled(target != null); + expand.setEnabled(target != null); + if (target != null) { + if (target.getWidth() > -1) { + componentWidth + .select(new Float(target.getWidth()).intValue() + + target.getWidthUnits().getSymbol()); + } else { + componentWidth.select(null); + } + if (target.getHeight() > -1) { + componentHeight + .select(new Float(target.getHeight()).intValue() + + target.getHeightUnits().getSymbol()); + } else { + componentHeight.select(null); + } + + align.select(l.getComponentAlignment(target)); + expand.setValue(new Boolean(l.getExpandRatio(target) > 0)); + + componentCaption.select(target.getCaption()); + if (target.getIcon() != null) { + componentIcon.select( + ((ThemeResource) target.getIcon()).getResourceId()); + } else { + componentIcon.select(null); + } + componentDescription.setValue(target.getDescription()); + componentError.setValue(target.getComponentError() != null); + if (target instanceof AbstractField) { + componentRequired + .setValue(((AbstractField<?>) target).isRequired()); } } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/CaptionLeak.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/CaptionLeak.java index e3ebb67cd6..848c0309a1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/CaptionLeak.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/CaptionLeak.java @@ -49,20 +49,15 @@ public class CaptionLeak extends AbstractReindeerTestUI { final Class<? extends ComponentContainer> targetClass) { Button btn = new Button(caption); btn.setId(caption); - btn.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - try { - ComponentContainer target = targetClass.newInstance(); - for (int i = 0; i < 61; i++) { - target.addComponent(new TextField("Test")); - } - parent.setContent(target); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); + btn.addClickListener(event -> { + try { + ComponentContainer target = targetClass.newInstance(); + for (int i = 0; i < 61; i++) { + target.addComponent(new TextField("Test")); } + parent.setContent(target); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException(e); } }); return btn; diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ExpandChangeReattach.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ExpandChangeReattach.java index 9287aae2b0..8b3781277f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ExpandChangeReattach.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ExpandChangeReattach.java @@ -20,7 +20,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -34,14 +33,11 @@ public class ExpandChangeReattach extends AbstractReindeerTestUI { Table table = new Table("Table", TestUtils.getISO3166Container()); verticalLayout.addComponent(table); verticalLayout.addComponent( - new Button("Toggle expand logic", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (verticalLayout.getHeight() == -1) { - verticalLayout.setHeight("900px"); - } else { - verticalLayout.setHeight(null); - } + new Button("Toggle expand logic", event -> { + if (verticalLayout.getHeight() == -1) { + verticalLayout.setHeight("900px"); + } else { + verticalLayout.setHeight(null); } })); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java index 358a7ccc6c..efea634afd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java @@ -5,8 +5,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.ui.TextField; @@ -42,13 +40,10 @@ public class HorizontalLayoutFullsizeContentWithErrorMsg Button toggleError = new Button("Toggle error"); toggleError.setId(BUTTON_ID); - toggleError.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + toggleError.addClickListener(event -> tf.setComponentError(tf.getComponentError() == null - ? new UserError("foo") : null); - } - }); + ? new UserError("foo") + : null)); hl.addComponent(toggleError); addComponent(hl); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/InsertComponentInHorizontalLayout.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/InsertComponentInHorizontalLayout.java index 193e6327e1..97718e4b0a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/InsertComponentInHorizontalLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/InsertComponentInHorizontalLayout.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; @@ -31,23 +29,14 @@ public class InsertComponentInHorizontalLayout extends AbstractReindeerTestUI { private Component getTestLayout() { ComboBox a = new ComboBox("initial"); - Button b = new Button("x", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.markAsDirty(); - } - }); + Button b = new Button("x", event -> layout.markAsDirty()); final HorizontalLayout hl = new HorizontalLayout(a, b); hl.setSpacing(true); Button add = new Button( "Insert 2 comboboxes between combobox(es) and button 'x'"); - add.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(new ComboBox("Added " + added++), 1); - hl.addComponent(new ComboBox("Added " + added++), 2); - } + add.addClickListener(event -> { + hl.addComponent(new ComboBox("Added " + added++), 1); + hl.addComponent(new ComboBox("Added " + added++), 2); }); layout = new VerticalLayout(hl, add); return layout; diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java index f55db0d0ee..7e1bc91a0b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.orderedlayout; import java.util.Arrays; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; @@ -58,27 +56,22 @@ public class LayoutClickListenerTest extends TestBase { layout.addComponent(nestedLayout); // Listen for layout click events - layout.addLayoutClickListener(new LayoutClickListener() { - @Override - public void layoutClick(LayoutClickEvent event) { - - // Get the deepest nested component which was clicked - Component clickedComponent = event.getClickedComponent(); - - if (clickedComponent == null) { - // Not over any child component - LayoutClickListenerTest.this.addComponent( - new Label("The click was not over any component.")); - } else { - // Over a child component - String message = "The click was over a " - + clickedComponent.getClass().getCanonicalName() - + " in an immediate child component of type " - + event.getChildComponent().getClass() - .getCanonicalName(); - LayoutClickListenerTest.this - .addComponent(new Label(message)); - } + layout.addLayoutClickListener(event -> { + // Get the deepest nested component which was clicked + Component clickedComponent = event.getClickedComponent(); + + if (clickedComponent == null) { + // Not over any child component + LayoutClickListenerTest.this.addComponent( + new Label("The click was not over any component.")); + } else { + // Over a child component + String message = "The click was over a " + + clickedComponent.getClass().getCanonicalName() + + " in an immediate child component of type " + + event.getChildComponent().getClass() + .getCanonicalName(); + LayoutClickListenerTest.this.addComponent(new Label(message)); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java index 0d7a4b6628..19be078406 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java @@ -5,7 +5,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; @@ -36,23 +35,14 @@ public class LayoutResizeTest extends TestBase { new Label("<h2>Layout resize test</h2>", ContentMode.HTML)); Button resize = new Button("Resize to 700x400", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - event.getButton().getUI().getPage().getJavaScript() + event -> event.getButton().getUI().getPage().getJavaScript() .execute( - "setTimeout(function() {window.resizeTo(700,400)}, 500)"); - } - }); + "setTimeout(function() {window.resizeTo(700,400)}, 500)")); left.addComponent(resize); - resize = new Button("Resize to 900x600", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + resize = new Button("Resize to 900x600", event -> event.getButton().getUI().getPage().getJavaScript().execute( - "setTimeout(function() {window.resizeTo(900,600)}, 500)"); - } - }); + "setTimeout(function() {window.resizeTo(900,600)}, 500)")); left.addComponent(resize); left.addComponent(new Label( diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 71a6ee9f0d..a52a3b4361 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -12,12 +12,9 @@ import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.NativeSelect; @@ -32,50 +29,37 @@ public class OrderedLayoutCases extends AbstractReindeerTestUI { addStyleName("sampleChild"); addStyleName("sampleChild" + i); addComponent(createSimpleSelector("Child width", - new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - setWidth(event.getProperty().getValue().toString()); - } - }, dimensionValues)); + event -> setWidth( + event.getProperty().getValue().toString()), + dimensionValues)); addComponent(createSimpleSelector("Child height", - new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - setHeight( - event.getProperty().getValue().toString()); - } - }, dimensionValues)); + event ->setHeight( + event.getProperty().getValue().toString()) + , dimensionValues)); addComponent( - createSimpleSelector("Caption", new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - String value = event.getProperty().getValue() - .toString(); - if (value.isEmpty()) { - setCaption(null); - } else if (value.equals("Long")) { - setCaption( - "A rather long caption just to see what happens"); - } else { - setCaption(value); - } + createSimpleSelector("Caption", event -> { + String value = event.getProperty().getValue() + .toString(); + if (value.isEmpty()) { + setCaption(null); + } else if (value.equals("Long")) { + setCaption( + "A rather long caption just to see what happens"); + } else { + setCaption(value); } }, "", "Short", "Long")); addComponent(createSimpleSelector("Expand ratio", - new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent(); - if (parent == null) { - return; - } - String value = event.getProperty().getValue() - .toString(); - parent.setExpandRatio(SampleChild.this, - Float.parseFloat(value)); + event -> { + AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent(); + if (parent == null) { + return; } + String value = event.getProperty().getValue() + .toString(); + parent.setExpandRatio(SampleChild.this, + Float.parseFloat(value)); }, "0", "1", "2")); // Why is Alignment not an enum? Now we have to use reflection just @@ -88,25 +72,22 @@ public class OrderedLayoutCases extends AbstractReindeerTestUI { } } addComponent(createSimpleSelector("Alignment", - new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - String value = event.getProperty().getValue() - .toString(); - AlignmentHandler parent = (AlignmentHandler) getParent(); - if (parent == null) { - return; - } - try { - Field field = Alignment.class - .getDeclaredField(value); - Alignment alignment = (Alignment) field - .get(null); - parent.setComponentAlignment(SampleChild.this, - alignment); - } catch (Exception e) { - throw new RuntimeException(e); - } + event -> { + String value = event.getProperty().getValue() + .toString(); + AlignmentHandler parent = (AlignmentHandler) getParent(); + if (parent == null) { + return; + } + try { + Field field = Alignment.class + .getDeclaredField(value); + Alignment alignment = (Alignment) field + .get(null); + parent.setComponentAlignment(SampleChild.this, + alignment); + } catch (Exception e) { + throw new RuntimeException(e); } }, alignmentValues, "TOP_LEFT")); // Sorry for not using // more reflection magic @@ -136,228 +117,181 @@ public class OrderedLayoutCases extends AbstractReindeerTestUI { sizeBar.setSpacing(true); sizeBar.addComponent( - createSimpleSelector("Layout width", new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - currentLayout.setWidth( - event.getProperty().getValue().toString()); - } - }, dimensionValues)); + createSimpleSelector("Layout width", + event -> currentLayout.setWidth( + event.getProperty().getValue().toString()), + dimensionValues)); sizeBar.addComponent(createSimpleSelector("Layout height", - new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - currentLayout.setHeight( - event.getProperty().getValue().toString()); - } - }, dimensionValues)); + event -> currentLayout + .setHeight(event.getProperty().getValue().toString()), + dimensionValues)); sizeBar.addComponent( - createSimpleSelector("Spacing", new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { + createSimpleSelector("Spacing", event -> currentLayout.setSpacing(Boolean.parseBoolean( - event.getProperty().getValue().toString())); - } - }, "false", "true")); + event.getProperty().getValue().toString())), "false", + "true")); sizeBar.addComponent( - createSimpleSelector("Margin", new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { + createSimpleSelector("Margin", event -> currentLayout.setMargin(Boolean.parseBoolean( - event.getProperty().getValue().toString())); - } - }, "false", "true")); + event.getProperty().getValue().toString())), "false", + "true")); sizeBar.addComponent( - createSimpleSelector("Direction", new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Object value = event.getProperty().getValue(); - - AbstractOrderedLayout newLayout; - if (value.equals("Horizontal")) { - newLayout = new HorizontalLayout(); - } else { - newLayout = new VerticalLayout(); - } + createSimpleSelector("Direction", event -> { + Object value = event.getProperty().getValue(); + + AbstractOrderedLayout newLayout; + if (value.equals("Horizontal")) { + newLayout = new HorizontalLayout(); + } else { + newLayout = new VerticalLayout(); + } - while (currentLayout.getComponentCount() > 0) { - Component child = currentLayout.getComponent(0); - Alignment alignment = currentLayout - .getComponentAlignment(child); - float expRatio = currentLayout - .getExpandRatio(child); - newLayout.addComponent(child); - newLayout.setExpandRatio(child, expRatio); - newLayout.setComponentAlignment(child, alignment); + while (currentLayout.getComponentCount() > 0) { + Component child = currentLayout.getComponent(0); + Alignment alignment = currentLayout + .getComponentAlignment(child); + float expRatio = currentLayout.getExpandRatio(child); + newLayout.addComponent(child); + newLayout.setExpandRatio(child, expRatio); + newLayout.setComponentAlignment(child, alignment); - } - newLayout.setStyleName("theLayout"); + } + newLayout.setStyleName("theLayout"); - newLayout.setHeight(currentLayout.getHeight(), - currentLayout.getHeightUnits()); - newLayout.setWidth(currentLayout.getWidth(), - currentLayout.getWidthUnits()); + newLayout.setHeight(currentLayout.getHeight(), + currentLayout.getHeightUnits()); + newLayout.setWidth(currentLayout.getWidth(), + currentLayout.getWidthUnits()); - newLayout.setMargin(currentLayout.getMargin()); - newLayout.setSpacing(currentLayout.isSpacing()); + newLayout.setMargin(currentLayout.getMargin()); + newLayout.setSpacing(currentLayout.isSpacing()); - getLayout().replaceComponent(currentLayout, newLayout); - getLayout().setExpandRatio(newLayout, 1); - currentLayout = newLayout; - } + getLayout().replaceComponent(currentLayout, newLayout); + getLayout().setExpandRatio(newLayout, 1); + currentLayout = newLayout; }, "Horizontal", "Vertical")); HorizontalLayout caseBar = new HorizontalLayout(); caseBar.addComponent( - new Button("Undefined without relative", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - setState(sizeBar, 2, 1); - // width: 350px to middle child - setChildState(1, 0, 2); - // middle center allign to middle child - setChildState(1, 4, 5); - // long captions to right child - setChildState(2, 2, 2); - } + new Button("Undefined without relative", event -> { + resetState(); + setState(sizeBar, 2, 1); + // width: 350px to middle child + setChildState(1, 0, 2); + // middle center allign to middle child + setChildState(1, 4, 5); + // long captions to right child + setChildState(2, 2, 2); })); caseBar.addComponent( - new Button("Undefined with relative", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // width: 100% to middle child - setChildState(1, 0, 4); - } + new Button("Undefined with relative", event -> { + resetState(); + // width: 100% to middle child + setChildState(1, 0, 4); })); caseBar.addComponent( - new Button("Fixed with overflow", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // layout width: 350px - setState(sizeBar, 0, 2); - // layout margin enabled - setState(sizeBar, 3, 1); - } + new Button("Fixed with overflow", event -> { + resetState(); + // layout width: 350px + setState(sizeBar, 0, 2); + // layout margin enabled + setState(sizeBar, 3, 1); })); caseBar.addComponent( - new Button("Fixed with extra space", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Layout width: 800px - setState(sizeBar, 0, 3); - // layout margin enabled - setState(sizeBar, 3, 1); - // width: 350px to middle child - setChildState(1, 0, 2); - // short caption for middle child - setChildState(1, 2, 1); - // top center align for middle child - setChildState(1, 4, 2); - } + new Button("Fixed with extra space", event -> { + resetState(); + // Layout width: 800px + setState(sizeBar, 0, 3); + // layout margin enabled + setState(sizeBar, 3, 1); + // width: 350px to middle child + setChildState(1, 0, 2); + // short caption for middle child + setChildState(1, 2, 1); + // top center align for middle child + setChildState(1, 4, 2); })); caseBar.addComponent( - new Button("Expand with alignment", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Layout width: 800px - setState(sizeBar, 0, 3); - // Layout height: 350px - setState(sizeBar, 1, 2); - // Expand: 1 to middle child - setChildState(1, 3, 1); - // Align bottom left to middle child - setChildState(1, 4, 6); - // Long caption to middle child - setChildState(1, 2, 2); - } + new Button("Expand with alignment", event -> { + resetState(); + // Layout width: 800px + setState(sizeBar, 0, 3); + // Layout height: 350px + setState(sizeBar, 1, 2); + // Expand: 1 to middle child + setChildState(1, 3, 1); + // Align bottom left to middle child + setChildState(1, 4, 6); + // Long caption to middle child + setChildState(1, 2, 2); })); caseBar.addComponent( - new Button("Multiple expands", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Layout width: 800px - setState(sizeBar, 0, 3); - // Layout height: 350px - setState(sizeBar, 1, 2); - // Long caption to left child - setChildState(0, 2, 2); - // Width 350px to middle child - setChildState(1, 0, 2); - // Apply to left and middle child - for (int i = 0; i < 2; i++) { - // Expand: 1 - setChildState(i, 3, 1); - // Align: middle center - setChildState(i, 4, 5); - } + new Button("Multiple expands", event -> { + resetState(); + // Layout width: 800px + setState(sizeBar, 0, 3); + // Layout height: 350px + setState(sizeBar, 1, 2); + // Long caption to left child + setChildState(0, 2, 2); + // Width 350px to middle child + setChildState(1, 0, 2); + // Apply to left and middle child + for (int i = 0; i < 2; i++) { + // Expand: 1 + setChildState(i, 3, 1); + // Align: middle center + setChildState(i, 4, 5); } })); caseBar.addComponent( - new Button("Fixed + relative height", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Layout height: 100% - setState(sizeBar, 1, 4); - // Height: 350px to left child - setChildState(0, 1, 2); - // Height: 100% to middle child - setChildState(1, 1, 4); - // Short caption to middle child - setChildState(1, 2, 1); - // Alignment: bottom left to right child - setChildState(2, 4, 7); - } + new Button("Fixed + relative height", event -> { + resetState(); + // Layout height: 100% + setState(sizeBar, 1, 4); + // Height: 350px to left child + setChildState(0, 1, 2); + // Height: 100% to middle child + setChildState(1, 1, 4); + // Short caption to middle child + setChildState(1, 2, 1); + // Alignment: bottom left to right child + setChildState(2, 4, 7); })); caseBar.addComponent( - new Button("Undefined + relative height", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Height: 350px to left child - setChildState(0, 1, 2); - // Short caption to left child - setChildState(0, 2, 1); - // Height: 100% to middle child - setChildState(1, 1, 4); - } + new Button("Undefined + relative height", event -> { + resetState(); + // Height: 350px to left child + setChildState(0, 1, 2); + // Short caption to left child + setChildState(0, 2, 1); + // Height: 100% to middle child + setChildState(1, 1, 4); })); caseBar.addComponent( - new Button("Undefined + alignments", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Height: 350px to left child - setChildState(0, 1, 2); - // Short caption to left child - setChildState(0, 2, 1); - // Alignment: bottom left to right child - setChildState(2, 4, 7); - } + new Button("Undefined + alignments", event -> { + resetState(); + // Height: 350px to left child + setChildState(0, 1, 2); + // Short caption to left child + setChildState(0, 2, 1); + // Alignment: bottom left to right child + setChildState(2, 4, 7); })); caseBar.addComponent(new Button("Relative child without expand", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - resetState(); - // Width 800px - setState(sizeBar, 0, 3); - // First child 100% wide - setChildState(0, 0, 4); - // Second child expand 1 - setChildState(1, 3, 1); - } + event -> { + resetState(); + // Width 800px + setState(sizeBar, 0, 3); + // First child 100% wide + setChildState(0, 0, 4); + // Second child expand 1 + setChildState(1, 3, 1); })); /* * Hidden for not to avoid changing screenshots, functionality is still diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutComponentOrdering.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutComponentOrdering.java index 114445c5ba..868995b167 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutComponentOrdering.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutComponentOrdering.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; public class OrderedLayoutComponentOrdering extends TestBase { @@ -21,52 +20,34 @@ public class OrderedLayoutComponentOrdering extends TestBase { addComponent(hl); Button addFirst = new Button("add first"); - addFirst.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(new Button(String.valueOf(++counter)), 0); - hl.addComponent(new Button(String.valueOf(++counter)), 1); - } + addFirst.addClickListener(event -> { + hl.addComponent(new Button(String.valueOf(++counter)), 0); + hl.addComponent(new Button(String.valueOf(++counter)), 1); }); addComponent(addFirst); Button add = new Button("add second"); - add.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(new Button(String.valueOf(++counter)), 1); - hl.addComponent(new Button(String.valueOf(++counter)), 2); - } + add.addClickListener(event -> { + hl.addComponent(new Button(String.valueOf(++counter)), 1); + hl.addComponent(new Button(String.valueOf(++counter)), 2); }); addComponent(add); Button addThird = new Button("add third"); - addThird.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(new Button(String.valueOf(++counter)), 2); - hl.addComponent(new Button(String.valueOf(++counter)), 3); - } + addThird.addClickListener(event -> { + hl.addComponent(new Button(String.valueOf(++counter)), 2); + hl.addComponent(new Button(String.valueOf(++counter)), 3); }); addComponent(addThird); Button move = new Button("move last to first"); - move.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + move.addClickListener(event -> hl.addComponentAsFirst( - hl.getComponent(hl.getComponentCount() - 1)); - } - }); + hl.getComponent(hl.getComponentCount() - 1))); addComponent(move); Button swap = new Button("move forth to second"); - swap.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(hl.getComponent(3), 1); - } - }); + swap.addClickListener(event -> hl.addComponent(hl.getComponent(3), 1)); addComponent(swap); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutInfiniteLayoutPasses.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutInfiniteLayoutPasses.java index 07ed21d121..0f91a4874a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutInfiniteLayoutPasses.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutInfiniteLayoutPasses.java @@ -4,8 +4,6 @@ import com.vaadin.server.Page; import com.vaadin.server.Page.Styles; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -28,13 +26,8 @@ public class OrderedLayoutInfiniteLayoutPasses extends UI { private Button createOpenWindowButton() { Button button = new Button("Open modal window"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().addWindow(createWindow()); - } - }); + button.addClickListener( + event -> UI.getCurrent().addWindow(createWindow())); return button; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java index 85db5dd22d..9138351120 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/RelativeChildrenWithoutExpand.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -25,12 +24,8 @@ public class RelativeChildrenWithoutExpand extends AbstractReindeerTestUI { HorizontalLayout verticalExpand = new HorizontalLayout(); verticalExpand.addComponent( - new Button("Add relative child", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - horizontalExpand.addComponent(new Label(loremIpsum), 0); - } - })); + new Button("Add relative child", event -> horizontalExpand + .addComponent(new Label(loremIpsum), 0))); vl.addComponent(verticalExpand); vl.setExpandRatio(verticalExpand, 1); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java index f18fb39fda..6a8b37db3e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; public class ReplaceComponentNPE extends TestBase { @@ -25,12 +24,9 @@ public class ReplaceComponentNPE extends TestBase { outer.setMargin(true); Button changer = new Button("ReplaceComponent"); - changer.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getLayout().replaceComponent(button, outer); - outer.addComponent(button); - } + changer.addClickListener(event -> { + getLayout().replaceComponent(button, outer); + outer.addComponent(button); }); getLayout().addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/SpacingLeak.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/SpacingLeak.java index 0705a14ee4..428a5860b6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/SpacingLeak.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/SpacingLeak.java @@ -26,29 +26,22 @@ public class SpacingLeak extends UI { final Button spacingButton = new Button("Add layout with spacing"); spacingButton.setId("addbutton"); root.addComponent(spacingButton); - spacingButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - spacingLayout = new HorizontalLayout(); - spacingLayout.setSpacing(true); - spacingLayout.setWidth("100%"); - - for (int i = 0; i < 100; ++i) { - spacingLayout.addComponent(new Button("" + i)); - } - - root.addComponent(spacingLayout); + spacingButton.addClickListener(event -> { + spacingLayout = new HorizontalLayout(); + spacingLayout.setSpacing(true); + spacingLayout.setWidth("100%"); + + for (int i = 0; i < 100; ++i) { + spacingLayout.addComponent(new Button("" + i)); } + + root.addComponent(spacingLayout); }); final Button removeButton = new Button("Remove layouts"); removeButton.setId("removebutton"); root.addComponent(removeButton); - removeButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - root.removeComponent(spacingLayout); - } - }); + removeButton + .addClickListener(event -> root.removeComponent(spacingLayout)); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java index 8f6a72c0f1..d32d7d3ee5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.VerticalLayout; @@ -43,13 +42,7 @@ public class VerticalLayoutWidthCalculation extends AbstractTestCase { Window wnd = new Window("Test", layout); layout.addComponent(hl); Button btn = new Button("Show/hide"); - btn.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tf2.setVisible(!tf2.isVisible()); - } - }); + btn.addClickListener(event -> tf2.setVisible(!tf2.isVisible())); layout.addComponent(btn); return wnd; diff --git a/uitest/src/main/java/com/vaadin/tests/components/page/PageReload.java b/uitest/src/main/java/com/vaadin/tests/components/page/PageReload.java index 033da4e0e8..85febade1e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/page/PageReload.java +++ b/uitest/src/main/java/com/vaadin/tests/components/page/PageReload.java @@ -2,19 +2,12 @@ package com.vaadin.tests.components.page; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; public class PageReload extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - addButton("Press to reload", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().reload(); - } - }); + addButton("Press to reload", event -> getPage().reload()); log("UI id: " + getUIId()); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java index 0e17a1729b..64a003babe 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java +++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java @@ -1,7 +1,5 @@ package com.vaadin.tests.components.panel; -import com.vaadin.event.MouseEvents.ClickEvent; -import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; @@ -13,14 +11,8 @@ public class PanelClickListenerRelativeCoordinates extends TestBase { VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setMargin(true); Panel panel = new Panel("Panel's caption", panelLayout); - panel.addClickListener(new ClickListener() { - - @Override - public void click(ClickEvent event) { - getMainWindow().showNotification("" + event.getRelativeX() - + ", " + event.getRelativeY()); - } - }); + panel.addClickListener(event -> getMainWindow().showNotification( + "" + event.getRelativeX() + ", " + event.getRelativeY())); addComponent(panel); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelConcurrentModificationException.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelConcurrentModificationException.java index 9aa173f195..5a56ff9b04 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelConcurrentModificationException.java +++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelConcurrentModificationException.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.panel; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; @@ -18,20 +17,11 @@ public class PanelConcurrentModificationException extends TestBase { panelLayout.setMargin(true); addComponent(new Button("Click here for exception", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - panelLayout.addComponent(new Label("Label")); - } - })); + event -> panelLayout.addComponent(new Label("Label")))); addComponent( - new Button("Or click here first", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + new Button("Or click here first", event -> Notification.show( - "It is now safe to click the other button"); - } - })); + "It is now safe to click the other button"))); addComponent(panel); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListener.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListener.java index 11932ec609..989de708a8 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListener.java +++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListener.java @@ -19,8 +19,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; @@ -61,13 +59,9 @@ public class PanelRemoveShortcutListener extends AbstractReindeerTestUI { private ClickListener createClickListener(final Panel panel, final ShortcutListener shortcut) { - return new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - panel.removeShortcutListener(shortcut); - addComponent(new Label("shortcut removed")); - } + return event -> { + panel.removeShortcutListener(shortcut); + addComponent(new Label("shortcut removed")); }; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java index 991410407c..f8027562e2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java +++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.panel; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; @@ -23,13 +21,10 @@ public class PanelShouldNotScroll extends TestBase { p.setHeight("600px"); pl.addComponent(foo()); addMore = new Button("Add"); - addMore.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - pl.removeComponent(addMore); - pl.addComponent(foo()); - pl.addComponent(addMore); - } + addMore.addClickListener(event -> { + pl.removeComponent(addMore); + pl.addComponent(foo()); + pl.addComponent(addMore); }); pl.addComponent(addMore); addComponent(p); diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldRemoveActionHandler.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldRemoveActionHandler.java index 46ca309518..fc4c1d638d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldRemoveActionHandler.java +++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldRemoveActionHandler.java @@ -9,7 +9,6 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.TextField; @@ -35,33 +34,11 @@ public class PanelShouldRemoveActionHandler extends TestBase { panel = new Panel("A panel", layout); layout.addComponent(new TextField()); Button add = new Button("Add an action handler", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - add(); - } - - }); + event -> add()); Button addAnother = new Button("Add another action handler", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - addAnother(); - } - - }); + event -> addAnother()); Button remove = new Button("Remove an action handler", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - remove(); - } - - }); - + event -> remove()); addComponent(panel); addComponent(add); addComponent(addAnother); diff --git a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewAndFragment.java b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewAndFragment.java index b6ceeb32dc..3f36e425b7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewAndFragment.java +++ b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewAndFragment.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.popupview; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.PopupView; @@ -30,13 +29,10 @@ public class PopupViewAndFragment extends AbstractReindeerTestUI { addComponent(pw); final Button button = new Button("Open and change fragment", - new Button.ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - pw.setPopupVisible(true); - getPage().setUriFragment( - String.valueOf(System.currentTimeMillis())); - } + event -> { + pw.setPopupVisible(true); + getPage().setUriFragment( + String.valueOf(System.currentTimeMillis())); }); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewNullValues.java b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewNullValues.java index 0ac0e8e433..80840c8088 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewNullValues.java +++ b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewNullValues.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.popupview; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.ui.PopupView; import com.vaadin.v7.ui.TextField; @@ -18,14 +16,8 @@ public class PopupViewNullValues extends TestBase { try { pv[0] = new PopupView("Popupview 1 - no component", null); addComponent(pv[0]); - b[0] = new Button("Open popupview 1", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pv[0].setPopupVisible(true); - } - - }); + b[0] = new Button("Open popupview 1", + event -> pv[0].setPopupVisible(true)); } catch (Exception e) { getMainWindow().showNotification( "Error, 'null content' should not throw an exception at this point", @@ -36,14 +28,8 @@ public class PopupViewNullValues extends TestBase { pv[1] = new PopupView(null, new TextField("Empty html, contains component")); addComponent(pv[1]); - b[1] = new Button("Open popupview 2", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pv[1].setPopupVisible(true); - } - - }); + b[1] = new Button("Open popupview 2", + event -> pv[1].setPopupVisible(true)); } catch (Exception e) { getMainWindow().showNotification( "Error, 'null html', should not throw an exception at this point", @@ -53,14 +39,8 @@ public class PopupViewNullValues extends TestBase { try { pv[2] = new PopupView(null, null); addComponent(pv[2]); - b[2] = new Button("Open popupview 3", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pv[2].setPopupVisible(true); - } - - }); + b[2] = new Button("Open popupview 3", + event -> pv[2].setPopupVisible(true)); } catch (Exception e) { getMainWindow().showNotification( "Error, 'null html, null content', should not throw an exception at this point", @@ -70,14 +50,8 @@ public class PopupViewNullValues extends TestBase { pv[3] = new PopupView("Popupview 4 - has component", new TextField("This is the content of popupview 4")); addComponent(pv[3]); - b[3] = new Button("Open popupview 4", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pv[3].setPopupVisible(true); - } - - }); + b[3] = new Button("Open popupview 4", + event -> pv[3].setPopupVisible(true)); } catch (Exception e) { getMainWindow().showNotification( "Error, 'null html, null content', should not throw an exception at this point", diff --git a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewOffScreen.java b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewOffScreen.java index fcc1fb8798..cedada9845 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewOffScreen.java +++ b/uitest/src/main/java/com/vaadin/tests/components/popupview/PopupViewOffScreen.java @@ -7,8 +7,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -40,13 +38,9 @@ public class PopupViewOffScreen extends TestBase { gl.setColumnExpandRatio(1, 1); gl.setRowExpandRatio(1, 1); - Button showall = new Button("Popup all", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - for (PopupView pv : popupViews) { - pv.setPopupVisible(true); - } + Button showall = new Button("Popup all", event -> { + for (PopupView pv : popupViews) { + pv.setPopupVisible(true); } }); gl.addComponent(showall, 1, 0); diff --git a/uitest/src/main/java/com/vaadin/tests/components/popupview/ReopenPopupView.java b/uitest/src/main/java/com/vaadin/tests/components/popupview/ReopenPopupView.java index 391ee216bd..1ace6d84c1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/popupview/ReopenPopupView.java +++ b/uitest/src/main/java/com/vaadin/tests/components/popupview/ReopenPopupView.java @@ -19,7 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.PopupView; public class ReopenPopupView extends AbstractReindeerTestUI { @@ -29,12 +28,7 @@ public class ReopenPopupView extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { addComponent(log); addComponent(new PopupView("PopupView", - new Button("Button", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.log("Button clicked"); - } - }))); + new Button("Button", event -> log.log("Button clicked")))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressBarTest.java b/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressBarTest.java index 0b14fbf6ae..c8a4c13970 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressBarTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressBarTest.java @@ -19,7 +19,6 @@ package com.vaadin.tests.components.progressindicator; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.ProgressBar; @@ -31,12 +30,9 @@ public class ProgressBarTest extends AbstractReindeerTestUI { private Thread updateThread = new Thread() { @Override public void run() { - Runnable updateTask = new Runnable() { - @Override - public void run() { - counter++; - updateLabel(); - } + Runnable updateTask = () -> { + counter++; + updateLabel(); }; while (true) { @@ -59,28 +55,15 @@ public class ProgressBarTest extends AbstractReindeerTestUI { updateLabel(); addComponent(updatedFromBackround); - addComponent(new Button("Use ProgressBar", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - useComponent(new ProgressBar()); - } - })); + addComponent(new Button("Use ProgressBar", + event -> useComponent(new ProgressBar()))); addComponent( - new Button("Use ProgressIndicator", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - useComponent(new ProgressIndicator()); - } - })); + new Button("Use ProgressIndicator", + event -> useComponent(new ProgressIndicator()))); addComponent(new Button("Stop background thread", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - stopUpdateThread(); - } - })); + event -> stopUpdateThread())); updateThread.setDaemon(true); updateThread.start(); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java b/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java index c3f99dff0a..91b6fccb3d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java +++ b/uitest/src/main/java/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.progressindicator; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.ProgressIndicator; @@ -20,48 +18,32 @@ public class ProgressIndicatorInvisible extends TestBase { lo.addComponent(pi); Button hideProgressIndicator = new Button("Hide progress indicator", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pi.setVisible(!pi.isVisible()); - event.getButton() - .setCaption((pi.isVisible() ? "Hide" : "Show") - + " progress indicator"); - - } + event -> { + pi.setVisible(!pi.isVisible()); + event.getButton() + .setCaption((pi.isVisible() ? "Hide" : "Show") + + " progress indicator"); }); addComponent(hideProgressIndicator); Button disableProgressIndicator = new Button( - "Disable progress indicator", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - pi.setEnabled(!pi.isEnabled()); - event.getButton().setCaption( - (pi.isEnabled() ? "Disable" : "Enable") - + " progress indicator"); - - } + "Disable progress indicator", event -> { + pi.setEnabled(!pi.isEnabled()); + event.getButton() + .setCaption((pi.isEnabled() ? "Disable" : "Enable") + + " progress indicator"); }); addComponent(disableProgressIndicator); Button removeProgressIndicator = new Button("Remove progress indicator", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (pi.getParent() != null) { - lo.removeComponent(pi); - event.getButton() - .setCaption("Add progress indicator"); - } else { - lo.addComponent(pi); - event.getButton() - .setCaption("Remove progress indicator"); - } - + event -> { + if (pi.getParent() != null) { + lo.removeComponent(pi); + event.getButton().setCaption("Add progress indicator"); + } else { + lo.addComponent(pi); + event.getButton() + .setCaption("Remove progress indicator"); } }); @@ -69,15 +51,10 @@ public class ProgressIndicatorInvisible extends TestBase { final Button b = new Button("Hide container of progress indicator"); addComponent(b); - b.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - lo.setVisible(!lo.isVisible()); - b.setCaption((lo.isVisible() ? "Hide" : "Show") - + " container of progress indicator"); - - } - + b.addClickListener(event -> { + lo.setVisible(!lo.isVisible()); + b.setCaption((lo.isVisible() ? "Hide" : "Show") + + " container of progress indicator"); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java b/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java index ef531b9f8e..ed9311fc07 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java +++ b/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.richtextarea; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.RichTextArea; @@ -27,13 +25,8 @@ public class RichTextAreaEmptyString extends TestBase { final Label l = new Label(area.getValue(), ContentMode.PREFORMATTED); l.setCaption("Value recieved from RichTextArea:"); - final Button b = new Button("get area value", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l.setValue(area.getValue()); - } - }); + final Button b = new Button("get area value", + event -> l.setValue(area.getValue())); addComponent(area); addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java b/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java index 44ffa529b4..c769fe02c0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.richtextarea; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.RichTextArea; import com.vaadin.ui.VerticalLayout; @@ -35,12 +34,8 @@ public class RichTextAreaRelativeHeightResize extends AbstractReindeerTestUI { layout.addComponent(richTextArea); addComponent(layout); - addComponent(new Button("Increase height", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.setHeight("400px"); - } - })); + addComponent(new Button("Increase height", + event -> layout.setHeight("400px"))); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java b/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java index d343d9d85e..39a7620c44 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.select; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.ComboBox; /** @@ -21,12 +19,7 @@ public class ComboBoxAddWhileFiltering extends TestBase { populate(comboBox); Button b = new Button("add item (^N)"); - b.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addItem(comboBox); - } - }); + b.addClickListener(event -> addItem(comboBox)); addComponent(b); addComponent(comboBox); getMainWindow().addAction(new Button.ClickShortcut(b, "^n")); diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/FocusListenerBreaksDropdownMenu.java b/uitest/src/main/java/com/vaadin/tests/components/select/FocusListenerBreaksDropdownMenu.java index bb84b9df2f..a14e5672a2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/FocusListenerBreaksDropdownMenu.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/FocusListenerBreaksDropdownMenu.java @@ -1,6 +1,5 @@ package com.vaadin.tests.components.select; -import com.vaadin.event.FieldEvents; import com.vaadin.tests.components.TestBase; import com.vaadin.v7.ui.ComboBox; @@ -13,12 +12,7 @@ public class FocusListenerBreaksDropdownMenu extends TestBase { comboBox.addItem("Item " + i); } - comboBox.addFocusListener(new FieldEvents.FocusListener() { - @Override - public void focus(FieldEvents.FocusEvent event) { - comboBox.addItem(); - } - }); + comboBox.addFocusListener(event -> comboBox.addItem()); comboBox.setImmediate(true); addComponent(comboBox); diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/NullSelectionItemId.java b/uitest/src/main/java/com/vaadin/tests/components/select/NullSelectionItemId.java index 6f7a837057..102ffe4426 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/NullSelectionItemId.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/NullSelectionItemId.java @@ -35,23 +35,13 @@ public class NullSelectionItemId extends TestBase implements ClickListener { button = new Button( "Select null with select(NULL_ITEM_ID) (should make value null)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - mySelect.select(NULL_ITEM_ID); - } - }); + event -> mySelect.select(NULL_ITEM_ID)); addComponent(button); button = new Button( "Select null with setValue(null) (should make value null)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - mySelect.setValue(null); - } - }); + event -> mySelect.setValue(null)); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/StylingPopupOpener.java b/uitest/src/main/java/com/vaadin/tests/components/select/StylingPopupOpener.java index 3ebd217818..2b5404944b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/StylingPopupOpener.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/StylingPopupOpener.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.select; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Select; public class StylingPopupOpener extends TestBase { @@ -16,12 +15,8 @@ public class StylingPopupOpener extends TestBase { final Select select = new Select(); addComponent(select); - addComponent(new Button("Update style", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - select.setStyleName("mystyle"); - } - })); + addComponent(new Button("Update style", + event -> select.setStyleName("mystyle"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java b/uitest/src/main/java/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java index 6491651c4b..b8f5e520b2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.select; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.TwinColSelect; public class TwinColSelectCaptionStyles extends TestBase { @@ -19,14 +18,9 @@ public class TwinColSelectCaptionStyles extends TestBase { addComponent(sel); Button b = new Button("Set height and width to 500px", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - sel.setHeight("500px"); - sel.setWidth("500px"); - - } + event -> { + sel.setHeight("500px"); + sel.setWidth("500px"); }); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderDisable.java b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderDisable.java index 7ea741bc83..400bcaccdf 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderDisable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderDisable.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.slider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Slider; import com.vaadin.ui.VerticalLayout; @@ -37,12 +35,7 @@ public class SliderDisable extends AbstractReindeerTestUI { Button disableButton = new Button("Disable slider"); disableButton.setId("disableButton"); - disableButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - slider.setEnabled(false); - } - }); + disableButton.addClickListener(event -> slider.setEnabled(false)); content.addComponent(slider); content.addComponent(disableButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderPrimaryStyleName.java b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderPrimaryStyleName.java index 1c0716fdce..064813d410 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderPrimaryStyleName.java +++ b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderPrimaryStyleName.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.slider; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Slider; public class SliderPrimaryStyleName extends TestBase { @@ -15,12 +14,8 @@ public class SliderPrimaryStyleName extends TestBase { addComponent(slider); addComponent( - new Button("Change primary style", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - slider.setPrimaryStyleName("my-second-slider"); - } - })); + new Button("Change primary style", event -> slider + .setPrimaryStyleName("my-second-slider"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderResize.java b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderResize.java index 96462b8888..741c198ffb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderResize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderResize.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.slider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Slider; import com.vaadin.ui.VerticalLayout; @@ -37,13 +36,7 @@ public class SliderResize extends AbstractReindeerTestUI { slider.setWidth("100%"); Button changeWidth = new Button("Set layout width to 300px", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.setWidth("300px"); - } - }); + event -> layout.setWidth("300px")); layout.addComponents(slider, changeWidth); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java index ec5357174b..9b1c18d280 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalSplitPanel; public class SplitPanelMoveComponent extends AbstractReindeerTestUI { @@ -32,20 +30,14 @@ public class SplitPanelMoveComponent extends AbstractReindeerTestUI { "Button in splitpanel. Click to move to the other side"); split.setFirstComponent(targetComponent); - targetComponent.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (split.getFirstComponent() != null) { - split.setFirstComponent(null); - split.setSecondComponent(targetComponent); - } else { - split.setSecondComponent(null); - split.setFirstComponent(targetComponent); - - } + targetComponent.addClickListener(event -> { + if (split.getFirstComponent() != null) { + split.setFirstComponent(null); + split.setSecondComponent(targetComponent); + } else { + split.setSecondComponent(null); + split.setFirstComponent(targetComponent); } - }); addComponent(split); diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java index 10d8ea9a85..812dd3e4ef 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java @@ -2,10 +2,7 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.server.Sizeable; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent; -import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.VerticalSplitPanel; @@ -24,14 +21,8 @@ public class SplitPanelReversePosition extends TestBase { final HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setSizeFull(); hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, hsplitReversed); - hsplit.addSplitterClickListener( - new HorizontalSplitPanel.SplitterClickListener() { - @Override - public void splitterClick(SplitterClickEvent event) { - getMainWindow().showNotification( - "Horizontal Splitter Clicked"); - } - }); + hsplit.addSplitterClickListener(event -> getMainWindow() + .showNotification("Horizontal Splitter Clicked")); TextArea area = new TextArea(""); area.setSizeFull(); @@ -40,12 +31,8 @@ public class SplitPanelReversePosition extends TestBase { final VerticalSplitPanel vsplit = new VerticalSplitPanel(); vsplit.setSizeFull(); vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, vsplitReversed); - vsplit.addSplitterClickListener(new SplitterClickListener() { - @Override - public void splitterClick(SplitterClickEvent event) { - getMainWindow().showNotification("Vertical Splitter Clicked"); - } - }); + vsplit.addSplitterClickListener(event -> getMainWindow() + .showNotification("Vertical Splitter Clicked")); hsplit.addComponent(vsplit); addComponent(hsplit); @@ -62,24 +49,17 @@ public class SplitPanelReversePosition extends TestBase { buttons.setSpacing(true); buttons.addComponent(new Button("Swap horizontal positioning", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - hsplitReversed = !hsplitReversed; - hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, - hsplitReversed); - - } + event -> { + hsplitReversed = !hsplitReversed; + hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, + hsplitReversed); })); buttons.addComponent(new Button("Swap vertical positioning", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - vsplitReversed = !vsplitReversed; - vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, - vsplitReversed); - } + event -> { + vsplitReversed = !vsplitReversed; + vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, + vsplitReversed); })); addComponent(buttons); diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java index f8f56f17d6..ab774bbe1d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; @@ -46,18 +45,13 @@ public class SplitPanelSplitterWidth extends TestBase { split2.addComponent(p); getLayout() - .addComponent(new Button("Unlock", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - split.setLocked(false); - split2.setLocked(false); - getMainWindow().showNotification( - "Try moving split. Then reload page.", - Notification.TYPE_WARNING_MESSAGE); - getLayout().removeComponent(event.getButton()); - } - + .addComponent(new Button("Unlock", event -> { + split.setLocked(false); + split2.setLocked(false); + getMainWindow().showNotification( + "Try moving split. Then reload page.", + Notification.TYPE_WARNING_MESSAGE); + getLayout().removeComponent(event.getButton()); })); getLayout().addComponent(split); getLayout().addComponent(split2); diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSwapComponents.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSwapComponents.java index 26abd0a782..0b7caba574 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSwapComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelSwapComponents.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; @@ -18,18 +17,15 @@ public class SplitPanelSwapComponents extends TestBase { hsplit.setFirstComponent(new Label("Another label")); getLayout().addComponent(hsplit); - Button swap = new Button("Swap components", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Component first = hsplit.getFirstComponent(); - hsplit.removeComponent(first); + Button swap = new Button("Swap components", event -> { + Component first = hsplit.getFirstComponent(); + hsplit.removeComponent(first); - Component second = hsplit.getSecondComponent(); - hsplit.removeComponent(second); + Component second = hsplit.getSecondComponent(); + hsplit.removeComponent(second); - hsplit.setFirstComponent(second); - hsplit.setSecondComponent(first); - } + hsplit.setFirstComponent(second); + hsplit.setSecondComponent(first); }); getLayout().addComponent(swap); diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelWithMinimumAndMaximum.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelWithMinimumAndMaximum.java index f44129f3af..668592a56b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelWithMinimumAndMaximum.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelWithMinimumAndMaximum.java @@ -280,41 +280,17 @@ public class SplitPanelWithMinimumAndMaximum extends AbstractReindeerTestUI { buttonLayout.setSpacing(false); Button disableMinimum = new Button("Disable min limit", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - togglableSplitPanel.setMinSplitPosition(0, - Sizeable.UNITS_PERCENTAGE); - - } - }); + event -> togglableSplitPanel.setMinSplitPosition(0, + Sizeable.UNITS_PERCENTAGE)); Button enableMinimum = new Button("Enable min limit", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - togglableSplitPanel.setMinSplitPosition(10, - Sizeable.UNITS_PERCENTAGE); - - } - }); + event -> togglableSplitPanel.setMinSplitPosition(10, + Sizeable.UNITS_PERCENTAGE)); Button disableMaximum = new Button("Disable max limit", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - togglableSplitPanel.setMaxSplitPosition(100, - Sizeable.UNITS_PERCENTAGE); - - } - }); + event -> togglableSplitPanel.setMaxSplitPosition(100, + Sizeable.UNITS_PERCENTAGE)); Button enableMaximum = new Button("Enable max limit", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - togglableSplitPanel.setMaxSplitPosition(80, - Sizeable.UNITS_PERCENTAGE); - - } - }); + event -> togglableSplitPanel.setMaxSplitPosition(80, + Sizeable.UNITS_PERCENTAGE)); buttonLayout.addComponent(disableMinimum); buttonLayout.addComponent(enableMinimum); buttonLayout.addComponent(disableMaximum); diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPositionChange.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPositionChange.java index ca77971c4b..4e9bddc85e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPositionChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPositionChange.java @@ -50,18 +50,11 @@ public class SplitPositionChange extends AbstractTestUIWithLog { splitPanel.addComponent(buildPanel(firstCaption)); splitPanel.addComponent(buildPanel(secondCaption)); splitPanel.addSplitPositionChangeListener( - new AbstractSplitPanel.SplitPositionChangeListener() { - - @Override - public void onSplitPositionChanged( - AbstractSplitPanel.SplitPositionChangeEvent event) { - log(String.format( - "Split position changed: %s, position: %s %s", - (horizontal ? "horizontal" : "vertical"), - event.getSplitPosition(), - event.getSplitPositionUnit())); - } - }); + event -> log(String.format( + "Split position changed: %s, position: %s %s", + (horizontal ? "horizontal" : "vertical"), + event.getSplitPosition(), + event.getSplitPositionUnit()))); addComponent(splitPanel); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/AddItemToEmptyTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/AddItemToEmptyTable.java index 23122f90c3..769f8ab2b2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/AddItemToEmptyTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/AddItemToEmptyTable.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.v7.data.Item; import com.vaadin.v7.ui.Table; @@ -57,26 +56,15 @@ public class AddItemToEmptyTable extends TestBase { addComponent(rightTable); - Button b = new Button("Add item", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Object id = rightTable.addItem(); - Item item = rightTable.getItem(id); - item.getItemProperty("name").setValue("Role"); - item.getItemProperty("info").setValue(new Button("Button")); - - } + Button b = new Button("Add item", event -> { + Object id = rightTable.addItem(); + Item item = rightTable.getItem(id); + item.getItemProperty("name").setValue("Role"); + item.getItemProperty("info").setValue(new Button("Button")); }); addComponent(b); - b = new Button("Clear", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - rightTable.removeAllItems(); - } - }); + b = new Button("Clear", event -> rightTable.removeAllItems()); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java b/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java index 3ec2a430aa..1e3e30863b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.Table; public class AddNonRenderedRow extends TestBase { @@ -21,12 +19,7 @@ public class AddNonRenderedRow extends TestBase { } Button addrowButton = new Button("Add row"); - addrowButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent pEvent) { - addRow(); - } - }); + addrowButton.addClickListener(evet -> addRow()); addComponent(table); addComponent(addrowButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java b/uitest/src/main/java/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java index 65b30c6fcb..e343650c7f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/AddSelectionToRemovedRange.java @@ -56,20 +56,16 @@ public class AddSelectionToRemovedRange extends AbstractReindeerTestUI { layout.addComponent(table); Button button = new Button("Remove"); - button.addClickListener(new Button.ClickListener() { + button.addClickListener(event -> { + Set<Integer> selected = (Set<Integer>) table.getValue(); - @Override - public void buttonClick(Button.ClickEvent event) { - Set<Integer> selected = (Set<Integer>) table.getValue(); - - for (Integer item : selected) { - if (null == item) { - new Notification("ERROR", - "Table value has null in Set of selected items!", - Type.ERROR_MESSAGE).show(getPage()); - } - table.removeItem(item); + for (Integer item : selected) { + if (null == item) { + new Notification("ERROR", + "Table value has null in Set of selected items!", + Type.ERROR_MESSAGE).show(getPage()); } + table.removeItem(item); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/AsyncPushUpdates.java b/uitest/src/main/java/com/vaadin/tests/components/table/AsyncPushUpdates.java index bdb6adba2f..8eef651713 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/AsyncPushUpdates.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/AsyncPushUpdates.java @@ -44,44 +44,40 @@ public class AsyncPushUpdates extends AbstractReindeerTestUI { table.setContainerDataSource(container); Button button = new Button("START"); - button.addClickListener(new Button.ClickListener() { + button.addClickListener(event -> { + ++clickCount; - @Override - public void buttonClick(ClickEvent event) { - ++clickCount; - - container.removeAllItems(); - for (int i = 0; i < 100; i++) { - container.getContainerProperty(container.addItem(), - VALUE_PROPERTY_ID).setValue("A" + i); - } - - Runnable generateNewRows = new Runnable() { - public int id = 0; - - @Override - public void run() { - getSession().lock(); - try { - Thread.sleep(500); - ++id; - container.removeAllItems(); - for (int i = 0; i < 11; i++) { - container.getContainerProperty( - container.addItem(), VALUE_PROPERTY_ID) - .setValue(clickCount + " - " + id - + " - " + i); - } + container.removeAllItems(); + for (int i = 0; i < 100; i++) { + container.getContainerProperty(container.addItem(), + VALUE_PROPERTY_ID).setValue("A" + i); + } - } catch (InterruptedException e) { - // NOOP - } finally { - getSession().unlock(); + Runnable generateNewRows = new Runnable() { + public int id = 0; + + @Override + public void run() { + getSession().lock(); + try { + Thread.sleep(500); + ++id; + container.removeAllItems(); + for (int i = 0; i < 11; i++) { + container.getContainerProperty( + container.addItem(), VALUE_PROPERTY_ID) + .setValue(clickCount + " - " + id + + " - " + i); } + + } catch (InterruptedException e) { + // NOOP + } finally { + getSession().unlock(); } - }; - new Thread(generateNewRows).start(); - } + } + }; + new Thread(generateNewRows).start(); }); addComponent(table); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java index e784f9b125..448dbf1c23 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java @@ -5,12 +5,8 @@ import com.vaadin.event.Action.Handler; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Table.ColumnCollapseEvent; -import com.vaadin.v7.ui.Table.ColumnCollapseListener; public class ColumnCollapsingAndColumnExpansion extends AbstractReindeerTestUIWithLog { @@ -53,34 +49,20 @@ public class ColumnCollapsingAndColumnExpansion "cell " + 2 + "-" + y, "cell " + 3 + "-" + y, }, new Object()); } - table.addColumnCollapseListener(new ColumnCollapseListener() { - - @Override - public void columnCollapseStateChange(ColumnCollapseEvent event) { + table.addColumnCollapseListener(event -> log("Collapse state for " + event.getPropertyId() + " changed to " - + table.isColumnCollapsed(event.getPropertyId())); - - } - }); + + table.isColumnCollapsed(event.getPropertyId()))); addComponent(table); for (int i = 1; i <= 3; i++) { HorizontalLayout hl = new HorizontalLayout(); final String id = "Col" + i; - Button hide = new Button("Collapse " + id, new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed(id, true); - } - }); - - Button show = new Button("Show " + id, new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed(id, false); - } - }); + Button hide = new Button("Collapse " + id, + event -> table.setColumnCollapsed(id, true)); + + Button show = new Button("Show " + id, + event -> table.setColumnCollapsed(id, false)); hl.addComponent(hide); hl.addComponent(show); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnHeaderAlignments.java b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnHeaderAlignments.java index 2d3ac270d6..bfc6e77b35 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnHeaderAlignments.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnHeaderAlignments.java @@ -4,8 +4,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Select; import com.vaadin.v7.ui.Table; @@ -28,12 +26,8 @@ public class ColumnHeaderAlignments extends TestBase { theme.setValue("reindeer"); theme.setNullSelectionAllowed(false); theme.setImmediate(true); - theme.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - setTheme(String.valueOf(event.getProperty().getValue())); - } - }); + theme.addValueChangeListener(event -> setTheme( + String.valueOf(event.getProperty().getValue()))); addComponent(theme); CheckBox footers = new CheckBox("Show footers"); footers.addValueChangeListener(event -> { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnReorderEvent.java b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnReorderEvent.java index 68ed142a83..0778305f4e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnReorderEvent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnReorderEvent.java @@ -82,13 +82,8 @@ public class ColumnReorderEvent extends TestBase { table.setColumnHeader("firstname", "FirstName"); table.setColumnHeader("lastname", "LastName"); - table.addListener(new Table.ColumnReorderListener() { - @Override - public void columnReorder( - com.vaadin.v7.ui.Table.ColumnReorderEvent event) { - order.setValue(aToString(table.getVisibleColumns())); - } - }); + table.addColumnReorderListener( + event -> order.setValue(aToString(table.getVisibleColumns()))); table.setColumnReorderingAllowed(true); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnResizeEvent.java b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnResizeEvent.java index 63c85779fc..e1024c381d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnResizeEvent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnResizeEvent.java @@ -6,7 +6,6 @@ import com.vaadin.ui.Label; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Table.ColumnResizeListener; @SuppressWarnings("serial") public class ColumnResizeEvent extends TestBase { @@ -83,24 +82,16 @@ public class ColumnResizeEvent extends TestBase { table.setColumnWidth("150pxfixedCol", 150); column3Width.setValue(table.getColumnWidth("150pxfixedCol") + "px"); - table.addListener(new ColumnResizeListener() { - @Override - public void columnResize( - com.vaadin.v7.ui.Table.ColumnResizeEvent event) { - - if (event.getPropertyId().equals("firstname")) { - column1Width.setValue( - event.getCurrentWidth() + "px (previously " - + event.getPreviousWidth() + "px)"); - } else if (event.getPropertyId().equals("lastname")) { - column2Width.setValue( - event.getCurrentWidth() + "px (previously " - + event.getPreviousWidth() + "px)"); - } else if (event.getPropertyId().equals("150pxfixedCol")) { - column3Width.setValue( - event.getCurrentWidth() + "px (previously " - + event.getPreviousWidth() + "px)"); - } + table.addColumnResizeListener(event -> { + if (event.getPropertyId().equals("firstname")) { + column1Width.setValue(event.getCurrentWidth() + + "px (previously " + event.getPreviousWidth() + "px)"); + } else if (event.getPropertyId().equals("lastname")) { + column2Width.setValue(event.getCurrentWidth() + + "px (previously " + event.getPreviousWidth() + "px)"); + } else if (event.getPropertyId().equals("150pxfixedCol")) { + column3Width.setValue(event.getCurrentWidth() + + "px (previously " + event.getPreviousWidth() + "px)"); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnWidthsAfterChangeTableColumnsCountOrOrder.java b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnWidthsAfterChangeTableColumnsCountOrOrder.java index b36d8f6bd1..ef50c6876a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ColumnWidthsAfterChangeTableColumnsCountOrOrder.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ColumnWidthsAfterChangeTableColumnsCountOrOrder.java @@ -37,23 +37,16 @@ public class ColumnWidthsAfterChangeTableColumnsCountOrOrder layout.addComponent(table); Button buttonChangeOrderAndWidth = new Button("Change order and width", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - table.setVisibleColumns("name", "descr", "id"); - table.setColumnWidth("descr", NEW_COLUMN_WIDTH); - } + event -> { + table.setVisibleColumns("name", "descr", "id"); + table.setColumnWidth("descr", NEW_COLUMN_WIDTH); }); buttonChangeOrderAndWidth.setId(BUTTON_CHANGE_ORDER_AND_WIDTH_ID); Button buttonChangeColumnCountAndWidth = new Button( - "Change columns count and width", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - table.setVisibleColumns( - new Object[] { "name", "descr" }); - table.setColumnWidth("descr", NEW_COLUMN_WIDTH); - } + "Change columns count and width", event -> { + table.setVisibleColumns(new Object[] { "name", "descr" }); + table.setColumnWidth("descr", NEW_COLUMN_WIDTH); }); buttonChangeColumnCountAndWidth .setId(BUTTON_CHANGE_COLUMN_COUNT_AND_WIDTH); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java index 0807f7946b..6b05ea8c17 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; @@ -67,33 +65,27 @@ public class ContainerChangeWithPartlySamePropertyIds extends TestBase { public TableTestComponent() { Button switchContainerButton = new Button("switch container"); - switchContainerButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (testTable.getContainerDataSource() == containerA) { - testTable.setContainerDataSource(containerB); - } else { - testTable.setContainerDataSource(containerA); - } + switchContainerButton.addClickListener(event -> { + if (testTable.getContainerDataSource() == containerA) { + testTable.setContainerDataSource(containerB); + } else { + testTable.setContainerDataSource(containerA); } }); this.addComponent(switchContainerButton); Button clearButton = new Button("clear (click twice)"); - clearButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - me.removeComponent(testTable); - - testTable = new Table(); - createContainers(); - testTable.setContainerDataSource(containerA); - - me.addComponent(testTable); - } catch (Exception e) { - e.printStackTrace(); - } + clearButton.addClickListener(event -> { + try { + me.removeComponent(testTable); + + testTable = new Table(); + createContainers(); + testTable.setContainerDataSource(containerA); + + me.addComponent(testTable); + } catch (Exception e) { + e.printStackTrace(); } }); this.addComponent(clearButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChange.java b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChange.java index a8781a861c..776e187d54 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChange.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; @@ -30,30 +29,14 @@ public class ContainerSizeChange extends TestBase { table.setPageLength(5); addComponent(table); - Button b = new Button("Decrease size", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - ds.decreaseSize(); - } - - }); + Button b = new Button("Decrease size", event -> ds.decreaseSize()); addComponent(b); - b = new Button("Increase size", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - ds.increaseSize(); - } - - }); + b = new Button("Increase size", event -> ds.increaseSize()); addComponent(b); - } - } class MyDataSource extends IndexedContainer { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChangeDuringTablePaint.java b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChangeDuringTablePaint.java index 84ff54ba19..28e5d30aca 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChangeDuringTablePaint.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerSizeChangeDuringTablePaint.java @@ -23,7 +23,6 @@ import com.vaadin.server.PaintTarget; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; @@ -104,17 +103,13 @@ public class ContainerSizeChangeDuringTablePaint addComponent(table); Button button = new Button( "Add an item and also trigger an ItemSetChangeEvent in Container during next Table paint", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + event -> { + // we need this to simply trigger a table paint. + addItem(container, "A", "New", "Row"); + container.sabotageNextPaint(); - // we need this to simply trigger a table paint. - addItem(container, "A", "New", "Row"); - container.sabotageNextPaint(); - - event.getButton() - .setCaption("Event was fired successfully."); - } + event.getButton() + .setCaption("Event was fired successfully."); }); button.setId("addRow"); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/DelayedColumnLayouting.java b/uitest/src/main/java/com/vaadin/tests/components/table/DelayedColumnLayouting.java index 906d01255f..9f9c00fc7b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/DelayedColumnLayouting.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/DelayedColumnLayouting.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -43,12 +41,7 @@ public class DelayedColumnLayouting extends UI { Button reset = new Button("Recreate layout with contained table"); verticalLayout.addComponent(reset); - reset.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - fillLayout(layout); - } - }); + reset.addClickListener(event -> fillLayout(layout)); fillLayout(layout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/DisabledSortingTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/DisabledSortingTable.java index 2bcc5da59d..bdc02b2d68 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/DisabledSortingTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/DisabledSortingTable.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.v7.ui.Table; public class DisabledSortingTable extends AbstractReindeerTestUI { @@ -26,26 +25,12 @@ public class DisabledSortingTable extends AbstractReindeerTestUI { addComponent(table); - addButton("Enable sorting", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setSortEnabled(true); - } - }); - - addButton("Disable sorting", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setSortEnabled(false); - } - }); - - addButton("Sort by empty array", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.sort(new Object[] {}, new boolean[] {}); - } - }); + addButton("Enable sorting", event -> table.setSortEnabled(true)); + + addButton("Disable sorting", event -> table.setSortEnabled(false)); + + addButton("Sort by empty array", + event -> table.sort(new Object[] {}, new boolean[] {})); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java b/uitest/src/main/java/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java index 0af01b4057..77599c6005 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.v7.ui.Table; @@ -15,13 +14,10 @@ public class DisabledTableShouldNotSendPageLengthUpdates extends TestBase { protected void setup() { HorizontalSplitPanel split = new HorizontalSplitPanel(); table.addContainerProperty("name", Integer.class, 0); - Button button = new Button("Add items", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - for (int i = 0; i < 5; i++) { - Object id = table.addItem(); - table.getItem(id).getItemProperty("name").setValue(i); - } + Button button = new Button("Add items", event -> { + for (int i = 0; i < 5; i++) { + Object id = table.addItem(); + table.getItem(id).getItemProperty("name").setValue(i); } }); table.setEnabled(false); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/DoublesInTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/DoublesInTable.java index 9bcbd6e2f5..f231257d3c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/DoublesInTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/DoublesInTable.java @@ -14,8 +14,6 @@ import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.util.Log; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComboBox; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.data.util.converter.Converter; import com.vaadin.v7.data.util.converter.StringToDoubleConverter; @@ -111,14 +109,8 @@ public class DoublesInTable extends TestBase { } t.setSelectable(true); t.setImmediate(true); - t.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log.log("Value is now: " + event.getProperty().getValue()); - - } - }); + t.addValueChangeListener(event -> log + .log("Value is now: " + event.getProperty().getValue())); return t; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/EditableModeChange.java b/uitest/src/main/java/com/vaadin/tests/components/table/EditableModeChange.java index 9a17cf0bc2..56c8e4d933 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/EditableModeChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/EditableModeChange.java @@ -44,16 +44,12 @@ public class EditableModeChange extends AbstractReindeerTestUI { .setValue(new FormattedDate(cal.getTime().getTime())); } - items.addItemClickListener(new ItemClickEvent.ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { - if (event.isDoubleClick()) { - selectionEvent = event; - items.setEditable(true); - } else if (items.isEditable()) { - items.setEditable(false); - } + items.addItemClickListener(event -> { + if (event.isDoubleClick()) { + selectionEvent = event; + items.setEditable(true); + } else if (items.isEditable()) { + items.setEditable(false); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/EditableTableLeak.java b/uitest/src/main/java/com/vaadin/tests/components/table/EditableTableLeak.java index e9ddb52ab6..6e2b049a0c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/EditableTableLeak.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/EditableTableLeak.java @@ -11,8 +11,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; @@ -104,21 +102,14 @@ public class EditableTableLeak extends TestBase { addComponent(sizeLabel); - addComponent(new Button("Show size of the table", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.markAsDirtyRecursive(); - updateSize(); - } - + addComponent(new Button("Show size of the table", event -> { + table.markAsDirtyRecursive(); + updateSize(); })); - addComponent(new Button("Select the second row", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.select("AL"); - updateSize(); - } + addComponent(new Button("Select the second row", event -> { + table.select("AL"); + updateSize(); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java b/uitest/src/main/java/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java index a1685ab858..ce5f5ce651 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java @@ -10,8 +10,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; @@ -113,24 +111,14 @@ public class EmptyRowsWhenScrolling extends UI { image.setWidth("50px"); image.setHeight("50px"); image.addClickListener( - new com.vaadin.event.MouseEvents.ClickListener() { - @Override - public void click( - com.vaadin.event.MouseEvents.ClickEvent event) { - Notification.show("Image clicked!"); - } - }); + event -> Notification.show("Image clicked!")); return image; } }); // Refresh table button - getBtnRefreshTable().addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.refreshRowCache(); - } - }); + getBtnRefreshTable() + .addClickListener(event -> table.refreshRowCache()); } @AutoGenerated diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ExpandingContainer.java b/uitest/src/main/java/com/vaadin/tests/components/table/ExpandingContainer.java index 9d01660b46..f09348e016 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ExpandingContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ExpandingContainer.java @@ -68,12 +68,9 @@ public class ExpandingContainer extends AbstractContainer implements new Thread() { @Override public void run() { - ExpandingContainer.this.invoke(session, new Runnable() { - @Override - public void run() { - log("*** Firing item set change event"); - ExpandingContainer.this.fireItemSetChange(); - } + ExpandingContainer.this.invoke(session, () -> { + log("*** Firing item set change event"); + ExpandingContainer.this.fireItemSetChange(); }); } }.start(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/FocusOnSelectedItem.java b/uitest/src/main/java/com/vaadin/tests/components/table/FocusOnSelectedItem.java index 0948833476..4569acc399 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/FocusOnSelectedItem.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/FocusOnSelectedItem.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Table; /** @@ -49,13 +47,10 @@ public class FocusOnSelectedItem extends AbstractReindeerTestUI { } addComponent(table); - addButton("Select", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setValue("Item 198"); - table.setCurrentPageFirstItemId("Item 198"); - table.focus(); - } + addButton("Select", event -> { + table.setValue("Item 198"); + table.setCurrentPageFirstItemId("Item 198"); + table.focus(); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/Footer.java b/uitest/src/main/java/com/vaadin/tests/components/table/Footer.java index a0ebe6fa18..d220c00e30 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/Footer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/Footer.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; @@ -51,13 +50,10 @@ public class Footer extends AbstractReindeerTestUI { options.addComponent(visible); final TextField footer1Value = new TextField(null, "Footer1"); - Button footer1Btn = new Button("Change", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + Button footer1Btn = new Button("Change", event -> table.setColumnFooter("col1", footer1Value.getValue() == null - ? "" : footer1Value.getValue()); - } - }); + ? "" + : footer1Value.getValue())); HorizontalLayout footer1 = new HorizontalLayout(); footer1.setSpacing(false); footer1.addComponent(footer1Value); @@ -65,13 +61,10 @@ public class Footer extends AbstractReindeerTestUI { options.addComponent(footer1); final TextField footer2Value = new TextField(null, "Footer2"); - Button footer2Btn = new Button("Change", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + Button footer2Btn = new Button("Change", event -> table.setColumnFooter("col2", footer2Value.getValue() == null - ? "" : footer2Value.getValue()); - } - }); + ? "" + : footer2Value.getValue())); HorizontalLayout footer2 = new HorizontalLayout(); footer2.setSpacing(false); footer2.addComponent(footer2Value); @@ -79,13 +72,10 @@ public class Footer extends AbstractReindeerTestUI { options.addComponent(footer2); final TextField footer3Value = new TextField(null, "Footer3"); - Button footer3Btn = new Button("Change", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + Button footer3Btn = new Button("Change", event -> table.setColumnFooter("col3", footer3Value.getValue() == null - ? "" : footer3Value.getValue()); - } - }); + ? "" + : footer3Value.getValue())); HorizontalLayout footer3 = new HorizontalLayout(); footer3.setSpacing(false); footer3.addComponent(footer3Value); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/FooterClick.java b/uitest/src/main/java/com/vaadin/tests/components/table/FooterClick.java index 438e102d41..ca716d0c57 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/FooterClick.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/FooterClick.java @@ -8,7 +8,6 @@ import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Table.FooterClickEvent; public class FooterClick extends AbstractTestUIWithLog { @@ -35,12 +34,9 @@ public class FooterClick extends AbstractTestUIWithLog { columnField.setId("ClickedColumn"); // Add a footer click listener - table.addFooterClickListener(new Table.FooterClickListener() { - @Override - public void footerClick(FooterClickEvent event) { - columnField.setValue(String.valueOf(event.getPropertyId())); - log("Clicked on footer: " + event.getPropertyId()); - } + table.addFooterClickListener(event -> { + columnField.setValue(String.valueOf(event.getPropertyId())); + log("Clicked on footer: " + event.getPropertyId()); }); CheckBox immediateCheckbox = new CheckBox("Immediate"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderClick.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderClick.java index 80a75bdb9d..a1e4c479ee 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderClick.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderClick.java @@ -8,7 +8,6 @@ import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Table.HeaderClickEvent; public class HeaderClick extends AbstractReindeerTestUI { @@ -25,12 +24,8 @@ public class HeaderClick extends AbstractReindeerTestUI { "ProperyId of clicked column"); // Add a header click listener - table.addHeaderClickListener(new Table.HeaderClickListener() { - @Override - public void headerClick(HeaderClickEvent event) { - columnField.setValue(String.valueOf(event.getPropertyId())); - } - }); + table.addHeaderClickListener(event -> columnField + .setValue(String.valueOf(event.getPropertyId()))); CheckBox immediateCheckbox = new CheckBox("Immediate"); immediateCheckbox.setValue(table.isImmediate()); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java index 1db44b00e2..5c07ab7811 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java @@ -36,17 +36,12 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog { headerClickListenerCheckbox.addValueChangeListener( new HasValue.ValueChangeListener<Boolean>() { - private HeaderClickListener headerClickListener = new HeaderClickListener() { - - @Override - public void headerClick(HeaderClickEvent event) { - String type = event.isDoubleClick() ? "Double click" - : "Click"; - log(type + " on header " - + event.getPropertyId().toString() - + " using " + event.getButtonName()); - } - + private HeaderClickListener headerClickListener = event -> { + String type = event.isDoubleClick() ? "Double click" + : "Click"; + log(type + " on header " + + event.getPropertyId().toString() + " using " + + event.getButtonName()); }; @Override @@ -67,16 +62,12 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog { footerClickListenerCheckbox.addValueChangeListener( new HasValue.ValueChangeListener<Boolean>() { - private FooterClickListener footerClickListener = new FooterClickListener() { - - @Override - public void footerClick(FooterClickEvent event) { - String type = event.isDoubleClick() ? "Double click" - : "Click"; - log(type + " on footer " - + event.getPropertyId().toString() - + " using " + event.getButtonName()); - } + private FooterClickListener footerClickListener = event -> { + String type = event.isDoubleClick() ? "Double click" + : "Click"; + log(type + " on footer " + + event.getPropertyId().toString() + " using " + + event.getButtonName()); }; @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java index 84c676b878..b2f78a395f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java @@ -23,21 +23,16 @@ public class HeaderRightClickAfterDrag extends AbstractReindeerTestUI { table.setPageLength(10); table.setColumnReorderingAllowed(true); - table.addHeaderClickListener(new Table.HeaderClickListener() { - @Override - public void headerClick(Table.HeaderClickEvent event) { - if (MouseEventDetails.MouseButton.RIGHT - .equals(event.getButton())) { - Window window = new Window("Right-clicked:", - new Label("<center>" - + event.getPropertyId().toString() - .toUpperCase(Locale.ROOT) - + "</center>", ContentMode.HTML)); - window.setPositionX(event.getClientX()); - window.setPositionY(event.getClientY()); - window.setResizable(false); - addWindow(window); - } + table.addHeaderClickListener(event -> { + if (MouseEventDetails.MouseButton.RIGHT.equals(event.getButton())) { + Window window = new Window("Right-clicked:", new Label( + "<center>" + event.getPropertyId().toString() + .toUpperCase(Locale.ROOT) + "</center>", + ContentMode.HTML)); + window.setPositionX(event.getClientX()); + window.setPositionY(event.getClientY()); + window.setResizable(false); + addWindow(window); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderSyncOnScroll.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderSyncOnScroll.java index 6adf37fe4b..4cf5eb333a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderSyncOnScroll.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderSyncOnScroll.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.ui.Table; @@ -52,30 +50,14 @@ public class HeaderSyncOnScroll extends AbstractReindeerTestUI { addComponent(buttonsLo); Button setTableWidth100 = new Button("table.setWidth(100%)", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setWidth("100%"); - } - }); + event -> table.setWidth("100%")); Button setParent500px = new Button("layout.setWidth(500px)", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.getParent().setWidth("500px"); - } - }); + event -> table.getParent().setWidth("500px")); Button setParent100 = new Button("layout.setWidth(100%)", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.getParent().setWidth("100%"); - } - }); + event -> table.getParent().setWidth("100%")); buttonsLo.addComponents(setTableWidth100, setParent500px, setParent100); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java b/uitest/src/main/java/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java index e51facb6d9..98731954d6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java @@ -4,8 +4,6 @@ import java.util.Random; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.Item; import com.vaadin.v7.ui.Table; @@ -34,20 +32,12 @@ public class HiddenColumnsExpandRatios extends TestBase { item.getItemProperty("dfgh").setValue(genValue()); } - addComponent(new Button("All", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setVisibleColumns( - table.getContainerPropertyIds().toArray()); - } - })); - addComponent(new Button("Some", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setWidth("100px"); - table.setWidth("800px"); - table.setVisibleColumns("foo", "bar", "baz"); - } + addComponent(new Button("All", event ->table.setVisibleColumns( + table.getContainerPropertyIds().toArray()))); + addComponent(new Button("Some", event ->{ + table.setWidth("100px"); + table.setWidth("800px"); + table.setVisibleColumns("foo", "bar", "baz"); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ItemClickEvents.java b/uitest/src/main/java/com/vaadin/tests/components/table/ItemClickEvents.java index 1fbc932374..446831990d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ItemClickEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ItemClickEvents.java @@ -5,12 +5,10 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.AbstractSelect; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Tree; @@ -32,15 +30,11 @@ public class ItemClickEvents extends AbstractReindeerTestUI { log.setId("log"); HorizontalLayout ol = createHorizontalLayout(tree); - Button b = new Button("icon", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (tree.getItemIconPropertyId() == null) { - tree.setItemIconPropertyId("icon"); - } else { - tree.setItemIconPropertyId(null); - } - + Button b = new Button("icon", event -> { + if (tree.getItemIconPropertyId() == null) { + tree.setItemIconPropertyId("icon"); + } else { + tree.setItemIconPropertyId(null); } }); ol.addComponent(b); @@ -61,12 +55,7 @@ public class ItemClickEvents extends AbstractReindeerTestUI { new ExternalResource( "https://vaadin.com/vaadin-theme/images/vaadin-logo.png")); - tree.addListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - logEvent(event, "tree"); - } - }); + tree.addItemClickListener(event -> logEvent(event, "tree")); tree.setId("tree"); HorizontalLayout ol2 = createHorizontalLayout(table); @@ -80,22 +69,11 @@ public class ItemClickEvents extends AbstractReindeerTestUI { item.getItemProperty("Column").setValue("Row " + i); } - table.addListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - logEvent(event, "table"); - } - }); + table.addItemClickListener(event -> logEvent(event, "table")); table.setId("table"); addComponent(log); - addComponent(new Button("Clear log", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - } - })); + addComponent(new Button("Clear log", event -> log.clear())); addComponent(ol); addComponent(tree); addComponent(ol2); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java index 7ed5ff32bf..94296f42bd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LabelEmbeddedClickThroughForTable.java @@ -6,8 +6,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.v7.data.Item; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.shared.ui.label.ContentMode; import com.vaadin.v7.ui.Label; import com.vaadin.v7.ui.Table; @@ -54,16 +52,9 @@ public class LabelEmbeddedClickThroughForTable extends AbstractReindeerTestUI { item.getItemProperty("Column 4").setValue(new Embedded("", new ThemeResource("../runo/icons/32/cancel.png"))); - table.addItemClickListener(new ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { - System.out.println("Clickevent on item " + event.getItemId() - + ", column: " + event.getPropertyId()); - - } - - }); + table.addItemClickListener(event -> System.out + .println("Clickevent on item " + event.getItemId() + + ", column: " + event.getPropertyId())); addComponent(table); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java index ccc0f634a1..f73434b61d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java @@ -11,7 +11,6 @@ import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.Align; @@ -102,17 +101,14 @@ public class LargeSelectionCausesNPE extends TestBase { button.addClickListener(clickListener); } - Table.ValueChangeListener valueChangeListener = new Table.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - // in multiselect mode, a Set of itemIds is returned, - // in singleselect mode the itemId is returned directly - Set<?> value = (Set<?>) event.getProperty().getValue(); - if (null == value || value.isEmpty()) { - selected.setValue("No selection"); - } else { - selected.setValue("Selected: " + table.getValue()); - } + Table.ValueChangeListener valueChangeListener = event -> { + // in multiselect mode, a Set of itemIds is returned, + // in singleselect mode the itemId is returned directly + Set<?> value = (Set<?>) event.getProperty().getValue(); + if (null == value || value.isEmpty()) { + selected.setValue("No selection"); + } else { + selected.setValue("Selected: " + table.getValue()); } }; diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LastColumnNegative.java b/uitest/src/main/java/com/vaadin/tests/components/table/LastColumnNegative.java index ea9d05d34e..8d601cec9a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LastColumnNegative.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LastColumnNegative.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; @@ -14,30 +13,11 @@ public class LastColumnNegative extends TestBase { @Override public void setup() { Button addButton = new Button("Add a table", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - wrapper.addComponent(table); - } - - }); + event -> wrapper.addComponent(table)); Button removeButton = new Button("Remove a table", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - wrapper.removeComponent(table); - } - }); + event -> wrapper.removeComponent(table)); Button shrinkWrapper = new Button("Shrink wrapper", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - wrapper.setWidth("400px"); - } - }); + event -> wrapper.setWidth("400px")); addComponent(addButton); addComponent(removeButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LeftColumnAlignment.java b/uitest/src/main/java/com/vaadin/tests/components/table/LeftColumnAlignment.java index c980f928fb..01ab1b7f66 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LeftColumnAlignment.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LeftColumnAlignment.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import com.vaadin.annotations.Theme; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.Align; @@ -51,13 +49,8 @@ public class LeftColumnAlignment extends AbstractReindeerTestUI { addComponent(table); - addButton("Align to Left", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnAlignment("name", Align.LEFT); - } - }); + addButton("Align to Left", + event -> table.setColumnAlignment("name", Align.LEFT)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LongMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/table/LongMultiselect.java index e7ee6f2ade..16111635d4 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LongMultiselect.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LongMultiselect.java @@ -33,19 +33,16 @@ public class LongMultiselect extends AbstractReindeerTestUI { } // Add action button - addComponent(new Button("Do It", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - // Set ItemProperty.COLUMN2 for all selected values of table - Collection selectedIds = (Collection) table.getValue(); - for (final Object itemId : selectedIds) { - final Property p = table.getItem(itemId) - .getItemProperty(ItemProperty.COLUMN2); - if (p.getValue() instanceof String) { - p.setValue(null); - } else { - p.setValue("updated"); - } + addComponent(new Button("Do It", event -> { + // Set ItemProperty.COLUMN2 for all selected values of table + Collection selectedIds = (Collection) table.getValue(); + for (final Object itemId : selectedIds) { + final Property p = table.getItem(itemId) + .getItemProperty(ItemProperty.COLUMN2); + if (p.getValue() instanceof String) { + p.setValue(null); + } else { + p.setValue("updated"); } } })); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MemoryLeakTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/MemoryLeakTable.java index 2a185f30a9..764384abbf 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/MemoryLeakTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/MemoryLeakTable.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; @@ -56,18 +54,8 @@ public class MemoryLeakTable extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - btnAdd.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addRows(); - } - }); - btnRemove.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - removeRows(); - } - }); + btnAdd.addClickListener(event -> addRows()); + btnRemove.addClickListener(event -> removeRows()); addComponent(btnAdd); addComponent(btnRemove); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MissingScrollbar.java b/uitest/src/main/java/com/vaadin/tests/components/table/MissingScrollbar.java index 98e121e73d..97bb3cfa2c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/MissingScrollbar.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/MissingScrollbar.java @@ -5,7 +5,6 @@ import java.io.Serializable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; @@ -42,23 +41,12 @@ public class MissingScrollbar extends TestBase { VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setWidth(null); - Button b = new Button("Set items to 2", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setContainerDataSource(container2); - } - }); + Button b = new Button("Set items to 2", + event -> table.setContainerDataSource(container2)); buttonLayout.addComponent(b); - b = new Button("Set items to 50", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setContainerDataSource(container50); - } - - }); + b = new Button("Set items to 50", + event -> table.setContainerDataSource(container50)); buttonLayout.addComponent(b); hl.addComponent(buttonLayout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ModifyContainerProperty.java b/uitest/src/main/java/com/vaadin/tests/components/table/ModifyContainerProperty.java index a21774cce6..f9fea18175 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ModifyContainerProperty.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ModifyContainerProperty.java @@ -25,29 +25,19 @@ public class ModifyContainerProperty extends TestBase { table.setContainerDataSource(ic); addComponent(new Button("Remove container property", - new Button.ClickListener() { - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent arg0) { - ic.removeContainerProperty("one"); - } - })); + event -> ic.removeContainerProperty("one"))); addComponent(new Button("Add container property", - new Button.ClickListener() { - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent arg0) { - boolean added = ic.addContainerProperty("three", - String.class, "three"); - if (added) { - Object[] current = table.getVisibleColumns(); - Object[] vis = new Object[current.length + 1]; - for (int i = 0; i < current.length; i++) { - vis[i] = current[i]; - } - vis[current.length] = "three"; - table.setVisibleColumns(vis); + event -> { + boolean added = ic.addContainerProperty("three", + String.class, "three"); + if (added) { + Object[] current = table.getVisibleColumns(); + Object[] vis = new Object[current.length + 1]; + for (int i = 0; i < current.length; i++) { + vis[i] = current[i]; } + vis[current.length] = "three"; + table.setVisibleColumns(vis); } })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MultiClickingItemThatDetachesTable.java b/uitest/src/main/java/com/vaadin/tests/components/table/MultiClickingItemThatDetachesTable.java index 9c6293bc2d..bba7866ed7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/MultiClickingItemThatDetachesTable.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/MultiClickingItemThatDetachesTable.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; import com.vaadin.v7.data.Item; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; @SuppressWarnings("serial") @@ -20,18 +18,15 @@ public class MultiClickingItemThatDetachesTable extends TestBase { item.getItemProperty("p2").setValue(i + ""); item.getItemProperty("p1").setValue(i + ""); } - table.addListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - if (event.isDoubleClick()) { - try { - // Wait a bit so there's time to click multiple times - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - replaceComponent(table, new Label("Completed!")); + table.addItemClickListener(event -> { + if (event.isDoubleClick()) { + try { + // Wait a bit so there's time to click multiple times + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); } + replaceComponent(table, new Label("Completed!")); } }); addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java index acc7414ed3..1de99763ab 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Notification; import com.vaadin.v7.data.Container; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; @@ -19,13 +17,8 @@ public class MultiSelectWithNotIdentityEqualIds extends TestBase { t.setMultiSelect(true); t.setSelectable(true); t.setImmediate(true); - t.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Notification.show("Selected: " + event.getProperty()); - - } - }); + t.addValueChangeListener( + event -> Notification.show("Selected: " + event.getProperty())); getLayout().addComponent(t); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java index c4df124a15..0d262c8b4d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java @@ -6,7 +6,6 @@ import java.util.Collection; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; @@ -47,37 +46,27 @@ public class MultiSelectWithRemovedRow extends TestBase { addComponent(table); Button showButton = new Button("Show selection"); - showButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - Collection<?> selection = (Collection<?>) table.getValue(); - log.log("Selection: " + selection); - } + showButton.addClickListener(event -> { + Collection<?> selection = (Collection<?>) table.getValue(); + log.log("Selection: " + selection); }); addComponent(showButton); Button removeButton = new Button("Remove selection"); - removeButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - Collection<?> selection = (Collection<?>) table.getValue(); - for (Object selected : selection) { - container.removeItem(selected); - } + removeButton.addClickListener(event -> { + Collection<?> selection = (Collection<?>) table.getValue(); + for (Object selected : selection) { + container.removeItem(selected); } }); addComponent(removeButton); addComponent(new Button("Remove first selected row", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Collection<?> selection = (Collection<?>) table - .getValue(); - if (!selection.isEmpty()) { - Object firstSelected = selection.iterator().next(); - container.removeItem(firstSelected); - } + event -> { + Collection<?> selection = (Collection<?>) table.getValue(); + if (!selection.isEmpty()) { + Object firstSelected = selection.iterator().next(); + container.removeItem(firstSelected); } })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ProgrammaticUnselectInRange.java b/uitest/src/main/java/com/vaadin/tests/components/table/ProgrammaticUnselectInRange.java index d5c6836760..18998465ea 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ProgrammaticUnselectInRange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ProgrammaticUnselectInRange.java @@ -2,10 +2,7 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.ui.Table; public class ProgrammaticUnselectInRange extends TestBase { @@ -28,21 +25,12 @@ public class ProgrammaticUnselectInRange extends TestBase { Integer value = Integer.valueOf(i + 1); table.addItem(new Object[] { value }, value); } - table.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - updateSelectionLabel(); - } - }); + table.addValueChangeListener(event -> updateSelectionLabel()); addComponent(table); addComponent(selectionLabel); - addComponent(new Button("Deselect item 2", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.unselect(Integer.valueOf(2)); - } - })); + addComponent(new Button("Deselect item 2", + event -> table.unselect(Integer.valueOf(2)))); updateSelectionLabel(); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/PropertyValueChange.java b/uitest/src/main/java/com/vaadin/tests/components/table/PropertyValueChange.java index 70ee69d5d9..aaa7a0403d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/PropertyValueChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/PropertyValueChange.java @@ -6,8 +6,6 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.AbstractSelect.NewItemHandler; import com.vaadin.v7.ui.ComboBox; @@ -57,12 +55,8 @@ public class PropertyValueChange extends TestBase { // cases (e.g. edit mode) if (integer instanceof Property.ValueChangeNotifier) { Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) integer; - notifier.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - l.setValue(String.valueOf(getMultipliedValue(integer))); - } - }); + notifier.addValueChangeListener(event -> l + .setValue(String.valueOf(getMultipliedValue(integer)))); } return l; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/RefreshRenderedCellsOnlyIfAttached.java b/uitest/src/main/java/com/vaadin/tests/components/table/RefreshRenderedCellsOnlyIfAttached.java index 7ef43e338f..5dc79adb42 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/RefreshRenderedCellsOnlyIfAttached.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/RefreshRenderedCellsOnlyIfAttached.java @@ -19,7 +19,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -75,15 +74,11 @@ public class RefreshRenderedCellsOnlyIfAttached extends AbstractReindeerTestUI { addComponent(l2); addComponent(layout); - Button b = new Button("Detach table", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - check = true; - removeTableParent(); - // call refreshRenderedCells - t.setColumnCollapsingAllowed(true); - } + Button b = new Button("Detach table", event -> { + check = true; + removeTableParent(); + // call refreshRenderedCells + t.setColumnCollapsingAllowed(true); }); b.setId("button"); addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ReloadWidgets.java b/uitest/src/main/java/com/vaadin/tests/components/table/ReloadWidgets.java index 2c4b2db662..34aaa6326d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ReloadWidgets.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ReloadWidgets.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; @@ -27,12 +26,9 @@ public class ReloadWidgets extends AbstractReindeerTestUI { Button button = new Button("Refresh"); button.setId("refresh"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.removeAllItems(); - fillTable(table); - } + button.addClickListener(event -> { + table.removeAllItems(); + fillTable(table); }); getLayout().addComponent(button); getLayout().addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/RemoveItemOnClick.java b/uitest/src/main/java/com/vaadin/tests/components/table/RemoveItemOnClick.java index ca055ac6c5..7dcd6bd822 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/RemoveItemOnClick.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/RemoveItemOnClick.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.Table; @@ -37,12 +35,8 @@ public class RemoveItemOnClick extends AbstractReindeerTestUI { table.setPageLength(20); table.setSelectable(true); table.setImmediate(true); - table.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - table.removeItem(table.getValue()); - } - }); + table.addValueChangeListener( + event -> table.removeItem(table.getValue())); addComponent(table); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/RowAdditionTest.java b/uitest/src/main/java/com/vaadin/tests/components/table/RowAdditionTest.java index 7d323b979a..68093bbe46 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/RowAdditionTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/RowAdditionTest.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.IndexedContainer; @@ -32,28 +31,19 @@ public class RowAdditionTest extends TestBase { } HorizontalLayout hl = new HorizontalLayout(); - hl.addComponent(new Button("Add first", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Item item = container.addItemAt(0, new Object()); - item.getItemProperty("column1").setValue("0"); - } + hl.addComponent(new Button("Add first", event -> { + Item item = container.addItemAt(0, new Object()); + item.getItemProperty("column1").setValue("0"); })); hl.addComponent( - new Button("Add at position 50", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Item item = container.addItemAt(50, new Object()); - item.getItemProperty("column1").setValue("50"); - } + new Button("Add at position 50", event -> { + Item item = container.addItemAt(50, new Object()); + item.getItemProperty("column1").setValue("50"); })); hl.addComponent( - new Button("Add at position 100", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Item item = container.addItemAt(100, new Object()); - item.getItemProperty("column1").setValue("100"); - } + new Button("Add at position 100", event -> { + Item item = container.addItemAt(100, new Object()); + item.getItemProperty("column1").setValue("100"); })); getLayout().addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java b/uitest/src/main/java/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java index 5c4e7be94b..03eeb7048f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.event.Action; import com.vaadin.tests.components.TestBase; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.ProgressIndicator; import com.vaadin.v7.ui.Table; @@ -17,14 +15,11 @@ public class RowUpdateShouldRetainContextMenu extends TestBase { @Override protected void setup() { indicator.setWidth("200px"); - indicator.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - // Do some changes to the table - table.setColumnHeader("Column", "Column " + ctr); - table.getItem(2).getItemProperty("Column") - .setValue("Test " + ctr++); - } + indicator.addValueChangeListener(event -> { + // Do some changes to the table + table.setColumnHeader("Column", "Column " + ctr); + table.getItem(2).getItemProperty("Column") + .setValue("Test " + ctr++); }); Thread updater = new Thread() { private float progress = 0; diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java b/uitest/src/main/java/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java index 8e46f8f7c1..7524fa3275 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java @@ -5,8 +5,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class SafariRenderingBugWhiteSpace extends TestBase { @@ -32,15 +30,11 @@ public class SafariRenderingBugWhiteSpace extends TestBase { table.setSelectable(true); table.setImmediate(true); table.setSizeFull(); - table.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if (table.getValue() == null) { - split.setSplitPosition(100, Sizeable.UNITS_PERCENTAGE); - } else { - split.setSplitPosition(20, Sizeable.UNITS_PERCENTAGE); - } + table.addValueChangeListener(event -> { + if (table.getValue() == null) { + split.setSplitPosition(100, Sizeable.UNITS_PERCENTAGE); + } else { + split.setSplitPosition(20, Sizeable.UNITS_PERCENTAGE); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java index 4f5f088a16..4a58a4e04d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; @@ -45,24 +44,16 @@ public class ScrollDetachSynchronization extends TestBase { mainLayout.addComponent(firstLayout); mainLayout.setExpandRatio(firstLayout, 1); - first.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (mainLayout.getComponent(1).equals(secondLayout)) { - mainLayout.replaceComponent(secondLayout, firstLayout); - mainLayout.setExpandRatio(firstLayout, 1); - } + first.addClickListener(event -> { + if (mainLayout.getComponent(1).equals(secondLayout)) { + mainLayout.replaceComponent(secondLayout, firstLayout); + mainLayout.setExpandRatio(firstLayout, 1); } }); - second.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (mainLayout.getComponent(1).equals(firstLayout)) { - mainLayout.replaceComponent(firstLayout, secondLayout); - mainLayout.setExpandRatio(secondLayout, 1); - } + second.addClickListener(event -> { + if (mainLayout.getComponent(1).equals(firstLayout)) { + mainLayout.replaceComponent(firstLayout, secondLayout); + mainLayout.setExpandRatio(secondLayout, 1); } }); return mainLayout; diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SelectAllRows.java b/uitest/src/main/java/com/vaadin/tests/components/table/SelectAllRows.java index 2df3a4cdc7..52b32cfe34 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SelectAllRows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SelectAllRows.java @@ -50,13 +50,9 @@ public class SelectAllRows extends AbstractReindeerTestUI { label.setCaption("Selected count:"); addComponent(label); - button.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(Button.ClickEvent event) { - Set selected = (Set) table.getValue(); - label.setValue(String.valueOf(selected.size())); - } + button.addClickListener(event -> { + Set selected = (Set) table.getValue(); + label.setValue(String.valueOf(selected.size())); }); for (int i = 0; i < TOTAL_NUMBER_OF_ROWS; i++) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java index 439ebf6975..18a728b223 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -29,12 +27,9 @@ public class SetCurrentPageFirstItemId extends TestBase { } Button addrowButton = new Button("Add row"); - addrowButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent pEvent) { - Object id = addRow(); - table.setCurrentPageFirstItemId(id); - } + addrowButton.addClickListener(event -> { + Object id = addRow(); + table.setCurrentPageFirstItemId(id); }); mainLayout.addComponent(addrowButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.java b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.java index 9dac740a12..e7fce925fd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.java @@ -22,7 +22,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.ColumnGenerator; @@ -62,21 +61,17 @@ public class SetCurrentPageFirstItemIndex extends AbstractReindeerTestUI { imageTable.setCurrentPageFirstItemIndex(index); - vl.addComponent(new Button("Click", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - if (index != 5) { - index = 5; - imageTable.setCurrentPageFirstItemIndex(index); - } else { - index = 20; - imageTable.setCurrentPageFirstItemIndex(index); - } + vl.addComponent(new Button("Click", event -> { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + } + if (index != 5) { + index = 5; + imageTable.setCurrentPageFirstItemIndex(index); + } else { + index = 20; + imageTable.setCurrentPageFirstItemIndex(index); } })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SetDataSourceWithPropertyIds.java b/uitest/src/main/java/com/vaadin/tests/components/table/SetDataSourceWithPropertyIds.java index b9a9ddd7e8..ccfe115962 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SetDataSourceWithPropertyIds.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SetDataSourceWithPropertyIds.java @@ -43,12 +43,7 @@ public class SetDataSourceWithPropertyIds extends AbstractReindeerTestUI { Button button = new Button("Toggle editability"); button.setId("button"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - refreshTable(); - } - }); + button.addClickListener(event -> refreshTable()); label.setSizeUndefined(); label.setId("label"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ShowLastItem.java b/uitest/src/main/java/com/vaadin/tests/components/table/ShowLastItem.java index 0f3cf952bc..7b12e16750 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ShowLastItem.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ShowLastItem.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Table; public class ShowLastItem extends AbstractReindeerTestUI { @@ -26,18 +25,13 @@ public class ShowLastItem extends AbstractReindeerTestUI { .setValue("row " + String.valueOf(i)); } - Button addItemBtn = new Button("Add item", new Button.ClickListener() { + Button addItemBtn = new Button("Add item", event -> { + Object itemId = "row " + table.getItemIds().size(); - @Override - public void buttonClick(ClickEvent event) { - Object itemId = "row " + table.getItemIds().size(); + table.addItem(itemId).getItemProperty("Col") + .setValue(String.valueOf(itemId)); - table.addItem(itemId).getItemProperty("Col") - .setValue(String.valueOf(itemId)); - - table.setCurrentPageFirstItemIndex( - table.getItemIds().size() - 1); - } + table.setCurrentPageFirstItemIndex(table.getItemIds().size() - 1); }); addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SortableHeaderStyles.java b/uitest/src/main/java/com/vaadin/tests/components/table/SortableHeaderStyles.java index 43ba7547e9..d86dc5a04f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/SortableHeaderStyles.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/SortableHeaderStyles.java @@ -20,8 +20,6 @@ import java.util.Collection; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.PersonContainer; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.OptionGroup; import com.vaadin.v7.ui.Table; @@ -50,12 +48,9 @@ public class SortableHeaderStyles extends AbstractReindeerTestUI { }; table.setContainerDataSource(container); - sortableSelector.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - // Trigger repaint that will read the value again - table.markAsDirty(); - } + sortableSelector.addValueChangeListener(event -> { + // Trigger repaint that will read the value again + table.markAsDirty(); }); addComponent(sortableSelector); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableAfterRemovingExpandRatios.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableAfterRemovingExpandRatios.java index 2d613a21bb..013de2211b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableAfterRemovingExpandRatios.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableAfterRemovingExpandRatios.java @@ -23,8 +23,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeButton; import com.vaadin.v7.ui.Table; @@ -65,14 +63,9 @@ public class TableAfterRemovingExpandRatios extends AbstractReindeerTestUI { private NativeButton createSetExpandRatiosButton(final Table table) { NativeButton button = new NativeButton("Set expand", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnExpandRatio("column1", 1.0f); - table.setColumnExpandRatio("column2", 3.0f); - - } + event -> { + table.setColumnExpandRatio("column1", 1.0f); + table.setColumnExpandRatio("column2", 3.0f); }); button.setId("expand-button"); return button; @@ -80,13 +73,9 @@ public class TableAfterRemovingExpandRatios extends AbstractReindeerTestUI { private NativeButton createUnsetExpandRatiosButton(final Table table) { NativeButton button = new NativeButton("Unset expand", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnExpandRatio("column1", -1); - table.setColumnExpandRatio("column2", -1); - } + event -> { + table.setColumnExpandRatio("column1", -1); + table.setColumnExpandRatio("column2", -1); }); button.setId("unexpand-button"); return button; @@ -94,13 +83,7 @@ public class TableAfterRemovingExpandRatios extends AbstractReindeerTestUI { private NativeButton createAddItemButton(final Table table) { NativeButton button = new NativeButton("Add item", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.addItem(); - } - }); + event -> table.addItem()); button.setId("add-button"); return button; diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableBlurFocus.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableBlurFocus.java index 50516e7b9e..5070c52109 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableBlurFocus.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableBlurFocus.java @@ -17,15 +17,9 @@ package com.vaadin.tests.components.table; import java.util.Map; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.v7.ui.Table; @@ -50,29 +44,12 @@ public class TableBlurFocus extends AbstractReindeerTestUIWithLog { System.out .println("TableBlurFocus/TableInIframeRowClickScrollJumpTest"); Button button = new Button("click to focus"); - button.addFocusListener(new FocusListener() { - - @Override - public void focus(FocusEvent event) { - log("focus"); - } - }); - button.addBlurListener(new BlurListener() { - - @Override - public void blur(BlurEvent event) { - log("blur"); - } - }); + button.addFocusListener(event -> log("focus")); + button.addBlurListener(event -> log("blur")); final Button scrollButton = new Button( "focus lowest button to scroll down"); scrollButton.setId("scroll-button"); - scrollButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - focusButton.focus(); - } - }); + scrollButton.addClickListener(event -> focusButton.focus()); Label spacerLabel = new Label("spacer"); spacerLabel.setHeight("300px"); @@ -83,12 +60,8 @@ public class TableBlurFocus extends AbstractReindeerTestUIWithLog { addComponent(spacerLabel); addComponent(focusButton = new Button("for focus")); focusButton.setId("focus-button"); - focusButton.addFocusListener(new FocusListener() { - @Override - public void focus(FocusEvent event) { - focusButton.setCaption("focused"); - } - }); + focusButton + .addFocusListener(event -> focusButton.setCaption("focused")); } private Table createTable() { @@ -125,14 +98,10 @@ public class TableBlurFocus extends AbstractReindeerTestUIWithLog { table.setColumnHeader(Columns.COLUMN1, "Column"); for (int x = 0; x < 120; x++) { final Label buttonLabel = new Label("Not clicked"); - Button button = new Button("Click me?", new Button.ClickListener() { - - @Override - public void buttonClick(Button.ClickEvent event) { - ++count; - buttonLabel.setValue("Clicked " + count + " times"); - Notification.show("Clicked!"); - } + Button button = new Button("Click me?", event -> { + ++count; + buttonLabel.setValue("Clicked " + count + " times"); + Notification.show("Clicked!"); }); table.addItem(new Object[] { "entryString" + x, buttonLabel, button, " " }, "entryID" + x); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java index 8f4a202dcf..001b2fe79b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; import com.vaadin.v7.data.Property; @@ -43,14 +42,7 @@ public class TableCacheBuildEfficiency extends TestBase { table.addContainerProperty("foo", String.class, "bar"); - Button b = new Button("Click to add row", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.addItem(); - - } - }); + Button b = new Button("Click to add row", event -> table.addItem()); getLayout().addComponent(table); getLayout().addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java index a95ca38038..373f504509 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java @@ -6,7 +6,6 @@ import java.util.List; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.util.BeanContainer; import com.vaadin.v7.ui.Table; @@ -42,12 +41,8 @@ public class TableCacheMinimizingOnFetchRows extends AbstractTestUIWithLog { table.setWidth("800px"); Button button = new Button("scroll down"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setCurrentPageFirstItemIndex(table.size()); - } - }); + button.addClickListener( + event -> table.setCurrentPageFirstItemIndex(table.size())); addComponent(table); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java index a334c55cf5..eabbe16bba 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java @@ -6,8 +6,6 @@ import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HasChildMeasurementHint.ChildMeasurementHint; import com.vaadin.ui.HorizontalLayout; @@ -48,30 +46,21 @@ public class TableChildMeasurementHint extends AbstractReindeerTestUI { table3.setChildMeasurementHint(ChildMeasurementHint.MEASURE_NEVER); buttonLayout - .addComponent(new Button("Show table1", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.addComponent(table1); - table1.focus(); - } + .addComponent(new Button("Show table1", event -> { + layout.addComponent(table1); + table1.focus(); })); buttonLayout - .addComponent(new Button("Show table2", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.removeComponent(table1); - layout.addComponent(table2); - table2.focus(); - } + .addComponent(new Button("Show table2", event -> { + layout.removeComponent(table1); + layout.addComponent(table2); + table2.focus(); })); buttonLayout - .addComponent(new Button("Show table3", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.removeComponent(table2); - layout.addComponent(table3); - table3.focus(); - } + .addComponent(new Button("Show table3", event -> { + layout.removeComponent(table2); + layout.addComponent(table3); + table3.focus(); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java index b986a7d6f6..691d0d316d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java @@ -6,10 +6,6 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; public class TableClickValueChangeInteraction extends TestBase { @@ -59,24 +55,15 @@ public class TableClickValueChangeInteraction extends TestBase { table.setWidth("100px"); table.setHeight("100px"); if (listenClicks) { - table.addListener(new ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { - table.markAsDirty(); - clickLabel.setValue("Click " + event.getItemId()); - } + table.addItemClickListener(event -> { + table.markAsDirty(); + clickLabel.setValue("Click " + event.getItemId()); }); } if (listenValueChanges) { - table.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { + table.addValueChangeListener(event -> valueChangeLabel.setValue( - "Value " + event.getProperty().getValue()); - } - }); + "Value " + event.getProperty().getValue())); } Layout result = new VerticalLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnAddAndResize.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnAddAndResize.java index 5280b49e4f..7725521b6d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnAddAndResize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnAddAndResize.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -50,14 +48,9 @@ public class TableColumnAddAndResize extends AbstractReindeerTestUI { table.setVisibleColumns("Id1"); content.addComponent(table); Button button = new Button("Add and Resize"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setVisibleColumns("Id1", "Id2"); - table.setColumnWidth("Id2", 200); - - } + button.addClickListener(event -> { + table.setVisibleColumns("Id1", "Id2"); + table.setColumnWidth("Id2", 200); }); content.addComponent(button); addComponent(content); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java index 3aaeaf237e..952d51e50f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.ColumnGenerator; import com.vaadin.v7.ui.TextField; @@ -31,19 +30,13 @@ public class TableColumnResizeContentsWidth extends AbstractReindeerTestUI { table.setColumnWidth(COL1, 100); addComponent(table); - addComponent(new Button("Increase width", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnWidth(COL1, table.getColumnWidth(COL1) + 20); - table.markAsDirty(); - } + addComponent(new Button("Increase width", event -> { + table.setColumnWidth(COL1, table.getColumnWidth(COL1) + 20); + table.markAsDirty(); })); - addComponent(new Button("Decrease width", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnWidth(COL1, table.getColumnWidth(COL1) - 40); - table.markAsDirty(); - } + addComponent(new Button("Decrease width", event -> { + table.setColumnWidth(COL1, table.getColumnWidth(COL1) - 40); + table.markAsDirty(); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java index a8a57b2f1c..1833792811 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeButton; import com.vaadin.v7.ui.Table; @@ -36,13 +34,7 @@ public class TableColumnWidthsAndExpandRatios extends TestBase { private NativeButton createResetButton(final Object property, final Table table) { return new NativeButton("Reset " + property + " width", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnWidth(property, -1); - } - }); + event -> table.setColumnWidth(property, -1)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndSorting.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndSorting.java index 82f69c3986..31d18afd9b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndSorting.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableColumnWidthsAndSorting.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.fieldgroup.ComplexPerson; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.Table; public class TableColumnWidthsAndSorting extends AbstractTestUIWithLog { @@ -35,13 +33,8 @@ public class TableColumnWidthsAndSorting extends AbstractTestUIWithLog { t.setSelectable(true); addComponent(t); - Button b = new Button("Sort according to gender", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - t.sort(new Object[] { "gender" }, new boolean[] { true }); - } - }); + Button b = new Button("Sort according to gender", event -> t + .sort(new Object[] { "gender" }, new boolean[] { true })); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java index a559e8f743..aa42c5db66 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components.table; import com.vaadin.event.Action; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Component; @@ -44,14 +42,8 @@ public class TableContextMenuOnField extends TestBase { VerticalLayout layout = new VerticalLayout(); layout.addComponent(new TextField()); - layout.addLayoutClickListener(new LayoutClickListener() { - - @Override - public void layoutClick(LayoutClickEvent event) { - getMainWindow().showNotification("HELLO"); - - } - }); + layout.addLayoutClickListener( + event -> getMainWindow().showNotification("HELLO")); return layout; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableFirstRowFlicker.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableFirstRowFlicker.java index c2321c807c..abeaf50e5a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableFirstRowFlicker.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableFirstRowFlicker.java @@ -27,11 +27,7 @@ public class TableFirstRowFlicker extends LegacyApplication { ((VerticalLayout) mainWindow.getContent()).setExpandRatio(t, 1); // Button button = new Button("Refresh"); - // button.addListener(new Button.ClickListener() { - // public void buttonClick(ClickEvent event) { - // t.refreshRowCache(); - // } - // }); + // button.addListener(event -> t.refreshRowCache()); // mainWindow.addComponent(button); ProgressIndicator pi = new ProgressIndicator(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableFocusOnRefreshRowCache.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableFocusOnRefreshRowCache.java index 2df2eb0e5e..2bf7dea65d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableFocusOnRefreshRowCache.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableFocusOnRefreshRowCache.java @@ -1,8 +1,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; public class TableFocusOnRefreshRowCache extends TestBase { @@ -17,12 +15,7 @@ public class TableFocusOnRefreshRowCache extends TestBase { } table.setSelectable(true); - table.addListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - table.refreshRowCache(); - } - }); + table.addItemClickListener(event -> table.refreshRowCache()); addComponent(table); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java index 202593a526..ce98e72927 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java @@ -2,13 +2,9 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.UI; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; -import com.vaadin.ui.Window.CloseListener; import com.vaadin.v7.ui.Table; public class TableInSubWindowMemoryLeak extends TestBase { @@ -18,44 +14,30 @@ public class TableInSubWindowMemoryLeak extends TestBase { final Label label = new Label("Hello Vaadin user"); addComponent(label); final Button openButton = new Button("open me"); - openButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(final ClickEvent event) { - final Window window = new Window("Simple Window"); - window.setModal(true); - window.setHeight("200px"); - window.setWidth("200px"); - final Table table = new Table(); - window.setContent(table); - UI.getCurrent().addWindow(window); - window.addCloseListener(new CloseListener() { - @Override - public void windowClose(final CloseEvent e) { - window.setContent(new Label()); - UI.getCurrent().removeWindow(window); - } - }); - } + openButton.addClickListener(event -> { + final Window window = new Window("Simple Window"); + window.setModal(true); + window.setHeight("200px"); + window.setWidth("200px"); + final Table table = new Table(); + window.setContent(table); + UI.getCurrent().addWindow(window); + window.addCloseListener(closeEvent -> { + window.setContent(new Label()); + UI.getCurrent().removeWindow(window); + }); }); addComponent(openButton); final Button openButton2 = new Button("open me without Table"); - openButton2.addClickListener(new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - final Window window = new Window("Simple Window"); - window.setModal(true); - window.setHeight("200px"); - window.setWidth("200px"); - UI.getCurrent().addWindow(window); - window.addCloseListener(new CloseListener() { - @Override - public void windowClose(final CloseEvent e) { - UI.getCurrent().removeWindow(window); - } - }); - } + openButton2.addClickListener(event -> { + final Window window = new Window("Simple Window"); + window.setModal(true); + window.setHeight("200px"); + window.setWidth("200px"); + UI.getCurrent().addWindow(window); + window.addCloseListener( + closeEvent -> UI.getCurrent().removeWindow(window)); }); addComponent(openButton2); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableJumpUI.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableJumpUI.java index 76a86a6d61..fc797c32d2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableJumpUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableJumpUI.java @@ -15,14 +15,8 @@ */ package com.vaadin.tests.components.table; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.TextField; @@ -68,28 +62,12 @@ public class TableJumpUI extends AbstractTestUIWithLog { TextField tf = new TextField(); tf.setValue(String.valueOf(i)); final int j = i; - tf.addFocusListener(new FocusListener() { - @Override - public void focus(FocusEvent event) { - log("Tf " + j + " focus"); - } - }); - tf.addBlurListener(new BlurListener() { - @Override - public void blur(BlurEvent event) { - log("Tf " + j + " Blur"); - } - }); + tf.addFocusListener(event -> log("Tf " + j + " focus")); + tf.addBlurListener(event -> log("Tf " + j + " Blur")); addComponent(tf); } - addButton("refresh row cache", new ClickListener() { - - @Override - public void buttonClick(final ClickEvent event) { - table.refreshRowCache(); - } - }); + addButton("refresh row cache", event -> table.refreshRowCache()); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java index 68641544e0..344a0607da 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; @@ -63,13 +61,7 @@ public class TableMatchesMouseDownMouseUpElement Button clear = new Button("Clear"); clear.setId(CLEAR_BUTTON_ID); - clear.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setValue(null); - } - }); + clear.addClickListener(event -> table.setValue(null)); addComponent(table); addComponent(clear); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java index b8ad883d5d..5b74f208f2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java @@ -19,13 +19,9 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -53,17 +49,14 @@ public class TableMoveFocusWithSelection extends AbstractReindeerTestUI { l.setId("row-" + i); l.setHeight(20, Unit.PIXELS); l.setData(i); - l.addLayoutClickListener(new LayoutClickListener() { - @Override - public void layoutClick(LayoutClickEvent event) { - if (t.isMultiSelect()) { - Set<Object> values = new HashSet<>( - (Set<Object>) t.getValue()); - values.add(l.getData()); - t.setValue(values); - } else { - t.setValue(l.getData()); - } + l.addLayoutClickListener(event -> { + if (t.isMultiSelect()) { + Set<Object> values = new HashSet<>( + (Set<Object>) t.getValue()); + values.add(l.getData()); + t.setValue(values); + } else { + t.setValue(l.getData()); } }); t.getContainerProperty(i, "layout").setValue(l); @@ -75,28 +68,18 @@ public class TableMoveFocusWithSelection extends AbstractReindeerTestUI { Button toggleSelectMode = new Button(t.isMultiSelect() ? "Press to use single select" : "Press to use multi select"); toggleSelectMode.setId("toggle-mode"); - toggleSelectMode.addClickListener(new ClickListener() { + toggleSelectMode.addClickListener(event -> { + t.setMultiSelect(!t.isMultiSelect()); - @Override - public void buttonClick(ClickEvent event) { - t.setMultiSelect(!t.isMultiSelect()); - - event.getButton().setCaption( - t.isMultiSelect() ? "Press to use single select" - : "Press to use multi select"); - } + event.getButton() + .setCaption(t.isMultiSelect() ? "Press to use single select" + : "Press to use multi select"); }); addComponent(toggleSelectMode); Button select5210 = new Button("Select row 5-10", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - t.setValue(Arrays.asList(5, 6, 7, 8, 9, 10)); - } - }); + event -> t.setValue(Arrays.asList(5, 6, 7, 8, 9, 10))); select5210.setId("select-510"); addComponent(select5210); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableMultiSelectSimple.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableMultiSelectSimple.java index 81a2b9a43a..6b09380c8e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableMultiSelectSimple.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableMultiSelectSimple.java @@ -8,8 +8,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class TableMultiSelectSimple extends TestBase { @@ -26,14 +24,10 @@ public class TableMultiSelectSimple extends TestBase { t.setMultiSelect(true); t.setMultiSelectMode(MultiSelectMode.SIMPLE); t.setImmediate(true); - t.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - TreeSet<?> sorted = new TreeSet<Object>( - (Set<?>) event.getProperty().getValue()); - log.log("Selected value: " + sorted); - } + t.addValueChangeListener(event -> { + TreeSet<?> sorted = new TreeSet<Object>( + (Set<?>) event.getProperty().getValue()); + log.log("Selected value: " + sorted); }); t.addContainerProperty("string", String.class, null); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TablePageLengthUpdate.java b/uitest/src/main/java/com/vaadin/tests/components/table/TablePageLengthUpdate.java index e0b99dd367..3409e66f7e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TablePageLengthUpdate.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TablePageLengthUpdate.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.v7.data.util.MethodProperty; import com.vaadin.v7.ui.Table; @@ -45,13 +43,7 @@ public class TablePageLengthUpdate extends TestBase { addComponent(pageLengthLabel); Button updateButton = new Button("Update pageLength", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - updatePageLengthLabel(); - } - }); + event -> updatePageLengthLabel()); addComponent(updateButton); TextField tableHeight = new TextField("Table height", diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableParentEnabledStateChange.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableParentEnabledStateChange.java index a4932d9bf5..c9d34e9543 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableParentEnabledStateChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableParentEnabledStateChange.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; @@ -39,18 +38,13 @@ public class TableParentEnabledStateChange extends AbstractTestUIWithLog { toggle = new Button( "Toggle enabled state ; " + customComponent.isEnabled()); - toggle.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - customComponent.setEnabled(!customComponent.isEnabled()); - toggle.setCaption("Toggle enabled state ; " - + customComponent.isEnabled()); - } + toggle.addClickListener(event -> { + customComponent.setEnabled(!customComponent.isEnabled()); + toggle.setCaption( + "Toggle enabled state ; " + customComponent.isEnabled()); }); addComponent(toggle); addComponent(customComponent); - } class MyCustomComponent extends CustomComponent { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java index 4b9f4455eb..0309a4de94 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java @@ -6,7 +6,6 @@ import java.util.List; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.v7.data.Container.Filter; @@ -64,40 +63,34 @@ public class TableReduceContainerSize extends TestBase { final Label label = new Label(); addComponent(label); Button button = new Button("Click"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - reduceData = !reduceData; - table.refreshRowCache(); - label.setValue("Index: " - + table.getCurrentPageFirstItemIndex()); - } catch (Exception e) { - label.setValue( - "Exception: " + e.getClass().getSimpleName()); - } + button.addClickListener(event -> { + try { + reduceData = !reduceData; + table.refreshRowCache(); + label.setValue( + "Index: " + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue( + "Exception: " + e.getClass().getSimpleName()); } }); addComponent(button); Button button2 = new Button("Filter"); - button2.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - if (filter != null) { - container.removeAllContainerFilters(); - filter = null; - } else { - filter = new DecimateFilter(); - container.addContainerFilter(filter); - } - table.refreshRowCache(); - label.setValue("Index: " - + table.getCurrentPageFirstItemIndex()); - } catch (Exception e) { - label.setValue( - "Exception: " + e.getClass().getSimpleName()); + button2.addClickListener(event -> { + try { + if (filter != null) { + container.removeAllContainerFilters(); + filter = null; + } else { + filter = new DecimateFilter(); + container.addContainerFilter(filter); } + table.refreshRowCache(); + label.setValue( + "Index: " + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue( + "Exception: " + e.getClass().getSimpleName()); } }); addComponent(button2); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java index 8e00357b56..70868615f6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java @@ -25,7 +25,6 @@ import com.vaadin.server.StreamVariable; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ConnectorTracker; import com.vaadin.v7.ui.Table; @@ -205,12 +204,7 @@ public class TableRemovedQuicklySendsInvalidRpcCalls @Override protected void setup(VaadinRequest request) { - button = new Button("Blink a table", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - blinkTable(); - } - }); + button = new Button("Blink a table", event -> blinkTable()); button.setId(BUTTON_ID); addComponent(button); } @@ -242,13 +236,10 @@ public class TableRemovedQuicklySendsInvalidRpcCalls getSession().lock(); try { Thread.sleep(500); - access(new Runnable() { - @Override - public void run() { - System.out.println("removing component"); - removeComponent(table); - button.setCaption(SUCCESS_CAPTION); - } + access(() -> { + System.out.println("removing component"); + removeComponent(table); + button.setCaption(SUCCESS_CAPTION); }); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java index 739bf9e6d6..8b44127acd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.Table; public class TableRepaintWhenMadeVisibile extends TestBase { @@ -15,21 +13,9 @@ public class TableRepaintWhenMadeVisibile extends TestBase { table.addItem(new Object[] { "something" }, 1); addComponent(table); - Button show = new Button("show", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setVisible(true); - } - }); + Button show = new Button("show", event -> table.setVisible(true)); addComponent(show); - Button hide = new Button("hide", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setVisible(false); - } - }); + Button hide = new Button("hide", event -> table.setVisible(false)); addComponent(hide); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java index e121846c94..56b4e52ee4 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java @@ -7,7 +7,6 @@ import java.util.List; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; @@ -36,26 +35,18 @@ public class TableRepairsScrollPositionOnReAddingAllRows Button buttonRestore = new Button("Restore table rows"); buttonRestore.setId("buttonRestore"); - buttonRestore.addClickListener(new ClickListener() { - - @Override - public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - cont.addAll(restoringItemList); - } + buttonRestore.addClickListener(event -> { + cont.removeAllItems(); + cont.addAll(restoringItemList); }); Button buttonReAddAllViaAddAll = new Button("Re-add rows all at once"); buttonReAddAllViaAddAll.setId("buttonReAddAllViaAddAll"); - buttonReAddAllViaAddAll.addClickListener(new ClickListener() { - - @Override - public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { - List<TableItem> originalItemIds = new ArrayList<>( - cont.getItemIds()); - cont.removeAllItems(); - cont.addAll(originalItemIds); - } + buttonReAddAllViaAddAll.addClickListener(event -> { + List<TableItem> originalItemIds = new ArrayList<>( + cont.getItemIds()); + cont.removeAllItems(); + cont.addAll(originalItemIds); }); Button buttonReplaceByAnotherCollectionViaAddAll = new Button( @@ -63,22 +54,17 @@ public class TableRepairsScrollPositionOnReAddingAllRows buttonReplaceByAnotherCollectionViaAddAll .setId("buttonReplaceByAnotherCollectionViaAddAll"); buttonReplaceByAnotherCollectionViaAddAll - .addClickListener(new ClickListener() { - - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - // create new collection (of different items) with other - // size - List<TableItem> itemList = new ArrayList<>(); - for (int i = 0; i < 79; i++) { - TableItem ti = new TableItem(); - ti.setName("AnotherItem1_" + i); - itemList.add(ti); - } - cont.addAll(itemList); + .addClickListener(event -> { + cont.removeAllItems(); + // create new collection (of different items) with other + // size + List<TableItem> itemList = new ArrayList<>(); + for (int i = 0; i < 79; i++) { + TableItem ti = new TableItem(); + ti.setName("AnotherItem1_" + i); + itemList.add(ti); } + cont.addAll(itemList); }); Button buttonReplaceByAnotherCollectionViaAdd = new Button( @@ -86,18 +72,13 @@ public class TableRepairsScrollPositionOnReAddingAllRows buttonReplaceByAnotherCollectionViaAdd .setId("buttonReplaceByAnotherCollectionViaAdd"); buttonReplaceByAnotherCollectionViaAdd - .addClickListener(new ClickListener() { - - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - for (int i = 0; i < 81; i++) { - TableItem ti = new TableItem(); - ti.setName("AnotherItem2_" + i); - // add one by one in container - cont.addBean(ti); - } + .addClickListener(event -> { + cont.removeAllItems(); + for (int i = 0; i < 81; i++) { + TableItem ti = new TableItem(); + ti.setName("AnotherItem2_" + i); + // add one by one in container + cont.addBean(ti); } }); @@ -106,14 +87,9 @@ public class TableRepairsScrollPositionOnReAddingAllRows buttonReplaceBySubsetOfSmallerSize .setId("buttonReplaceBySubsetOfSmallerSize"); buttonReplaceBySubsetOfSmallerSize - .addClickListener(new ClickListener() { - - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - cont.addAll(restoringItemList.subList(0, 20)); - } + .addClickListener(event -> { + cont.removeAllItems(); + cont.addAll(restoringItemList.subList(0, 20)); }); Button buttonReplaceByWholeSubsetPlusOneNew = new Button( @@ -121,54 +97,40 @@ public class TableRepairsScrollPositionOnReAddingAllRows buttonReplaceByWholeSubsetPlusOneNew .setId("buttonReplaceByWholeSubsetPlusOneNew"); buttonReplaceByWholeSubsetPlusOneNew - .addClickListener(new ClickListener() { + .addClickListener(event -> { + cont.removeAllItems(); - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - - List<TableItem> list = new ArrayList<>( - restoringItemList); - TableItem ti = new TableItem(); - ti.setName("AnotherItem3_" + 80); - list.add(ti); - cont.addAll(list); - } + List<TableItem> list = new ArrayList<>(restoringItemList); + TableItem ti = new TableItem(); + ti.setName("AnotherItem3_" + 80); + list.add(ti); + cont.addAll(list); }); Button buttonRemoveAllAddOne = new Button( "Remove all items and add only one new item"); buttonRemoveAllAddOne.setId("buttonRemoveAllAddOne"); - buttonRemoveAllAddOne.addClickListener(new ClickListener() { - - @Override - public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - TableItem ti = new TableItem(); - ti.setName("Item_" + 20); - cont.addBean(ti); - } + buttonRemoveAllAddOne.addClickListener(event -> { + cont.removeAllItems(); + TableItem ti = new TableItem(); + ti.setName("Item_" + 20); + cont.addBean(ti); }); // This should be the last test as it changes the table datasource Button buttonReplaceByNewDatasource = new Button( "Remove all items and add new datasource"); buttonReplaceByNewDatasource.setId("buttonReplaceByNewDatasource"); - buttonReplaceByNewDatasource.addClickListener(new ClickListener() { - - @Override - public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { - cont.removeAllItems(); - BeanItemContainer<TableItem> newContainer = new BeanItemContainer<>( - TableItem.class); - for (int i = 0; i < 50; i++) { - TableItem ti = new TableItem(); - ti.setName("Item_" + i); - newContainer.addBean(ti); - } - table.setContainerDataSource(newContainer); + buttonReplaceByNewDatasource.addClickListener(event -> { + cont.removeAllItems(); + BeanItemContainer<TableItem> newContainer = new BeanItemContainer<>( + TableItem.class); + for (int i = 0; i < 50; i++) { + TableItem ti = new TableItem(); + ti.setName("Item_" + i); + newContainer.addBean(ti); } + table.setContainerDataSource(newContainer); }); for (int i = 0; i < 80; i++) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableRequiredIndicator.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableRequiredIndicator.java index 3555f300a0..1007ddb241 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableRequiredIndicator.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableRequiredIndicator.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Notification; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class TableRequiredIndicator extends AbstractReindeerTestUI { @@ -45,17 +43,12 @@ public class TableRequiredIndicator extends AbstractReindeerTestUI { // This should cause red asterisk to the vertical layout table.setRequired(true); - table.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - Object value = table.getValue(); - if (value != null) { - Notification.show("Value is set."); - } else { - Notification.show("Value is NOT set."); - } - + table.addValueChangeListener(event -> { + Object value = table.getValue(); + if (value != null) { + Notification.show("Value is set."); + } else { + Notification.show("Value is NOT set."); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollAfterAddRow.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollAfterAddRow.java index abbc47e7eb..81cfed8dfe 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollAfterAddRow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollAfterAddRow.java @@ -17,7 +17,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.NativeButton; import com.vaadin.ui.VerticalLayout; @@ -60,44 +59,19 @@ public class TableScrollAfterAddRow extends AbstractReindeerTestUI { layout.addComponent(label); NativeButton addRowButton = new NativeButton("Add row", - new NativeButton.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - addRow(datasource); - } - }); + event -> addRow(datasource)); NativeButton jumpToLastRowButton = new NativeButton("Jump to last row", - new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - jumpToLastRow(table); - } - }); + event -> jumpToLastRow(table)); NativeButton jumpTo15thRowButton = new NativeButton("Jump to 15th row", - new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - jumpToFifteenthRow(table); - } - }); + event -> jumpToFifteenthRow(table)); NativeButton jumpToFirstRowButton = new NativeButton( - "Jump to first row", new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - jumpToFirstRow(table); - } - }); + "Jump to first row", event -> jumpToFirstRow(table)); NativeButton updateLabelButton = new NativeButton("UpdateLabel", - new NativeButton.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + event -> label.setValue(Integer.toString( - table.getCurrentPageFirstItemIndex())); - } - }); + table.getCurrentPageFirstItemIndex()))); layout.addComponent(addRowButton); layout.addComponent(jumpToLastRowButton); layout.addComponent(jumpTo15thRowButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollUpOnSelect.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollUpOnSelect.java index 3654f9a084..e00ae4beeb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollUpOnSelect.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollUpOnSelect.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.TextField; @@ -51,15 +49,10 @@ public class TableScrollUpOnSelect extends AbstractReindeerTestUI { final VerticalLayout layout = new VerticalLayout(); - table.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if (table.getValue() != null) { - text.setValue(table.getValue().toString()); - } + table.addValueChangeListener(event -> { + if (table.getValue() != null) { + text.setValue(table.getValue().toString()); } - }); table.setCurrentPageFirstItemIndex(49); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableSetUndefinedSize.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableSetUndefinedSize.java index 2544720eee..5d9a127650 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableSetUndefinedSize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableSetUndefinedSize.java @@ -25,38 +25,19 @@ public class TableSetUndefinedSize extends AbstractReindeerTestUI { } private Button createSizeUndefinedButton(final Table table) { - return new Button("size undefined", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setSizeUndefined(); - } - }); + return new Button("size undefined", event -> table.setSizeUndefined()); } private HorizontalLayout createWidthButtons(final Table table) { HorizontalLayout layout = new HorizontalLayout(); layout.addComponent( - new Button("width 500px", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setWidth("500px"); - } - })); + new Button("width 500px", event -> table.setWidth("500px"))); layout.addComponent( - new Button("width 100%", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setWidth("100%"); - } - })); + new Button("width 100%", event -> table.setWidth("100%"))); layout.addComponent( - new Button("undefined width", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setWidthUndefined(); - } - })); + new Button("undefined width", + event -> table.setWidthUndefined())); return layout; } @@ -65,33 +46,14 @@ public class TableSetUndefinedSize extends AbstractReindeerTestUI { HorizontalLayout layout = new HorizontalLayout(); layout.addComponent( - new Button("height 200px", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setHeight("200px"); - } - })); + new Button("height 200px", event -> table.setHeight("200px"))); layout.addComponent( - new Button("height 300px", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setHeight("300px"); - } - })); + new Button("height 300px", event -> table.setHeight("300px"))); layout.addComponent( - new Button("height 100%", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setHeight("100%"); - } - })); + new Button("height 100%", event -> table.setHeight("100%"))); layout.addComponent( - new Button("undefined height", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - table.setHeightUndefined(); - } - })); + new Button("undefined height", + event -> table.setHeightUndefined())); return layout; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.java index 8c28b8f789..db9298cdaa 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Notification; -import com.vaadin.v7.event.ItemClickEvent; import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.TableDragMode; @@ -25,14 +24,9 @@ public class TableShouldNotEatValueChanges extends TestBase { final TextField tf = new TextField(); tf.setTabIndex(1); - ItemClickListener l = new ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { + ItemClickListener l = event -> Notification.show("TF Value on the server:" + tf.getValue(), - Notification.TYPE_WARNING_MESSAGE); - } - }; + Notification.TYPE_WARNING_MESSAGE); t.addListener(l); addComponent(tf); addComponent(t); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableSingleSelect.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableSingleSelect.java index caf4c22d94..0dc83e8278 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableSingleSelect.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableSingleSelect.java @@ -4,8 +4,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class TableSingleSelect extends TestBase { @@ -20,13 +18,8 @@ public class TableSingleSelect extends TestBase { t.setSelectable(true); t.setNullSelectionAllowed(true); t.setImmediate(true); - t.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log.log("Selected value: " + event.getProperty().getValue()); - } - }); + t.addValueChangeListener(event -> log + .log("Selected value: " + event.getProperty().getValue())); t.addContainerProperty("string", String.class, null); t.addContainerProperty("button", Component.class, null); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableSorting.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableSorting.java index 9aba9b8868..a4c8da2928 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableSorting.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableSorting.java @@ -4,8 +4,6 @@ import java.io.Serializable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; @@ -31,13 +29,10 @@ public class TableSorting extends TestBase { testTable.setVisibleColumns("testName"); // Handle selection change. - testTable.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - System.out.println( - "ValueChanged: " + testTable.getValue().toString()); - showID.setCaption("ID: " + testTable.getValue().toString()); - } + testTable.addValueChangeListener(event -> { + System.out.println( + "ValueChanged: " + testTable.getValue().toString()); + showID.setCaption("ID: " + testTable.getValue().toString()); }); addComponent(testTable); addComponent(showID); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingIndicator.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingIndicator.java index bb883b48e2..da1fa2a87e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingIndicator.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingIndicator.java @@ -20,8 +20,6 @@ import java.util.Random; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; @@ -45,13 +43,8 @@ public class TableSortingIndicator extends AbstractReindeerTestUI { final Table table = new Table("Test table", buildContainer()); table.setSizeFull(); addComponent(table); - Button sortButton = new Button("Sort", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.sort(new Object[] { "val1" }, new boolean[] { false }); - } - }); + Button sortButton = new Button("Sort", event -> table + .sort(new Object[] { "val1" }, new boolean[] { false })); addComponent(sortButton); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingStopsWorkingOnChrome.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingStopsWorkingOnChrome.java index d39e463c9f..75a4a1d210 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingStopsWorkingOnChrome.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableSortingStopsWorkingOnChrome.java @@ -11,10 +11,6 @@ import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Table.ColumnReorderEvent; -import com.vaadin.v7.ui.Table.ColumnReorderListener; -import com.vaadin.v7.ui.Table.HeaderClickEvent; -import com.vaadin.v7.ui.Table.HeaderClickListener; @SuppressWarnings("serial") public class TableSortingStopsWorkingOnChrome extends AbstractTestUI { @@ -63,21 +59,11 @@ public class TableSortingStopsWorkingOnChrome extends AbstractTestUI { } }); - table.addColumnReorderListener(new ColumnReorderListener() { + table.addColumnReorderListener( + event -> System.out.println("columnReorder")); - @Override - public void columnReorder(ColumnReorderEvent event) { - System.out.println("columnReorder"); - } - }); - - table.addHeaderClickListener(new HeaderClickListener() { - - @Override - public void headerClick(HeaderClickEvent event) { - System.out.println("Header was clicked"); - } - }); + table.addHeaderClickListener( + event -> System.out.println("Header was clicked")); layout.addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleColumnVisibility.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleColumnVisibility.java index d6c17838ca..efe7bc7261 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleColumnVisibility.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleColumnVisibility.java @@ -19,8 +19,6 @@ import com.vaadin.server.ClassResource; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -55,24 +53,16 @@ public class TableToggleColumnVisibility extends AbstractReindeerTestUI { final Button visibToggler = new Button("visibility"); visibToggler.setId("visib-toggler"); - visibToggler.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - currentSetNumber = (currentSetNumber == 0) ? 1 : 0; - table.setVisibleColumns(columnSets[currentSetNumber]); - } + visibToggler.addClickListener(event -> { + currentSetNumber = (currentSetNumber == 0) ? 1 : 0; + table.setVisibleColumns(columnSets[currentSetNumber]); }); final Button orderToggler = new Button("change order"); orderToggler.setId("order-toggler"); - orderToggler.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - currentSetNumber = (currentSetNumber == 1) ? 2 : 1; - table.setVisibleColumns(columnSets[currentSetNumber]); - } + orderToggler.addClickListener(event -> { + currentSetNumber = (currentSetNumber == 1) ? 2 : 1; + table.setVisibleColumns(columnSets[currentSetNumber]); }); layout.addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java index dd88b6cf72..7498471fa0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java @@ -138,24 +138,17 @@ public class TableToggleVisibility extends AbstractTestCase { setCaption("- " + table.getCaption()); - addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - boolean wasVisible = ToggleButton.this.table.isVisible(); - - ToggleButton.this.table.setVisible(!wasVisible); - setCaption((wasVisible ? "+ " : "- ") - + ToggleButton.this.table.getCaption()); - setDescription( - (wasVisible ? "Show " : "Hide ") + "the list with " - + ToggleButton.this.table.getCaption()); - - } + addClickListener(event -> { + boolean wasVisible = ToggleButton.this.table.isVisible(); + + ToggleButton.this.table.setVisible(!wasVisible); + setCaption((wasVisible ? "+ " : "- ") + + ToggleButton.this.table.getCaption()); + setDescription( + (wasVisible ? "Show " : "Hide ") + "the list with " + + ToggleButton.this.table.getCaption()); }); } - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableUndefinedSize.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableUndefinedSize.java index 53bb8e25df..441730c101 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableUndefinedSize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableUndefinedSize.java @@ -5,12 +5,9 @@ import java.util.Arrays; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Container; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.Table; @@ -37,46 +34,34 @@ public class TableUndefinedSize extends TestBase { log = new Log(5); controls.addComponent( - new Button("Fixed size (200x200)", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tbl.setWidth("200px"); - tbl.setHeight("200px"); - log.log("Size 200x200 pixels"); - } + new Button("Fixed size (200x200)", event -> { + tbl.setWidth("200px"); + tbl.setHeight("200px"); + log.log("Size 200x200 pixels"); })); controls.addComponent( - new Button("Fixed size (600x200)", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tbl.setWidth("600px"); - tbl.setHeight("200px"); - log.log("Size 600x200 pixels"); - } + new Button("Fixed size (600x200)", event -> { + tbl.setWidth("600px"); + tbl.setHeight("200px"); + log.log("Size 600x200 pixels"); })); controls.addComponent( - new Button("Undefined size", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tbl.setSizeUndefined(); - log.log("Size undefined"); - } + new Button("Undefined size", event -> { + tbl.setSizeUndefined(); + log.log("Size undefined"); })); NativeSelect pageLength = new NativeSelect("PageLength", Arrays.asList(0, 1, 2, 4, 8, 10)); pageLength.setImmediate(true); pageLength.setNullSelectionAllowed(false); - pageLength.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - int pageLength = Integer - .valueOf(event.getProperty().getValue().toString()); - tbl.setPageLength(pageLength); - log.log("Page length: " + pageLength); - } + pageLength.addValueChangeListener(event -> { + int pageLengthValue = Integer + .valueOf(event.getProperty().getValue().toString()); + tbl.setPageLength(pageLengthValue); + log.log("Page length: " + pageLengthValue); }); controls.addComponent(pageLength); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableUnregisterComponent.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableUnregisterComponent.java index 9e8e0cc483..166dcd2cea 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableUnregisterComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableUnregisterComponent.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; @@ -76,21 +74,12 @@ public class TableUnregisterComponent extends TestBase { addComponent(log); addComponent(table); - addComponent(new Button("Switch column collapse", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed(COL_A, - !table.isColumnCollapsed(COL_A)); - } - })); - - addComponent(new Button("Switch editable", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setEditable(!table.isEditable()); - } - })); + addComponent(new Button("Switch column collapse", + event -> table.setColumnCollapsed(COL_A, + !table.isColumnCollapsed(COL_A)))); + addComponent(new Button("Switch editable", + event -> table.setEditable(!table.isEditable()))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWidthItemRemove.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWidthItemRemove.java index 68d6653f1a..def30f9d04 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWidthItemRemove.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWidthItemRemove.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.Table; /** @@ -45,20 +43,11 @@ public class TableWidthItemRemove extends AbstractReindeerTestUI { table.setColumnWidth("lastName", 100); table.setColumnWidth("year", 50); - addButton("Clean", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.removeAllItems(); - } - }); + addButton("Clean", event -> table.removeAllItems()); - addButton("Populate", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { + addButton("Populate", event -> table.addItem(new Object[] { "John", "Doe", new Integer(1980) }, - Math.random() * 1000); - } - }); + Math.random() * 1000)); addComponent(table); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java index 0d947c1dc7..8f987b973a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java @@ -22,7 +22,6 @@ import com.vaadin.server.ServerRpcManager.RpcInvocationException; import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Notification; import com.vaadin.v7.data.Item; @@ -99,13 +98,9 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { table.setPageLength(20); Button refreshTableCache = new Button("Refresh table cache", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.markAsDirty(); - table.refreshRowCache(); - } + event -> { + table.markAsDirty(); + table.refreshRowCache(); }); addComponent(refreshTableCache); addComponent(brokenContainer); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java index aec5606f86..faa58789d6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java @@ -6,7 +6,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.v7.data.util.BeanContainer; import com.vaadin.v7.data.util.BeanItem; @@ -56,13 +55,9 @@ public class TableWithContainerRequiringEqualsForItemId public Component generateCell(final Table source, final Object itemId, final Object columnId) { Button tripFolderLink = new Button("Button" + itemId); - tripFolderLink.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { + tripFolderLink.addClickListener(event -> log.log("Button " + event.getButton().getCaption() - + " clicked"); - } - }); + + " clicked")); tripFolderLink.setStyleName(Reindeer.BUTTON_SMALL); return tripFolderLink; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithNoncollapsibleColumns.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithNoncollapsibleColumns.java index 482c230124..e9a649a1b9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithNoncollapsibleColumns.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithNoncollapsibleColumns.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.Table; @@ -30,50 +29,30 @@ public class TableWithNoncollapsibleColumns extends TestBase { layout.addComponent(table); final Button button1 = new Button("Column 1: collapse/show", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed("Column 1 - noncollapsible", + event -> table.setColumnCollapsed("Column 1 - noncollapsible", !table.isColumnCollapsed( - "Column 1 - noncollapsible")); - } - }); + "Column 1 - noncollapsible"))); final Button button2 = new Button("Column 2: collapse/show", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed("Column 2 - collapsible", + event -> table.setColumnCollapsed("Column 2 - collapsible", !table.isColumnCollapsed( - "Column 2 - collapsible")); - } - }); + "Column 2 - collapsible"))); final Button button3 = new Button("Column 3: collapse/show", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed("Column 3 - toggle collapsing", + event -> table.setColumnCollapsed( + "Column 3 - toggle collapsing", !table.isColumnCollapsed( - "Column 3 - toggle collapsing")); - } - }); + "Column 3 - toggle collapsing"))); final Button button4 = new Button( "Column 3: make noncollapsible/collapsible", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsible( + event -> table.setColumnCollapsible( "Column 3 - toggle collapsing", !table.isColumnCollapsible( - "Column 3 - toggle collapsing")); - } - }); + "Column 3 - toggle collapsing"))); layout.addComponent(button1); layout.addComponent(button2); layout.addComponent(button3); layout.addComponent(button4); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java b/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java index c08ec93a8e..fecae08714 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -20,15 +19,11 @@ public class TextFieldValueGoesMissing extends AbstractReindeerTestUI { final Label label2 = new Label("2"); Button button = new Button("Replace label"); - button.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (verticalLayout.getComponentIndex(label1) > -1) { - verticalLayout.replaceComponent(label1, label2); - } else { - verticalLayout.replaceComponent(label2, label1); - } + button.addClickListener(event -> { + if (verticalLayout.getComponentIndex(label1) > -1) { + verticalLayout.replaceComponent(label1, label2); + } else { + verticalLayout.replaceComponent(label2, label1); } }); verticalLayout.addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/UncollapsedCollumnWidth.java b/uitest/src/main/java/com/vaadin/tests/components/table/UncollapsedCollumnWidth.java index 76360c74b5..547619bc28 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/UncollapsedCollumnWidth.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/UncollapsedCollumnWidth.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Table; public class UncollapsedCollumnWidth extends TestBase { @@ -22,12 +21,8 @@ public class UncollapsedCollumnWidth extends TestBase { table.addItem(new Object[] { "Cell 1", "Cell 2" }, new Object()); addComponent(table); - addComponent(new Button("Uncollapse col2", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.setColumnCollapsed("Col2", false); - } - })); + addComponent(new Button("Uncollapse col2", + event -> table.setColumnCollapsed("Col2", false))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java b/uitest/src/main/java/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java index f90d9c9f4c..0b1fc07191 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.table; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.TabSheet; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; @@ -24,16 +23,11 @@ public class UpdateTableWhenUnfocused extends AbstractReindeerTestUI { addComponent(tabSheet); final Button button = new Button("Refresh table"); - button.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - button.focus(); - table.refreshRowCache(); - } + button.addClickListener(event -> { + button.focus(); + table.refreshRowCache(); }); addComponent(button); - } private Table createTable() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ValueAfterClearingContainer.java b/uitest/src/main/java/com/vaadin/tests/components/table/ValueAfterClearingContainer.java index 9fbb0256b7..e8807a6d7d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ValueAfterClearingContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ValueAfterClearingContainer.java @@ -3,11 +3,8 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Notification; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class ValueAfterClearingContainer extends TestBase { @@ -24,13 +21,8 @@ public class ValueAfterClearingContainer extends TestBase { table.setSelectable(true); table.addContainerProperty(PROPERTY_ID, Integer.class, null); table.setImmediate(true); - table.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log.log("Value changed to " + event.getProperty().getValue()); - } - }); + table.addValueChangeListener(event -> log + .log("Value changed to " + event.getProperty().getValue())); addComponent(log); addComponent(table); @@ -42,95 +34,64 @@ public class ValueAfterClearingContainer extends TestBase { }); addComponent(multiselect); Button addItemsButton = new Button("Add table items", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (!table.getItemIds().isEmpty()) { - Notification.show( - "Only possible when the table is empty"); - return; - } else { - for (int i = 0; i < 5; i++) { - table.addItem( - new Object[] { Integer.valueOf(i) }, - Integer.valueOf(i)); - } - } + event -> { + if (!table.getItemIds().isEmpty()) { + Notification + .show("Only possible when the table is empty"); + return; + } + for (int i = 0; i < 5; i++) { + table.addItem(new Object[] { Integer.valueOf(i) }, + Integer.valueOf(i)); } }); addItemsButton.setId("addItemsButton"); addComponent(addItemsButton); Button showValueButton = new Button("Show value", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.log("Table selection: " + table.getValue()); - } - }); + event -> log.log("Table selection: " + table.getValue())); showValueButton.setId("showValueButton"); addComponent(showValueButton); Button removeItemsFromTableButton = new Button( - "Remove items from table", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.removeAllItems(); - } - }); + "Remove items from table", event -> table.removeAllItems()); removeItemsFromTableButton.setId("removeItemsFromTableButton"); addComponent(removeItemsFromTableButton); Button removeItemsFromContainerButton = new Button( - "Remove items from container", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.getContainerDataSource().removeAllItems(); - } - }); + "Remove items from container", + event -> table.getContainerDataSource().removeAllItems()); removeItemsFromContainerButton.setId("removeItemsFromContainerButton"); addComponent(removeItemsFromContainerButton); Button removeItemsFromContainerAndSanitizeButton = new Button( "Remove items from container and sanitize", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.getContainerDataSource().removeAllItems(); - table.sanitizeSelection(); - } + event -> { + table.getContainerDataSource().removeAllItems(); + table.sanitizeSelection(); }); removeItemsFromContainerAndSanitizeButton .setId("removeItemsFromContainerAndSanitizeButton"); addComponent(removeItemsFromContainerAndSanitizeButton); Button removeSelectedFromTableButton = new Button( - "Remove selected item from table", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object selection = table.getValue(); - if (selection == null) { - Notification.show("There is no selection"); - return; - } else { - table.removeItem(selection); - } + "Remove selected item from table", event -> { + Object selection = table.getValue(); + if (selection == null) { + Notification.show("There is no selection"); + return; } + table.removeItem(selection); }); removeSelectedFromTableButton.setId("removeSelectedFromTableButton"); addComponent(removeSelectedFromTableButton); Button removeSelectedFromContainer = new Button( "Remove selected item from container", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object selection = table.getValue(); - if (selection == null) { - Notification.show("There is no selection"); - return; - } else { - table.getContainerDataSource() - .removeItem(selection); - } + event -> { + Object selection = table.getValue(); + if (selection == null) { + Notification.show("There is no selection"); + return; } + table.getContainerDataSource().removeItem(selection); }); removeSelectedFromContainer.setId("removeSelectedFromContainer"); addComponent(removeSelectedFromContainer); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ViewPortCalculation.java b/uitest/src/main/java/com/vaadin/tests/components/table/ViewPortCalculation.java index 76ec5e4437..88c06da535 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/ViewPortCalculation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/ViewPortCalculation.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.v7.data.Item; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.CellStyleGenerator; @@ -53,14 +51,11 @@ public class ViewPortCalculation extends TestBase { } }); - table.addItemClickListener(new ItemClickListener() { - @Override - public void itemClick(ItemClickEvent event) { - if (event.isDoubleClick()) { - lastDoubleClickedItemId = event.getItemId(); - table.refreshRowCache(); - table.select(event.getItemId()); - } + table.addItemClickListener(event -> { + if (event.isDoubleClick()) { + lastDoubleClickedItemId = event.getItemId(); + table.refreshRowCache(); + table.select(event.getItemId()); } }); return table; diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/AddAndRemoveTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/AddAndRemoveTabs.java index 4b5d216906..758f5c4cf8 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/AddAndRemoveTabs.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/AddAndRemoveTabs.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TabSheet; @@ -18,14 +17,7 @@ public class AddAndRemoveTabs extends TestBase { addComponent(tabSheet); Button addTabBtn = new Button("Add new tab", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - addTab(); - } - - }); + event -> addTab()); addComponent(addTabBtn); } @@ -33,15 +25,8 @@ public class AddAndRemoveTabs extends TestBase { final HorizontalLayout layout = new HorizontalLayout(); layout.setCaption("Test " + counter); - Button closeTab = new Button("Close tab", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tabSheet.removeComponent(layout); - - } - - }); + Button closeTab = new Button("Close tab", + event -> tabSheet.removeComponent(layout)); layout.addComponent(closeTab); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheet.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheet.java index 2bca014917..d93d18e7d6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheet.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheet.java @@ -25,12 +25,8 @@ public class FirstTabNotVisibleInTabsheet extends AbstractReindeerTestUI { } addComponent(new VerticalLayout(tabSheet, - new Button("Toggle first tab", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - firstTab.setVisible(!firstTab.isVisible()); - } - }))); + new Button("Toggle first tab", + event -> firstTab.setVisible(!firstTab.isVisible())))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClipped.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClipped.java index 19dcf30d37..066de6b59f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClipped.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClipped.java @@ -20,20 +20,12 @@ public class FirstTabNotVisibleWhenTabsheetNotClipped @Override protected void setup(VaadinRequest request) { - addButton("Toggle first not clipped tab", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - firstNotClippedTab.setVisible(!firstNotClippedTab.isVisible()); - } - }); + addButton("Toggle first not clipped tab", event -> firstNotClippedTab + .setVisible(!firstNotClippedTab.isVisible())); addComponent(createNotClippedTabSheet()); - addButton("Toggle first clipped tab", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - firstClippedTab.setVisible(!firstClippedTab.isVisible()); - } - }); + addButton("Toggle first clipped tab", event -> firstClippedTab + .setVisible(!firstClippedTab.isVisible())); addComponent(createClippedTabSheet()); addComponent(new Label("VerticalLayout:")); @@ -102,22 +94,18 @@ public class FirstTabNotVisibleWhenTabsheetNotClipped private Button.ClickListener createTabListener( final Map<String, TabSheet.Tab> map, final TabSheet tabsheet) { - Button.ClickListener clickListener = new Button.ClickListener() { - - @Override - public void buttonClick(Button.ClickEvent event) { - // id of the button is the same as the tab's caption - String tabName = event.getComponent().getId(); + Button.ClickListener clickListener = event -> { + // id of the button is the same as the tab's caption + String tabName = event.getComponent().getId(); - for (Map.Entry<String, TabSheet.Tab> entry : map.entrySet()) { - TabSheet.Tab tab = entry.getValue(); + for (Map.Entry<String, TabSheet.Tab> entry : map.entrySet()) { + TabSheet.Tab tab = entry.getValue(); - if (entry.getKey().equals(tabName)) { - tab.setVisible(true); - tabsheet.setSelectedTab(tab.getComponent()); - } else { - tab.setVisible(false); - } + if (entry.getKey().equals(tabName)) { + tab.setVisible(true); + tabsheet.setSelectedTab(tab.getComponent()); + } else { + tab.setVisible(false); } } }; diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java index eac786d9b3..e237679eb6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -16,12 +15,7 @@ public class HiddenTabSheetBrowserResize extends TestBase { tabSheet.addTab(new Label("Label2"), "Tab2"); Button toggleButton = new Button("Toggle TabSheet", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabSheet.setVisible(!tabSheet.isVisible()); - } - }); + event -> tabSheet.setVisible(!tabSheet.isVisible())); addComponent(toggleButton); addComponent(tabSheet); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/MoveComponentBetweenTabsheets.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/MoveComponentBetweenTabsheets.java index 30b3be0c51..72cfefcb53 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/MoveComponentBetweenTabsheets.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/MoveComponentBetweenTabsheets.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -30,12 +29,7 @@ public class MoveComponentBetweenTabsheets extends AbstractReindeerTestUI { // TODO Auto-generated method stub Button button = new Button("Move L1 to the right tabsheet"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - doTestOperation(); - } - }); + button.addClickListener(event -> doTestOperation()); getLayout().addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/NestedTabSheetsHideTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/NestedTabSheetsHideTabs.java index 0e958e632c..d60a4ceb5c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/NestedTabSheetsHideTabs.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/NestedTabSheetsHideTabs.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -15,12 +14,8 @@ public class NestedTabSheetsHideTabs extends TestBase { @Override public void setup() { - addComponent(new Button("Toggle tabs", new Button.ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - main.hideTabs(!main.areTabsHidden()); - } - })); + addComponent(new Button("Toggle tabs", + event -> main.hideTabs(!main.areTabsHidden()))); sub = new TabSheet(); sub.addTab(newPage(21), "Page 21"); sub.addTab(newPage(22), "Page 22"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java index 4a04ff669c..c8e7d61934 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java @@ -6,7 +6,6 @@ import java.util.List; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractComponentContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -47,56 +46,25 @@ public class RemoveTabs extends TestBase { getLayout().addComponent(tabsheet); closeCurrent = new Button("Close current tab"); - closeCurrent.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - closeCurrentTab(); - - } - }); + closeCurrent.addClickListener(event -> closeCurrentTab()); closeCurrentWithTab = new Button("Close current tab with Tab"); - closeCurrentWithTab.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - closeCurrentTabWithTab(); - - } - }); + closeCurrentWithTab.addClickListener(event -> closeCurrentTabWithTab()); closeFirst = new Button("close first tab"); - closeFirst.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - closeFirstTab(); - - } - }); + closeFirst.addClickListener(event -> closeFirstTab()); closeLast = new Button("close last tab"); - closeLast.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - closeLastTab(); - - } - }); + closeLast.addClickListener(event -> closeLastTab()); reorderTabs = new Button("reorder"); - reorderTabs.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - reorder(); - - } - }); + reorderTabs.addClickListener(event -> reorder()); getLayout().addComponent(closeFirst); getLayout().addComponent(closeLast); getLayout().addComponent(closeCurrent); getLayout().addComponent(closeCurrentWithTab); getLayout().addComponent(reorderTabs); - } private void closeCurrentTab() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java index a480751b15..268ed70df2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabGetAndReplaceComponent.java @@ -4,7 +4,6 @@ import java.util.Iterator; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -24,20 +23,16 @@ public class TabGetAndReplaceComponent extends TestBase { addComponent(tabs); Button replace2 = new Button("Replace Content 2", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Iterator<Component> iter = tabs.getComponentIterator(); - iter.next(); + event -> { + Iterator<Component> iter = tabs.getComponentIterator(); + iter.next(); - Component content2 = iter.next(); - Tab tab = tabs.getTab(content2); + Component content2 = iter.next(); + Tab tab = tabs.getTab(content2); - // Replace content - tabs.replaceComponent(tab.getComponent(), - new Label("Replacement 2")); - - } + // Replace content + tabs.replaceComponent(tab.getComponent(), + new Label("Replacement 2")); }); addComponent(replace2); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java index 36365993ce..1177aef0fc 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java @@ -3,16 +3,10 @@ package com.vaadin.tests.components.tabsheet; import java.util.ArrayList; import java.util.List; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -41,36 +35,16 @@ public class TabKeyboardNavigation extends AbstractReindeerTestUI { ts.setWidth("500px"); ts.setHeight("500px"); - ts.addFocusListener(new FocusListener() { - @Override - public void focus(FocusEvent event) { - focusblur.log("Tabsheet focused!"); - } - }); + ts.addFocusListener(event -> focusblur.log("Tabsheet focused!")); - ts.addBlurListener(new BlurListener() { - @Override - public void blur(BlurEvent event) { - focusblur.log("Tabsheet blurred!"); - } - }); + ts.addBlurListener(event -> focusblur.log("Tabsheet blurred!")); for (int i = 0; i < 5; ++i) { addTab(); } - Button addTab = new Button("Add a tab", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addTab(); - } - }); - Button focus = new Button("Focus tabsheet", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ts.focus(); - } - }); + Button addTab = new Button("Add a tab", event -> addTab()); + Button focus = new Button("Focus tabsheet", event -> ts.focus()); addComponent(addTab); addComponent(focus); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java index 404794608f..560dab6211 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java @@ -6,8 +6,6 @@ import java.util.List; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Layout; import com.vaadin.ui.TabSheet; @@ -30,18 +28,8 @@ public class TabKeyboardNavigationWaiAria extends AbstractReindeerTestUI { addTab(); } - Button addTab = new Button("Add a tab", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addTab(); - } - }); - Button focus = new Button("Focus tabsheet", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ts.focus(); - } - }); + Button addTab = new Button("Add a tab", event -> addTab()); + Button focus = new Button("Focus tabsheet", event -> ts.focus()); addComponent(addTab); addComponent(focus); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java index bd81b45b38..d63ba25310 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java @@ -2,14 +2,10 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; -import com.vaadin.ui.TabSheet.SelectedTabChangeListener; /** * TabSheet test in case user selects a tab and on the selection listener the @@ -43,28 +39,18 @@ public class TabSelectionRevertedByServer extends AbstractReindeerTestUI { final Component lastTab = lastLabel; - tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() { + tabsheet.addSelectedTabChangeListener(event -> { + if (tabsheet.getSelectedTab().equals(lastTab)) { - @Override - public void selectedTabChange(SelectedTabChangeEvent event) { - if (tabsheet.getSelectedTab().equals(lastTab)) { - - // Set focus back to first tab in tabsheet - tabsheet.setSelectedTab(0); - Notification.show("Focus set back to tab at position 0"); - } + // Set focus back to first tab in tabsheet + tabsheet.setSelectedTab(0); + Notification.show("Focus set back to tab at position 0"); } }); addComponent(tabsheet); - addButton("Select Last Tab", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tabsheet.setSelectedTab(lastTab); - } - }); + addButton("Select Last Tab", event -> tabsheet.setSelectedTab(lastTab)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java index 899de78252..4d43020496 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java @@ -6,7 +6,6 @@ import java.util.Locale; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; @@ -45,22 +44,14 @@ public class TabSheetCaptions extends TestBase { tabSheet.addTab(panel1); Button button = new Button("Update tab caption"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabSheet.getTab(panel1).setCaption("This is a new tab caption " - + dateFormatter.format(date)); - } - }); + button.addClickListener(event -> tabSheet.getTab(panel1) + .setCaption("This is a new tab caption " + + dateFormatter.format(date))); Button button2 = new Button("Update panel caption"); - button2.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - panel1.setCaption("This is a new panel caption " - + dateFormatter.format(date)); - } - }); + button2.addClickListener(event -> panel1.setCaption( + "This is a new panel caption " + + dateFormatter.format(date))); addComponent(tabSheet); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java index dfe37f2e27..3669808b6e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.TabSheet; public class TabSheetDisabling extends TestBase { @@ -18,36 +16,21 @@ public class TabSheetDisabling extends TestBase { for (int i = 0; i < NR_BUTTONS; i++) { if (i % 2 == 0) { buttons[i] = new Button("Disable this tab", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Button b = event.getButton(); - tabSheet.getTab(b).setEnabled(false); - - } - + event -> { + Button b = event.getButton(); + tabSheet.getTab(b).setEnabled(false); }); } else { - buttons[i] = new Button("Hide this tab", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Button b = event.getButton(); - tabSheet.getTab(b).setVisible(false); - } - + buttons[i] = new Button("Hide this tab", event -> { + Button b = event.getButton(); + tabSheet.getTab(b).setVisible(false); }); } tabSheet.addTab(buttons[i]); } - Button button = new Button("Enable/disable", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabSheet.setEnabled(!tabSheet.isEnabled()); - } - }); + Button button = new Button("Enable/disable", + event -> tabSheet.setEnabled(!tabSheet.isEnabled())); addComponent(tabSheet); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java index 146397a7e0..f3bfa402da 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -31,12 +30,9 @@ public class TabSheetDiscardsMovedComponents extends TestBase { private void addTestComponent(final Component component) { grid.addComponent(component); - grid.addComponent(new Button("Move to tab", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabSheet.addTab(component); - grid.removeComponent(event.getButton()); - } + grid.addComponent(new Button("Move to tab", event -> { + tabSheet.addTab(component); + grid.removeComponent(event.getButton()); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParent.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParent.java index eb4da30c3f..79b800043e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParent.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -34,13 +32,8 @@ public class TabSheetInDisabledParent extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { final HorizontalLayout layout = new HorizontalLayout(); - addComponent(new Button("toggle", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.setEnabled(!layout.isEnabled()); - } - })); + addComponent(new Button("toggle", + event -> layout.setEnabled(!layout.isEnabled()))); addComponent(layout); TabSheet sheet = new TabSheet(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java index 3426cb1b7e..d23b85b60a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetIndexOperations.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.Tab; @@ -23,47 +22,29 @@ public class TabSheetIndexOperations extends TestBase { addComponent(tabs); Button addTab = new Button("Add tab at index 2", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabs.addTab(new Label("Content " + tabCounter), - "Added Tab " + tabCounter, null, 2); - tabCounter++; - } + event -> { + tabs.addTab(new Label("Content " + tabCounter), + "Added Tab " + tabCounter, null, 2); + tabCounter++; }); addComponent(addTab); Button setCaption = new Button("Invert tab caption at index 2", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Tab tab = tabs.getTab(2); - tab.setCaption(new StringBuilder(tab.getCaption()) - .reverse().toString()); - } + event -> { + Tab tab = tabs.getTab(2); + tab.setCaption(new StringBuilder(tab.getCaption()).reverse() + .toString()); }); addComponent(setCaption); Button move = new Button("Move selected tab to index 2", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tabs.setTabPosition(tabs.getTab(tabs.getSelectedTab()), - 2); - } - }); + event -> tabs.setTabPosition(tabs.getTab(tabs.getSelectedTab()), + 2)); addComponent(move); Button getIndex = new Button("Get selected tab index", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().showNotification( - "Index: " + tabs.getTabPosition( - tabs.getTab(tabs.getSelectedTab()))); - - } - }); + event -> getMainWindow().showNotification("Index: " + tabs + .getTabPosition(tabs.getTab(tabs.getSelectedTab())))); addComponent(getIndex); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java index b6cf27f6bb..9a843ffed3 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -14,14 +13,9 @@ public class TabSheetMinimal extends TestBase { @Override protected void setup() { ts.setStyleName("minimal"); - Button b = new Button("Add a tab", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - ts.addTab(new Label("" + index), "Tab " + index, null); - index++; - - } + Button b = new Button("Add a tab", event -> { + ts.addTab(new Label("" + index), "Tab " + index, null); + index++; }); addComponent(ts); addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java index 913bfa7dcc..a96cd83f30 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -54,13 +53,9 @@ public class TabSheetScrollOnTabClose extends AbstractReindeerTestUI { for (int i = 0; i < 10; i++) { final String tabCaption = "tab " + i; final Button b = new Button("" + i); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - b.setEnabled(false); - tabSheet.removeTab(getTab(tabSheet, tabCaption)); - } + b.addClickListener(event -> { + b.setEnabled(false); + tabSheet.removeTab(getTab(tabSheet, tabCaption)); }); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java index bd4c229a23..bf6d779f2a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java @@ -22,7 +22,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.Tab; @@ -41,25 +40,17 @@ public class TabSheetWithTabIds extends AbstractReindeerTestUI { addComponent(tabSheet); - Button b = new Button("Set ids", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tab1.setId("tab1"); - tab2.setId("tab2"); - tab3.setId("tab3"); - } + Button b = new Button("Set ids", event -> { + tab1.setId("tab1"); + tab2.setId("tab2"); + tab3.setId("tab3"); }); addComponent(b); - Button b2 = new Button("Clear ids", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tab1.setId(null); - tab2.setId(null); - tab3.setId(null); - } + Button b2 = new Button("Clear ids", event -> { + tab1.setId(null); + tab2.setId(null); + tab3.setId(null); }); addComponent(b2); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java index bfc1b5329d..2fe29817dc 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoView.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; @@ -30,38 +28,26 @@ public class TabsheetScrollIntoView extends AbstractReindeerTestUI { Layout buttonLayout = new VerticalLayout(); buttonLayout - .addComponent(new Button("Hide TabSheet", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - panel.setSplitPosition(100, Unit.PERCENTAGE); - panel.removeComponent(tabSheetInSplitPanel); - } + .addComponent(new Button("Hide TabSheet", event -> { + panel.setSplitPosition(100, Unit.PERCENTAGE); + panel.removeComponent(tabSheetInSplitPanel); })); Button showLast = new Button("Show TabSheet and select last tab", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - panel.setSecondComponent(tabSheetInSplitPanel); - panel.setSplitPosition(250, Unit.PIXELS); - tabSheetInSplitPanel.setSelectedTab( - tabSheetInSplitPanel.getComponentCount() - 1); - } + event -> { + panel.setSecondComponent(tabSheetInSplitPanel); + panel.setSplitPosition(250, Unit.PIXELS); + tabSheetInSplitPanel.setSelectedTab( + tabSheetInSplitPanel.getComponentCount() - 1); }); showLast.setId(BTN_SELECT_LAST_TAB); buttonLayout.addComponent(showLast); buttonLayout.addComponent(new Button( - "Show TabSheet and select first tab", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - panel.setSecondComponent(tabSheetInSplitPanel); - panel.setSplitPosition(250, Unit.PIXELS); - tabSheetInSplitPanel.setSelectedTab(0); - } + "Show TabSheet and select first tab", event -> { + panel.setSecondComponent(tabSheetInSplitPanel); + panel.setSplitPosition(250, Unit.PIXELS); + tabSheetInSplitPanel.setSelectedTab(0); })); panel.setFirstComponent(buttonLayout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java index a3301a905d..33a0740427 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.Tab; @@ -22,15 +20,8 @@ public class TabsheetScrolling extends TestBase { for (int i = 0; i < 100; i++) { Button b = new Button("Hide this tab (" + i + ")", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - fixedSizeTabSheet.getTab(event.getButton()) - .setVisible(false); - } - - }); + event -> fixedSizeTabSheet.getTab(event.getButton()) + .setVisible(false)); Tab t = fixedSizeTabSheet.addTab(b, "Tab " + i, null); if (i % 2 == 0) { t.setVisible(false); @@ -45,14 +36,8 @@ public class TabsheetScrolling extends TestBase { for (int i = 0; i < 10; i++) { Button b = new Button("Hide this tab (" + i + ")", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - autoWideTabSheet.getTab(event.getButton()) - .setVisible(false); - } - }); + event -> autoWideTabSheet.getTab(event.getButton()) + .setVisible(false)); Tab t = autoWideTabSheet.addTab(b, "Tab " + i, null); if (i % 2 == 0) { @@ -63,25 +48,18 @@ public class TabsheetScrolling extends TestBase { addComponent(autoWideTabSheet); Button selectFirst = new Button("Select first tab in both tabsheets", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - fixedSizeTabSheet.setSelectedTab(0); - autoWideTabSheet.setSelectedTab(0); - } + event -> { + fixedSizeTabSheet.setSelectedTab(0); + autoWideTabSheet.setSelectedTab(0); }); selectFirst.setId(SELECT_FIRST); addComponent(selectFirst); Button selectLast = new Button("Select last tab in both tabsheets", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - int lastFixed = fixedSizeTabSheet.getComponentCount() - - 1; - fixedSizeTabSheet.setSelectedTab(lastFixed); - int lastAuto = autoWideTabSheet.getComponentCount() - 1; - autoWideTabSheet.setSelectedTab(lastAuto); - } + event -> { + int lastFixed = fixedSizeTabSheet.getComponentCount() - 1; + fixedSizeTabSheet.setSelectedTab(lastFixed); + int lastAuto = autoWideTabSheet.getComponentCount() - 1; + autoWideTabSheet.setSelectedTab(lastAuto); }); selectLast.setId(SELECT_LAST); addComponent(selectLast); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java index 22e27e3111..8131fa8c01 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetShouldUpdateHeight.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; @@ -24,13 +23,9 @@ public class TabsheetShouldUpdateHeight extends TestBase { tabsOuter.addTab(getLayoutWithComponents(10, "tab1"), "Tab 1"); final Button btnSwitch = new Button("switch to Tab2", - new Button.ClickListener() { - - @Override - public void buttonClick(final ClickEvent inEvent) { - tabsOuter.setSelectedTab(tabsInner); - tabsInner.setSelectedTab(tab2); - } + event -> { + tabsOuter.setSelectedTab(tabsInner); + tabsInner.setSelectedTab(tab2); }); addComponent(tabsOuter); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/VetoTabChange.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/VetoTabChange.java index 7e2ef2c22e..7208e42641 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/VetoTabChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/VetoTabChange.java @@ -19,20 +19,13 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; -import com.vaadin.ui.TabSheet.SelectedTabChangeListener; public class VetoTabChange extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { final TabSheet ts = new TabSheet(); - ts.addSelectedTabChangeListener(new SelectedTabChangeListener() { - @Override - public void selectedTabChange(SelectedTabChangeEvent event) { - ts.setSelectedTab(0); - } - }); + ts.addSelectedTabChangeListener(event -> ts.setSelectedTab(0)); ts.addTab(new Label("Tab 1"), "Tab 1"); ts.addTab(new Label("Tab 2"), "Tab 2"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java index 1e56aa49a7..421bca3c17 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -16,15 +15,12 @@ public class WrapTabSheetInTabSheet extends TestBase { addComponent(mainLayout); Button b = new Button("Wrap main layout in a TabSheet"); - b.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - TabSheet tabsheet = new TabSheet(); - ComponentContainer mainParent = (ComponentContainer) mainLayout - .getParent(); - mainParent.replaceComponent(mainLayout, tabsheet); - tabsheet.addTab(mainLayout, "Default tab"); - } + b.addClickListener(event -> { + TabSheet tabsheet = new TabSheet(); + ComponentContainer mainParent = (ComponentContainer) mainLayout + .getParent(); + mainParent.replaceComponent(mainLayout, tabsheet); + tabsheet.addTab(mainLayout, "Default tab"); }); mainLayout.addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java index dd6a088b1a..a92e75552f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.textarea; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.TextArea; /** @@ -25,48 +23,20 @@ public class ScrollCursor extends TestBase { + "ds\n" + "fds\n" + "fds\nfs"); addComponent(textArea); Button button = new Button("Scroll"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - textArea.setCursorPosition(getPosition()); - } - }); + button.addClickListener( + event -> textArea.setCursorPosition(getPosition())); Button wrap = new Button("Set wrap"); - wrap.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - textArea.setWordWrap(false); - } - }); + wrap.addClickListener(event -> textArea.setWordWrap(false)); Button toBegin = new Button("To begin"); - toBegin.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - position = 3; - } - }); + toBegin.addClickListener(event -> position = 3); Button toMiddle = new Button("To middle"); - toMiddle.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - position = 130; - } - }); + toMiddle.addClickListener(event -> position = 130); Button toEnd = new Button("To end"); - toEnd.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - position = textArea.getValue().length(); - } - }); + toEnd.addClickListener( + event -> position = textArea.getValue().length()); addComponent(button); addComponent(wrap); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java index d96e5b9b56..2b6d85ce24 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java @@ -15,12 +15,9 @@ */ package com.vaadin.tests.components.textarea; -import com.vaadin.event.UIEvents; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; @@ -78,21 +75,10 @@ public class TextAreaSizeResetted extends AbstractReindeerTestUI { Label text = new Label(); textArea.addValueChangeListener( event -> text.setValue(event.getValue())); - Button hbutton = new Button("check height", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - serverHeight.setValue(textArea.getHeight() + " "); - } - }); - Button button = new Button("Change Height", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - textArea.setHeight(textField.getValue()); - } - }); + Button hbutton = new Button("check height", + event -> serverHeight.setValue(textArea.getHeight() + " ")); + Button button = new Button("Change Height", + event -> textArea.setHeight(textField.getValue())); addComponent(layout); @@ -104,13 +90,8 @@ public class TextAreaSizeResetted extends AbstractReindeerTestUI { layout.addComponent(serverHeight); layout.addComponent(text); - addPollListener(new UIEvents.PollListener() { - @Override - public void poll(UIEvents.PollEvent event) { - pollIndicator - .setValue(String.valueOf(System.currentTimeMillis())); - } - }); + addPollListener(event -> pollIndicator + .setValue(String.valueOf(System.currentTimeMillis()))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java index c6030f9223..d349f46250 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java @@ -18,10 +18,7 @@ package com.vaadin.tests.components.textfield; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.TextField; @@ -75,13 +72,8 @@ public class AutomaticImmediate extends AbstractTestUIWithLog { }; textField.setId(FIELD); - final ValueChangeListener listener = new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log("Value changed: " + event.getProperty().getValue()); - } - }; + final ValueChangeListener listener = event -> log( + "Value changed: " + event.getProperty().getValue()); final CheckBox checkBox = new CheckBox("Toggle listener"); checkBox.addValueChangeListener(valueChange -> { @@ -95,21 +87,11 @@ public class AutomaticImmediate extends AbstractTestUIWithLog { Button b = new Button( "setImmediate(false), sets explicitly false and causes server roundtrip", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - textField.setImmediate(false); - } - }); + event -> textField.setImmediate(false)); b.setId(EXPLICIT_FALSE); Button b2 = new Button("Hit server, causes server roundtrip", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - } + event -> { }); b2.setId(BUTTON); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/BigDecimalTextField.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/BigDecimalTextField.java index b657e2cef9..f9bc880e2c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/BigDecimalTextField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/BigDecimalTextField.java @@ -22,8 +22,6 @@ import java.util.Locale; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.FormLayout; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.fieldgroup.FieldGroup; @@ -54,25 +52,19 @@ public class BigDecimalTextField extends AbstractTestUIWithLog { final FieldGroup fieldGroup = new FieldGroup(beanItem); fieldGroup.bind(textField, "decimal"); - Button setValue = new Button("Set value to 15,2", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ((TextField) fieldGroup.getField("decimal")).setValue("15,2"); - } - }); + Button setValue = new Button("Set value to 15,2", + event -> ((TextField) fieldGroup.getField("decimal")) + .setValue("15,2")); Button button = new Button("Commit"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - try { - fieldGroup.commit(); - log("Commit ok. Property value: " - + fieldGroup.getItemDataSource() - .getItemProperty("decimal").getValue()); - } catch (FieldGroup.CommitException e) { - log("Commit failed: " + e.getMessage()); - } + button.addClickListener(event -> { + try { + fieldGroup.commit(); + log("Commit ok. Property value: " + + fieldGroup.getItemDataSource() + .getItemProperty("decimal").getValue()); + } catch (FieldGroup.CommitException e) { + log("Commit failed: " + e.getMessage()); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/EnterShortcutMaySendInputPromptAsValue.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/EnterShortcutMaySendInputPromptAsValue.java index cecd559fdc..9e4fc3a254 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/EnterShortcutMaySendInputPromptAsValue.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/EnterShortcutMaySendInputPromptAsValue.java @@ -4,8 +4,6 @@ import com.vaadin.event.Action; import com.vaadin.event.ShortcutAction; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.TextField; public class EnterShortcutMaySendInputPromptAsValue extends TestBase { @@ -45,13 +43,10 @@ public class EnterShortcutMaySendInputPromptAsValue extends TestBase { } }); - testField.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - String value = event.getProperty().getValue().toString(); - addComponent(new Label("TextField sent value: " + value)); - testField.setValue(""); - } + testField.addValueChangeListener(event -> { + String value = event.getProperty().getValue().toString(); + addComponent(new Label("TextField sent value: " + value)); + testField.setValue(""); }); addComponent(testField); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/EnumTextField.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/EnumTextField.java index 97e19bc3d5..429b0bd3c1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/EnumTextField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/EnumTextField.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.ui.TextField; @@ -32,15 +30,11 @@ public class EnumTextField extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { final TextField tf = new TextField(); tf.setNullRepresentation(""); - tf.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if (tf.isValid()) { - log(tf.getValue() + " (valid)"); - } else { - log(tf.getValue() + " (INVALID)"); - } + tf.addValueChangeListener(event -> { + if (tf.isValid()) { + log(tf.getValue() + " (valid)"); + } else { + log(tf.getValue() + " (INVALID)"); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java index 6369caf964..ca475f218b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; @@ -18,15 +17,8 @@ public class InputPromptAndCursorPosition extends AbstractReindeerTestUI { tf.setPlaceholder("This is an input prompt"); final Label l = new Label("Cursor position: ?"); - Button button = new Button("Update cursor position", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l.setValue( - "Cursor position: " + tf.getCursorPosition()); - } - }); + Button button = new Button("Update cursor position", event -> l + .setValue("Cursor position: " + tf.getCursorPosition())); addComponent(tf); addComponent(l); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptGetText.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptGetText.java index da707b0b98..e815ab0ffc 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptGetText.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptGetText.java @@ -21,7 +21,6 @@ import com.vaadin.event.ShortcutListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.v7.ui.TextField; @@ -58,14 +57,11 @@ public class InputPromptGetText extends AbstractReindeerTestUI { Button button = new Button("Click Me"); button.setId(BUTTON); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - String input = tf.getValue(); - Label label = new Label("Your input was: " + input); - label.setId(LABEL2); - getLayout().addComponent(label); - } + button.addClickListener(event -> { + String input = tf.getValue(); + Label label = new Label("Your input was: " + input); + label.setId(LABEL2); + getLayout().addComponent(label); }); tf.addShortcutListener( new ShortcutListener("Shortcut", KeyCode.ENTER, null) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/LocaleChangeOnReadOnlyField.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/LocaleChangeOnReadOnlyField.java index 76c6aa3536..89bc3e5972 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/LocaleChangeOnReadOnlyField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/LocaleChangeOnReadOnlyField.java @@ -33,12 +33,8 @@ public class LocaleChangeOnReadOnlyField extends AbstractReindeerTestUI { private Button addLocaleChangeButton(final TextField textField) { Button changeLocaleButton = new Button(); changeLocaleButton.setCaption("Change Locale"); - changeLocaleButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - textField.setLocale(Locale.GERMANY); - } - }); + changeLocaleButton + .addClickListener(event -> textField.setLocale(Locale.GERMANY)); return changeLocaleButton; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/RequiredTextField.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/RequiredTextField.java index 0fd95311db..0753fcf215 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/RequiredTextField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/RequiredTextField.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.TextField; /** @@ -35,13 +33,8 @@ public class RequiredTextField extends AbstractReindeerTestUI { addComponent(field); - Button button = new Button("Set/unset required", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - field.setRequired(!field.isRequired()); - } - }); + Button button = new Button("Set/unset required", + event -> field.setRequired(!field.isRequired())); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldEmptyingPrompt.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldEmptyingPrompt.java index fc75a27de8..0ed7bf5e5b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldEmptyingPrompt.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldEmptyingPrompt.java @@ -19,7 +19,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; @@ -52,14 +51,7 @@ public class TextFieldEmptyingPrompt extends AbstractReindeerTestUI { addComponent(textField); Button button = new Button("Click To Remove Prompt"); - button.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - textField.setPlaceholder(""); - } - }); + button.addClickListener(event -> textField.setPlaceholder("")); addComponent(button); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java index b278afa892..6443279806 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java @@ -4,8 +4,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.v7.ui.TextField; @@ -16,12 +14,8 @@ public class TextFieldInputPromptAndClickShortcut extends TestBase { final Log log = new Log(5); final TextField textField = new TextField(); - Button button = new Button("Show Text", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.log("Field value: " + textField.getValue()); - } - }); + Button button = new Button("Show Text", + event -> log.log("Field value: " + textField.getValue())); button.setClickShortcut(KeyCode.ESCAPE); final CheckBox inputPromptSelection = new CheckBox("Input prompt"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java index 01625d0d42..f11f533a03 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java @@ -1,7 +1,5 @@ package com.vaadin.tests.components.textfield; -import com.vaadin.event.FieldEvents; -import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.tests.components.TestBase; import com.vaadin.v7.ui.TextField; @@ -15,13 +13,9 @@ public class TextFieldMaxLengthRemovedFromDOM extends TestBase { tf.setImmediate(true); addComponent(tf); - tf.addFocusListener(new FieldEvents.FocusListener() { - - @Override - public void focus(FocusEvent event) { - // Resetting Max length should not remove maxlength attribute - tf.setMaxLength(11); - } + tf.addFocusListener(event -> { + // Resetting Max length should not remove maxlength attribute + tf.setMaxLength(11); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldPrimaryStyleName.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldPrimaryStyleName.java index bb653695bb..7ce7f9df89 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldPrimaryStyleName.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldPrimaryStyleName.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.TextField; public class TextFieldPrimaryStyleName extends TestBase { @@ -14,13 +13,7 @@ public class TextFieldPrimaryStyleName extends TestBase { addComponent(field); addComponent(new Button("Change primary style name", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - field.setPrimaryStyleName("my-dynamic-textfield"); - } - })); - + event -> field.setPrimaryStyleName("my-dynamic-textfield"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java index 98900e9aaf..a92294102e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java @@ -20,7 +20,6 @@ import com.vaadin.annotations.Theme; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.FormLayout; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -38,13 +37,8 @@ public class TextFieldTruncatesUnderscoresInModalDialogs formLayout.setSpacing(true); formLayout.addComponent( - new Button("Disappear", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - event.getButton().setVisible(false); - } - })); + new Button("Disappear", + event -> event.getButton().setVisible(false))); formLayout.addComponent(new TextField(null, "____pqjgy____")); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java index 9ffc7cce38..74845d49ee 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.textfield; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.ui.TextField; @@ -23,14 +21,8 @@ public class TextFieldWithProperty extends TestBase { Button b = new Button( "Set BAR to underlaying property (should propagate to UI)"); - b.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - op.setValue("BAR"); - } - }); + b.addClickListener(event -> op.setValue("BAR")); addComponent(b); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java index 0ae27ac6c1..14be2dbd14 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java @@ -7,8 +7,6 @@ import java.util.Locale; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.Property; import com.vaadin.v7.data.util.PropertyFormatter; import com.vaadin.v7.ui.TextField; @@ -95,19 +93,11 @@ public class TextFieldWithPropertyFormatter extends TestBase { Button b = new Button( "Sync (typing 12345.6789 and clicking this should format field)"); - b.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - } + b.addClickListener(event -> { }); addComponent(b); b = new Button("Set '12345.6789' to textfield on the server side"); - b.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tf1.setValue("12345.6789"); - } - }); + b.addClickListener(event -> tf1.setValue("12345.6789")); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/AddNodesOnExpand.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/AddNodesOnExpand.java index 37cbe741d7..13a072b556 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/AddNodesOnExpand.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/AddNodesOnExpand.java @@ -1,9 +1,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; -import com.vaadin.v7.ui.Tree; -import com.vaadin.v7.ui.Tree.CollapseEvent; -import com.vaadin.v7.ui.Tree.ExpandEvent; import com.vaadin.v7.ui.TreeTable; public class AddNodesOnExpand extends TestBase { @@ -17,26 +14,19 @@ public class AddNodesOnExpand extends TestBase { treetable.setHeight(null); treetable.setPageLength(0); treetable.addContainerProperty("foo", String.class, ""); - treetable.addListener(new Tree.ExpandListener() { - @Override - public void nodeExpand(ExpandEvent event) { - Object openedItemId = event.getItemId(); - if (!treetable.hasChildren(openedItemId)) { - for (int j = 0; j < 3; j++) { - treetable.addItem(new String[] { "Subitem " + j }, - openedItemId + "-" + j); - treetable.setParent(openedItemId + "-" + j, - openedItemId); - } + treetable.addExpandListener(event -> { + Object openedItemId = event.getItemId(); + if (!treetable.hasChildren(openedItemId)) { + for (int j = 0; j < 3; j++) { + treetable.addItem(new String[] { "Subitem " + j }, + openedItemId + "-" + j); + treetable.setParent(openedItemId + "-" + j, openedItemId); } } }); - treetable.addListener(new Tree.CollapseListener() { - @Override - public void nodeCollapse(CollapseEvent event) { - /* Uncomment this to "fix" the TreeTable */ - // orgTree.refreshRowCache(); - } + treetable.addCollapseListener(event -> { + /* Uncomment this to "fix" the TreeTable */ + // orgTree.refreshRowCache(); }); for (int i = 0; i < 3; i++) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java index a3e73bd40c..19e9d668b8 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java @@ -20,19 +20,9 @@ public class ChangeDataSourcePageLengthZero extends TestBase { setupContainer(tt, 20); addComponent(tt); Button page1 = new Button("Set new data source (20 items)"); - page1.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setupContainer(tt, 20); - } - }); + page1.addClickListener(event -> setupContainer(tt, 20)); Button page2 = new Button("Set new data source (10 items)"); - page2.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setupContainer(tt, 10); - } - }); + page2.addClickListener(event -> setupContainer(tt, 10)); Button addButton = new Button("Add item"); addButton.addClickListener(new Button.ClickListener() { private int i = 1; diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java index 14cc5a0d08..33e0873ee9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java @@ -2,10 +2,7 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Tree.CollapseEvent; import com.vaadin.v7.ui.Tree.CollapseListener; import com.vaadin.v7.ui.Tree.ExpandEvent; @@ -35,42 +32,20 @@ public class KeepAllItemsVisible extends TestBase tt.addListener((ExpandListener) this); tt.addListener((CollapseListener) this); - tt.addListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - recalculatePageLength(tt); - tt.markAsDirty(); - } + tt.addValueChangeListener(event -> { + recalculatePageLength(tt); + tt.markAsDirty(); }); addComponent(tt); recalculatePageLength(tt); Button b = new Button("Set pagelength to 10", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tt.setPageLength(10); - } - }); + event -> tt.setPageLength(10)); addComponent(b); - b = new Button("Set pagelength to 20", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tt.setPageLength(20); - } - }); + b = new Button("Set pagelength to 20", event -> tt.setPageLength(20)); addComponent(b); - b = new Button("Set pagelength to 0", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - tt.setPageLength(0); - } - }); + b = new Button("Set pagelength to 0", event -> tt.setPageLength(0)); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java index dc642c8ab9..78d96b974e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java @@ -30,22 +30,16 @@ public class ProgrammaticCollapse extends TestBase { } layout.addComponent(table); layout.addComponent( - new Button("Expand / Collapse", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - boolean collapsed = !table.isCollapsed(1); - Notification.show("set collapsed: " + collapsed); - table.setCollapsed(1, collapsed); - } + new Button("Expand / Collapse", event -> { + boolean collapsed = !table.isCollapsed(1); + Notification.show("set collapsed: " + collapsed); + table.setCollapsed(1, collapsed); })); layout.addComponent( - new Button("Expand / Collapse last", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - boolean collapsed = !table.isCollapsed(100); - Notification.show("set collapsed: " + collapsed); - table.setCollapsed(100, collapsed); - } + new Button("Expand / Collapse last", event -> { + boolean collapsed = !table.isCollapsed(100); + Notification.show("set collapsed: " + collapsed); + table.setCollapsed(100, collapsed); })); layout.addComponent( new Button("Expand / Collapse multiple", new ClickListener() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticSelect.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticSelect.java index 8a6fb535c5..7882ddeb20 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticSelect.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/ProgrammaticSelect.java @@ -5,7 +5,6 @@ import java.util.List; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.HierarchicalContainer; @@ -21,13 +20,9 @@ public class ProgrammaticSelect extends TestBase { addComponent(tt); Button selectItem = new Button("Select first row", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Object id = tt.getItemIds().iterator().next(); - tt.select(id); - } + event -> { + Object id = tt.getItemIds().iterator().next(); + tt.select(id); }); addComponent(selectItem); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java index 8e5b30639c..9749128005 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java @@ -17,8 +17,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.HierarchicalContainer; @@ -50,21 +48,11 @@ public class RemoveAllItemsRefresh extends TestBase { addComponent(treeLayout); Button cleanUp = new Button("clear"); - cleanUp.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - treeContainer.removeAllItems(); - } - }); + cleanUp.addClickListener(event -> treeContainer.removeAllItems()); addComponent(cleanUp); Button refresh = new Button("fill"); - refresh.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - fill(); - } - }); + refresh.addClickListener(event -> fill()); addComponent(refresh); fill(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java index b341bdc37f..ff5be4dbb4 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.ui.TreeTable; @@ -23,33 +21,20 @@ public class RowHeightWithoutRows extends TestBase { Button refresh = new Button("Add two elements"); addComponent(refresh); - refresh.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addTwoElements(); - } - }); + refresh.addClickListener(event -> addTwoElements()); Button reset = new Button("Reset"); addComponent(reset); - reset.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - container.removeAllItems(); - } - }); + reset.addClickListener(event -> container.removeAllItems()); Button refresh5 = new Button("Add five elements"); addComponent(refresh5); - refresh5.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - container.addBean(new User("John", "Doe")); - container.addBean(new User("Mark", "Twain")); - container.addBean(new User("M", "T")); - container.addBean(new User("J", "D")); - container.addBean(new User("J", "T")); - } + refresh5.addClickListener(event -> { + container.addBean(new User("John", "Doe")); + container.addBean(new User("Mark", "Twain")); + container.addBean(new User("M", "T")); + container.addBean(new User("J", "D")); + container.addBean(new User("J", "T")); }); addTwoElements(); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java index 02ef27d340..88fc371764 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java @@ -8,23 +8,15 @@ import java.util.Map; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.NativeButton; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Container.Ordered; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.data.util.ContainerHierarchicalWrapper; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.Table.ColumnGenerator; -import com.vaadin.v7.ui.Tree.CollapseEvent; -import com.vaadin.v7.ui.Tree.CollapseListener; -import com.vaadin.v7.ui.Tree.ExpandEvent; -import com.vaadin.v7.ui.Tree.ExpandListener; import com.vaadin.v7.ui.TreeTable; public class TreeTableCacheOnPartialUpdates extends TestBase { @@ -76,14 +68,10 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { Button btnCol3 = new NativeButton(identifier); btnCol3.setId( "cacheTestButton-" + tb.getCol1() + "-" + tb.getCol2()); - btnCol3.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.log("Button " + event.getButton().getCaption() + btnCol3.addClickListener( + event -> log.log("Button " + event.getButton().getCaption() + " clicked. Row index: " - + indexOfId(source, itemId)); - } - }); + + indexOfId(source, itemId))); return btnCol3; } @@ -98,16 +86,10 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { Button btnCol4 = new NativeButton(identifier); btnCol4.setId("cacheTestButtonToggle-" + tb.getCol1() + "-" + tb.getCol2()); - btnCol4.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - treeTable.setCollapsed(itemId, - !treeTable.isCollapsed(itemId)); - } - }); + btnCol4.addClickListener(event -> treeTable.setCollapsed(itemId, + !treeTable.isCollapsed(itemId))); return btnCol4; } - } protected int indexOfId(Table source, Object itemId) { @@ -134,14 +116,8 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { // pixels works as expected Button b = new Button("Show first"); addComponent(b); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.log("First visible item id is: " - + treeTable.getCurrentPageFirstItemId()); - } - }); + b.addClickListener(event -> log.log("First visible item id is: " + + treeTable.getCurrentPageFirstItemId())); NativeSelect cacheRateSelect = new NativeSelect("Cache rate"); cacheRateSelect.setImmediate(true); cacheRateSelect.setNullSelectionAllowed(false); @@ -149,14 +125,8 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { cacheRateSelect.addItem(new Integer(1)); cacheRateSelect.addItem(new Integer(2)); cacheRateSelect.setValue(2); - cacheRateSelect.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - treeTable - .setCacheRate((Integer) event.getProperty().getValue()); - } - }); + cacheRateSelect.addValueChangeListener(event -> treeTable + .setCacheRate((Integer) event.getProperty().getValue())); addComponent(cacheRateSelect); treeTable = new TreeTable(); treeTable.addStyleName("table-equal-rowheight"); @@ -173,22 +143,10 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { treeTable.setContainerDataSource(createContainer(100, hasChildren)); treeTable.addGeneratedColumn("col3", new Col3ColumnGenerator()); treeTable.addGeneratedColumn("col4", new Col4ColumnGenerator()); - treeTable.addExpandListener(new ExpandListener() { - - @Override - public void nodeExpand(ExpandEvent event) { - logExpandCollapse(event.getItemId(), "expanded"); - - } - }); - treeTable.addCollapseListener(new CollapseListener() { - - @Override - public void nodeCollapse(CollapseEvent event) { - logExpandCollapse(event.getItemId(), "collapsed"); - - } - }); + treeTable.addExpandListener( + event -> logExpandCollapse(event.getItemId(), "expanded")); + treeTable.addCollapseListener( + event -> logExpandCollapse(event.getItemId(), "collapsed")); treeTable.setVisibleColumns(visibleColumns); treeTable.setColumnHeaders(columnHeaders); treeTable.setColumnWidth("col1", 150); @@ -202,7 +160,6 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { String identifier = "Item " + itemId; log.log("Row " + identifier + " " + operation + ". Row index: " + indexOfId(treeTable, itemId)); - } private Container createContainer(int items, diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableContainerHierarchicalWrapper.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableContainerHierarchicalWrapper.java index e3edabe758..6b9a1ff271 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableContainerHierarchicalWrapper.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableContainerHierarchicalWrapper.java @@ -4,8 +4,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.v7.data.util.BeanItemContainer; import com.vaadin.v7.data.util.ContainerHierarchicalWrapper; -import com.vaadin.v7.ui.Tree.ExpandEvent; -import com.vaadin.v7.ui.Tree.ExpandListener; import com.vaadin.v7.ui.TreeTable; @SuppressWarnings("serial") @@ -26,18 +24,14 @@ public class TreeTableContainerHierarchicalWrapper treetable.setPageLength(0); treetable.setContainerDataSource(hierarchicalWrapper); - treetable.addExpandListener(new ExpandListener() { - @Override - public void nodeExpand(ExpandEvent event) { - Bean parent = ((Bean) event.getItemId()); - if (!hierarchicalWrapper.hasChildren(parent)) { - for (int i = 1; i <= 5; i++) { - Bean newChild = new Bean(parent.getId() + "-" + i); - beanContainer.addBean(newChild); - hierarchicalWrapper.setParent(newChild, parent); - } + treetable.addExpandListener(event -> { + Bean parent = ((Bean) event.getItemId()); + if (!hierarchicalWrapper.hasChildren(parent)) { + for (int i = 1; i <= 5; i++) { + Bean newChild = new Bean(parent.getId() + "-" + i); + beanContainer.addBean(newChild); + hierarchicalWrapper.setParent(newChild, parent); } - } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java index 0dcdfafc11..30288d1506 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.v7.ui.Table; @@ -47,21 +45,17 @@ public class TreeTableExtraScrollbar extends TestBase { Button button = new Button("Add"); button.setId("button"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.addItem(new TestObject("name 6-1", "value 6-1")); - table.addItem(new TestObject("name 6-2", "value 6-2")); - table.addItem(new TestObject("name 6-3", "value 6-3")); - table.addItem(new TestObject("name 6-4", "value 6-4")); - table.addItem(new TestObject("name 6-5", "value 6-5")); - table.addItem(new TestObject("name 6-6", "value 6-6")); - table.addItem(new TestObject("name 6-7", "value 6-7")); - table.addItem(new TestObject("name 6-8", "value 6-8")); - table.addItem(new TestObject("name 6-9", "value 6-9")); - table.addItem(new TestObject("name 6-9", "value 6-10")); - } + button.addClickListener(event -> { + table.addItem(new TestObject("name 6-1", "value 6-1")); + table.addItem(new TestObject("name 6-2", "value 6-2")); + table.addItem(new TestObject("name 6-3", "value 6-3")); + table.addItem(new TestObject("name 6-4", "value 6-4")); + table.addItem(new TestObject("name 6-5", "value 6-5")); + table.addItem(new TestObject("name 6-6", "value 6-6")); + table.addItem(new TestObject("name 6-7", "value 6-7")); + table.addItem(new TestObject("name 6-8", "value 6-8")); + table.addItem(new TestObject("name 6-9", "value 6-9")); + table.addItem(new TestObject("name 6-9", "value 6-10")); }); addComponent(layout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java index d85218ddd6..973f2bdfe0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; @@ -60,13 +58,9 @@ public class TreeTableExtraScrollbarWithChildren extends TestBase { Button button = new Button("Toggle"); button.setId("button"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setCollapsed(parent, !table.isCollapsed(parent)); - Notification.show("collapsed: " + table.isCollapsed(parent)); - } + button.addClickListener(event -> { + table.setCollapsed(parent, !table.isCollapsed(parent)); + Notification.show("collapsed: " + table.isCollapsed(parent)); }); addComponent(layout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableInternalError.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableInternalError.java index 8f609f08db..bd08c6ea5e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableInternalError.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableInternalError.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.NativeButton; import com.vaadin.ui.VerticalLayout; @@ -29,12 +28,7 @@ public class TreeTableInternalError extends TestBase { Button button = new Button("Resize") { { - addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - t.setHeight("300px"); - } - }); + addClickListener(event -> t.setHeight("300px")); } }; button.setId("resize"); @@ -71,15 +65,10 @@ public class TreeTableInternalError extends TestBase { String identifier = "Expand/Collapse"; Button btnCol = new NativeButton(identifier); btnCol.setId("cacheTestButtonToggle-" + itemId); - btnCol.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - t.setCollapsed(itemId, !t.isCollapsed(itemId)); - } - }); + btnCol.addClickListener( + event -> t.setCollapsed(itemId, !t.isCollapsed(itemId))); return btnCol; } - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableOutOfSync.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableOutOfSync.java index b457b56a0b..68bda9cc2b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableOutOfSync.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableOutOfSync.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.v7.ui.Table; import com.vaadin.v7.ui.TreeTable; @@ -37,12 +36,8 @@ public class TreeTableOutOfSync extends AbstractReindeerTestUI { Button button = new Button("text " + source.getContainerDataSource().getItem(itemId) .getItemProperty("i").getValue()); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Notification.show("click"); - } - }); + button.addClickListener( + event -> Notification.show("click")); return button; } return null; diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableSetCollapsed.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableSetCollapsed.java index 4d9081dd9d..9d4a0bee50 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableSetCollapsed.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableSetCollapsed.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.treetable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.TreeTable; public class TreeTableSetCollapsed extends TestBase { @@ -11,12 +10,7 @@ public class TreeTableSetCollapsed extends TestBase { protected void setup() { createTreeTableAndPopulate(); addComponent(new Button("Create another TreeTable", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - createTreeTableAndPopulate(); - } - })); + event -> createTreeTableAndPopulate())); } private void createTreeTableAndPopulate() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/IdOverrideTest.java b/uitest/src/main/java/com/vaadin/tests/components/ui/IdOverrideTest.java index 3bef55450a..19fdf6948a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/IdOverrideTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/IdOverrideTest.java @@ -8,8 +8,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.IdTestLabel; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @Widgetset(TestingWidgetSet.NAME) @@ -47,21 +45,17 @@ public class IdOverrideTest extends AbstractReindeerTestUI { Button button = new Button(); button.setCaption("Toggle"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (idTestLabelWithId.getId() == null) { - idTestLabelWithId.setId("set10179"); - idTestLabelWithId.setValue("set id"); - idTestLabel.setValue("default id"); - label.setValue("no id"); - } else { - idTestLabelWithId.setId(null); - idTestLabelWithId.setValue("removed id"); - idTestLabel.setValue("still default id"); - label.setValue("still no id"); - } + button.addClickListener(event -> { + if (idTestLabelWithId.getId() == null) { + idTestLabelWithId.setId("set10179"); + idTestLabelWithId.setValue("set id"); + idTestLabel.setValue("default id"); + label.setValue("no id"); + } else { + idTestLabelWithId.setId(null); + idTestLabelWithId.setValue("removed id"); + idTestLabel.setValue("still default id"); + label.setValue("still no id"); } }); button.setId("toggle"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/InitialFragmentEvent.java b/uitest/src/main/java/com/vaadin/tests/components/ui/InitialFragmentEvent.java index d8d197c881..78badb61ff 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/InitialFragmentEvent.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/InitialFragmentEvent.java @@ -1,11 +1,7 @@ package com.vaadin.tests.components.ui; -import com.vaadin.server.Page.UriFragmentChangedEvent; -import com.vaadin.server.Page.UriFragmentChangedListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class InitialFragmentEvent extends AbstractTestUIWithLog { @@ -14,31 +10,14 @@ public class InitialFragmentEvent extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { getPage().addUriFragmentChangedListener( - new UriFragmentChangedListener() { - - @Override - public void uriFragmentChanged( - UriFragmentChangedEvent source) { - String newFragment = source.getUriFragment(); - log("Fragment changed from " + lastKnownFragment - + " to " + newFragment); - lastKnownFragment = newFragment; - } + event -> { + String newFragment = event.getUriFragment(); + log("Fragment changed from " + lastKnownFragment + " to " + + newFragment); + lastKnownFragment = newFragment; }); - addButton("Set fragment to 'foo'", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - setFragment("foo"); - } - }); - addButton("Set fragment to 'bar'", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - setFragment("bar"); - } - }); + addButton("Set fragment to 'foo'", event -> setFragment("foo")); + addButton("Set fragment to 'bar'", event -> setFragment("bar")); } protected void setFragment(String fragment) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java b/uitest/src/main/java/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java index 093cf2d7d5..6c9fb19208 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java @@ -3,12 +3,8 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeButton; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.ui.TextField; public class LoadingIndicatorConfigurationTest extends AbstractTestUIWithLog { @@ -24,45 +20,29 @@ public class LoadingIndicatorConfigurationTest extends AbstractTestUIWithLog { delayField.setConvertedValue(1000); NativeButton delayButton = new NativeButton("Wait"); - delayButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - try { - Thread.sleep((Integer) delayField.getConvertedValue()); - } catch (InterruptedException e) { - e.printStackTrace(); - } + delayButton.addClickListener(event -> { + try { + Thread.sleep((Integer) delayField.getConvertedValue()); + } catch (InterruptedException e) { + e.printStackTrace(); } }); firstDelay = createIntegerTextField("First delay (ms)", getState().loadingIndicatorConfiguration.firstDelay); - firstDelay.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getLoadingIndicatorConfiguration().setFirstDelay( - (Integer) firstDelay.getConvertedValue()); - } - }); + firstDelay.addValueChangeListener( + event -> getLoadingIndicatorConfiguration().setFirstDelay( + (Integer) firstDelay.getConvertedValue())); secondDelay = createIntegerTextField("Second delay (ms)", getState().loadingIndicatorConfiguration.secondDelay); - secondDelay.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getLoadingIndicatorConfiguration().setSecondDelay( - (Integer) secondDelay.getConvertedValue()); - } - }); + secondDelay.addValueChangeListener( + event -> getLoadingIndicatorConfiguration().setSecondDelay( + (Integer) secondDelay.getConvertedValue())); thirdDelay = createIntegerTextField("Third delay (ms)", getState().loadingIndicatorConfiguration.thirdDelay); - thirdDelay.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getLoadingIndicatorConfiguration().setThirdDelay( - (Integer) thirdDelay.getConvertedValue()); - } - }); + thirdDelay.addValueChangeListener( + event -> getLoadingIndicatorConfiguration().setThirdDelay( + (Integer) thirdDelay.getConvertedValue())); getLayout().addComponents(firstDelay, secondDelay, thirdDelay); @@ -71,7 +51,6 @@ public class LoadingIndicatorConfigurationTest extends AbstractTestUIWithLog { hl.setDefaultComponentAlignment(Alignment.BOTTOM_RIGHT); hl.addComponents(delayField, delayButton); addComponent(hl); - } private TextField createIntegerTextField(String caption, int initialValue) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/MultiFileUploadTest.java b/uitest/src/main/java/com/vaadin/tests/components/ui/MultiFileUploadTest.java index ffa9b55b3a..8f043f8f97 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/MultiFileUploadTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/MultiFileUploadTest.java @@ -21,30 +21,17 @@ import java.io.OutputStream; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.ChangeEvent; import com.vaadin.ui.Upload.ChangeListener; -import com.vaadin.ui.Upload.FailedEvent; -import com.vaadin.ui.Upload.FailedListener; -import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.SucceededEvent; -import com.vaadin.ui.Upload.SucceededListener; import com.vaadin.ui.VerticalLayout; public class MultiFileUploadTest extends AbstractTestUIWithLog { - private ChangeListener changeListener = new ChangeListener() { - - @Override - public void filenameChanged(ChangeEvent event) { - if (event.getFilename().isEmpty()) { - removeUpload(event.getSource()); - } else { - addUpload(); - } - + private ChangeListener changeListener = event -> { + if (event.getFilename().isEmpty()) { + removeUpload(event.getSource()); + } else { + addUpload(); } }; private VerticalLayout uploadsLayout = new VerticalLayout(); @@ -55,13 +42,9 @@ public class MultiFileUploadTest extends AbstractTestUIWithLog { .add(".v-upload-hidden-button .v-button {display:none};"); addUpload(); addComponent(uploadsLayout); - addComponent(new Button("Upload files", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - for (Upload u : getUploads()) { - u.submitUpload(); - } + addComponent(new Button("Upload files", event -> { + for (Upload u : getUploads()) { + u.submitUpload(); } })); } @@ -77,33 +60,21 @@ public class MultiFileUploadTest extends AbstractTestUIWithLog { protected void addUpload() { Upload upload = createUpload(); - upload.addSucceededListener(new SucceededListener() { - - @Override - public void uploadSucceeded(SucceededEvent event) { - log("Upload of " + event.getFilename() + " complete"); - uploadsLayout.removeComponent(event.getUpload()); - } + upload.addSucceededListener(event -> { + log("Upload of " + event.getFilename() + " complete"); + uploadsLayout.removeComponent(event.getUpload()); }); - upload.addFailedListener(new FailedListener() { - @Override - public void uploadFailed(FailedEvent event) { - log("Upload of " + event.getFilename() + " FAILED"); - } - }); + upload.addFailedListener( + event -> log("Upload of " + event.getFilename() + " FAILED")); - upload.setReceiver(new Receiver() { - @Override - public OutputStream receiveUpload(String filename, - String mimeType) { - return new OutputStream() { - @Override - public void write(int arg0) throws IOException { + upload.setReceiver((filename, mimeType) -> { + return new OutputStream() { + @Override + public void write(int arg0) throws IOException { - } - }; - } + } + }; }); upload.setStyleName("hidden-button"); uploadsLayout.addComponent(upload); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/MultipleUIUploadTest.java b/uitest/src/main/java/com/vaadin/tests/components/ui/MultipleUIUploadTest.java index fd345c3ae6..2eb60d498f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/MultipleUIUploadTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/MultipleUIUploadTest.java @@ -9,8 +9,6 @@ import com.vaadin.server.StreamResource; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.ui.Upload; import com.vaadin.ui.VerticalLayout; @@ -47,15 +45,9 @@ public class MultipleUIUploadTest extends AbstractReindeerTestUI { Button button = new Button("show notification"); button.setId("notify"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification.show("uploaded: " + buffer.getFileName()); - } - }); + button.addClickListener(event -> Notification + .show("uploaded: " + buffer.getFileName())); layout.addComponent(button); - } public class MemoryBuffer diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java b/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java index d72e5f24af..55fa374a2b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java @@ -4,12 +4,9 @@ import java.net.URI; import com.vaadin.annotations.Title; import com.vaadin.server.Page; -import com.vaadin.server.Page.PopStateEvent; -import com.vaadin.server.Page.PopStateListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; @@ -26,13 +23,9 @@ public class PushStateAndReplaceState extends AbstractReindeerTestUI { addComponent(locationLabel); updateLabel(); - getPage().addPopStateListener(new PopStateListener() { - - @Override - public void uriChanged(PopStateEvent event) { - Notification.show("Popstate event"); - updateLabel(); - } + getPage().addPopStateListener(event -> { + Notification.show("Popstate event"); + updateLabel(); }); replace = new CheckBox("replace"); @@ -47,17 +40,14 @@ public class PushStateAndReplaceState extends AbstractReindeerTestUI { private Button createButton(String id, String caption, final String newUri) { - Button button = new Button(caption, new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setTitle(caption); - if (replace.getValue()) { - getPage().replaceState(newUri); - } else { - getPage().pushState(newUri); - } - updateLabel(); + Button button = new Button(caption, event -> { + getPage().setTitle(caption); + if (replace.getValue()) { + getPage().replaceState(newUri); + } else { + getPage().pushState(newUri); } + updateLabel(); }); button.setId(id); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java b/uitest/src/main/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java index a31eb519b6..feff7f84ac 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.PageClientRpc; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class RpcInvocationHandlerToString extends AbstractTestUIWithLog { @@ -28,31 +26,13 @@ public class RpcInvocationHandlerToString extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { addButton("Exec toString() for an invocation proxy", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("An invoation proxy: " + dummyProxy); - } - }); + event -> log("An invoation proxy: " + dummyProxy)); addButton("Exec hashCode() for an invocation proxy", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Invocation proxy.hashCode(): " - + dummyProxy.hashCode()); - } - }); + event -> log("Invocation proxy.hashCode(): " + + dummyProxy.hashCode())); addButton("Exec equals(false) for an invocation proxy", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Invocation proxy.equals(false): " - + dummyProxy.equals(false)); - } - }); + event -> log("Invocation proxy.equals(false): " + + dummyProxy.equals(false))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/TextAreaEventPropagation.java b/uitest/src/main/java/com/vaadin/tests/components/ui/TextAreaEventPropagation.java index ff6da5b4b4..234a46ebaf 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/TextAreaEventPropagation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/TextAreaEventPropagation.java @@ -20,8 +20,6 @@ import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.FormLayout; import com.vaadin.ui.TextField; import com.vaadin.v7.ui.TextArea; @@ -43,46 +41,21 @@ public class TextAreaEventPropagation extends AbstractTestUIWithLog { Button enterButton = new Button("Enter"); enterButton.setClickShortcut(KeyCode.ENTER); - enterButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - log("Enter button pressed"); - } - }); + enterButton.addClickListener(event -> log("Enter button pressed")); Button shiftEnterButton = new Button("Shift-Enter"); shiftEnterButton.setClickShortcut(KeyCode.ENTER, ModifierKey.SHIFT); - shiftEnterButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - log("Shift-Enter button pressed"); - } - }); + shiftEnterButton + .addClickListener(event -> log("Shift-Enter button pressed")); Button ctrlEnterButton = new Button("Ctrl-Enter"); ctrlEnterButton.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL); - ctrlEnterButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - log("Ctrl-Enter button pressed"); - } - }); + ctrlEnterButton + .addClickListener(event -> log("Ctrl-Enter button pressed")); Button escapeButton = new Button("Escape"); escapeButton.setClickShortcut(KeyCode.ESCAPE); - escapeButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Escape button pressed"); - } - }); + escapeButton.addClickListener(event -> log("Escape button pressed")); form.addComponent(textArea); form.addComponent(textField); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java b/uitest/src/main/java/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java index 308c02dd31..6d5c57136d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java @@ -22,7 +22,6 @@ import com.vaadin.server.SystemMessagesProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; public class TimeoutRedirectResetsOnActivity extends AbstractReindeerTestUI { @@ -45,13 +44,8 @@ public class TimeoutRedirectResetsOnActivity extends AbstractReindeerTestUI { final Label expiresLabel = new Label(); expiresLabel.setId("actualExpireTime"); - Button button = new Button("Reset", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - expiresLabel.setValue(String.valueOf(getExpireTime())); - } - - }); + Button button = new Button("Reset", event -> expiresLabel + .setValue(String.valueOf(getExpireTime()))); button.setId("reset"); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java index 93ac99c186..879aeb4689 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java @@ -27,7 +27,6 @@ import com.vaadin.server.VaadinSession; import com.vaadin.shared.communication.PushMode; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -53,280 +52,216 @@ public class UIAccess extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { addComponent( - new Button("Access from UI thread", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - // Ensure beforeClientResponse is invoked - markAsDirty(); - checkFromBeforeClientResponse = access(new Runnable() { - @Override - public void run() { - log("Access from UI thread is run"); - } - }); - log("Access from UI thread future is done? " - + checkFromBeforeClientResponse.isDone()); - } + new Button("Access from UI thread", event -> { + log.clear(); + // Ensure beforeClientResponse is invoked + markAsDirty(); + checkFromBeforeClientResponse = access( + () -> log("Access from UI thread is run")); + log("Access from UI thread future is done? " + + checkFromBeforeClientResponse.isDone()); })); addComponent(new Button("Access from background thread", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - final CountDownLatch latch = new CountDownLatch(1); + event -> { + log.clear(); + final CountDownLatch latch = new CountDownLatch(1); - new Thread() { - @Override - public void run() { - final boolean threadHasCurrentResponse = VaadinService - .getCurrentResponse() != null; - // session is locked by request thread at this - // point - final Future<Void> initialFuture = access( - new Runnable() { - @Override - public void run() { - log("Initial background message"); - log("Thread has current response? " - + threadHasCurrentResponse); - } - }); + new Thread() { + @Override + public void run() { + final boolean threadHasCurrentResponse = VaadinService + .getCurrentResponse() != null; + // session is locked by request thread at this + // point + final Future<Void> initialFuture = access( + () -> { + log("Initial background message"); + log("Thread has current response? " + + threadHasCurrentResponse); + }); - // Let request thread continue - latch.countDown(); + // Let request thread continue + latch.countDown(); - // Wait until thread can be locked - while (!getSession().getLockInstance() - .tryLock()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } + // Wait until thread can be locked + while (!getSession().getLockInstance().tryLock()) { try { - log("Thread got lock, inital future done? " - + initialFuture.isDone()); - setPollInterval(-1); - } finally { - getSession().unlock(); + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); } } - }.start(); - - // Wait for thread to do initialize before continuing - try { - latch.await(); - } catch (InterruptedException e) { - throw new RuntimeException(e); + try { + log("Thread got lock, inital future done? " + + initialFuture.isDone()); + setPollInterval(-1); + } finally { + getSession().unlock(); + } } + }.start(); - setPollInterval(3000); + // Wait for thread to do initialize before continuing + try { + latch.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); } + + setPollInterval(3000); })); addComponent(new Button("Access throwing exception", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - final Future<Void> firstFuture = access(new Runnable() { - @Override - public void run() { - log("Throwing exception in access"); - throw new RuntimeException( - "Catch me if you can"); - } - }); - access(new Runnable() { - @Override - public void run() { - log("firstFuture is done? " - + firstFuture.isDone()); - try { - firstFuture.get(); - log("Should not get here"); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } catch (ExecutionException e) { - log("Got exception from firstFuture: " - + e.getMessage()); - } - } - }); - } + event -> { + log.clear(); + final Future<Void> firstFuture = access(() -> { + log("Throwing exception in access"); + throw new RuntimeException("Catch me if you can"); + }); + access(() -> { + log("firstFuture is done? " + firstFuture.isDone()); + try { + firstFuture.get(); + log("Should not get here"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + log("Got exception from firstFuture: " + + e.getMessage()); + } + }); })); addComponent(new Button("Cancel future before started", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - Future<Void> future = access(new Runnable() { - @Override - public void run() { - log("Should not get here"); - } - }); - future.cancel(false); - log("future was cancelled, should not start"); - } + event -> { + log.clear(); + Future<Void> future = access( + () -> log("Should not get here")); + future.cancel(false); + log("future was cancelled, should not start"); })); addComponent( - new Button("Cancel running future", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - final ReentrantLock interruptLock = new ReentrantLock(); + new Button("Cancel running future", event -> { + log.clear(); + final ReentrantLock interruptLock = new ReentrantLock(); - final Future<Void> future = access(new Runnable() { - @Override - public void run() { - log("Waiting for thread to start"); - while (!interruptLock.isLocked()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - log("Premature interruption"); - throw new RuntimeException(e); - } - } + final Future<Void> future = access(() -> { + log("Waiting for thread to start"); + while (!interruptLock.isLocked()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + log("Premature interruption"); + throw new RuntimeException(e); + } + } - log("Thread started, waiting for interruption"); + log("Thread started, waiting for interruption"); + try { + interruptLock.lockInterruptibly(); + } catch (InterruptedException e) { + log("I was interrupted"); + } + }); + + new Thread() { + @Override + public void run() { + interruptLock.lock(); + // Wait until UI thread has started waiting for + // the lock + while (!interruptLock.hasQueuedThreads()) { try { - interruptLock.lockInterruptibly(); + Thread.sleep(100); } catch (InterruptedException e) { - log("I was interrupted"); + throw new RuntimeException(e); } } - }); - - new Thread() { - @Override - public void run() { - interruptLock.lock(); - // Wait until UI thread has started waiting for - // the lock - while (!interruptLock.hasQueuedThreads()) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - future.cancel(true); - } - }.start(); - } + future.cancel(true); + } + }.start(); })); addComponent(new Button("CurrentInstance accessSynchronously values", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - // accessSynchronously should maintain values - CurrentInstance.set(CurrentInstanceTestType.class, - new CurrentInstanceTestType( - "Set before accessSynchronosly")); - accessSynchronously(new Runnable() { - @Override - public void run() { - log.log("accessSynchronously has request? " - + (VaadinService - .getCurrentRequest() != null)); - log.log("Test value in accessSynchronously: " - + CurrentInstance.get( - CurrentInstanceTestType.class)); - CurrentInstance.set( - CurrentInstanceTestType.class, - new CurrentInstanceTestType( - "Set in accessSynchronosly")); - } - }); - log.log("has request after accessSynchronously? " + event -> { + log.clear(); + // accessSynchronously should maintain values + CurrentInstance.set(CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set before accessSynchronosly")); + accessSynchronously(() -> { + log.log("accessSynchronously has request? " + (VaadinService.getCurrentRequest() != null)); - log("Test value after accessSynchornously: " + log.log("Test value in accessSynchronously: " + CurrentInstance .get(CurrentInstanceTestType.class)); - } - })); - addComponent(new Button("CurrentInstance access values", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - // accessSynchronously should maintain values CurrentInstance.set(CurrentInstanceTestType.class, new CurrentInstanceTestType( - "Set before access")); - access(new Runnable() { - @Override - public void run() { - log.log("access has request? " + (VaadinService - .getCurrentRequest() != null)); - log.log("Test value in access: " - + CurrentInstance.get( - CurrentInstanceTestType.class)); - CurrentInstance.set( - CurrentInstanceTestType.class, - new CurrentInstanceTestType( - "Set in access")); - } - }); + "Set in accessSynchronosly")); + }); + log.log("has request after accessSynchronously? " + + (VaadinService.getCurrentRequest() != null)); + log("Test value after accessSynchornously: " + + CurrentInstance + .get(CurrentInstanceTestType.class)); + })); + addComponent(new Button("CurrentInstance access values", + event -> { + log.clear(); + // accessSynchronously should maintain values + CurrentInstance.set(CurrentInstanceTestType.class, + new CurrentInstanceTestType("Set before access")); + access(() -> { + log.log("access has request? " + + (VaadinService.getCurrentRequest() != null)); + log.log("Test value in access: " + CurrentInstance + .get(CurrentInstanceTestType.class)); CurrentInstance.set(CurrentInstanceTestType.class, - new CurrentInstanceTestType( - "Set before run pending")); + new CurrentInstanceTestType("Set in access")); + }); + CurrentInstance.set(CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set before run pending")); - getSession().getService() - .runPendingAccessTasks(getSession()); + getSession().getService() + .runPendingAccessTasks(getSession()); - log.log("has request after access? " - + (VaadinService.getCurrentRequest() != null)); - log("Test value after access: " + CurrentInstance - .get(CurrentInstanceTestType.class)); - } + log.log("has request after access? " + + (VaadinService.getCurrentRequest() != null)); + log("Test value after access: " + CurrentInstance + .get(CurrentInstanceTestType.class)); })); addComponent(new Button("CurrentInstance when pushing", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - if (getPushConfiguration() - .getPushMode() != PushMode.AUTOMATIC) { - log("Can only test with automatic push enabled"); - return; - } + event -> { + log.clear(); + if (getPushConfiguration() + .getPushMode() != PushMode.AUTOMATIC) { + log("Can only test with automatic push enabled"); + return; + } - final VaadinSession session = getSession(); - new Thread() { - @Override - public void run() { - // Pretend this isn't a Vaadin thread - CurrentInstance.clearAll(); + final VaadinSession session = getSession(); + new Thread() { + @Override + public void run() { + // Pretend this isn't a Vaadin thread + CurrentInstance.clearAll(); - /* - * Get explicit lock to ensure the (implicit) - * push does not happen during normal request - * handling. - */ - session.lock(); - try { - access(new Runnable() { - @Override - public void run() { - checkCurrentInstancesBeforeResponse = true; - // Trigger beforeClientResponse - markAsDirty(); - } - }); - } finally { - session.unlock(); - } + /* + * Get explicit lock to ensure the (implicit) push + * does not happen during normal request handling. + */ + session.lock(); + try { + access(() -> { + checkCurrentInstancesBeforeResponse = true; + // Trigger beforeClientResponse + markAsDirty(); + }); + } finally { + session.unlock(); } - }.start(); - } + } + }.start(); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java index 5321827ed3..2dce0fa74a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java @@ -26,7 +26,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -40,85 +39,56 @@ public class UIAccessExceptionHandling extends AbstractTestUIWithLog getSession().setErrorHandler(this); addComponent(new Button("Throw RuntimeException on UI.access", - new Button.ClickListener() { + event -> { + log.clear(); - @Override - public void buttonClick(ClickEvent event) { - log.clear(); + // Ensure beforeClientResponse is invoked + markAsDirty(); - // Ensure beforeClientResponse is invoked - markAsDirty(); - - future = access(new Runnable() { - @Override - public void run() { - throw new RuntimeException(); - } - }); - } + future = access(() -> { + throw new RuntimeException(); + }); })); addComponent(new Button("Throw RuntimeException on Session.access", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - - // Ensure beforeClientResponse is invoked - markAsDirty(); + event -> { + log.clear(); - VaadinService service = VaadinService.getCurrent(); + // Ensure beforeClientResponse is invoked + markAsDirty(); - future = service.accessSession(getSession(), - new Runnable() { + VaadinService service = VaadinService.getCurrent(); - @Override - public void run() { - throw new RuntimeException(); - } - }); - } + future = service.accessSession(getSession(), () -> { + throw new RuntimeException(); + }); })); addComponent( new Button("Throw RuntimeException after removing instances", - new Button.ClickListener() { + event -> { + log.clear(); - @Override - public void buttonClick(ClickEvent event) { - log.clear(); + // Ensure beforeClientResponse is invoked + markAsDirty(); - // Ensure beforeClientResponse is invoked - markAsDirty(); + assert UI + .getCurrent() == UIAccessExceptionHandling.this; - assert UI - .getCurrent() == UIAccessExceptionHandling.this; + Map<Class<?>, CurrentInstance> instances = CurrentInstance + .getInstances(); + CurrentInstance.clearAll(); - Map<Class<?>, CurrentInstance> instances = CurrentInstance - .getInstances(); - CurrentInstance.clearAll(); + assert UI.getCurrent() == null; - assert UI.getCurrent() == null; - - future = access(new Runnable() { - @Override - public void run() { - throw new RuntimeException(); - } - }); + future = access(() -> { + throw new RuntimeException(); + }); - CurrentInstance.restoreInstances(instances); - } + CurrentInstance.restoreInstances(instances); })); - addComponent(new Button("Clear", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.clear(); - } - })); + addComponent(new Button("Clear", event -> log.clear())); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIPolling.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIPolling.java index 936d6a9b18..5ee99720ec 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIPolling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIPolling.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.util.Log; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.MethodProperty; import com.vaadin.v7.ui.TextField; @@ -39,12 +37,8 @@ public class UIPolling extends AbstractTestUIWithLog { } catch (InterruptedException e) { } final int iteration = i; - access(new Runnable() { - @Override - public void run() { - log.log((iteration * SLEEP_TIME) + "ms has passed"); - } - }); + access(() -> log + .log((iteration * SLEEP_TIME) + "ms has passed")); } } } @@ -59,18 +53,14 @@ public class UIPolling extends AbstractTestUIWithLog { new MethodProperty<Integer>(this, "pollInterval")); pollingInterval.setImmediate(true); pollingInterval.setValue("-1"); - pollingInterval.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - if (logger != null) { - logger.stop(); - logger = null; - } - if (getPollInterval() >= 0) { - logger = new BackgroundLogger(); - logger.start(); - } + pollingInterval.addValueChangeListener(event -> { + if (logger != null) { + logger.stop(); + logger = null; + } + if (getPollInterval() >= 0) { + logger = new BackgroundLogger(); + logger.start(); } }); addComponent(pollingInterval); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UISerialization.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UISerialization.java index d60c2a7a82..ef200e7201 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UISerialization.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UISerialization.java @@ -30,8 +30,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; public class UISerialization extends AbstractReindeerTestUI { @@ -41,36 +39,31 @@ public class UISerialization extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { addComponent(log); - addComponent(new Button("Serialize UI", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Date d = new Date(); - try { - byte[] result = serialize(UISerialization.this); - long elapsed = new Date().getTime() - d.getTime(); - log.log("Serialized UI in " + elapsed + "ms into " - + result.length + " bytes"); - Object diffStateBefore = getConnectorTracker() - .getDiffState(UISerialization.this); - UISerialization app = (UISerialization) deserialize(result); - log.log("Deserialized UI in " + elapsed + "ms"); - Object diffStateAfter = getConnectorTracker() - .getDiffState(UISerialization.this); - if (diffStateBefore.equals(diffStateAfter)) { - log.log("Diff states match, size: " - + diffStateBefore.toString().length()); - } else { - log.log("Diff states do not match"); - } - } catch (Exception e) { - log.log("Exception caught: " + e.getMessage()); - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - addComponent( - new Label(sw.toString(), ContentMode.PREFORMATTED)); + addComponent(new Button("Serialize UI", event -> { + Date d = new Date(); + try { + byte[] result = serialize(UISerialization.this); + long elapsed = new Date().getTime() - d.getTime(); + log.log("Serialized UI in " + elapsed + "ms into " + + result.length + " bytes"); + Object diffStateBefore = getConnectorTracker() + .getDiffState(UISerialization.this); + UISerialization app = (UISerialization) deserialize(result); + log.log("Deserialized UI in " + elapsed + "ms"); + Object diffStateAfter = getConnectorTracker() + .getDiffState(UISerialization.this); + if (diffStateBefore.equals(diffStateAfter)) { + log.log("Diff states match, size: " + + diffStateBefore.toString().length()); + } else { + log.log("Diff states do not match"); } - + } catch (Exception e) { + log.log("Exception caught: " + e.getMessage()); + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + addComponent( + new Label(sw.toString(), ContentMode.PREFORMATTED)); } })); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UITabIndex.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UITabIndex.java index 2d4d16242f..e70982a68b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UITabIndex.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UITabIndex.java @@ -2,31 +2,14 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; public class UITabIndex extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addButton("Set tabIndex to -1", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTabIndex(-1); - } - }); - addButton("Set tabIndex to 0", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTabIndex(0); - } - }); - addButton("Set tabIndex to 1", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTabIndex(1); - } - }); + addButton("Set tabIndex to -1", event -> setTabIndex(-1)); + addButton("Set tabIndex to 0", event -> setTabIndex(0)); + addButton("Set tabIndex to 1", event -> setTabIndex(1)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java index 61d7776439..851ab63d8d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java @@ -1,12 +1,9 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.ExternalResource; -import com.vaadin.server.Page; -import com.vaadin.server.Page.UriFragmentChangedEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Link; @@ -19,14 +16,7 @@ public class UriFragment extends AbstractReindeerTestUI { fragmentLabel.setId("fragmentLabel"); addComponent(fragmentLabel); updateLabel(); - getPage().addUriFragmentChangedListener( - new Page.UriFragmentChangedListener() { - @Override - public void uriFragmentChanged( - UriFragmentChangedEvent event) { - updateLabel(); - } - }); + getPage().addUriFragmentChangedListener(event -> updateLabel()); addComponent(createButton("test", "Navigate to #test", "test")); addComponent(createButton("empty", "Navigate to #", "")); @@ -41,12 +31,8 @@ public class UriFragment extends AbstractReindeerTestUI { private Button createButton(String id, String caption, final String fragment) { - Button button = new Button(caption, new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setUriFragment(fragment); - } - }); + Button button = new Button(caption, + event -> getPage().setUriFragment(fragment)); button.setId(id); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java b/uitest/src/main/java/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java index bda4cf8af5..950d653bfc 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java @@ -21,47 +21,34 @@ public class WindowAndUIShortcuts extends UI { final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.addComponent( - new Button("Show page", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - final VerticalLayout pageLayout = new VerticalLayout(); - pageLayout.setSpacing(true); - - pageLayout.addComponent(new Label("Page")); - pageLayout.addComponent(new Button("Open dialog window", - new Button.ClickListener() { - @Override - public void buttonClick( - Button.ClickEvent clickEvent) { - Window dialog = new Window(); - dialog.setModal(true); - dialog.setCaption("Press ESC shortcut"); - dialog.setWidth("300px"); - dialog.setHeight("100px"); - - dialog.setContent(new TextField( - "TextField in window")); - addWindow(dialog); - } - })); - Button closeButton = new Button("Close page", - new Button.ClickListener() { - @Override - public void buttonClick( - Button.ClickEvent clickEvent) { - mainLayout.removeComponent(pageLayout); - - Notification.show( - "OMG! Page is also closed!"); - } - }); - closeButton.setClickShortcut( - ShortcutAction.KeyCode.ESCAPE); - pageLayout.addComponent(closeButton); - - mainLayout.addComponent(pageLayout); - mainLayout.setExpandRatio(pageLayout, 1); - } + new Button("Show page", event -> { + final VerticalLayout pageLayout = new VerticalLayout(); + pageLayout.setSpacing(true); + + pageLayout.addComponent(new Label("Page")); + pageLayout.addComponent(new Button("Open dialog window", + clickEvent -> { + Window dialog = new Window(); + dialog.setModal(true); + dialog.setCaption("Press ESC shortcut"); + dialog.setWidth("300px"); + dialog.setHeight("100px"); + + dialog.setContent( + new TextField("TextField in window")); + addWindow(dialog); + })); + Button closeButton = new Button("Close page", + clickEvent -> { + mainLayout.removeComponent(pageLayout); + + Notification.show("OMG! Page is also closed!"); + }); + closeButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); + pageLayout.addComponent(closeButton); + + mainLayout.addComponent(pageLayout); + mainLayout.setExpandRatio(pageLayout, 1); })); layout.addComponent(mainLayout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/BackButtonTest.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/BackButtonTest.java index 045b91adbb..6c56d250f7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/BackButtonTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/BackButtonTest.java @@ -1,15 +1,10 @@ package com.vaadin.tests.components.uitest; -import com.vaadin.server.Page.UriFragmentChangedEvent; -import com.vaadin.server.Page.UriFragmentChangedListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.TextField; public class BackButtonTest extends AbstractReindeerTestUI { @@ -32,19 +27,14 @@ public class BackButtonTest extends AbstractReindeerTestUI { p2 = new Page2(); getPage().addUriFragmentChangedListener( - new UriFragmentChangedListener() { - - @Override - public void uriFragmentChanged( - UriFragmentChangedEvent event) { - String f = event.getUriFragment(); - if ("page2".equals(f)) { - showPage2(); - } - - if ("page1".equals(f)) { - showPage1(); - } + event -> { + String f = event.getUriFragment(); + if ("page2".equals(f)) { + showPage2(); + } + + if ("page1".equals(f)) { + showPage1(); } }); } @@ -57,12 +47,9 @@ public class BackButtonTest extends AbstractReindeerTestUI { l.setCaption("Data from Page 1 : " + value); addComponent(l); - Button b = new Button("Go to Page 2", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - l.setCaption("Data from Page 1 : " + value); - getPage().setUriFragment("page2"); - } + Button b = new Button("Go to Page 2", event -> { + l.setCaption("Data from Page 1 : " + value); + getPage().setUriFragment("page2"); }); addComponent(b); } @@ -86,25 +73,17 @@ public class BackButtonTest extends AbstractReindeerTestUI { setSizeFull(); addComponent(f); - f.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - value = f.getValue(); - p1.l.setCaption("Data from Page 2 : " + value); - } + f.addValueChangeListener(event -> { + value = f.getValue(); + p1.l.setCaption("Data from Page 2 : " + value); }); - Button b = new Button("Go Back", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setUriFragment("page1"); - } - }); + Button b = new Button("Go Back", + event -> getPage().setUriFragment("page1")); addComponent(b); addComponent(new Label( "Go back with the back button without creating a blur event on the text field. Text should transfer to page1 label.")); } - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/ThemeTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/ThemeTestUI.java index 7de0eaf083..9355c47ef9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/ThemeTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/ThemeTestUI.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.uitest; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.ui.TextField; @@ -35,15 +34,9 @@ public class ThemeTestUI extends AbstractReindeerTestUI { private void createCustomStyleStringField() { customStyle = new TextField(); customStyle.setId("customstyle"); - setStyleName = new Button("Set stylename", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - onCustomStyleNameChanged(customStyle.getValue()); - } - }); + setStyleName = new Button("Set stylename", + event -> onCustomStyleNameChanged(customStyle.getValue())); setStyleName.setId("setcuststyle"); - } private void onCustomStyleNameChanged(String newStyleName) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/UIScrolling.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/UIScrolling.java index 74d56bd04e..89f84e5ae1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/UIScrolling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/UIScrolling.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.uitest; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.ui.UI; @@ -13,23 +12,13 @@ public class UIScrolling extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { // Set layout to high enough to get scroll. getLayout().setHeight("2250px"); - addComponent(new Button("scroll to 1000px", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().setScrollTop(1000); - } - })); + addComponent(new Button("scroll to 1000px", + event -> UI.getCurrent().setScrollTop(1000))); addComponent(new Button( "This button is halfway down. Click to report scroll position.", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Notification.show("Scrolled to " - + event.getButton().getUI().getScrollTop() - + " px"); - } - })); + event -> Notification.show("Scrolled to " + + event.getButton().getUI().getScrollTop() + + " px"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/NotificationsCssTest.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/NotificationsCssTest.java index 3997c3ca4c..200e24d6d5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/NotificationsCssTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/NotificationsCssTest.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.uitest.components; import com.vaadin.tests.components.uitest.TestSampler; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.ui.VerticalLayout; @@ -19,42 +18,20 @@ public class NotificationsCssTest extends VerticalLayout { parent.registerComponent(this); Button humanized = new Button("Humanized message", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createNotification("A message", "A description", - Notification.Type.HUMANIZED_MESSAGE); - } - }); + event -> createNotification("A message", "A description", + Notification.Type.HUMANIZED_MESSAGE)); humanized.setId("notifButt" + debugIdCounter++); Button warning = new Button("Warning message", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createNotification("A message", "A description", - Notification.Type.WARNING_MESSAGE); - } - }); + event -> createNotification("A message", "A description", + Notification.Type.WARNING_MESSAGE)); warning.setId("notifButt" + debugIdCounter++); - Button error = new Button("Error message", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createNotification("A message", "A description", - Notification.Type.ERROR_MESSAGE); - } - }); + Button error = new Button("Error message", + event -> createNotification("A message", "A description", + Notification.Type.ERROR_MESSAGE)); error.setId("notifButt" + debugIdCounter++); - Button tray = new Button("Tray message", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createNotification("A message", "A description", - Notification.Type.TRAY_NOTIFICATION); - } - }); + Button tray = new Button("Tray message", + event -> createNotification("A message", "A description", + Notification.Type.TRAY_NOTIFICATION)); tray.setId("notifButt" + debugIdCounter++); addComponent(humanized); diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/WindowsCssTest.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/WindowsCssTest.java index 86d5bff57e..d6026be678 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/uitest/components/WindowsCssTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/uitest/components/WindowsCssTest.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.uitest.components; import com.vaadin.tests.components.uitest.TestSampler; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -25,46 +24,23 @@ public class WindowsCssTest extends VerticalLayout { parent.registerComponent(this); Button defWindow = new Button("Default window", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createWindowWith(caption, null, styleName); - } - }); + event -> createWindowWith(caption, null, styleName)); defWindow.setId("windButton" + debugIdCounter++); - Button light = new Button("Light window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createWindowWith(caption, Reindeer.WINDOW_LIGHT, styleName); - } - }); + Button light = new Button("Light window", + event -> createWindowWith(caption, Reindeer.WINDOW_LIGHT, + styleName)); light.setId("windButton" + debugIdCounter++); - Button black = new Button("Black window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createWindowWith(caption, Reindeer.WINDOW_BLACK, styleName); - } - }); + Button black = new Button("Black window", + event -> createWindowWith(caption, Reindeer.WINDOW_BLACK, + styleName)); black.setId("windButton" + debugIdCounter++); - Button dialog = new Button("Dialog window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createWindowWith(caption, Runo.WINDOW_DIALOG, styleName); - } - }); + Button dialog = new Button("Dialog window", + event -> createWindowWith(caption, Runo.WINDOW_DIALOG, + styleName)); dialog.setId("windButton" + debugIdCounter++); - Button opaque = new Button("Opaque window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - createWindowWith(caption, ChameleonTheme.WINDOW_OPAQUE, - styleName); - } - }); + Button opaque = new Button("Opaque window", + event -> createWindowWith(caption, ChameleonTheme.WINDOW_OPAQUE, + styleName)); opaque.setId("windButton" + debugIdCounter++); addComponent(defWindow); @@ -72,7 +48,6 @@ public class WindowsCssTest extends VerticalLayout { addComponent(black); addComponent(dialog); addComponent(opaque); - } /** @@ -106,7 +81,6 @@ public class WindowsCssTest extends VerticalLayout { } parent.getUI().addWindow(window); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java b/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java index 5a73cd3fbd..767f72d036 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.upload; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.Upload; public class DisabledUploadButton extends AbstractReindeerTestUI { @@ -13,12 +12,7 @@ public class DisabledUploadButton extends AbstractReindeerTestUI { addComponent(upload); - addButton("Set disabled", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - upload.setEnabled(false); - } - }); + addButton("Set disabled", event -> upload.setEnabled(false)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java b/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java index 4b0b8e99c3..6392d5c7ff 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java @@ -5,13 +5,8 @@ import java.io.OutputStream; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FailedEvent; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.StartedEvent; import com.vaadin.v7.ui.TextField; public class ForceSubmit extends TestBase implements Receiver { @@ -40,42 +35,24 @@ public class ForceSubmit extends TestBase implements Receiver { addComponent(u); - u.addFinishedListener(new Upload.FinishedListener() { - @Override - public void uploadFinished(FinishedEvent event) { - String filename = event.getFilename(); - long length = event.getLength(); - getMainWindow().showNotification( - "Done. Filename : " + filename + " Lenght: " + length); - } + u.addFinishedListener(event -> { + String filename = event.getFilename(); + long length = event.getLength(); + getMainWindow().showNotification( + "Done. Filename : " + filename + " Lenght: " + length); }); - u.addFailedListener(new Upload.FailedListener() { - @Override - public void uploadFailed(FailedEvent event) { - getMainWindow().showNotification("Failed. No file selected?"); - } - }); + u.addFailedListener(event -> getMainWindow() + .showNotification("Failed. No file selected?")); - u.addStartedListener(new Upload.StartedListener() { - @Override - public void uploadStarted(StartedEvent event) { - getMainWindow().showNotification( - "Started upload. TF value :" + textField.getValue()); - } - }); + u.addStartedListener(event -> getMainWindow().showNotification( + "Started upload. TF value :" + textField.getValue())); Button button = new Button( "I'm an external button (not the uploads builtin), hit me to start upload."); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - u.submitUpload(); - } - }); + button.addClickListener(event -> u.submitUpload()); addComponent(button); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUpload.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUpload.java index e400dcb0be..52bf052778 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUpload.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUpload.java @@ -8,11 +8,7 @@ import org.apache.commons.codec.digest.DigestUtils; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FailedEvent; -import com.vaadin.ui.Upload.FailedListener; import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.SucceededEvent; -import com.vaadin.ui.Upload.SucceededListener; public class TestFileUpload extends TestBase implements Receiver { @@ -31,27 +27,19 @@ public class TestFileUpload extends TestBase implements Receiver { } }); u.setId("UPL"); - u.addFailedListener(new FailedListener() { + u.addFailedListener(event -> { + String hash = DigestUtils.md5Hex(baos.toByteArray()); - @Override - public void uploadFailed(FailedEvent event) { - String hash = DigestUtils.md5Hex(baos.toByteArray()); - - log.log("<span style=\"color: red;\">Upload failed. Name: " - + event.getFilename() + ", Size: " + baos.size() - + ", md5: " + hash + "</span>"); - baos.reset(); - } + log.log("<span style=\"color: red;\">Upload failed. Name: " + + event.getFilename() + ", Size: " + baos.size() + ", md5: " + + hash + "</span>"); + baos.reset(); }); - u.addSucceededListener(new SucceededListener() { - - @Override - public void uploadSucceeded(SucceededEvent event) { - String hash = DigestUtils.md5Hex(baos.toByteArray()); - log.log("Upload finished. Name: " + event.getFilename() - + ", Size: " + baos.size() + ", md5: " + hash); - baos.reset(); - } + u.addSucceededListener(event -> { + String hash = DigestUtils.md5Hex(baos.toByteArray()); + log.log("Upload finished. Name: " + event.getFilename() + ", Size: " + + baos.size() + ", md5: " + hash); + baos.reset(); }); u.setImmediateMode(false); diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUploadSize.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUploadSize.java index 4744c935c6..5904c6915b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUploadSize.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestFileUploadSize.java @@ -9,9 +9,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.StartedEvent; public class TestFileUploadSize extends TestBase implements Receiver { @@ -35,21 +33,12 @@ public class TestFileUploadSize extends TestBase implements Receiver { } }); u.setId("UPL"); - u.addStartedListener(new Upload.StartedListener() { - - @Override - public void uploadStarted(StartedEvent event) { - expectedSize.setValue(String.valueOf(event.getContentLength())); - } - }); - u.addFinishedListener(new Upload.FinishedListener() { - - @Override - public void uploadFinished(FinishedEvent event) { - label.setValue("Upload finished. Name: " + event.getFilename()); - receivedSize.setValue(String.valueOf(baos.size())); - baos.reset(); - } + u.addStartedListener(event -> expectedSize + .setValue(String.valueOf(event.getContentLength()))); + u.addFinishedListener(event -> { + label.setValue("Upload finished. Name: " + event.getFilename()); + receivedSize.setValue(String.valueOf(baos.size())); + baos.reset(); }); expectedSize.setId("expected"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUpload.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUpload.java index 519296d006..d5be9b5abb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUpload.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUpload.java @@ -9,7 +9,6 @@ import com.vaadin.tests.components.ComponentTestCase; import com.vaadin.ui.Component; import com.vaadin.ui.Notification; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; public class TestUpload extends ComponentTestCase<Upload> implements Receiver { @@ -32,17 +31,11 @@ public class TestUpload extends ComponentTestCase<Upload> implements Receiver { u.setSizeUndefined(); addTestComponent(u); - u.addFinishedListener(new Upload.FinishedListener() { - @Override - public void uploadFinished(FinishedEvent event) { - Notification.show("Done"); - } - }); + u.addFinishedListener(event -> Notification.show("Done")); u = new Upload("300px wide upload", this); u.setWidth("300px"); addTestComponent(u); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java index f2b076b60a..00c99a6dc1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java @@ -10,9 +10,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.StartedEvent; public class TestUploadAndDisableOnSuccess extends ComponentTestCase<Upload> implements Receiver { @@ -50,28 +48,19 @@ public class TestUploadAndDisableOnSuccess extends ComponentTestCase<Upload> l = new Label(getUploadcount()); addComponent(l); - u.addStartedListener(new Upload.StartedListener() { - - @Override - public void uploadStarted(StartedEvent event) { - /* - * Remove component before upload from the same vertical layout. - * Causes upload to be detached/attached -> upload loses it - * target iframes onload listener -> puts VUpload inappropriate - * state. - */ - getLayout().removeComponent(labe); - } + u.addStartedListener(event -> { + /* + * Remove component before upload from the same vertical layout. + * Causes upload to be detached/attached -> upload loses it target + * iframes onload listener -> puts VUpload inappropriate state. + */ + getLayout().removeComponent(labe); }); - u.addFinishedListener(new Upload.FinishedListener() { - @Override - public void uploadFinished(FinishedEvent event) { - Notification.show("Done"); - l.setValue(getUploadcount()); - } + u.addFinishedListener(event -> { + Notification.show("Done"); + l.setValue(getUploadcount()); }); - } private String getUploadcount() { @@ -82,13 +71,8 @@ public class TestUploadAndDisableOnSuccess extends ComponentTestCase<Upload> protected List<Component> createActions() { List<Component> actions = new ArrayList<>(); actions.add(createButtonAction("Toggle Enabled", - new Command<Upload, Boolean>() { - - @Override - public void execute(Upload c, Boolean value, Object data) { - c.setEnabled(!c.isEnabled()); - } - })); + (upload, value, data) -> upload + .setEnabled(!upload.isEnabled()))); return actions; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java index 41f4f31588..9667860584 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java @@ -6,7 +6,6 @@ import java.io.OutputStream; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; public class TestUploadFilename extends TestBase { @@ -22,14 +21,9 @@ public class TestUploadFilename extends TestBase { addComponent(upload); addComponent(result); - upload.addFinishedListener(new Upload.FinishedListener() { - @Override - public void uploadFinished(FinishedEvent event) { - result.setValue("Got file (should not contain path): " - + receiver.getFilename()); - } - }); - + upload.addFinishedListener( + event -> result.setValue("Got file (should not contain path): " + + receiver.getFilename())); } public static class UploadReceiver implements Receiver { diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java index e2d5fa2f52..f57dd3d811 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadNoSelection.java @@ -21,8 +21,6 @@ import java.io.OutputStream; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.FailedEvent; -import com.vaadin.ui.Upload.FinishedEvent; import com.vaadin.ui.Upload.Receiver; public class UploadNoSelection extends AbstractTestUIWithLog @@ -56,22 +54,15 @@ public class UploadNoSelection extends AbstractTestUIWithLog addComponent(u); - u.addFinishedListener(new Upload.FinishedListener() { - @Override - public void uploadFinished(FinishedEvent event) { - log(UPLOAD_FINISHED); - log(FILE_LENGTH_PREFIX + " " + event.getLength()); - log(FILE_NAME_PREFIX + " " + event.getFilename()); - } + u.addFinishedListener(event -> { + log(UPLOAD_FINISHED); + log(FILE_LENGTH_PREFIX + " " + event.getLength()); + log(FILE_NAME_PREFIX + " " + event.getFilename()); }); - u.addFailedListener(new Upload.FailedListener() { - - @Override - public void uploadFailed(FailedEvent event) { - log("Upload Failed"); - log(FILE_LENGTH_PREFIX + " " + event.getLength()); - log(FILE_NAME_PREFIX + " " + event.getFilename()); - } + u.addFailedListener(event -> { + log("Upload Failed"); + log(FILE_LENGTH_PREFIX + " " + event.getLength()); + log(FILE_NAME_PREFIX + " " + event.getFilename()); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java index bd0cb109b0..a8f86d1659 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java @@ -6,8 +6,6 @@ import com.vaadin.server.VaadinService; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.LegacyWindow; @@ -89,14 +87,7 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase { log(this); } }; - okButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.log("Button clicked"); - - } - }); + okButton.addClickListener(event -> log.log("Button clicked")); okButton.setClickShortcut(KeyCode.ENTER); layout.addComponent(okButton); w.center(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpened.java b/uitest/src/main/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpened.java index f25e4e9349..2aca0b91f2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpened.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/BackspaceKeyWithModalOpened.java @@ -21,7 +21,6 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.TextField; @@ -44,13 +43,8 @@ public class BackspaceKeyWithModalOpened extends AbstractReindeerTestUI { @Override public void enter(ViewChangeEvent event) { - Button btnNext = new Button("Next", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - navigator.navigateTo(SECOND_VIEW_ID); - } - }); + Button btnNext = new Button("Next", + clickEvent -> navigator.navigateTo(SECOND_VIEW_ID)); btnNext.setId(BTN_NEXT_ID); addComponent(btnNext); @@ -62,29 +56,25 @@ public class BackspaceKeyWithModalOpened extends AbstractReindeerTestUI { @Override public void enter(ViewChangeEvent event) { Button btnOpenModal = new Button("Open modal", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Window window = new Window("Caption"); - window.setId(MODAL_ID); + clickEvent -> { + Window window = new Window("Caption"); + window.setId(MODAL_ID); - VerticalLayout layout = new VerticalLayout(); - layout.setWidth("300px"); - layout.setHeight("300px"); + VerticalLayout layout = new VerticalLayout(); + layout.setWidth("300px"); + layout.setHeight("300px"); - TextField textField = new TextField(); - textField.setId(TEXT_FIELD_IN_MODAL); + TextField textField = new TextField(); + textField.setId(TEXT_FIELD_IN_MODAL); - layout.addComponent(textField); - window.setContent(layout); + layout.addComponent(textField); + window.setContent(layout); - addWindow(window); + addWindow(window); - window.setModal(true); + window.setModal(true); - setFocusedComponent(window); - } + setFocusedComponent(window); }); btnOpenModal.setId(BTN_OPEN_MODAL_ID); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/BottomComponentScrollsUp.java b/uitest/src/main/java/com/vaadin/tests/components/window/BottomComponentScrollsUp.java index 34a9fe6ae4..b362ef219e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/BottomComponentScrollsUp.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/BottomComponentScrollsUp.java @@ -22,8 +22,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -46,14 +44,7 @@ public class BottomComponentScrollsUp extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { Button b = new Button("Open window"); addComponent(b); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - openWindow(); - } - - }); + b.addClickListener(event -> openWindow()); openWindow(); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/CenteredInVisualViewport.java b/uitest/src/main/java/com/vaadin/tests/components/window/CenteredInVisualViewport.java index c241d42dff..02424279b0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/CenteredInVisualViewport.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/CenteredInVisualViewport.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Window; @@ -26,41 +25,28 @@ public class CenteredInVisualViewport extends TestBase { layout.setHeight("1000px"); addComponent(layout); - Button b = new Button("Open", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Window centered = new Window("A window", - new Label("Centered window")); - centered.center(); - getMainWindow().addWindow(centered); - } + Button b = new Button("Open", event -> { + Window centered = new Window("A window", + new Label("Centered window")); + centered.center(); + getMainWindow().addWindow(centered); }); layout.addComponent(b, 0, 0); - b = new Button("Open", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Window centered = new Window("A window", - new Label("Centered window")); - centered.center(); - getMainWindow().addWindow(centered); - } + b = new Button("Open", event -> { + Window centered = new Window("A window", + new Label("Centered window")); + centered.center(); + getMainWindow().addWindow(centered); }); layout.addComponent(b, 1, 1); - b = new Button("Open", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Window centered = new Window("A window", - new Label("Centered window")); - centered.center(); - getMainWindow().addWindow(centered); - } + b = new Button("Open", event -> { + Window centered = new Window("A window", + new Label("Centered window")); + centered.center(); + getMainWindow().addWindow(centered); }); layout.addComponent(b, 2, 2); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/CloseModalSubWindow.java b/uitest/src/main/java/com/vaadin/tests/components/window/CloseModalSubWindow.java index 30b75a356e..da6c50ab53 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/CloseModalSubWindow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/CloseModalSubWindow.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.UI; @@ -81,32 +80,20 @@ public class CloseModalSubWindow extends AbstractTestUIWithLog { table.removeItem(itemId); } - private ClickListener deleteClickListener = new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - win = new ConfirmWindow(event.getButton().getData()); - log("Modal sub-window opened"); - } + private ClickListener deleteClickListener = event -> { + win = new ConfirmWindow(event.getButton().getData()); + log("Modal sub-window opened"); }; - private ClickListener confirmClickListener = new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - deleteItem(event.getButton().getData()); - win.close(); - log("Modal sub-window closed"); - } + private ClickListener confirmClickListener = event -> { + deleteItem(event.getButton().getData()); + win.close(); + log("Modal sub-window closed"); }; - private ClickListener cancelClickListener = new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - win.close(); - log("Modal sub-window closed"); - } + private ClickListener cancelClickListener = event -> { + win.close(); + log("Modal sub-window closed"); }; /** Modal confirmation sub-window. */ diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/CloseSubWindow.java b/uitest/src/main/java/com/vaadin/tests/components/window/CloseSubWindow.java index 83eebc4531..80400b18ca 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/CloseSubWindow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/CloseSubWindow.java @@ -3,12 +3,8 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; -import com.vaadin.ui.Window.CloseListener; public class CloseSubWindow extends AbstractTestUIWithLog { @@ -16,12 +12,9 @@ public class CloseSubWindow extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { Button openWindowButton = new Button("Open sub-window"); openWindowButton.setId("opensub"); - openWindowButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Window sub = createClosableSubWindow("Sub-window"); - getUI().addWindow(sub); - } + openWindowButton.addClickListener(event -> { + Window sub = createClosableSubWindow("Sub-window"); + getUI().addWindow(sub); }); addComponent(openWindowButton); @@ -36,29 +29,15 @@ public class CloseSubWindow extends AbstractTestUIWithLog { window.setClosable(true); Button closeButton = new Button("Close"); - closeButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - event.getButton().findAncestor(Window.class).close(); - } - }); + closeButton.addClickListener( + event -> event.getButton().findAncestor(Window.class).close()); layout.addComponent(closeButton); Button removeButton = new Button("Remove from UI"); - removeButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getUI().removeWindow(window); - } - }); + removeButton.addClickListener(event -> getUI().removeWindow(window)); layout.addComponent(removeButton); - window.addCloseListener(new CloseListener() { - @Override - public void windowClose(CloseEvent e) { - log("Window '" + title + "' closed"); - } - }); + window.addCloseListener(event -> log("Window '" + title + "' closed")); return window; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/DownloadAndUpdate.java b/uitest/src/main/java/com/vaadin/tests/components/window/DownloadAndUpdate.java index 9eddcc6c69..5659cae7ae 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/DownloadAndUpdate.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/DownloadAndUpdate.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.ExternalResource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Table; public class DownloadAndUpdate extends TestBase { @@ -11,12 +10,8 @@ public class DownloadAndUpdate extends TestBase { @Override protected void setup() { addComponent( - new Button("Download and update", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - downloadAndUpdate(); - } - })); + new Button("Download and update", + event -> downloadAndUpdate())); } protected void downloadAndUpdate() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java b/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java index 1a54c399d8..4054e0112a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; @@ -27,13 +26,7 @@ public class ExecuteJavaScript extends AbstractTestCase { private Button createScriptButton(final String script) { Button b = new Button(script); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().executeJavaScript(script); - } - }); + b.addClickListener(event -> getMainWindow().executeJavaScript(script)); return b; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShown.java b/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShown.java index e3542ae8a5..35ad3abf03 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShown.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShown.java @@ -5,7 +5,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -13,30 +12,16 @@ public class ExtraWindowShown extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - Button b = new Button("Open window", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - final Window w = new Window("Sub window", layout); - w.center(); - layout.addComponent( - new Button("Close", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - w.close(); - } - })); - Button iconButton = new Button("A button with icon"); - iconButton - .setIcon(new ThemeResource("../runo/icons/16/ok.png")); - layout.addComponent(iconButton); - event.getButton().getUI().addWindow(w); - } - + Button b = new Button("Open window", event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + final Window w = new Window("Sub window", layout); + w.center(); + layout.addComponent(new Button("Close", clickEvent -> w.close())); + Button iconButton = new Button("A button with icon"); + iconButton.setIcon(new ThemeResource("../runo/icons/16/ok.png")); + layout.addComponent(iconButton); + event.getButton().getUI().addWindow(w); }); getLayout().getParent().setSizeFull(); getLayout().setSizeFull(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java b/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java index a7fb47be9b..75267a5762 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java @@ -5,7 +5,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.window.WindowRole; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.CssLayout; import com.vaadin.ui.FormLayout; @@ -33,116 +32,92 @@ public class ExtraWindowShownWaiAria extends AbstractReindeerTestUI { "Bottom Tab Stop Message"); Button simple = new Button("Open Alert Dialog", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - CssLayout layout = new CssLayout(); - - final Window w = new Window("Sub window", layout); - w.center(); - w.setModal(modal.getValue()); - w.setAssistiveRole(WindowRole.ALERTDIALOG); - w.setAssistivePrefix(prefix.getValue()); - w.setAssistivePostfix(postfix.getValue()); - - Label description1 = new Label("Simple alert dialog."); - layout.addComponent(description1); - - if (!additionalDescription.getValue()) { - w.setAssistiveDescription(description1); - } else { - Label description2 = new Label( - "Please select what to do!"); - layout.addComponent(description2); - - w.setAssistiveDescription(description1, - description2); - } - - w.setTabStopEnabled(tabStop.getValue()); - w.setTabStopTopAssistiveText( - topTabStopMessage.getValue()); - w.setTabStopBottomAssistiveText( - bottomTabStopMessage.getValue()); - - Button close = new Button("Close", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - w.close(); - } - }); - layout.addComponent(close); - Button iconButton = new Button("A button with icon"); - iconButton.setIcon( - new ThemeResource("../runo/icons/16/ok.png")); - layout.addComponent(iconButton); - - event.getButton().getUI().addWindow(w); - iconButton.focus(); - - if (tabOrder.getValue()) { - close.setTabIndex(5); - } + event -> { + CssLayout layout = new CssLayout(); + + final Window w = new Window("Sub window", layout); + w.center(); + w.setModal(modal.getValue()); + w.setAssistiveRole(WindowRole.ALERTDIALOG); + w.setAssistivePrefix(prefix.getValue()); + w.setAssistivePostfix(postfix.getValue()); + + Label description1 = new Label("Simple alert dialog."); + layout.addComponent(description1); + + if (!additionalDescription.getValue()) { + w.setAssistiveDescription(description1); + } else { + Label description2 = new Label( + "Please select what to do!"); + layout.addComponent(description2); + + w.setAssistiveDescription(description1, description2); } + w.setTabStopEnabled(tabStop.getValue()); + w.setTabStopTopAssistiveText(topTabStopMessage.getValue()); + w.setTabStopBottomAssistiveText( + bottomTabStopMessage.getValue()); + + Button close = new Button("Close", clickEvent -> w.close()); + layout.addComponent(close); + Button iconButton = new Button("A button with icon"); + iconButton.setIcon( + new ThemeResource("../runo/icons/16/ok.png")); + layout.addComponent(iconButton); + + event.getButton().getUI().addWindow(w); + iconButton.focus(); + + if (tabOrder.getValue()) { + close.setTabIndex(5); + } }); getLayout().addComponent(simple); Button complex = new Button("Open Entry Dialog", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - FormLayout form = new FormLayout(); - - final Window w = new Window("Form Window", form); - w.center(); - w.setModal(modal.getValue()); - w.setAssistivePrefix(prefix.getValue()); - w.setAssistivePostfix(postfix.getValue()); - - Label description1 = new Label( - "Please fill in your data"); - form.addComponent(description1); - - if (!additionalDescription.getValue()) { - w.setAssistiveDescription(description1); - } else { - Label description2 = new Label( - "and press the button save."); - form.addComponent(description2); - - w.setAssistiveDescription(description1, - description2); - } - - w.setTabStopEnabled(tabStop.getValue()); - w.setTabStopTopAssistiveText( - topTabStopMessage.getValue()); - w.setTabStopBottomAssistiveText( - bottomTabStopMessage.getValue()); - - TextField name = new TextField("Name:"); - form.addComponent(name); - - form.addComponent(new TextField("Address")); - - Button saveButton = new Button("Save", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - w.close(); - } - }); - form.addComponent(saveButton); - - event.getButton().getUI().addWindow(w); - name.focus(); - - if (tabOrder.getValue()) { - name.setTabIndex(5); - } + event -> { + FormLayout form = new FormLayout(); + + final Window w = new Window("Form Window", form); + w.center(); + w.setModal(modal.getValue()); + w.setAssistivePrefix(prefix.getValue()); + w.setAssistivePostfix(postfix.getValue()); + + Label description1 = new Label("Please fill in your data"); + form.addComponent(description1); + + if (!additionalDescription.getValue()) { + w.setAssistiveDescription(description1); + } else { + Label description2 = new Label( + "and press the button save."); + form.addComponent(description2); + + w.setAssistiveDescription(description1, description2); + } + + w.setTabStopEnabled(tabStop.getValue()); + w.setTabStopTopAssistiveText(topTabStopMessage.getValue()); + w.setTabStopBottomAssistiveText( + bottomTabStopMessage.getValue()); + + TextField name = new TextField("Name:"); + form.addComponent(name); + + form.addComponent(new TextField("Address")); + + Button saveButton = new Button("Save", + clickEvent -> w.close()); + form.addComponent(saveButton); + + event.getButton().getUI().addWindow(w); + name.focus(); + + if (tabOrder.getValue()) { + name.setTabIndex(5); } }); getLayout().addComponent(complex); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/GridInWindow.java b/uitest/src/main/java/com/vaadin/tests/components/window/GridInWindow.java index 788b334998..24bc94f384 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/GridInWindow.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/GridInWindow.java @@ -31,15 +31,12 @@ public class GridInWindow extends AbstractTestUIWithLog { grid.addRow("Close and reopen and it vanishes"); Button popupButton = new Button("Open PopUp", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - Window subWindow = new Window("Sub-window"); - subWindow.setContent(grid); - subWindow.setWidth(600, Unit.PIXELS); - subWindow.setWidth(400, Unit.PIXELS); - getUI().addWindow(subWindow); - } + event -> { + Window subWindow = new Window("Sub-window"); + subWindow.setContent(grid); + subWindow.setWidth(600, Unit.PIXELS); + subWindow.setWidth(400, Unit.PIXELS); + getUI().addWindow(subWindow); }); addComponent(popupButton); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/LegacyWindowOpenTest.java b/uitest/src/main/java/com/vaadin/tests/components/window/LegacyWindowOpenTest.java index 3a46d8c299..50dea6ab0f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/LegacyWindowOpenTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/LegacyWindowOpenTest.java @@ -4,7 +4,6 @@ import com.vaadin.server.ExternalResource; import com.vaadin.tests.TestForWindowOpen; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.LegacyWindow; public class LegacyWindowOpenTest extends TestBase { @@ -18,55 +17,24 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new TestForWindowOpen()); addComponent(new Button("Window.open _blank always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.open(r, "_blank", true); - } - })); + event -> win.open(r, "_blank", true))); addComponent(new Button("Window.open _blank NOT always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.open(r, "_blank", false); - } - })); + event -> win.open(r, "_blank", false))); addComponent(new Button("Window.open _new always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.open(r, "_new", true); - } - })); + event -> win.open(r, "_new", true))); addComponent(new Button("Window.open _new NOT always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.open(r, "_new", false); - } - })); + event -> win.open(r, "_new", false))); addComponent(new Button( "Window execute Javascript window.open(www.google.com, _blank)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.executeJavaScript( - "window.open(\"http://www.google.com\", \"_blank\");"); - } - })); + event -> win.executeJavaScript( + "window.open(\"http://www.google.com\", \"_blank\");"))); addComponent(new Button( "Window execute Javascript window.open(www.google.com, _blank, resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - win.executeJavaScript( - "window.open(\"http://www.google.com\", \"_blank\", \"resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes\");"); - } - })); - + event-> win.executeJavaScript( + "window.open(\"http://www.google.com\", \"_blank\", \"resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes\");"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/LongNotifications.java b/uitest/src/main/java/com/vaadin/tests/components/window/LongNotifications.java index 621c869e43..8dffc295a9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/LongNotifications.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/LongNotifications.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; public class LongNotifications extends TestBase { @@ -23,58 +22,31 @@ public class LongNotifications extends TestBase { setTheme("tests-tickets"); Button b = new Button("Show loooong notification", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - getMainWindow().showNotification(text, - "This is description for the same notifications." - + text, - Notification.TYPE_HUMANIZED_MESSAGE); - } - }); + event -> getMainWindow().showNotification(text, + "This is description for the same notifications." + + text, + Notification.TYPE_HUMANIZED_MESSAGE)); getLayout().addComponent(b); - b = new Button("Show notifications", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - getMainWindow().showNotification("Example failed", + b = new Button("Show notifications", + event -> getMainWindow().showNotification("Example failed", "This is description for the same notifications.", - Notification.TYPE_HUMANIZED_MESSAGE); - } - }); + Notification.TYPE_HUMANIZED_MESSAGE)); getLayout().addComponent(b); b = new Button("Show loooong notification (error)", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - getMainWindow().showNotification(text, - "This is description for the same notifications." - + text, - Notification.TYPE_ERROR_MESSAGE); - } - }); + event -> getMainWindow().showNotification(text, + "This is description for the same notifications." + + text, + Notification.TYPE_ERROR_MESSAGE)); getLayout().addComponent(b); - b = new Button("Show notification (error)", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - getMainWindow().showNotification("Example failed", + b = new Button("Show notification (error)", + event -> getMainWindow().showNotification("Example failed", "This is description for the same notifications.", - Notification.TYPE_ERROR_MESSAGE); - } - }); + Notification.TYPE_ERROR_MESSAGE)); getLayout().addComponent(b); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/MaximizedWindowOrder.java b/uitest/src/main/java/com/vaadin/tests/components/window/MaximizedWindowOrder.java index 258578cfac..03f244a180 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/MaximizedWindowOrder.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/MaximizedWindowOrder.java @@ -4,8 +4,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.window.WindowMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -14,12 +12,7 @@ public class MaximizedWindowOrder extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addButton("Open Maximized Window", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - openWindow(true); - } - }); + addButton("Open Maximized Window", event -> openWindow(true)); } private void openWindow(boolean maximized) { @@ -30,14 +23,7 @@ public class MaximizedWindowOrder extends AbstractReindeerTestUI { layout.addComponent(label); Button button = new Button("Open Normal Window"); - button.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - openWindow(false); - } - - }); + button.addClickListener(event -> openWindow(false)); layout.addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowFocus.java b/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowFocus.java index c4358d8eec..a9578840d2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowFocus.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowFocus.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Window; @@ -30,33 +29,27 @@ public class ModalWindowFocus extends AbstractReindeerTestUI { Button button = new Button("Open windows"); button.setId("firstButton"); addComponent(button); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Window w = new Window("This is first window"); - w.setModal(true); - addWindow(w); + button.addClickListener(event -> { + Window w = new Window("This is first window"); + w.setModal(true); + addWindow(w); - Window w2 = new Window("This is second window"); - w2.setModal(true); - addWindow(w2); + Window w2 = new Window("This is second window"); + w2.setModal(true); + addWindow(w2); - HorizontalLayout lay = new HorizontalLayout(); - Button buttonInWindow = new Button("Open window"); - buttonInWindow.setId("windowButton"); - lay.addComponent(buttonInWindow); - w2.setContent(lay); + HorizontalLayout lay = new HorizontalLayout(); + Button buttonInWindow = new Button("Open window"); + buttonInWindow.setId("windowButton"); + lay.addComponent(buttonInWindow); + w2.setContent(lay); - buttonInWindow.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent e) { - Window w3 = new Window("This is third window"); - w3.setModal(true); - w3.setId("window3"); - addWindow(w3); - } - }); - } + buttonInWindow.addClickListener(clickEvent -> { + Window w3 = new Window("This is third window"); + w3.setModal(true); + w3.setId("window3"); + addWindow(w3); + }); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowInitialLocation.java b/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowInitialLocation.java index 68d7c009cf..61f25c9e64 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowInitialLocation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/ModalWindowInitialLocation.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.v7.ui.ListSelect; @@ -56,12 +54,9 @@ public class ModalWindowInitialLocation extends AbstractReindeerTestUI { w.setContent(layout); Button b = new Button("Open window"); - b.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - w.setModal(true); - getUI().addWindow(w); - } + b.addClickListener(event -> { + w.setModal(true); + getUI().addWindow(w); }); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/OpenModalWindowAndFocusField.java b/uitest/src/main/java/com/vaadin/tests/components/window/OpenModalWindowAndFocusField.java index 3fa8075be9..7bb515e12f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/OpenModalWindowAndFocusField.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/OpenModalWindowAndFocusField.java @@ -18,7 +18,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Window; import com.vaadin.v7.ui.TextArea; @@ -28,25 +27,13 @@ public class OpenModalWindowAndFocusField extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { Button button = new Button("Open modal and focus textarea"); button.setId("openFocus"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - open(true); - } - }); + button.addClickListener(event -> open(true)); addComponent(button); button = new Button("Only open modal"); button.setId("open"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - open(false); - } - - }); + button.addClickListener(event -> open(false)); addComponent(button); - } private void open(boolean focus) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/PageOpenTest.java b/uitest/src/main/java/com/vaadin/tests/components/window/PageOpenTest.java index 3f0a2afe99..33e16c46cc 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/PageOpenTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/PageOpenTest.java @@ -5,7 +5,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.TestForWindowOpen; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.JavaScript; public class PageOpenTest extends AbstractReindeerTestUI { @@ -19,55 +18,23 @@ public class PageOpenTest extends AbstractReindeerTestUI { addComponent(new TestForWindowOpen()); addComponent(new Button("Page.open _blank always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - page.open(url, "_blank", true); - } - })); + event -> page.open(url, "_blank", true))); addComponent(new Button("Page.open _blank NOT always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - page.open(url, "_blank", false); - } - })); - + event -> page.open(url, "_blank", false))); addComponent(new Button("Page.open _new always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - page.open(url, "_new", true); - } - })); + event -> page.open(url, "_new", true))); addComponent(new Button("Page.open _new NOT always as popup", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - page.open(url, "_new", false); - } - })); + event -> page.open(url, "_new", false))); addComponent(new Button( "Execute Javascript window.open(www.google.com, _blank)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - JavaScript.getCurrent().execute( - "window.open(\"http://www.google.com\", \"_blank\");"); - } - })); + event -> JavaScript.getCurrent().execute( + "window.open(\"http://www.google.com\", \"_blank\");"))); addComponent(new Button( "Execute Javascript window.open(www.google.com, _blank, resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - JavaScript.getCurrent().execute( - "window.open(\"http://www.google.com\", \"_blank\", \"resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes\");"); - } - })); - + event -> JavaScript.getCurrent().execute( + "window.open(\"http://www.google.com\", \"_blank\", \"resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes\");"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/RepaintWindowContents.java b/uitest/src/main/java/com/vaadin/tests/components/window/RepaintWindowContents.java index 1a2ac3e831..774ac3c878 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/RepaintWindowContents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/RepaintWindowContents.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -28,21 +26,9 @@ public class RepaintWindowContents extends AbstractReindeerTestUI { window.setContent(layout1); - button1.addClickListener(new ClickListener() { + button1.addClickListener(event -> window.setContent(layout2)); - @Override - public void buttonClick(ClickEvent event) { - window.setContent(layout2); - } - }); - - button2.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - window.setContent(layout1); - } - }); + button2.addClickListener(event -> window.setContent(layout1)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocus.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocus.java index 54d8942b4b..62e9baee7b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocus.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocus.java @@ -4,7 +4,6 @@ import com.vaadin.event.Action; import com.vaadin.event.ShortcutAction; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -41,49 +40,41 @@ public class SubWindowFocus extends TestBase { tf.setInputPrompt("Tab index 0"); addComponent(tf); - Button b = new Button("new", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - final Window win = new Window("Subwin", layout); - layout.setWidth(null); - win.center(); - win.setClosable(false); - getMainWindow().addWindow(win); - layout.addComponent(new Label("SPACE notifies, ESC closes.")); - - win.addActionHandler(new Action.Handler() { - - ShortcutAction esc = new ShortcutAction("Close", - ShortcutAction.KeyCode.ESCAPE, null); - ShortcutAction spc = new ShortcutAction("Space", - ShortcutAction.KeyCode.SPACEBAR, null); - - @Override - public Action[] getActions(Object target, Object sender) { - return new Action[] { esc, spc }; + Button b = new Button("new", event -> { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + final Window win = new Window("Subwin", layout); + layout.setWidth(null); + win.center(); + win.setClosable(false); + getMainWindow().addWindow(win); + layout.addComponent(new Label("SPACE notifies, ESC closes.")); + + win.addActionHandler(new Action.Handler() { + + ShortcutAction esc = new ShortcutAction("Close", + ShortcutAction.KeyCode.ESCAPE, null); + ShortcutAction spc = new ShortcutAction("Space", + ShortcutAction.KeyCode.SPACEBAR, null); + + @Override + public Action[] getActions(Object target, Object sender) { + return new Action[] { esc, spc }; + } + + @Override + public void handleAction(Action action, Object sender, + Object target) { + if (action == esc) { + getMainWindow().removeWindow(win); + } else { + getMainWindow().showNotification(action.getCaption()); } + } + }); - @Override - public void handleAction(Action action, Object sender, - Object target) { - if (action == esc) { - getMainWindow().removeWindow(win); - } else { - getMainWindow() - .showNotification(action.getCaption()); - } - - } - - }); - - layout.addComponent(new TextField()); - } - + layout.addComponent(new TextField()); }); addComponent(b); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java index 9510348c31..479d3a5346 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java @@ -2,14 +2,9 @@ package com.vaadin.tests.components.window; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.ShortcutAction; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Notification; import com.vaadin.ui.UI; @@ -39,19 +34,9 @@ public class SubWindowFocusAndBlurListeners extends TestBase { layout.setSizeUndefined(); layout.addComponent(new TextField()); - window.addFocusListener(new FocusListener() { - @Override - public void focus(FocusEvent event) { - Notification.show("Focused window"); - } - }); + window.addFocusListener(event -> Notification.show("Focused window")); - window.addBlurListener(new BlurListener() { - @Override - public void blur(BlurEvent event) { - Notification.show("Blurred window"); - } - }); + window.addBlurListener(event -> Notification.show("Blurred window")); window.addActionHandler(new Handler() { @@ -76,12 +61,7 @@ public class SubWindowFocusAndBlurListeners extends TestBase { ((ComponentContainer) main.getContent()).addComponent(new TextField()); Button button = new Button("Bring to front (should focus too)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - window.bringToFront(); - } - }); + event -> window.bringToFront()); ((ComponentContainer) main.getContent()).addComponent(button); Window window2 = new Window("Another window for testing"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java index 8ef94a2465..6ec323353e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java @@ -59,12 +59,8 @@ public class SubWindowWithUndefinedHeight extends TestBase { }); layout.addComponent(tabsheet); - Button button = new Button("click me", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - getMainWindow().addWindow(subwindow); - } - }); + Button button = new Button("click me", + event -> getMainWindow().addWindow(subwindow)); getMainWindow().addComponent(button); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java index 62443f43cd..3a57951c84 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.HorizontalLayout; @@ -31,14 +29,9 @@ public class SubWindows extends TestBase { private Component createRemoveButton() { Button b = new Button("Remove"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Button b = event.getButton(); - ComponentContainer cc = (ComponentContainer) b.getParent(); - cc.removeComponent(b); - } + b.addClickListener(event -> { + ComponentContainer cc = (ComponentContainer) b.getParent(); + cc.removeComponent(b); }); return b; @@ -51,15 +44,8 @@ public class SubWindows extends TestBase { hl.setSizeUndefined(); hl.addComponent(new TextField("Field 1")); hl.addComponent(new TextField("Field 2")); - hl.addComponent(new Button("Add", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - hl.addComponent(createRemoveButton()); - - } - - })); + hl.addComponent(new Button("Add", + event -> hl.addComponent(createRemoveButton()))); getMainWindow().addWindow(autoWideWindow); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubwindowDraggability.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubwindowDraggability.java index 45fb343b45..2ef5a38893 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/SubwindowDraggability.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubwindowDraggability.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Window; public class SubwindowDraggability extends TestBase { @@ -19,19 +18,13 @@ public class SubwindowDraggability extends TestBase { getMainWindow().addWindow(draggableSubWindow); getMainWindow().addWindow(fixedSubWindow); - Button b = new Button("Swap", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - boolean b = draggableSubWindow.isDraggable(); - - draggableSubWindow.setDraggable(!b); - fixedSubWindow.setDraggable(b); - - } + Button button = new Button("Swap", event -> { + boolean draggable = draggableSubWindow.isDraggable(); + draggableSubWindow.setDraggable(!draggable); + fixedSubWindow.setDraggable(draggable); }); - addComponent(b); + addComponent(button); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCaption.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCaption.java index e7f39874b1..b71ce3edf1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCaption.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCaption.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Window; @@ -45,31 +43,13 @@ public class WindowCaption extends AbstractReindeerTestUI { addWindow(htmlWindow); addWindow(textWindow); - Button red = new Button("Red", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setWindowCaption( - "<font style='color: red;'>This may or may not be red</font>"); - } - }); - Button plainText = new Button("Plain text", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setWindowCaption("This is just text"); - } - }); - Button nullCaption = new Button("Null", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setWindowCaption(null); - } - }); - Button empty = new Button("Empty", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setWindowCaption(""); - } - }); + Button red = new Button("Red", event -> setWindowCaption( + "<font style='color: red;'>This may or may not be red</font>")); + Button plainText = new Button("Plain text", + event -> setWindowCaption("This is just text")); + Button nullCaption = new Button("Null", + event -> setWindowCaption(null)); + Button empty = new Button("Empty", event -> setWindowCaption("")); addComponents(red, plainText, nullCaption, empty); red.click(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java index 65a6256b89..a0a6c513ed 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java @@ -1,9 +1,6 @@ package com.vaadin.tests.components.window; -import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.MouseEvents.ClickEvent; -import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; @@ -28,31 +25,16 @@ public class WindowClickEvents extends TestBase { @Override protected void setup() { VerticalLayout layout = new VerticalLayout(); - layout.addLayoutClickListener(new LayoutClickListener() { - @Override - public void layoutClick(LayoutClickEvent event) { - WindowClickEvents.this.click("Sub window layout", event); - } - }); + layout.addLayoutClickListener(event -> WindowClickEvents.this + .click("Sub window layout", event)); ((VerticalLayout) getMainWindow().getContent()) - .addLayoutClickListener(new LayoutClickListener() { - @Override - public void layoutClick(LayoutClickEvent event) { - WindowClickEvents.this.click("Main window layout", - event); - } - }); + .addLayoutClickListener(event -> WindowClickEvents.this + .click("Main window layout", event)); layout.setMargin(true); Window centered = new Window("A window with a click listener", layout); - centered.addClickListener(new ClickListener() { - - @Override - public void click(ClickEvent event) { - WindowClickEvents.this.click("Sub window", event); - } - - }); + centered.addClickListener( + event -> WindowClickEvents.this.click("Sub window", event)); centered.setSizeUndefined(); layout.setSizeUndefined(); centered.center(); @@ -61,33 +43,19 @@ public class WindowClickEvents extends TestBase { l.setSizeUndefined(); Button b = new Button( "Clicking here should not produce a layout click event"); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { - log.log("Click on button"); - } - - }); + b.addClickListener(event -> log.log("Click on button")); layout.addComponent(l); layout.addComponent(b); getMainWindow().addWindow(centered); log = new Log(5); addComponent(log); - getMainWindow().addClickListener(new ClickListener() { - - @Override - public void click(ClickEvent event) { - WindowClickEvents.this.click("Main window", event); - } - }); - + getMainWindow().addClickListener( + event -> WindowClickEvents.this.click("Main window", event)); } private void click(String target, ClickEvent event) { log.log("Click using " + event.getButtonName() + " on " + target); // + " at " + event.getClientX() + "," + event.getClientY()); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java index 43307223ad..876f209dab 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowCloseShortcuts.java @@ -32,8 +32,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.RichTextArea; @@ -64,54 +62,35 @@ public class WindowCloseShortcuts extends AbstractTestUI { buttonLayout.setSizeFull(); buttonPanel.setCaption("Demo controls"); - addButton(new Button("Open window", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - UI.getCurrent().addWindow(window); - window.center(); - updateDesign(); - } + addButton(new Button("Open window", event -> { + UI.getCurrent().addWindow(window); + window.center(); + updateDesign(); })); - addButton(new Button("Add ENTER close shortcut", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - window.addCloseShortcut(KeyCode.ENTER); - updateDesign(); - } + addButton(new Button("Add ENTER close shortcut", event -> { + window.addCloseShortcut(KeyCode.ENTER); + updateDesign(); })); - addButton(new Button("Add TAB close shortcut", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - window.addCloseShortcut(KeyCode.TAB); - updateDesign(); - } + addButton(new Button("Add TAB close shortcut", event -> { + window.addCloseShortcut(KeyCode.TAB); + updateDesign(); })); - addButton(new Button("Remove ESC close shortcut", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - window.removeCloseShortcut(KeyCode.ESCAPE); - updateDesign(); - } + addButton(new Button("Remove ESC close shortcut", event -> { + window.removeCloseShortcut(KeyCode.ESCAPE); + updateDesign(); })); - addButton(new Button("Clear all close shortcuts", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - window.removeAllCloseShortcuts(); - updateDesign(); - } + addButton(new Button("Clear all close shortcuts", event -> { + window.removeAllCloseShortcuts(); + updateDesign(); })); - addButton(new Button("Reset to default state", new ClickListener() { - @Override - @SuppressWarnings("deprecation") - public void buttonClick(ClickEvent event) { - window.removeCloseShortcut(); - updateDesign(); - } + addButton(new Button("Reset to default state", event -> { + window.removeCloseShortcut(); + updateDesign(); })); buttonPanel.setContent(buttonLayout); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java index d18357c782..ed2ec06b5f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java @@ -14,8 +14,6 @@ import com.vaadin.ui.NativeButton; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.WindowModeChangeEvent; -import com.vaadin.ui.Window.WindowModeChangeListener; public class WindowMaximizeRestoreTest extends AbstractReindeerTestUI { @Override @@ -68,18 +66,14 @@ public class WindowMaximizeRestoreTest extends AbstractReindeerTestUI { }); ((ComponentContainer) w.getContent()).addComponent(maximize); - w.addWindowModeChangeListener(new WindowModeChangeListener() { - - @Override - public void windowModeChanged(WindowModeChangeEvent event) { - WindowMode state = (event.getWindow().getWindowMode()); - if (state == WindowMode.NORMAL) { - w.setCaption("Window " + w.getData() + " Normal"); - maximize.setCaption("Maximize"); - } else if (state == WindowMode.MAXIMIZED) { - w.setCaption("Window " + w.getData() + " Maximized"); - maximize.setCaption("Restore"); - } + w.addWindowModeChangeListener(event -> { + WindowMode state = (event.getWindow().getWindowMode()); + if (state == WindowMode.NORMAL) { + w.setCaption("Window " + w.getData() + " Normal"); + maximize.setCaption("Maximize"); + } else if (state == WindowMode.MAXIMIZED) { + w.setCaption("Window " + w.getData() + " Maximized"); + maximize.setCaption("Restore"); } }); final CheckBox resizeable = new CheckBox("Resizeable"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowMoveListener.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowMoveListener.java index b566f95f12..657c970c51 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowMoveListener.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowMoveListener.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Window; @SuppressWarnings("serial") @@ -30,17 +28,12 @@ public class WindowMoveListener extends AbstractReindeerTestUI { Button b = new Button(); b.setId("testbutton"); addComponent(b); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - for (Window window : getWindows()) { - window.setPositionX(100); - window.setPositionY(100); - } + b.addClickListener(event -> { + for (Window window : getWindows()) { + window.setPositionX(100); + window.setPositionY(100); } }); - } /* diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowOrder.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowOrder.java index 9b20686fe1..66b87c6b59 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowOrder.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowOrder.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Window; import com.vaadin.ui.Window.WindowOrderChangeEvent; @@ -68,49 +66,30 @@ public class WindowOrder extends AbstractTestUI { addComponent(infoLabel); addComponent(uiLabel); - Button first = new Button("Bring first to front", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - w1.bringToFront(); - } - }); + Button first = new Button("Bring first to front", + event -> w1.bringToFront()); first.addStyleName("bring-to-front-first"); addComponent(first); getLayout().setComponentAlignment(first, Alignment.MIDDLE_RIGHT); Button all = new Button("Bring to front all windows", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - w3.bringToFront(); - w1.bringToFront(); - w2.bringToFront(); - } + event -> { + w3.bringToFront(); + w1.bringToFront(); + w2.bringToFront(); }); all.addStyleName("bring-to-front-all"); addComponent(all); getLayout().setComponentAlignment(all, Alignment.MIDDLE_RIGHT); - Button detach = new Button("Detach last window", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getUI().removeWindow(w3); - } - }); + Button detach = new Button("Detach last window", + event -> getUI().removeWindow(w3)); detach.addStyleName("detach-window"); addComponent(detach); getLayout().setComponentAlignment(detach, Alignment.MIDDLE_RIGHT); - Button add = new Button("Add new window", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getUI().addWindow(w4); - } - }); + Button add = new Button("Add new window", + event -> getUI().addWindow(w4)); add.addStyleName("add-window"); addComponent(add); getLayout().setComponentAlignment(add, Alignment.MIDDLE_RIGHT); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java index eed034dd11..4005725841 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -61,21 +59,11 @@ public class WindowScrollingComponentIntoView extends AbstractTestCase { window.setPositionY(200); layout.addComponent( - new Button("Scroll mainwin to X9", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().scrollIntoView(x9); - - } - })); + new Button("Scroll mainwin to X9", + event -> getMainWindow().scrollIntoView(x9))); layout.addComponent( - new Button("Scroll mainwin to Y9", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().scrollIntoView(y9); - - } - })); + new Button("Scroll mainwin to Y9", + event -> getMainWindow().scrollIntoView(y9))); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setMargin(true); @@ -105,25 +93,18 @@ public class WindowScrollingComponentIntoView extends AbstractTestCase { final Component y29 = l; ((VerticalLayout) getMainWindow().getContent()).addComponent( - new Button("Scroll win to X9", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - throw new RuntimeException("Currently not implemented"); - // window.scrollIntoView(x29); - } + new Button("Scroll win to X9", event -> { + throw new RuntimeException("Currently not implemented"); + // window.scrollIntoView(x29); }), 0); ((VerticalLayout) getMainWindow().getContent()).addComponent( - new Button("Scroll win to Y9", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - throw new RuntimeException("Currently not implemented"); - // window.scrollIntoView(y29); - } + new Button("Scroll win to Y9", event -> { + throw new RuntimeException("Currently not implemented"); + // window.scrollIntoView(y29); }), 0); layout.addComponent(panel); getMainWindow().addWindow(window); - } private Component l(String string) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java index 2c3eb75244..28d5a456b1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java @@ -2,7 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.LegacyWindow; import com.vaadin.v7.ui.Table; @@ -24,13 +23,7 @@ public class WindowScrollingUp extends AbstractTestCase { table.setPageLength(50); final Button up = new Button("up"); - up.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - up.getUI().setScrollTop(0); - } - }); + up.addClickListener(event -> up.getUI().setScrollTop(0)); setMainWindow(new LegacyWindow("")); getMainWindow().addComponent(table); diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java index b784cc72e5..22cbe0d973 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java @@ -10,8 +10,6 @@ import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.v7.ui.TextField; @@ -37,30 +35,9 @@ public class WindowShouldRemoveActionHandler extends AbstractReindeerTestUI { state.setId("state"); addComponents(state, new TextField()); - addButton("Add an action handler", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - add(); - } - - }); - addButton("Add another action handler", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - addAnother(); - } - - }); - addButton("Remove an action handler", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - remove(); - } - - }); + addButton("Add an action handler", event -> add()); + addButton("Add another action handler", event -> addAnother()); + addButton("Remove an action handler", event -> remove()); } public void remove() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowStyleNames.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowStyleNames.java index 615f391613..aa433bd892 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowStyleNames.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowStyleNames.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; public class WindowStyleNames extends TestBase { @@ -20,33 +18,14 @@ public class WindowStyleNames extends TestBase { @Override protected void setup() { setWindowStyle("old"); - addComponent(new Button("Set style to 'new'", new ClickListener() { + addComponent(new Button("Set style to 'new'", + event -> setWindowStyle("new"))); - @Override - public void buttonClick(ClickEvent event) { - setWindowStyle("new"); - } - - })); - - addComponent(new Button("Set style to 'custom'", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - setWindowStyle("custom"); - } - - })); - - addComponent(new Button("Add 'foo' style", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().addStyleName("foo"); - } - - })); + addComponent(new Button("Set style to 'custom'", + event -> setWindowStyle("custom"))); + addComponent(new Button("Add 'foo' style", + event -> getMainWindow().addStyleName("foo"))); } protected void setWindowStyle(String string) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java index ec79a8e6c3..da0d09ee5d 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java @@ -3,21 +3,14 @@ package com.vaadin.tests.components.window; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; -import com.vaadin.ui.Window.CloseListener; public class WindowWithInvalidCloseListener extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { Window w = new Window("Close me"); - w.addCloseListener(new CloseListener() { - - @Override - public void windowClose(CloseEvent e) { - throw new RuntimeException( - "Close listener intentionally failed"); - } + w.addCloseListener(event-> { + throw new RuntimeException("Close listener intentionally failed"); }); addWindow(w); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowZIndex.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowZIndex.java index 7e94539c8a..360ad60acd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowZIndex.java +++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowZIndex.java @@ -7,8 +7,6 @@ import java.util.Queue; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Window; @@ -29,26 +27,20 @@ public class WindowZIndex extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addComponent(new Button("Add window", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Window window = new Window(); - window.setPositionX(100 + 20 * windowCount); - window.setPositionY(100 + 20 * windowCount); - window.setHeight(200, Unit.PIXELS); - window.setWidth(200, Unit.PIXELS); - window.setContent(new Label("Window " + ++windowCount)); - addWindow(window); - windows.add(window); - } + addComponent(new Button("Add window", event -> { + Window window = new Window(); + window.setPositionX(100 + 20 * windowCount); + window.setPositionY(100 + 20 * windowCount); + window.setHeight(200, Unit.PIXELS); + window.setWidth(200, Unit.PIXELS); + window.setContent(new Label("Window " + ++windowCount)); + addWindow(window); + windows.add(window); })); - addComponent(new Button("Close window", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - windows.remove().close(); - } catch (NoSuchElementException e) { - } + addComponent(new Button("Close window", event -> { + try { + windows.remove().close(); + } catch (NoSuchElementException e) { } })); } diff --git a/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java b/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java index 9141665a94..2b908859a6 100644 --- a/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java +++ b/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java @@ -3,7 +3,6 @@ package com.vaadin.tests.containers; import com.vaadin.server.Sizeable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -101,38 +100,31 @@ public class BeanItemContainerFilteringTest extends TestBase { // addItemAt(idx), addItemAfter(selection), addItem() final Button addItemButton = new Button("addItem()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - container.addItem( - new TestBean("addItem() " + nextToAdd, - "value " + nextToAdd)); - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); - } + event -> { + container.addItem(new TestBean("addItem() " + nextToAdd, + "value " + nextToAdd)); + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemButton); final Button addItemAfterButton = new Button("addItemAfter()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object selection = table.getValue(); - if (selection == null) { - return; - } - TestBean bean = new TestBean( - "addItemAfter() " + nextToAdd, - "value " + nextToAdd); - Item item = container.addItemAfter(selection, bean); - if (item == null) { - getMainWindow() - .showNotification("Adding item after " - + selection + " failed"); - } - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); + event -> { + Object selection = table.getValue(); + if (selection == null) { + return; + } + TestBean bean = new TestBean( + "addItemAfter() " + nextToAdd, + "value " + nextToAdd); + Item item = container.addItemAfter(selection, bean); + if (item == null) { + getMainWindow() + .showNotification("Adding item after " + + selection + " failed"); } + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemAfterButton); @@ -140,23 +132,18 @@ public class BeanItemContainerFilteringTest extends TestBase { vl.addComponent(position); final Button addItemAtButton = new Button("addItemAt()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - int index = Integer.parseInt(position.getValue()); - TestBean bean = new TestBean( - "addItemAt() " + nextToAdd, - "value " + nextToAdd); - Item item = container.addItemAt(index, bean); - if (item == null) { - getMainWindow().showNotification( - "Adding item at index " - + position.getValue() - + " failed"); - } - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); + event -> { + int index = Integer.parseInt(position.getValue()); + TestBean bean = new TestBean("addItemAt() " + nextToAdd, + "value " + nextToAdd); + Item item = container.addItemAt(index, bean); + if (item == null) { + getMainWindow() + .showNotification("Adding item at index " + + position.getValue() + " failed"); } + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemAtButton); diff --git a/uitest/src/main/java/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java b/uitest/src/main/java/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java index 4eff474113..f573985ad9 100644 --- a/uitest/src/main/java/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java +++ b/uitest/src/main/java/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java @@ -2,8 +2,6 @@ package com.vaadin.tests.containers; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Layout; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Item; @@ -91,23 +89,17 @@ public class HierarchicalWrapperOrdering extends TestBase { // This contains a bug, changes not reflected back to client Button modify = new Button("Modify and sort (has a bug)", - new ClickListener() { - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - // Get first item - Object itemId = indexedContainer.getIdByIndex(0); - Item item = indexedContainer.getItem(itemId); - Property<String> property = item - .getItemProperty("name"); - // Prepend with Z so item should get sorted later - property.setValue("Z " + property.getValue()); - // this does not work alone, requires extraneous - // setContainerDataSource for server-side changes to be - // reflected back to client-side - sort(indexedContainer); - } + event -> { + // Get first item + Object itemId = indexedContainer.getIdByIndex(0); + Item item = indexedContainer.getItem(itemId); + Property<String> property = item.getItemProperty("name"); + // Prepend with Z so item should get sorted later + property.setValue("Z " + property.getValue()); + // this does not work alone, requires extraneous + // setContainerDataSource for server-side changes to be + // reflected back to client-side + sort(indexedContainer); }); l.addComponent(modify); diff --git a/uitest/src/main/java/com/vaadin/tests/containers/IndexedContainerFilteringTest.java b/uitest/src/main/java/com/vaadin/tests/containers/IndexedContainerFilteringTest.java index d020d53ad8..d2daffdabe 100644 --- a/uitest/src/main/java/com/vaadin/tests/containers/IndexedContainerFilteringTest.java +++ b/uitest/src/main/java/com/vaadin/tests/containers/IndexedContainerFilteringTest.java @@ -3,7 +3,6 @@ package com.vaadin.tests.containers; import com.vaadin.server.Sizeable; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -68,41 +67,34 @@ public class IndexedContainerFilteringTest extends TestBase { // addItemAt(idx), addItemAfter(selection), addItem() final Button addItemButton = new Button("addItem()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Item item = container.addItem("addItem() " + nextToAdd); - if (item != null) { - item.getItemProperty("column1") - .setValue("addItem() " + nextToAdd); - } - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); + event -> { + Item item = container.addItem("addItem() " + nextToAdd); + if (item != null) { + item.getItemProperty("column1") + .setValue("addItem() " + nextToAdd); } + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemButton); final Button addItemAfterButton = new Button("addItemAfter()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Object selection = table.getValue(); - if (selection == null) { - return; - } - String id = "addItemAfter() " + nextToAdd; - Item item = container.addItemAfter(selection, id); - if (item != null) { - item.getItemProperty("column1").setValue(id); - table.setValue(id); - } else { - getMainWindow() - .showNotification("Adding item after " - + selection + " failed"); - } - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); + event -> { + Object selection = table.getValue(); + if (selection == null) { + return; } + String id = "addItemAfter() " + nextToAdd; + Item item = container.addItemAfter(selection, id); + if (item != null) { + item.getItemProperty("column1").setValue(id); + table.setValue(id); + } else { + getMainWindow().showNotification( + "Adding item after " + selection + " failed"); + } + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemAfterButton); @@ -110,23 +102,19 @@ public class IndexedContainerFilteringTest extends TestBase { vl.addComponent(position); final Button addItemAtButton = new Button("addItemAt()", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - int index = Integer.parseInt(position.getValue()); - String id = "addItemAt() " + nextToAdd; - Item item = container.addItemAt(index, id); - if (item != null) { - item.getItemProperty("column1").setValue(id); - table.setValue(id); - } else { - getMainWindow() - .showNotification("Adding item at index " - + position.getValue() + " failed"); - } - nextToAdd++; - nextLabel.setCaption("Next id: " + nextToAdd); + event -> { + int index = Integer.parseInt(position.getValue()); + String id = "addItemAt() " + nextToAdd; + Item item = container.addItemAt(index, id); + if (item != null) { + item.getItemProperty("column1").setValue(id); + table.setValue(id); + } else { + getMainWindow().showNotification("Adding item at index " + + position.getValue() + " failed"); } + nextToAdd++; + nextLabel.setCaption("Next id: " + nextToAdd); }); vl.addComponent(addItemAtButton); diff --git a/uitest/src/main/java/com/vaadin/tests/containers/TestItemSorter.java b/uitest/src/main/java/com/vaadin/tests/containers/TestItemSorter.java index 0c6da38a1e..7f0191e8a5 100644 --- a/uitest/src/main/java/com/vaadin/tests/containers/TestItemSorter.java +++ b/uitest/src/main/java/com/vaadin/tests/containers/TestItemSorter.java @@ -1,7 +1,6 @@ package com.vaadin.tests.containers; import java.util.Collection; -import java.util.Comparator; import java.util.Locale; import com.vaadin.tests.components.TestBase; @@ -26,28 +25,24 @@ public class TestItemSorter extends TestBase { table = new Table("DefaultItemSorter with custom comparator"); container = createContainer(); populateContainer(container); - container.setItemSorter(new DefaultItemSorter(new Comparator<Object>() { - - @Override - public int compare(Object o1, Object o2) { - if (o1 instanceof CheckBox && o2 instanceof CheckBox) { - Boolean b1 = ((CheckBox) o1).getValue(); - return b1.compareTo(((CheckBox) o2).getValue()); - } else if (o1 instanceof Button && o2 instanceof Button) { - String caption1 = ((Button) o1).getCaption() - .toLowerCase(Locale.ROOT); - String caption2 = ((Button) o2).getCaption() - .toLowerCase(Locale.ROOT); - return caption1.compareTo(caption2); - - } else if (o1 instanceof String && o2 instanceof String) { - return ((String) o1).toLowerCase(Locale.ROOT) - .compareTo(((String) o2).toLowerCase(Locale.ROOT)); - } - - return 0; - + container.setItemSorter(new DefaultItemSorter((o1, o2) -> { + if (o1 instanceof CheckBox && o2 instanceof CheckBox) { + Boolean b1 = ((CheckBox) o1).getValue(); + return b1.compareTo(((CheckBox) o2).getValue()); + } + if (o1 instanceof Button && o2 instanceof Button) { + String caption1 = ((Button) o1).getCaption() + .toLowerCase(Locale.ROOT); + String caption2 = ((Button) o2).getCaption() + .toLowerCase(Locale.ROOT); + return caption1.compareTo(caption2); } + if (o1 instanceof String && o2 instanceof String) { + return ((String) o1).toLowerCase(Locale.ROOT) + .compareTo(((String) o2).toLowerCase(Locale.ROOT)); + } + + return 0; })); table.setContainerDataSource(container); diff --git a/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java b/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java index 618543aab9..131dc4db93 100644 --- a/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java +++ b/uitest/src/main/java/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java @@ -8,16 +8,11 @@ import java.util.List; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Container.Ordered; import com.vaadin.v7.data.util.FilesystemContainer; import com.vaadin.v7.ui.Table; -import com.vaadin.v7.ui.Tree.CollapseEvent; -import com.vaadin.v7.ui.Tree.CollapseListener; -import com.vaadin.v7.ui.Tree.ExpandEvent; -import com.vaadin.v7.ui.Tree.ExpandListener; import com.vaadin.v7.ui.TreeTable; public class FileSystemContainerInTreeTable extends TestBase { @@ -50,22 +45,10 @@ public class FileSystemContainerInTreeTable extends TestBase { treeTable.setItemIconPropertyId(FilesystemContainer.PROPERTY_ICON); treeTable.setVisibleColumns("Name"); treeTable.setColumnWidth("Name", 400); - treeTable.addListener(new ExpandListener() { - - @Override - public void nodeExpand(ExpandEvent event) { - logExpandCollapse(event.getItemId(), "expanded"); - - } - }); - treeTable.addListener(new CollapseListener() { - - @Override - public void nodeCollapse(CollapseEvent event) { - logExpandCollapse(event.getItemId(), "collapsed"); - - } - }); + treeTable.addExpandListener( + event -> logExpandCollapse(event.getItemId(), "expanded")); + treeTable.addCollapseListener( + event -> logExpandCollapse(event.getItemId(), "collapsed")); addComponent(log); addComponent(treeTable); @@ -73,29 +56,18 @@ public class FileSystemContainerInTreeTable extends TestBase { HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent( - new Button("Create dir11", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - new File(folder, "dir11").mkdir(); - log.log("Row dir11 created"); - } + new Button("Create dir11", event -> { + new File(folder, "dir11").mkdir(); + log.log("Row dir11 created"); })); buttonLayout.addComponent( - new Button("Delete dir11", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - new File(folder, "dir11").delete(); - log.log("Row dir11 deleted"); - } + new Button("Delete dir11", event -> { + new File(folder, "dir11").delete(); + log.log("Row dir11 deleted"); })); // to clean up explicitly before ending an automated test buttonLayout.addComponent( - new Button("Clean all files", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - folder.delete(); - } - })); + new Button("Clean all files", event -> folder.delete())); addComponent(buttonLayout); } catch (IOException e) { e.printStackTrace(); diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/AbstractContextClickUI.java b/uitest/src/main/java/com/vaadin/tests/contextclick/AbstractContextClickUI.java index 9dd2e47df5..5558f2700b 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/AbstractContextClickUI.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/AbstractContextClickUI.java @@ -50,25 +50,16 @@ public abstract class AbstractContextClickUI<T extends AbstractComponent, E exte } protected T testComponent; - private ContextClickListener defaultListener = new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - log("ContextClickEvent: (" + event.getClientX() + ", " + private ContextClickListener defaultListener = event -> log( + "ContextClickEvent: (" + event.getClientX() + ", " + event.getClientY() + ")"); - } - }; - private ContextClickListener typedListener = new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - try { - E typedEvent = (E) event; - handleContextClickEvent(typedEvent); - } catch (Exception e) { - log("UNEXPECTED EVENT TYPE!"); - } + private ContextClickListener typedListener = event -> { + try { + E typedEvent = (E) event; + handleContextClickEvent(typedEvent); + } catch (Exception e) { + log("UNEXPECTED EVENT TYPE!"); } }; diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java b/uitest/src/main/java/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java index 99540c3f77..cbd92ae792 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java @@ -16,15 +16,12 @@ package com.vaadin.tests.contextclick; import com.vaadin.annotations.Widgetset; -import com.vaadin.event.ContextClickEvent; -import com.vaadin.event.ContextClickEvent.ContextClickListener; import com.vaadin.server.AbstractExtension; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; @@ -42,26 +39,15 @@ public class BrowserContextMenuInSubComponent extends AbstractReindeerTestUI { // Make TextArea show regular context menu instead of firing the // server-side event. BrowserContextMenuExtension.extend(textArea); - final Button button = new Button("Submit", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification.show(textArea.getValue()); - } - }); + final Button button = new Button("Submit", + event -> Notification.show(textArea.getValue())); layout.addComponent(textArea); layout.addComponent(button); panel.setContent(layout); - panel.addContextClickListener(new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - button.click(); - } - }); + panel.addContextClickListener(event -> button.click()); addComponent(panel); } diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/GridContextClick.java b/uitest/src/main/java/com/vaadin/tests/contextclick/GridContextClick.java index c2ae8c7657..e2b98ecdb5 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/GridContextClick.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/GridContextClick.java @@ -21,7 +21,6 @@ import com.vaadin.shared.ui.grid.GridConstants.Section; import com.vaadin.tests.util.Person; import com.vaadin.tests.util.PersonContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.GridContextClickEvent; import com.vaadin.ui.HorizontalLayout; @@ -90,13 +89,8 @@ public class GridContextClick extends protected HorizontalLayout createContextClickControls() { HorizontalLayout controls = super.createContextClickControls(); controls.addComponent( - new Button("Remove all content", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.setItems(Collections.emptyList()); - } - })); + new Button("Remove all content", event -> testComponent + .setItems(Collections.emptyList()))); return controls; } } diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/TableContextClick.java b/uitest/src/main/java/com/vaadin/tests/contextclick/TableContextClick.java index 3a73b41074..533d569796 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/TableContextClick.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/TableContextClick.java @@ -17,7 +17,6 @@ package com.vaadin.tests.contextclick; import com.vaadin.tests.util.PersonContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.shared.ui.table.TableConstants.Section; @@ -58,13 +57,8 @@ public class TableContextClick protected HorizontalLayout createContextClickControls() { HorizontalLayout controls = super.createContextClickControls(); controls.addComponent( - new Button("Remove all content", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.getContainerDataSource().removeAllItems(); - } - })); + new Button("Remove all content", event -> testComponent + .getContainerDataSource().removeAllItems())); return controls; } } diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/TreeTableContextClick.java b/uitest/src/main/java/com/vaadin/tests/contextclick/TreeTableContextClick.java index 1ab7a9567a..e62d33ef35 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/TreeTableContextClick.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/TreeTableContextClick.java @@ -17,7 +17,6 @@ package com.vaadin.tests.contextclick; import com.vaadin.tests.util.PersonContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.shared.ui.table.TableConstants.Section; @@ -59,13 +58,8 @@ public class TreeTableContextClick protected HorizontalLayout createContextClickControls() { HorizontalLayout controls = super.createContextClickControls(); controls.addComponent( - new Button("Remove all content", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.getContainerDataSource().removeAllItems(); - } - })); + new Button("Remove all content", event -> testComponent + .getContainerDataSource().removeAllItems())); return controls; } } diff --git a/uitest/src/main/java/com/vaadin/tests/contextclick/TreeV8ContextClick.java b/uitest/src/main/java/com/vaadin/tests/contextclick/TreeV8ContextClick.java index 4af1fdf8b0..fa0713fac9 100644 --- a/uitest/src/main/java/com/vaadin/tests/contextclick/TreeV8ContextClick.java +++ b/uitest/src/main/java/com/vaadin/tests/contextclick/TreeV8ContextClick.java @@ -15,15 +15,14 @@ */ package com.vaadin.tests.contextclick; +import java.util.Collections; + import com.vaadin.data.TreeData; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.TreeContextClickEvent; -import java.util.Collections; - public class TreeV8ContextClick extends AbstractContextClickUI<Tree<String>, TreeContextClickEvent<String>> { @@ -57,13 +56,9 @@ public class TreeV8ContextClick extends protected HorizontalLayout createContextClickControls() { HorizontalLayout controls = super.createContextClickControls(); controls.addComponent( - new Button("Remove all content", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.setItems(Collections.emptyList()); - testComponent.setHeight("200px"); - } + new Button("Remove all content", event -> { + testComponent.setItems(Collections.emptyList()); + testComponent.setHeight("200px"); })); return controls; } diff --git a/uitest/src/main/java/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.java b/uitest/src/main/java/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.java index 890db5dcee..9bb88ddb54 100644 --- a/uitest/src/main/java/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.java +++ b/uitest/src/main/java/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.java @@ -4,8 +4,6 @@ import java.util.Locale; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.TextField; public class ConverterThatEnforcesAFormat extends AbstractTestUIWithLog { @@ -18,18 +16,15 @@ public class ConverterThatEnforcesAFormat extends AbstractTestUIWithLog { // this is needed so that IE tests pass tf.setNullRepresentation(""); tf.setConverter(new StringToDoubleConverterWithThreeFractionDigits()); - tf.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - log("Value changed to " + event.getProperty().getValue() - + "(converted value is " + tf.getConvertedValue() - + "). Two-way conversion gives: " - + tf.getConverter().convertToPresentation( - tf.getConverter().convertToModel(tf.getValue(), - Double.class, tf.getLocale()), - String.class, tf.getLocale()) - + ")"); - } + tf.addValueChangeListener(event -> { + log("Value changed to " + event.getProperty().getValue() + + "(converted value is " + tf.getConvertedValue() + + "). Two-way conversion gives: " + + tf.getConverter().convertToPresentation( + tf.getConverter().convertToModel(tf.getValue(), + Double.class, tf.getLocale()), + String.class, tf.getLocale()) + + ")"); }); tf.setImmediate(true); addComponent(tf); diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DDInterrupt.java b/uitest/src/main/java/com/vaadin/tests/dd/DDInterrupt.java index a16a627763..22ac4172d0 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/DDInterrupt.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/DDInterrupt.java @@ -9,8 +9,6 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CssLayout; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper.DragStartMode; @@ -32,13 +30,7 @@ public class DDInterrupt extends AbstractReindeerTestUI { layout.setWidth("500px"); layout.setHeight("500px"); - addButton("Click to interrupt next drag.", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - sp.interruptNext(); - } - }); + addButton("Click to interrupt next drag.", event -> sp.interruptNext()); final Label draggableLabel = new Label("Drag me"); draggableLabel.setId("draggable"); diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java b/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java index 86451975ca..76f547ed1d 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java @@ -148,17 +148,14 @@ public class DDTest6 extends TestBase { }; tree1.addActionHandler(actionHandler); - tree1.addListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Object value = event.getProperty().getValue(); - if (value != null && !(value instanceof Folder)) { - value = tree1.getParent(value); - } - FolderView folderView = FolderView.get((Folder) value); - sp.setSecondComponent(folderView); - folderView.reload(); + tree1.addValueChangeListener(event->{ + Object value = event.getProperty().getValue(); + if (value != null && !(value instanceof Folder)) { + value = tree1.getParent(value); } + FolderView folderView = FolderView.get((Folder) value); + sp.setSecondComponent(folderView); + folderView.reload(); }); l.addComponent(tree1); diff --git a/uitest/src/main/java/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/uitest/src/main/java/com/vaadin/tests/dd/NotPaintedAcceptSource.java index 35744ea7e0..f188bc3f4f 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/NotPaintedAcceptSource.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/NotPaintedAcceptSource.java @@ -6,7 +6,6 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.SourceIs; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.ui.AbstractSelect.AbstractSelectTargetDetails; @@ -56,18 +55,14 @@ public class NotPaintedAcceptSource extends TestBase { addComponent(horizontalLayout); - addComponent(new Button("Swap sources", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (source1.getParent() != null) { - horizontalLayout.replaceComponent(source1, source2); - } else { - horizontalLayout.replaceComponent(source2, source1); - } - target.markAsDirty(); + addComponent(new Button("Swap sources", event -> { + if (source1.getParent() != null) { + horizontalLayout.replaceComponent(source1, source2); + } else { + horizontalLayout.replaceComponent(source2, source1); } + target.markAsDirty(); })); - } private Table createTable(String caption) { diff --git a/uitest/src/main/java/com/vaadin/tests/dd/ScrolledDropTarget.java b/uitest/src/main/java/com/vaadin/tests/dd/ScrolledDropTarget.java index e5889c8975..54ebbe41fc 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/ScrolledDropTarget.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/ScrolledDropTarget.java @@ -7,7 +7,6 @@ import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.AbstractSelect.AbstractSelectTargetDetails; import com.vaadin.v7.ui.AbstractSelect.VerticalLocationIs; import com.vaadin.v7.ui.Table; @@ -45,15 +44,11 @@ public class ScrolledDropTarget extends TestBase { }); addComponent(table); - addComponent(new Button("Scroll body", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getMainWindow().executeJavaScript( + addComponent(new Button("Scroll body", + event -> getMainWindow().executeJavaScript( "document.body.style.overflow = 'auto';" + "document.body.style.height = '200%';" - + "window.scrollTo(0,18)"); - } - })); + + "window.scrollTo(0,18)"))); addComponent(log); } diff --git a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java index cab0e68f06..9b686ba02d 100644 --- a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java +++ b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java @@ -34,8 +34,6 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.v7.data.Property.ReadOnlyException; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.Property.ValueChangeNotifier; public class DeclarativeEditor extends UI { @@ -107,12 +105,7 @@ public class DeclarativeEditor extends UI { private void addValueChangeListeners(Component component) { if (component instanceof ValueChangeNotifier) { ((ValueChangeNotifier) component) - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - updateCode(); - } - }); + .addValueChangeListener(event -> updateCode()); } if (component instanceof HasComponents) { @@ -120,7 +113,6 @@ public class DeclarativeEditor extends UI { addValueChangeListeners(c); } } - } } diff --git a/uitest/src/main/java/com/vaadin/tests/declarative/PotusCrud.java b/uitest/src/main/java/com/vaadin/tests/declarative/PotusCrud.java index 92097c90be..a9411f7ad5 100644 --- a/uitest/src/main/java/com/vaadin/tests/declarative/PotusCrud.java +++ b/uitest/src/main/java/com/vaadin/tests/declarative/PotusCrud.java @@ -17,11 +17,8 @@ package com.vaadin.tests.declarative; import com.vaadin.annotations.DesignRoot; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.fieldgroup.FieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException; import com.vaadin.v7.data.util.BeanItemContainer; @@ -47,46 +44,18 @@ public class PotusCrud extends VerticalLayout { private void init() { initTable(); initForm(); - addNew.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - doAdd(); - } - }); + addNew.addClickListener(event -> doAdd()); } private void initTable() { potusList.setContainerDataSource(potusContainer); - potusList.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - doEdit(); - } - }); + potusList.addValueChangeListener(event -> doEdit()); } private void initForm() { - potusForm.save.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - doSave(); - } - - }); - potusForm.delete.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - doDelete(); - } - }); - potusForm.revert.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - doRevert(); - } - }); + potusForm.save.addClickListener(evenet -> doSave()); + potusForm.delete.addClickListener(event -> doDelete()); + potusForm.revert.addClickListener(event -> doRevert()); fg = new FieldGroup(); } diff --git a/uitest/src/main/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValue.java b/uitest/src/main/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValue.java index 0b52ca9589..ff64f489db 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValue.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValue.java @@ -103,12 +103,8 @@ public class CompatibilityComponentElementGetValue extends AbstractTestUI { DateField df = new DateField(); df.setDateFormat("yyyy-MM-dd"); df.setValue(TEST_DATE_VALUE); - df.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - valueChangeLabel.setValue(DATEFIELD_VALUE_CHANGE); - } - }); + df.addValueChangeListener( + event -> valueChangeLabel.setValue(DATEFIELD_VALUE_CHANGE)); return df; } @@ -122,12 +118,8 @@ public class CompatibilityComponentElementGetValue extends AbstractTestUI { private CheckBox createCheckBox() { CheckBox cb = new CheckBox(); cb.setValue(true); - cb.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - valueChangeLabel.setValue(CHECKBOX_VALUE_CHANGE); - } - }); + cb.addValueChangeListener( + value -> valueChangeLabel.setValue(CHECKBOX_VALUE_CHANGE)); return cb; } @@ -146,12 +138,8 @@ public class CompatibilityComponentElementGetValue extends AbstractTestUI { tab.addItems("item 1", TEST_STRING_VALUE, "item 3", "item 4"); // Preselect a few items by creating a set tab.setValue(new HashSet<String>(Arrays.asList(TEST_STRING_VALUE))); - tab.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - valueChangeLabel.setValue(TWINCOL_VALUE_CHANGE); - } - }); + tab.addValueChangeListener( + event -> valueChangeLabel.setValue(TWINCOL_VALUE_CHANGE)); return tab; } diff --git a/uitest/src/main/java/com/vaadin/tests/elements/TestBenchElementRightClick.java b/uitest/src/main/java/com/vaadin/tests/elements/TestBenchElementRightClick.java index 11af3fe772..bb26e5ecb2 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/TestBenchElementRightClick.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/TestBenchElementRightClick.java @@ -4,8 +4,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.MouseEventDetails.MouseButton; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Label; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; public class TestBenchElementRightClick extends AbstractTestUI { @@ -23,15 +21,11 @@ public class TestBenchElementRightClick extends AbstractTestUI { addComponent(table); addComponent(labelEvent); labelEvent.setValue("InitialValue"); - table.addItemClickListener(new ItemClickListener() { - - @Override - public void itemClick(ItemClickEvent event) { - if (event.getButton().equals(MouseButton.RIGHT)) { - labelEvent.setValue("RightClick"); - } else if (event.isDoubleClick()) { - labelEvent.setValue("DoubleClick"); - } + table.addItemClickListener(event -> { + if (event.getButton().equals(MouseButton.RIGHT)) { + labelEvent.setValue("RightClick"); + } else if (event.isDoubleClick()) { + labelEvent.setValue("DoubleClick"); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/elements/button/ButtonUI.java b/uitest/src/main/java/com/vaadin/tests/elements/button/ButtonUI.java index 905a9ef941..4eb5ed83e1 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/button/ButtonUI.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/button/ButtonUI.java @@ -67,27 +67,19 @@ public class ButtonUI extends AbstractTestUI { private Button addButtonWithDelay() { Button btn = new Button(); btn.setId(NORMAL_BUTTON_ID); - btn.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - testedField.setValue("Clicked"); - testedLabel.setValue("Clicked"); + btn.addClickListener(event -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { } + testedField.setValue("Clicked"); + testedLabel.setValue("Clicked"); }); return btn; } private void addListener(Button button, final String clickEventText) { - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent clickEvent) { - testedField.setValue(clickEventText); - } - }); + button.addClickListener(event -> testedField.setValue(clickEventText)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/elements/calendar/CalendarUI.java b/uitest/src/main/java/com/vaadin/tests/elements/calendar/CalendarUI.java index f6873857ae..007d09150f 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/calendar/CalendarUI.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/calendar/CalendarUI.java @@ -18,17 +18,14 @@ public class CalendarUI extends AbstractTestUI { Button monthView = new Button("Month view"); monthView.setId("month-view"); - monthView.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - java.util.Calendar javaCalendar = java.util.Calendar - .getInstance(Locale.ENGLISH); - javaCalendar.set(DAY_OF_MONTH, 1); - calendar.setStartDate(javaCalendar.getTime()); - javaCalendar.set(DAY_OF_MONTH, - javaCalendar.getActualMaximum(DAY_OF_MONTH)); - calendar.setEndDate(javaCalendar.getTime()); - } + monthView.addClickListener(event -> { + java.util.Calendar javaCalendar = java.util.Calendar + .getInstance(Locale.ENGLISH); + javaCalendar.set(DAY_OF_MONTH, 1); + calendar.setStartDate(javaCalendar.getTime()); + javaCalendar.set(DAY_OF_MONTH, + javaCalendar.getActualMaximum(DAY_OF_MONTH)); + calendar.setEndDate(javaCalendar.getTime()); }); addComponents(monthView, calendar); diff --git a/uitest/src/main/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescription.java b/uitest/src/main/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescription.java index d179f9c9ec..6cd99cb53d 100644 --- a/uitest/src/main/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescription.java +++ b/uitest/src/main/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescription.java @@ -32,13 +32,7 @@ public class NotificationGetTypeAndDescription extends AbstractTestUI { // add extra button which shows Notification only with caption #14356 Button btn = new Button("Show notification"); btn.setId("showid"); - btn.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification.show("test"); - } - }); + btn.addClickListener(event -> Notification.show("test")); addComponent(btn); } diff --git a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java index 38b8ba8859..6efdaa2af5 100644 --- a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java +++ b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java @@ -9,8 +9,6 @@ import com.vaadin.server.ServerRpcManager.RpcInvocationException; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; @@ -89,25 +87,17 @@ public class ErrorHandlers extends AbstractReindeerTestUI { private Button runtimeExceptionOnClick(Button customErrorButton) { customErrorButton.setCaption("RE: " + customErrorButton.getCaption()); - customErrorButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - throw new RuntimeException("Fail in click event"); - } + customErrorButton.addClickListener(event -> { + throw new RuntimeException("Fail in click event"); }); return customErrorButton; } private Button npeOnClick(Button customErrorButton) { customErrorButton.setCaption("NPE: " + customErrorButton.getCaption()); - customErrorButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Integer i = null; - i += 2; - } + customErrorButton.addClickListener(event -> { + Integer i = null; + i += 2; }); return customErrorButton; } diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/BasicExtensionTest.java b/uitest/src/main/java/com/vaadin/tests/extensions/BasicExtensionTest.java index a84bee1234..656ba4d464 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/BasicExtensionTest.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/BasicExtensionTest.java @@ -20,8 +20,6 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") @@ -35,12 +33,8 @@ public class BasicExtensionTest extends AbstractReindeerTestUI { final BasicExtension rootExtension = new BasicExtension(); rootExtension.extend(this); new BasicExtension().extend(label); - addComponent(new Button("Remove root extension", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - rootExtension.remove(); - } - })); + addComponent(new Button("Remove root extension", + event -> rootExtension.remove())); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java b/uitest/src/main/java/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java index 45d683d44b..a5ce7ee9c0 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java @@ -25,8 +25,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.components.popupview.ReopenPopupView; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; @@ -99,11 +97,7 @@ public class BrowserPopupExtensionTest extends AbstractReindeerTestUI { new BrowserWindowOpener(URL).extend(c); if (c instanceof Button) { - ((Button) c).addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - } + ((Button) c).addClickListener(event -> { }); } } catch (Exception e) { diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/HelloWorldExtensionTest.java b/uitest/src/main/java/com/vaadin/tests/extensions/HelloWorldExtensionTest.java index a9c7c6269e..9902ea8def 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/HelloWorldExtensionTest.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/HelloWorldExtensionTest.java @@ -19,7 +19,6 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") public class HelloWorldExtensionTest extends AbstractReindeerTestUI { @@ -30,12 +29,8 @@ public class HelloWorldExtensionTest extends AbstractReindeerTestUI { extension.setGreeting("Kind words"); addExtension(extension); - addComponent(new Button("Greet again", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - extension.greetAgain(); - } - })); + addComponent( + new Button("Greet again", event -> extension.greetAgain())); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java b/uitest/src/main/java/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java index 4dc270b747..87751739e8 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java @@ -19,19 +19,14 @@ import com.vaadin.annotations.StyleSheet; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; @StyleSheet("http://fonts.googleapis.com/css?family=Cabin+Sketch") public class ResponsiveWithCrossDomainStyles extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addComponent(new Button("Make responsive", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - event.getButton().setResponsive(true); - } - })); + addComponent(new Button("Make responsive", + event -> event.getButton().setResponsive(true))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java b/uitest/src/main/java/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java index 8dfc9f2034..0e4c8820e0 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java @@ -19,7 +19,6 @@ import com.vaadin.server.Responsive; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; @@ -35,12 +34,7 @@ public class SetThemeAndResponsiveLayout extends AbstractReindeerTestUI { responsiveLayout.addComponent(new Label( "First set the theme using the button and then resize the browser window in both dimensions to see the background color change.")); Button setThemeButton = new Button("Set theme"); - setThemeButton.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTheme("tests-responsive"); - } - }); + setThemeButton.addClickListener(event -> setTheme("tests-responsive")); responsiveLayout.addComponent(setThemeButton); Responsive.makeResponsive(responsiveLayout); } diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/uitest/src/main/java/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java index 6bf1f58fec..e5ca87bd70 100644 --- a/uitest/src/main/java/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java +++ b/uitest/src/main/java/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java @@ -25,7 +25,6 @@ import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.JavaScriptFunction; import com.vaadin.ui.Notification; @@ -102,20 +101,12 @@ public class SimpleJavaScriptExtensionTest extends AbstractReindeerTestUI { simpleJavascriptExtension.setPrefix("Prefix: "); addExtension(simpleJavascriptExtension); addComponent( - new Button("Send rpc greeting", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - simpleJavascriptExtension.greetRpc("Rpc greeting"); - } - })); + new Button("Send rpc greeting", + event -> simpleJavascriptExtension + .greetRpc("Rpc greeting"))); addComponent(new Button("Send callback greeting", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - simpleJavascriptExtension - .greetCallback("Callback greeting"); - } - })); + event -> simpleJavascriptExtension + .greetCallback("Callback greeting"))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBasicCrud.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBasicCrud.java index c8f761e237..ee23080116 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBasicCrud.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBasicCrud.java @@ -25,8 +25,6 @@ import com.vaadin.shared.util.SharedUtil; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; @@ -35,8 +33,6 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.Notification.Type; import com.vaadin.ui.themes.ValoTheme; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.Validator.InvalidValueException; import com.vaadin.v7.data.fieldgroup.BeanFieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException; @@ -86,17 +82,13 @@ public abstract class AbstractBasicCrud extends AbstractTestUIWithLog { "Auto generated form (TextFields)"); formType.setItemCaption(iterator.next(), "Auto generated form (Any fields)"); - formType.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - AbstractForm oldForm = form; - form = (AbstractForm) formType.getValue(); - replaceComponent(oldForm, form); - } + formType.addValueChangeListener(event -> { + AbstractForm oldForm = form; + form = (AbstractForm) formType.getValue(); + replaceComponent(oldForm, form); }); addComponent(formType); - } public class CustomForm extends AbstractForm { @@ -215,24 +207,18 @@ public abstract class AbstractBasicCrud extends AbstractTestUIWithLog { super(5, 1); setSpacing(true); setId("form"); - save.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - fieldGroup.commit(); - log("Saved " + fieldGroup.getItemDataSource()); - } catch (CommitException e) { - handleCommitException(e); - log("Commit failed: " + e.getMessage()); - } + save.addClickListener(event -> { + try { + fieldGroup.commit(); + log("Saved " + fieldGroup.getItemDataSource()); + } catch (CommitException e) { + handleCommitException(e); + log("Commit failed: " + e.getMessage()); } }); - cancel.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log("Discarded " + fieldGroup.getItemDataSource()); - discard(); - } + cancel.addClickListener(event -> { + log("Discarded " + fieldGroup.getItemDataSource()); + discard(); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java index 1b2ec56599..8016eb44e4 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java @@ -3,8 +3,6 @@ package com.vaadin.tests.fieldgroup; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.v7.data.fieldgroup.BeanFieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException; @@ -25,14 +23,9 @@ public abstract class AbstractBeanFieldGroupTest<T> extends TestBase { protected Button getDiscardButton() { if (discardButton == null) { - discardButton = new Button("Discard", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getFieldBinder().discard(); - log.log("Discarded changes"); - - } + discardButton = new Button("Discard", event -> { + getFieldBinder().discard(); + log.log("Discarded changes"); }); } return discardButton; @@ -41,15 +34,8 @@ public abstract class AbstractBeanFieldGroupTest<T> extends TestBase { protected Button getShowBeanButton() { if (showBeanButton == null) { showBeanButton = new Button("Show bean values", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.log(getFieldBinder().getItemDataSource() - .getBean().toString()); - - } - }); + event -> log.log(getFieldBinder().getItemDataSource() + .getBean().toString())); } return showBeanButton; } @@ -57,20 +43,15 @@ public abstract class AbstractBeanFieldGroupTest<T> extends TestBase { protected Button getCommitButton() { if (commitButton == null) { commitButton = new Button("Commit"); - commitButton.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - String msg = "Commit succesful"; - try { - getFieldBinder().commit(); - } catch (CommitException e) { - msg = "Commit failed: " + e.getMessage(); - } - Notification.show(msg); - log.log(msg); - + commitButton.addClickListener(event -> { + String msg = "Commit succesful"; + try { + getFieldBinder().commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); } + Notification.show(msg); + log.log(msg); }); } return commitButton; diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGrid.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGrid.java index b9c1ea65de..70711659f4 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGrid.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGrid.java @@ -18,8 +18,6 @@ package com.vaadin.tests.fieldgroup; import com.vaadin.server.VaadinRequest; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.BeanItem; -import com.vaadin.v7.event.SelectionEvent; -import com.vaadin.v7.event.SelectionEvent.SelectionListener; import com.vaadin.v7.ui.Grid; public class BasicCrudGrid extends AbstractBasicCrud { @@ -35,14 +33,10 @@ public class BasicCrudGrid extends AbstractBasicCrud { grid.setColumnOrder((Object[]) columns); grid.removeColumn("salary"); - grid.addSelectionListener(new SelectionListener() { - - @Override - public void select(SelectionEvent event) { - Item item = grid.getContainerDataSource() - .getItem(grid.getSelectedRow()); - form.edit((BeanItem<ComplexPerson>) item); - } + grid.addSelectionListener(event -> { + Item item = grid.getContainerDataSource() + .getItem(grid.getSelectedRow()); + form.edit((BeanItem<ComplexPerson>) item); }); grid.setSizeFull(); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRow.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRow.java index f2919b95ac..d33ac4e1bf 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRow.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRow.java @@ -22,8 +22,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.BeanItem; import com.vaadin.v7.data.validator.IntegerRangeValidator; -import com.vaadin.v7.event.SelectionEvent; -import com.vaadin.v7.event.SelectionEvent.SelectionListener; import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.renderers.DateRenderer; @@ -41,13 +39,10 @@ public class BasicCrudGridEditorRow extends AbstractBasicCrud { grid.setColumnOrder((Object[]) columns); grid.removeColumn("salary"); - grid.addSelectionListener(new SelectionListener() { - @Override - public void select(SelectionEvent event) { - Item item = grid.getContainerDataSource() - .getItem(grid.getSelectedRow()); - form.edit((BeanItem<ComplexPerson>) item); - } + grid.addSelectionListener(event -> { + Item item = grid.getContainerDataSource() + .getItem(grid.getSelectedRow()); + form.edit((BeanItem<ComplexPerson>) item); }); grid.setEditorEnabled(true); grid.setSizeFull(); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudTable.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudTable.java index 41ed55e43b..cfc82e36e9 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudTable.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicCrudTable.java @@ -16,8 +16,6 @@ package com.vaadin.tests.fieldgroup; import com.vaadin.server.VaadinRequest; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.BeanItem; import com.vaadin.v7.ui.Table; @@ -35,13 +33,8 @@ public class BasicCrudTable extends AbstractBasicCrud { table.setContainerDataSource(container); table.setVisibleColumns((Object[]) columns); - table.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - form.edit((BeanItem<ComplexPerson>) table - .getItem(table.getValue())); - } - }); + table.addValueChangeListener(event -> form.edit( + (BeanItem<ComplexPerson>) table.getItem(table.getValue()))); table.setSizeFull(); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java index 503e5bd4eb..63370fad56 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java @@ -7,7 +7,6 @@ import com.vaadin.tests.data.bean.Country; import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Notification; @@ -122,42 +121,25 @@ public class BasicPersonForm extends AbstractTestUIWithLog { addComponent(sex); addComponent(deceased); - Button commitButton = new Button("Commit", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - String msg = "Commit succesful"; - try { - fieldGroup.commit(); - } catch (CommitException e) { - msg = "Commit failed: " + e.getMessage(); - } - Notification notification = new Notification(msg); - notification.setDelayMsec(Notification.DELAY_FOREVER); - notification.show(getPage()); - log(msg); - + Button commitButton = new Button("Commit", event -> { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); } + Notification notification = new Notification(msg); + notification.setDelayMsec(Notification.DELAY_FOREVER); + notification.show(getPage()); + log(msg); }); Button discardButton = new Button("Discard", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - fieldGroup.discard(); - log("Discarded changes"); - - } + event -> { + fieldGroup.discard(); + log("Discarded changes"); }); Button showBean = new Button("Show bean values", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log(getPerson(fieldGroup).toString()); - - } - }); + event -> log(getPerson(fieldGroup).toString())); addComponent(commitButton); addComponent(discardButton); addComponent(showBean); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java index 7bf59a3889..5262ed76af 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java @@ -8,7 +8,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.data.bean.Person; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.v7.data.fieldgroup.BeanFieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup; @@ -89,39 +88,22 @@ public class DateForm extends AbstractTestUIWithLog { addComponent(inlineDateField); addComponent(textField); - Button commitButton = new Button("Commit", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - String msg = "Commit succesful"; - try { - fieldGroup.commit(); - } catch (CommitException e) { - msg = "Commit failed: " + e.getMessage(); - } - Notification.show(msg); - log(msg); - + Button commitButton = new Button("Commit", event -> { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); } + Notification.show(msg); + log(msg); + }); + Button discardButton = new Button("Discard", event -> { + fieldGroup.discard(); + log("Discarded changes"); }); - Button discardButton = new Button("Discard", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - fieldGroup.discard(); - log("Discarded changes"); - } - }); Button showBean = new Button("Show bean values", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log(getPerson(fieldGroup).toString()); - - } - }); + event -> log(getPerson(fieldGroup).toString())); addComponent(commitButton); addComponent(discardButton); addComponent(showBean); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java index 46d606027d..f8d0eb7eae 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java @@ -7,7 +7,6 @@ import com.vaadin.tests.data.bean.PersonWithBeanValidationAnnotations; import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.v7.data.fieldgroup.BeanFieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup; @@ -42,40 +41,23 @@ public class FieldBinderWithBeanValidation extends TestBase { addComponent(sex); addComponent(deceased); - Button commitButton = new Button("Commit", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - String msg = "Commit succesful"; - try { - fieldGroup.commit(); - } catch (CommitException e) { - msg = "Commit failed: " + e.getMessage(); - } - Notification.show(msg); - log.log(msg); - + Button commitButton = new Button("Commit", event -> { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); } + Notification.show(msg); + log.log(msg); }); Button discardButton = new Button("Discard", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - fieldGroup.discard(); - log.log("Discarded changes"); - - } + event -> { + fieldGroup.discard(); + log.log("Discarded changes"); }); Button showBean = new Button("Show bean values", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.log(getPerson(fieldGroup).toString()); - - } - }); + event -> log.log(getPerson(fieldGroup).toString())); addComponent(commitButton); addComponent(discardButton); addComponent(showBean); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java index 34161782a8..e78792ef59 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java @@ -5,7 +5,6 @@ import org.apache.commons.lang.StringEscapeUtils; import com.vaadin.server.AbstractErrorMessage; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.v7.data.Validator; import com.vaadin.v7.data.fieldgroup.FieldGroup; @@ -33,23 +32,18 @@ public class MultipleValidationErrors extends AbstractReindeerTestUI { validationErrors.setId("validationErrors"); addComponent(validationErrors); - addButton("Submit", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - validationErrors.setValue(""); - try { - fieldGroup.commit(); - } catch (FieldGroup.CommitException e) { - if (e.getCause() != null && e - .getCause() instanceof Validator.InvalidValueException) { - validationErrors.setValue(StringEscapeUtils - .unescapeHtml(AbstractErrorMessage - .getErrorMessageForException( - e.getCause()) - .getFormattedHtmlMessage())); - } + addButton("Submit", event -> { + validationErrors.setValue(""); + try { + fieldGroup.commit(); + } catch (FieldGroup.CommitException e) { + if (e.getCause() != null && e + .getCause() instanceof Validator.InvalidValueException) { + validationErrors.setValue( + StringEscapeUtils.unescapeHtml(AbstractErrorMessage + .getErrorMessageForException(e.getCause()) + .getFormattedHtmlMessage())); } - } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java b/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java index 18a2d2766e..df93a43a37 100644 --- a/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java +++ b/uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java @@ -7,8 +7,6 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Component; @@ -60,55 +58,39 @@ public class TabIndexes extends AbstractTestUIWithLog { HorizontalLayout buttonLayout = new HorizontalLayout(); addComponent(buttonLayout); Button clearTabIndexes = new Button("Set all tab indexes to 0"); - clearTabIndexes.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Setting tab indexes to 0"); - for (Focusable f : fields) { - f.setTabIndex(0); - } - updateCaptions(); + clearTabIndexes.addClickListener(event -> { + log("Setting tab indexes to 0"); + for (Focusable f : fields) { + f.setTabIndex(0); } + updateCaptions(); }); Button setTabIndexesToOne = new Button("Set all tab indexes to 1"); - setTabIndexesToOne.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Setting tab indexes to 1"); - for (Focusable f : fields) { - f.setTabIndex(1); - } - updateCaptions(); + setTabIndexesToOne.addClickListener(event -> { + log("Setting tab indexes to 1"); + for (Focusable f : fields) { + f.setTabIndex(1); } + updateCaptions(); }); Button setTabIndexesInOrder = new Button("Set tab indexes to 1..N"); - setTabIndexesInOrder.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - int tabIndex = 1; - log("Setting tab indexes to 1..N"); - for (Focusable f : fields) { - f.setTabIndex(tabIndex++); - } - updateCaptions(); + setTabIndexesInOrder.addClickListener(event -> { + int tabIndex = 1; + log("Setting tab indexes to 1..N"); + for (Focusable f : fields) { + f.setTabIndex(tabIndex++); } + updateCaptions(); }); Button setTabIndexesInReverseOrder = new Button( "Set tab indexes to N..1"); - setTabIndexesInReverseOrder.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - int tabIndex = fields.size(); - log("Setting tab indexes to N..1"); - for (Focusable f : fields) { - f.setTabIndex(tabIndex--); - } - updateCaptions(); + setTabIndexesInReverseOrder.addClickListener(event -> { + int tabIndex = fields.size(); + log("Setting tab indexes to N..1"); + for (Focusable f : fields) { + f.setTabIndex(tabIndex--); } + updateCaptions(); }); clearTabIndexes.click(); @@ -123,7 +105,6 @@ public class TabIndexes extends AbstractTestUIWithLog { vl.addComponent(f); } addComponent(vl); - } protected void updateCaptions() { diff --git a/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java b/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java index 97ea396f93..a652ffea1e 100644 --- a/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java +++ b/uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java @@ -28,7 +28,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; @@ -77,15 +76,10 @@ public class FontIcons extends AbstractReindeerTestUI { layout.setIcon(icon); layout.addComponent( - new Button("Switch icon type", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - buildUI(icon instanceof FontIcon + new Button("Switch icon type", + event -> buildUI(icon instanceof FontIcon ? new ThemeResource("../runo/icons/16/user.png") - : FontAwesome.ANDROID); - } - })); + : FontAwesome.ANDROID))); Handler actionHandler = new Handler() { Action[] actions = { new Action("Do it!", icon) }; diff --git a/uitest/src/main/java/com/vaadin/tests/integration/EmbedSizeTest.java b/uitest/src/main/java/com/vaadin/tests/integration/EmbedSizeTest.java index 5c8692ce1c..c9e6917cef 100644 --- a/uitest/src/main/java/com/vaadin/tests/integration/EmbedSizeTest.java +++ b/uitest/src/main/java/com/vaadin/tests/integration/EmbedSizeTest.java @@ -1,7 +1,5 @@ package com.vaadin.tests.integration; -import com.vaadin.server.Page; -import com.vaadin.server.Page.BrowserWindowResizeEvent; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.CheckBox; @@ -27,13 +25,9 @@ public class EmbedSizeTest extends TestBase { addComponent(lazyCheckBox); addComponent(log); - mainWindow.addListener(new Page.BrowserWindowResizeListener() { - @Override - public void browserWindowResized(BrowserWindowResizeEvent event) { - log.log("Resize event: " + event.getWidth() + " x " - + event.getHeight()); - } - }); + mainWindow.getPage().addBrowserWindowResizeListener( + event -> log.log("Resize event: " + event.getWidth() + " x " + + event.getHeight())); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/integration/IntegrationTestApplication.java b/uitest/src/main/java/com/vaadin/tests/integration/IntegrationTestApplication.java index 575b2efb27..9878d10bc6 100644 --- a/uitest/src/main/java/com/vaadin/tests/integration/IntegrationTestApplication.java +++ b/uitest/src/main/java/com/vaadin/tests/integration/IntegrationTestApplication.java @@ -6,8 +6,6 @@ import com.vaadin.server.Resource; import com.vaadin.ui.Label; import com.vaadin.ui.LegacyWindow; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class IntegrationTestApplication extends LegacyApplication { @@ -35,12 +33,8 @@ public class IntegrationTestApplication extends LegacyApplication { item.getItemProperty("country").setValue("Sweden"); final Label selectedLabel = new Label(); - table.addListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - selectedLabel.setValue(String.valueOf(table.getValue())); - } - }); + table.addValueChangeListener(event -> selectedLabel + .setValue(String.valueOf(table.getValue()))); window.addComponent(selectedLabel); } } diff --git a/uitest/src/main/java/com/vaadin/tests/integration/ProxyTest.java b/uitest/src/main/java/com/vaadin/tests/integration/ProxyTest.java index 3e9885116a..a9870eb594 100644 --- a/uitest/src/main/java/com/vaadin/tests/integration/ProxyTest.java +++ b/uitest/src/main/java/com/vaadin/tests/integration/ProxyTest.java @@ -64,15 +64,12 @@ public class ProxyTest extends AbstractReindeerTestUI { stopButton.setEnabled(false); startButton.setDisableOnClick(true); - addDetachListener(new DetachListener() { - @Override - public void detach(DetachEvent event) { - if (server != null && server.isRunning()) { - try { - server.stop(); - } catch (Exception e) { - throw new RuntimeException(e); - } + addDetachListener(event -> { + if (server != null && server.isRunning()) { + try { + server.stop(); + } catch (Exception e) { + throw new RuntimeException(e); } } }); diff --git a/uitest/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java b/uitest/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java index e2e198e8ed..4a25e75fc0 100755 --- a/uitest/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java +++ b/uitest/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java @@ -9,8 +9,6 @@ import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.Table; public class ServletIntegrationUI extends UI { @@ -39,12 +37,8 @@ public class ServletIntegrationUI extends UI { item.getItemProperty("country").setValue("Sweden"); final Label selectedLabel = new LabelFromDesign(); - table.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - selectedLabel.setValue(String.valueOf(table.getValue())); - } - }); + table.addValueChangeListener(event -> selectedLabel + .setValue(String.valueOf(table.getValue()))); layout.addComponent(selectedLabel); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/AbsoluteLayoutAddRemove.java b/uitest/src/main/java/com/vaadin/tests/layouts/AbsoluteLayoutAddRemove.java index b2cadebd02..7aa23dedf9 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/AbsoluteLayoutAddRemove.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/AbsoluteLayoutAddRemove.java @@ -3,7 +3,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; @@ -29,23 +28,16 @@ public class AbsoluteLayoutAddRemove extends TestBase { al.setHeight("200px"); main.addComponent(al); - final Button b = new Button("Add", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (l.getParent() == null) { - al.addComponent(l); - event.getButton().setCaption("Remove"); - } else { - al.removeComponent(l); - event.getButton().setCaption("Add"); - } - + final Button b = new Button("Add", event -> { + if (l.getParent() == null) { + al.addComponent(l); + event.getButton().setCaption("Remove"); + } else { + al.removeComponent(l); + event.getButton().setCaption("Add"); } - }); main.addComponent(b); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java index b6df3d34c3..24bb85567e 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java @@ -8,8 +8,6 @@ import com.vaadin.server.UserError; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; @@ -20,8 +18,6 @@ import com.vaadin.ui.Layout; import com.vaadin.ui.NativeButton; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.AbstractField; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.TextField; @@ -60,13 +56,7 @@ public class CaptionsInLayouts extends AbstractReindeerTestUI { private Component addCaptionText() { Button b = new Button("Add caption text"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - prependCaptions("a"); - } - }); + b.addClickListener(event -> prependCaptions("a")); return b; } @@ -74,7 +64,6 @@ public class CaptionsInLayouts extends AbstractReindeerTestUI { for (AbstractField<?> c : components) { c.setCaption(prepend + c.getCaption()); } - } private Component toggleRequired() { @@ -233,19 +222,13 @@ public class CaptionsInLayouts extends AbstractReindeerTestUI { } layoutSelect.setImmediate(true); - layoutSelect.addListener(new ValueChangeListener() { - - @Override - @SuppressWarnings("unchecked") - public void valueChange(ValueChangeEvent event) { - Item i = layoutSelect.getItem(event.getProperty().getValue()); - - setLayout(getLayout( - (String) i.getItemProperty(CAPTION).getValue(), - (Class<? extends Layout>) i.getItemProperty(CLASS) - .getValue(), - (String) i.getItemProperty(WIDTH).getValue())); - } + layoutSelect.addValueChangeListener(event -> { + Item i = layoutSelect.getItem(event.getProperty().getValue()); + + setLayout(getLayout((String) i.getItemProperty(CAPTION).getValue(), + (Class<? extends Layout>) i.getItemProperty(CLASS) + .getValue(), + (String) i.getItemProperty(WIDTH).getValue())); }); return layoutSelect; diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java index 38f6da9a21..d2a63b571a 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -10,8 +10,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Component; @@ -22,8 +20,6 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.AbstractLegacyComponent; import com.vaadin.v7.ui.Field; import com.vaadin.v7.ui.NativeSelect; @@ -70,13 +66,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase { private Component addCaptionText() { Button b = new Button("Add caption text"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - prependCaptions("a"); - } - }); + b.addClickListener(event -> prependCaptions("a")); return b; } @@ -84,7 +74,6 @@ public class CaptionsInLayoutsWaiAria extends TestBase { for (Component c : components) { c.setCaption(prepend + c.getCaption()); } - } private Component toggleRequired() { @@ -321,19 +310,13 @@ public class CaptionsInLayoutsWaiAria extends TestBase { } layoutSelect.setImmediate(true); - layoutSelect.addListener(new ValueChangeListener() { - - @Override - @SuppressWarnings("unchecked") - public void valueChange(ValueChangeEvent event) { - Item i = layoutSelect.getItem(event.getProperty().getValue()); - - setLayout(getLayout( - (String) i.getItemProperty(CAPTION).getValue(), - (Class<? extends Layout>) i.getItemProperty(CLASS) - .getValue(), - (String) i.getItemProperty(WIDTH).getValue())); - } + layoutSelect.addValueChangeListener(event -> { + Item i = layoutSelect.getItem(event.getProperty().getValue()); + + setLayout(getLayout((String) i.getItemProperty(CAPTION).getValue(), + (Class<? extends Layout>) i.getItemProperty(CLASS) + .getValue(), + (String) i.getItemProperty(WIDTH).getValue())); }); return layoutSelect; diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java b/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java index 2c670661fc..e8cb6ba4ec 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java @@ -37,46 +37,37 @@ public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase { // textfield spreads across all cols final TextField textfield = new TextField(); textfield.setWidth(100, Sizeable.UNITS_PERCENTAGE); - Button b1 = new Button("new button"); - Button b2 = new Button("nothing"); + Button button1 = new Button("new button"); + Button button2 = new Button("nothing"); gl.addComponent(textfield, 0, 0); - gl.addComponent(b1, 0, 1); - gl.addComponent(b2, 0, 2); - b1.setWidth(270, Sizeable.UNITS_PIXELS); - b2.setWidth(270, Sizeable.UNITS_PIXELS); - b1.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - cols++; - gl.setColumns(cols); - Button b1 = new Button("new button" + cols); - Button b2 = new Button("nothing" + cols); - gl.addComponent(b1, cols - 1, 1); - gl.addComponent(b2, cols - 1, 2); - b1.setWidth(270, Sizeable.UNITS_PIXELS); - b2.setWidth(270, Sizeable.UNITS_PIXELS); - // adjust expand ratios... - if (cols > 0) { - // next to last colum 0, last column 100 - gl.setColumnExpandRatio(cols - 2, 0); - gl.setColumnExpandRatio(cols - 1, 100); - } - gl.removeComponent(textfield); - gl.addComponent(textfield, 0, 0, cols - 1, 0); + gl.addComponent(button1, 0, 1); + gl.addComponent(button2, 0, 2); + button1.setWidth(270, Sizeable.UNITS_PIXELS); + button2.setWidth(270, Sizeable.UNITS_PIXELS); + button1.addClickListener(event -> { + cols++; + gl.setColumns(cols); + Button b1 = new Button("new button" + cols); + Button b2 = new Button("nothing" + cols); + gl.addComponent(b1, cols - 1, 1); + gl.addComponent(b2, cols - 1, 2); + b1.setWidth(270, Sizeable.UNITS_PIXELS); + b2.setWidth(270, Sizeable.UNITS_PIXELS); + // adjust expand ratios... + if (cols > 0) { + // next to last colum 0, last column 100 + gl.setColumnExpandRatio(cols - 2, 0); + gl.setColumnExpandRatio(cols - 1, 100); } + gl.removeComponent(textfield); + gl.addComponent(textfield, 0, 0, cols - 1, 0); }); gl.setSizeFull(); mainLayout.addComponent(gl); mainLayout.setExpandRatio(gl, 100); Button restart = new Button("restart"); mainLayout.addComponent(restart); - restart.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - close(); - } - }); - + restart.addClickListener(event -> close()); } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java index 7e5e0f34ef..2946500a40 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java @@ -2,8 +2,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CssLayout; import com.vaadin.v7.ui.TextField; @@ -13,15 +11,9 @@ public class CssLayoutRemoveComponentWithCaption extends TestBase { protected void setup() { final CssLayout layout = new CssLayout(); final TextField tf = new TextField("Caption"); - Button b = new Button("Remove field and add new", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.removeComponent(tf); - addComponent(new TextField("new field")); - - } - + Button b = new Button("Remove field and add new", event -> { + layout.removeComponent(tf); + addComponent(new TextField("new field")); }); layout.addComponent(tf); layout.addComponent(b); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java b/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java index 32da2b0c46..d991b6ea4a 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java @@ -2,14 +2,12 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.ui.ComboBox; public class DeepComponentTrees extends TestBase { @@ -44,14 +42,9 @@ public class DeepComponentTrees extends TestBase { root.setWidth("600px"); root.setHeight("200px"); final Button b = new Button("Go try your luck with " + i + " layouts!"); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - FF2KILLER(i++); - b.setCaption("Go try your luck with " + i + " layouts!"); - } - + b.addClickListener(event -> { + FF2KILLER(i++); + b.setCaption("Go try your luck with " + i + " layouts!"); }); final ComboBox s = new ComboBox("Restart game with select:"); @@ -61,18 +54,13 @@ public class DeepComponentTrees extends TestBase { s.addItem(VerticalLayout.class); s.addItem(HorizontalLayout.class); s.addItem(GridLayout.class); - s.addListener(new ComboBox.ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - Object value = s.getValue(); - if (!value.equals("-- Choose value --")) { - currentValue = (Class<?>) value; - i = 0; - s.setValue("-- Choose value --"); - b.setCaption("Go try your luck with " + i + " layouts!"); - } - + s.addValueChangeListener(event -> { + Object value = s.getValue(); + if (!value.equals("-- Choose value --")) { + currentValue = (Class<?>) value; + i = 0; + s.setValue("-- Choose value --"); + b.setCaption("Go try your luck with " + i + " layouts!"); } }); s.setImmediate(true); @@ -81,7 +69,6 @@ public class DeepComponentTrees extends TestBase { main.addComponent(b); main.addComponent(s); main.addComponent(root); - } private void FF2KILLER(int layouts) { diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java index 7e60b06ab0..794ecf1d38 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java @@ -2,7 +2,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -29,34 +28,21 @@ public class GridLayoutNPE extends TestBase { lo.addComponent(b); lo.addComponent(b2); - b.addClickListener(new Button.ClickListener() { + b.addClickListener(event -> { + gl.removeComponent(toRemove); - @Override - public void buttonClick(Button.ClickEvent event) { - gl.removeComponent(toRemove); - - // move another component to where the first was removed - // before rendering to the client - gl.removeComponent(toEdit); - // this could also be the result of removeAllComponents() - // followed by a loop of addComponent(c) - gl.addComponent(toEdit, 0, 0); - - b.setVisible(false); - b2.setVisible(true); - - } + // move another component to where the first was removed + // before rendering to the client + gl.removeComponent(toEdit); + // this could also be the result of removeAllComponents() + // followed by a loop of addComponent(c) + gl.addComponent(toEdit, 0, 0); + b.setVisible(false); + b2.setVisible(true); }); - b2.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - toEdit.setValue("Second (edited)"); - } - - }); + b2.addClickListener(event -> toEdit.setValue("Second (edited)")); addComponent(lo); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java index 5d45f72142..ab506169ca 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutRemoveFinalRow.java @@ -2,7 +2,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -25,12 +24,7 @@ public class GridLayoutRemoveFinalRow extends TestBase { addComponent(layout); Button removeRowBtn = new Button("Remove row", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.removeRow(0); - } - }); + event -> layout.removeRow(0)); addComponent(removeRowBtn); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/HiddenHorizontalLayout.java b/uitest/src/main/java/com/vaadin/tests/layouts/HiddenHorizontalLayout.java index f07b713a5d..2897904552 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/HiddenHorizontalLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/HiddenHorizontalLayout.java @@ -3,7 +3,6 @@ package com.vaadin.tests.layouts; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -46,14 +45,7 @@ public class HiddenHorizontalLayout extends TestBase { ContentMode.HTML); vl.addComponent(l); Button b = new Button("toggle layout visibility", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - hl.setVisible(!hl.isVisible()); - } - - }); + event -> hl.setVisible(!hl.isVisible())); vl.addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/LayoutPerformanceTests.java b/uitest/src/main/java/com/vaadin/tests/layouts/LayoutPerformanceTests.java index 4ec406129d..e28dc0b8ff 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/LayoutPerformanceTests.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/LayoutPerformanceTests.java @@ -9,7 +9,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; @@ -212,39 +211,32 @@ public class LayoutPerformanceTests extends TestBase { controls.addComponent(leafSelector); controls.addComponent(childAmount); - controls.addComponent(new Button("Clear", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTestLayout(new Label("")); - } - })); + controls.addComponent( + new Button("Clear", event -> setTestLayout(new Label("")))); - controls.addComponent(new Button("Apply", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - SampleType leafType = (SampleType) leafSelector.getValue(); - if (leafType == null) { - return; - } + controls.addComponent(new Button("Apply", event -> { + SampleType leafType = (SampleType) leafSelector.getValue(); + if (leafType == null) { + return; + } - ContainerType containerType = (ContainerType) containerSelector - .getValue(); - if (containerType == null) { - return; - } + ContainerType containerType = (ContainerType) containerSelector + .getValue(); + if (containerType == null) { + return; + } - boolean wrapped = wrapInPanel.getValue(); - ComponentContainer container = containerType.buildLayout( - ((Number) levels.getValue()).intValue(), - ((Number) childAmount.getValue()).intValue(), leafType, - !wrapped); - if (wrapped) { - Panel panel = new Panel(container); - panel.setSizeFull(); - setTestLayout(panel); - } else { - setTestLayout(container); - } + boolean wrapped = wrapInPanel.getValue(); + ComponentContainer container = containerType.buildLayout( + ((Number) levels.getValue()).intValue(), + ((Number) childAmount.getValue()).intValue(), leafType, + !wrapped); + if (wrapped) { + Panel panel = new Panel(container); + panel.setSizeFull(); + setTestLayout(panel); + } else { + setTestLayout(container); } })); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java index f641befb3c..c96e4286fa 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java @@ -9,7 +9,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ComboBox; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CssLayout; @@ -56,20 +55,16 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase { componentContainerSelect.setValue(componentContainerSelect .getDataProvider().fetch(new Query<>()).iterator().next()); Button but1 = new Button("Move in and out of component container", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cc.setVisible(!cc.isVisible()); - if (!cc.isVisible()) { - getLayout().addComponent(lab); - lab.setValue(lab.getValue().replace("inside", - "outside")); - } else { - addToCC(lab); - lab.setValue(lab.getValue().replace("outside", - "inside")); - } + event -> { + cc.setVisible(!cc.isVisible()); + if (!cc.isVisible()) { + getLayout().addComponent(lab); + lab.setValue( + lab.getValue().replace("inside", "outside")); + } else { + addToCC(lab); + lab.setValue( + lab.getValue().replace("outside", "inside")); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java b/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java index 1dc63f1240..90b5275c99 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java @@ -2,8 +2,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.TextField; @@ -21,20 +19,14 @@ public class MovingInvisibleField extends TestBase { "A visible text field"); tfHidden.setVisible(false); Button b = new Button("Move hidden textfield to other layout"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (layout1.getComponentIndex(tfHidden) != -1) { - layout2.addComponent(tfVisible); - layout2.addComponent(tfHidden); - } else { - layout1.addComponent(tfVisible); - layout1.addComponent(tfHidden); - } - + b.addClickListener(event -> { + if (layout1.getComponentIndex(tfHidden) != -1) { + layout2.addComponent(tfVisible); + layout2.addComponent(tfHidden); + } else { + layout1.addComponent(tfVisible); + layout1.addComponent(tfHidden); } - }); layout1.addComponent(tfVisible); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java index b2d871cf9a..482ece0562 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java @@ -10,8 +10,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -1032,45 +1030,29 @@ public class OrderedLayoutBasics extends TestBase { } private Button createAddButton(AbstractOrderedLayout ol) { - Button b = new Button("Add before", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { + Button b = new Button("Add before", event -> addBefore((AbstractOrderedLayout) event.getButton().getData(), - event.getButton().getParent(), ""); - } - - }); + event.getButton().getParent(), "")); b.setData(ol); return b; } private Button createWideAddButton(AbstractOrderedLayout ol) { - Button b = new Button("Add 100% before", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - addBefore((AbstractOrderedLayout) event.getButton().getData(), - event.getButton().getParent(), "100%"); - } - - }); + Button b = new Button("Add 100% before", + event -> addBefore( + (AbstractOrderedLayout) event.getButton().getData(), + event.getButton().getParent(), "100%")); b.setData(ol); return b; } private Button createRemoveButton(AbstractOrderedLayout ol, String suffix) { - Button b = new Button("Remove this " + suffix, new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - remove((AbstractOrderedLayout) event.getButton().getData(), - event.getButton().getParent()); - } - - }); + Button b = new Button("Remove this " + suffix, + event -> remove( + (AbstractOrderedLayout) event.getButton().getData(), + event.getButton().getParent())); b.setWidth("100%"); b.setData(ol); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java index c237d572bb..485c79e72a 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -1,7 +1,6 @@ package com.vaadin.tests.layouts; import com.vaadin.event.LayoutEvents.LayoutClickEvent; -import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUIWithLog; import com.vaadin.ui.AbsoluteLayout; @@ -45,23 +44,10 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog { "top: 120px; left: 20px; width: 100px;"); al.addComponent(new Button("A button with its own click listener", - new Button.ClickListener() { - - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - log("Button " + event.getButton().getCaption() - + " was clicked"); - - } - })); - al.addLayoutClickListener(new LayoutClickListener() { - - @Override - public void layoutClick(LayoutClickEvent event) { - logLayoutClick("AbsoluteLayout", event); - } - }); + event -> log("Button " + event.getButton().getCaption() + + " was clicked"))); + al.addLayoutClickListener( + event -> logLayoutClick("AbsoluteLayout", event)); return al; @@ -79,30 +65,14 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog { "This is another textfield")); cl.addComponent(new Button("A button with its own click listener", - new Button.ClickListener() { - - @Override - public void buttonClick( - com.vaadin.ui.Button.ClickEvent event) { - log("Button " + event.getButton().getCaption() - + " was clicked"); - - } - })); - cl.addLayoutClickListener(new LayoutClickListener() { - - @Override - public void layoutClick(LayoutClickEvent event) { - logLayoutClick("CSSLayout", event); - } - }); + event -> log("Button " + event.getButton().getCaption() + + " was clicked"))); + cl.addLayoutClickListener(event -> logLayoutClick("CSSLayout", event)); return cl; - } private Layout createClickableGridLayout() { - GridLayout gl = new GridLayout(4, 4); gl.setHeight("400px"); gl.setWidth("564px"); @@ -115,13 +85,7 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog { largeTextarea.setHeight("99%"); gl.addComponent(largeTextarea, 0, 3, 3, 3); - gl.addLayoutClickListener(new LayoutClickListener() { - - @Override - public void layoutClick(LayoutClickEvent event) { - logLayoutClick("GridLayout", event); - } - }); + gl.addLayoutClickListener(event -> logLayoutClick("GridLayout", event)); gl.setRowExpandRatio(3, 1); return wrap(gl, "GridLayout"); } @@ -148,14 +112,8 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog { VerticalLayout gl = new VerticalLayout(); addContent(gl, 5); - gl.addLayoutClickListener(new LayoutClickListener() { - - @Override - public void layoutClick(LayoutClickEvent event) { - logLayoutClick("VerticalLayout", event); - - } - }); + gl.addLayoutClickListener( + event -> logLayoutClick("VerticalLayout", event)); return wrap(gl, "Clickable VerticalLayout"); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java index 85533a8d2e..095f597873 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java @@ -4,7 +4,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; @@ -63,24 +62,19 @@ public class TestLayoutPerformance extends TestBase { Button b = new Button("Render component"); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - int components = Integer.parseInt(n.getValue()); - Layout layout = getCurrentLayout(); - for (int i = 0; i < components; i++) { - Component component = newTestComponent(); - if (cb.getValue()) { - component.setCaption("caption " + i); - } - layout.addComponent(component); + b.addClickListener(event -> { + int components = Integer.parseInt(n.getValue()); + Layout layout = getCurrentLayout(); + for (int i = 0; i < components; i++) { + Component component = newTestComponent(); + if (cb.getValue()) { + component.setCaption("caption " + i); } - - testarea.removeAllComponents(); - testarea.addComponent(layout); + layout.addComponent(component); } + testarea.removeAllComponents(); + testarea.addComponent(layout); }); getLayout().addComponent(ns); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java b/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java index 2a9892ad18..c510e8deba 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java @@ -2,8 +2,6 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -41,13 +39,9 @@ public class VerticalLayoutWithRelativeSizeComponentsInitiallyHidden Button b = new Button( "Click to set bar visible. Button should stay visible."); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - bar.setVisible(true); - foobar.setVisible(true); - } + b.addClickListener(event -> { + bar.setVisible(true); + foobar.setVisible(true); }); verticalLayout.addComponent(bar); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java b/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java index f94513f137..a46448eb03 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java @@ -3,7 +3,6 @@ package com.vaadin.tests.layouts.gridlayout; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.v7.ui.TextField; @@ -30,34 +29,25 @@ public class GridLayoutMoveComponent extends AbstractReindeerTestUI { grid.addComponent(tf, 0, 2); addComponent( - new Button("Shift label right", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - // Moving component from 0,0 -> 1,0 - grid.removeComponent(l); - grid.addComponent(l, 1, 0); - } + new Button("Shift label right", event -> { + // Moving component from 0,0 -> 1,0 + grid.removeComponent(l); + grid.addComponent(l, 1, 0); })); addComponent( - new Button("Shift button right", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.removeComponent(b); - grid.addComponent(b, 1, 1); - } + new Button("Shift button right", event -> { + grid.removeComponent(b); + grid.addComponent(b, 1, 1); })); addComponent(new Button("Shift text field right", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.removeComponent(tf); - Label label = new Label("I'm on left"); - label.setWidth("100%"); - grid.addComponent(label, 0, 2); - grid.addComponent(tf, 1, 2); - } + event -> { + grid.removeComponent(tf); + Label label = new Label("I'm on left"); + label.setWidth("100%"); + grid.addComponent(label, 0, 2); + grid.addComponent(tf, 1, 2); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java b/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java index d75bab9fe2..255800cf6c 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java @@ -3,7 +3,6 @@ package com.vaadin.tests.layouts.gridlayout; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.NativeButton; @@ -47,14 +46,7 @@ public class GridLayoutWidthChange extends AbstractReindeerTestUI { addComponent(cc); Button testButton = new Button("Reduce GridLayout parent width", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cc.setWidth((cc.getWidth() - 100) + "px"); - } - - }); + event -> cc.setWidth((cc.getWidth() - 100) + "px")); addComponent(testButton); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java index 9d94df21b4..9fc9c3d8b6 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java @@ -20,8 +20,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.v7.ui.Table; @@ -78,34 +76,12 @@ public class BaseAddReplaceMove extends BaseLayoutTestUI { l1.addComponent(btnMove); l1.addComponent(btnRemove); - btnAdd.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l2.addComponent(new TextField()); - } - }); - btnReplace.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l2.replaceComponent(c1, c3); - } - }); - btnMove.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l2.moveComponentsFrom(source); - } - }); - btnRemove.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - l2.removeComponent(c1); - l2.removeComponent(c2); - } + btnAdd.addClickListener(event -> l2.addComponent(new TextField())); + btnReplace.addClickListener(event -> l2.replaceComponent(c1, c3)); + btnMove.addClickListener(event -> l2.moveComponentsFrom(source)); + btnRemove.addClickListener(event -> { + l2.removeComponent(c1); + l2.removeComponent(c2); }); l2.addComponent(c1); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java index ca7fc72c3a..7b15e64d15 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java @@ -54,12 +54,9 @@ public class BaseLayoutExpand extends BaseLayoutTestUI { expandComp1 = e1; expandComp2 = e2; setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); - addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - l2.setExpandRatio(c1, expandComp1); - l2.setExpandRatio(c2, expandComp2); - } + addClickListener(event -> { + l2.setExpandRatio(c1, expandComp1); + l2.setExpandRatio(c2, expandComp2); }); } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java index c8dc8fade2..333a4a88b0 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.AbstractLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.v7.ui.Table; @@ -61,22 +59,12 @@ public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI { l2.addComponent(spacer); l2.addComponent(t2); final Button btn1 = new Button("Toggle margin on/off"); - btn1.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - boolean margin = l2.getMargin().hasLeft(); - l2.setMargin(!margin); - - } + btn1.addClickListener(event -> { + boolean margin = l2.getMargin().hasLeft(); + l2.setMargin(!margin); }); final Button btn2 = new Button("Toggle spacing on/off"); - btn2.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - l2.setSpacing(!l2.isSpacing()); - } - }); + btn2.addClickListener(event -> l2.setSpacing(!l2.isSpacing())); l1.addComponent(btn1); l1.addComponent(btn2); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java index d3727a1510..89f7d8f426 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java @@ -26,8 +26,6 @@ import com.vaadin.ui.AbstractLayout; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -116,23 +114,16 @@ public abstract class BaseLayoutTestUI extends AbstractReindeerTestUI { SetSizeButton(final String size) { super(); setCaption("Set size " + size); - addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (compType == "layout") { - l2.setHeight(size); - l2.setWidth(size); - } else if (compType == "component") { - c2.setHeight(size); - c2.setWidth(size); - } else { - } - + addClickListener(event -> { + if (compType == "layout") { + l2.setHeight(size); + l2.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); } }); } - } Button btn1 = new SetSizeButton("350px"); Button btn2 = new SetSizeButton("-1px"); @@ -154,15 +145,10 @@ public abstract class BaseLayoutTestUI extends AbstractReindeerTestUI { l2.setExpandRatio(c1, 0.5f); l2.setExpandRatio(c2, 0.5f); - btn2.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Label newLabel = new Label("--- NEW LABEL ---"); - newLabel.setSizeUndefined(); - l2.addComponent(newLabel); - - } + btn2.addClickListener(event -> { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + l2.addComponent(newLabel); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java index 05edfb0152..99b5ffcf95 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java @@ -19,8 +19,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.v7.ui.Table; @@ -70,34 +68,12 @@ public class GridAddReplaceMove extends GridBaseLayoutTestUI { layout.addComponent(btnMove); layout.addComponent(btnRemove); - btnAdd.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.addComponent(new TextField()); - } - }); - btnReplace.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.replaceComponent(c1, c3); - } - }); - btnMove.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.moveComponentsFrom(source); - } - }); - btnRemove.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - layout.removeComponent(c1); - layout.removeComponent(c2); - } + btnAdd.addClickListener(event -> layout.addComponent(new TextField())); + btnReplace.addClickListener(event -> layout.replaceComponent(c1, c3)); + btnMove.addClickListener(event -> layout.moveComponentsFrom(source)); + btnRemove.addClickListener(event -> { + layout.removeComponent(c1); + layout.removeComponent(c2); }); layout.addComponent(c1); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java index ebd345476e..87ff23bbf2 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java @@ -20,8 +20,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.layouts.layouttester.BaseLayoutTestUI; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -63,23 +61,16 @@ public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI { SetSizeButton(final String size) { super(); setCaption("Set size " + size); - addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - if (compType == "layout") { - layout.setHeight(size); - layout.setWidth(size); - } else if (compType == "component") { - c2.setHeight(size); - c2.setWidth(size); - } else { - } - + addClickListener(event -> { + if (compType == "layout") { + layout.setHeight(size); + layout.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); } }); } - } Button btn1 = new SetSizeButton("550px"); Button btn2 = new SetSizeButton("-1px"); @@ -98,14 +89,10 @@ public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI { layout.addComponent(c1); layout.addComponent(spacer); layout.addComponent(c2); - btn2.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Label newLabel = new Label("--- NEW LABEL ---"); - newLabel.setSizeUndefined(); - layout.addComponent(newLabel); - } + btn2.addClickListener(event -> { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + layout.addComponent(newLabel); }); } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java index 5a5d64f791..5b0d6e88c5 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java @@ -39,12 +39,9 @@ public class GridLayoutExpand extends GridBaseLayoutTestUI { final float e2) { super(); setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); - addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.setColumnExpandRatio(i1, e1); - layout.setColumnExpandRatio(i2, e2); - } + addClickListener(event -> { + layout.setColumnExpandRatio(i1, e1); + layout.setColumnExpandRatio(i2, e2); }); } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java index 20738556b3..4fc8819469 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java @@ -18,8 +18,6 @@ package com.vaadin.tests.layouts.layouttester.GridLayout; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.v7.ui.Table; @@ -43,22 +41,12 @@ public class GridLayoutMarginSpacing extends GridBaseLayoutTestUI { t2.setSizeFull(); final Button btn1 = new Button("Toggle margin on/off"); - btn1.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - boolean margin = layout.getMargin().hasLeft(); - layout.setMargin(!margin); - - } + btn1.addClickListener(event -> { + boolean margin = layout.getMargin().hasLeft(); + layout.setMargin(!margin); }); final Button btn2 = new Button("Toggle spacing on/off"); - btn2.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layout.setSpacing(!layout.isSpacing()); - } - }); + btn2.addClickListener(event -> layout.setSpacing(!layout.isSpacing())); layout.addComponent(btn1); layout.addComponent(btn2); diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java index 27364fe6b9..ad473327c8 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java @@ -4,7 +4,6 @@ import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.minitutorials.broadcastingmessages.Broadcaster.BroadcastListener; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; import com.vaadin.ui.Notification.Type; import com.vaadin.ui.UI; @@ -26,12 +25,8 @@ public class BroadcasterUI extends UI implements BroadcastListener { final Button button = new Button("Broadcast"); layout.addComponent(button); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Broadcaster.broadcast(message.getValue()); - } - }); + button.addClickListener( + event -> Broadcaster.broadcast(message.getValue())); // Register broadcast listener Broadcaster.register(this); @@ -45,15 +40,11 @@ public class BroadcasterUI extends UI implements BroadcastListener { @Override public void receiveBroadcast(final String message) { - access(new Runnable() { - @Override - public void run() { - Notification n = new Notification("Message received", message, - Type.TRAY_NOTIFICATION); - n.show(getPage()); - } + access(() -> { + Notification n = new Notification("Message received", message, + Type.TRAY_NOTIFICATION); + n.show(getPage()); }); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorListenerModifiesListeners.java b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorListenerModifiesListeners.java index c0874af3d1..b4ab0bc73c 100644 --- a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorListenerModifiesListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorListenerModifiesListeners.java @@ -7,8 +7,6 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; @@ -57,20 +55,14 @@ public class NavigatorListenerModifiesListeners extends AbstractReindeerTestUI { addComponent(label); Button buttonNavToAnotherView = new Button( - "Navigate to another view", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - navigator.navigateTo(AnotherView.NAME); - } - }); + "Navigate to another view", + event -> navigator.navigateTo(AnotherView.NAME)); addComponent(buttonNavToAnotherView); } @Override public void enter(ViewChangeEvent event) { } - } class AnotherView extends VerticalLayout implements View { diff --git a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java index 9a62729bd3..2e1c7b8abb 100644 --- a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java +++ b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java @@ -8,8 +8,6 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -42,13 +40,8 @@ public class NavigatorViewBlocksBackButtonAction addComponent(label); Button buttonNavToAnotherView = new Button( - "Navigate to another view", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - navigator.navigateTo(ViewWithPromptedLeave.NAME); - } - }); + "Navigate to another view", + event -> navigator.navigateTo(ViewWithPromptedLeave.NAME)); addComponent(buttonNavToAnotherView); } @@ -95,16 +88,11 @@ public class NavigatorViewBlocksBackButtonAction confirmationWindowLayout .addComponent(new Label("Really exit this view?")); confirmationWindowLayout.addComponent( - new Button("Yeah, sure!", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent buttonEvent) { - okToLeave = true; - getUI().removeWindow(confirmationWindow); - event.getNavigator() - .navigateTo(event.getViewName() + "/" - + event.getParameters()); - } + new Button("Yeah, sure!", clickEvent -> { + okToLeave = true; + getUI().removeWindow(confirmationWindow); + event.getNavigator().navigateTo(event.getViewName() + + "/" + event.getParameters()); })); getUI().addWindow(confirmationWindow); return false; diff --git a/uitest/src/main/java/com/vaadin/tests/overlays/OverlayTouchScrolling.java b/uitest/src/main/java/com/vaadin/tests/overlays/OverlayTouchScrolling.java index 462ac6ebba..eeff41d16e 100644 --- a/uitest/src/main/java/com/vaadin/tests/overlays/OverlayTouchScrolling.java +++ b/uitest/src/main/java/com/vaadin/tests/overlays/OverlayTouchScrolling.java @@ -7,7 +7,6 @@ package com.vaadin.tests.overlays; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; @@ -31,15 +30,11 @@ public class OverlayTouchScrolling extends AbstractReindeerTestUI { setContent(layout); Button button = new Button("Tap me with a touch device"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - - Notification.show( - "Now close this and you can scroll in mad places."); - green.addComponent(new Label( - "Thank you for clicking, now scroll (with touch device) to area without green background, which shouldn't be possible.")); - } + button.addClickListener(event -> { + Notification + .show("Now close this and you can scroll in mad places."); + green.addComponent(new Label( + "Thank you for clicking, now scroll (with touch device) to area without green background, which shouldn't be possible.")); }); green.addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/performance/BasicPerformanceTest.java b/uitest/src/main/java/com/vaadin/tests/performance/BasicPerformanceTest.java index 7b37a12ace..dbefe115e9 100644 --- a/uitest/src/main/java/com/vaadin/tests/performance/BasicPerformanceTest.java +++ b/uitest/src/main/java/com/vaadin/tests/performance/BasicPerformanceTest.java @@ -6,7 +6,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.HorizontalLayout; @@ -28,13 +27,10 @@ public class BasicPerformanceTest extends UI { private boolean reportBootstap = true; private String performanceTopic; private final Button reportPerformanceButton = new Button( - "Report some performance", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - TestUtils.reportPerformance(performanceTopic, serverLimit, - clientLimit, reportBootstap); - event.getButton().setEnabled(false); - } + "Report some performance", event -> { + TestUtils.reportPerformance(performanceTopic, serverLimit, + clientLimit, reportBootstap); + event.getButton().setEnabled(false); }); @Override @@ -73,90 +69,72 @@ public class BasicPerformanceTest extends UI { leftBar.addComponent(reportPerformanceButton); leftBar.addComponent(new Button("Set 20 panels as content", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - popupateContent(contentLayout, 20, true); - updatePerformanceReporting("20 panels", 100, 100); - } + event -> { + popupateContent(contentLayout, 20, true); + updatePerformanceReporting("20 panels", 100, 100); })); leftBar.addComponent(new Button("Set 40 panels as content", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - popupateContent(contentLayout, 40, true); - updatePerformanceReporting("40 panels", 100, 100); - } + event -> { + popupateContent(contentLayout, 40, true); + updatePerformanceReporting("40 panels", 100, 100); })); leftBar.addComponent(new Button("Set 40 layouts as content", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - popupateContent(contentLayout, 40, false); - updatePerformanceReporting("40 layouts", 100, 100); - } + event -> { + popupateContent(contentLayout, 40, false); + updatePerformanceReporting("40 layouts", 100, 100); })); leftBar.addComponent( - new Button("Update all labels", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Iterator<Component> componentIterator = contentLayout - .getComponentIterator(); - while (componentIterator.hasNext()) { - - Iterator<Component> columHolderIterator; - Component child = componentIterator.next(); - if (child instanceof Panel) { - columHolderIterator = ((ComponentContainer) ((Panel) child) - .getContent()).getComponentIterator(); - } else { - columHolderIterator = ((ComponentContainer) child) - .getComponentIterator(); - } - while (columHolderIterator.hasNext()) { - VerticalLayout column = (VerticalLayout) columHolderIterator - .next(); - Iterator<Component> columnIterator = column - .getComponentIterator(); - while (columnIterator.hasNext()) { - Label label = (Label) columnIterator.next(); - label.setValue("New value"); - } + new Button("Update all labels", event -> { + Iterator<Component> componentIterator = contentLayout + .getComponentIterator(); + while (componentIterator.hasNext()) { + + Iterator<Component> columHolderIterator; + Component child = componentIterator.next(); + if (child instanceof Panel) { + columHolderIterator = ((ComponentContainer) ((Panel) child) + .getContent()).getComponentIterator(); + } else { + columHolderIterator = ((ComponentContainer) child) + .getComponentIterator(); + } + while (columHolderIterator.hasNext()) { + VerticalLayout column = (VerticalLayout) columHolderIterator + .next(); + Iterator<Component> columnIterator = column + .getComponentIterator(); + while (columnIterator.hasNext()) { + Label label = (Label) columnIterator.next(); + label.setValue("New value"); } } - updatePerformanceReporting("Update labels", 100, 100); } + updatePerformanceReporting("Update labels", 100, 100); })); leftBar.addComponent( - new Button("Update one label", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Component child = contentLayout.getComponent(0); - if (child instanceof Panel) { - Panel panel = (Panel) child; - child = panel.getContent(); - } + new Button("Update one label", event -> { + Component child = contentLayout.getComponent(0); + if (child instanceof Panel) { + Panel panel = (Panel) child; + child = panel.getContent(); + } - AbstractOrderedLayout layout = (AbstractOrderedLayout) ((AbstractOrderedLayout) child) - .getComponent(0); - Label label = (Label) layout.getComponent(0); + AbstractOrderedLayout layout = (AbstractOrderedLayout) ((AbstractOrderedLayout) child) + .getComponent(0); + Label label = (Label) layout.getComponent(0); - label.setValue("New value " + updateOneCount++); + label.setValue("New value " + updateOneCount++); - updatePerformanceReporting("Update one", 10, 10); - } + updatePerformanceReporting("Update one", 10, 10); })); leftBar.addComponent( - new Button("Clear content", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - contentLayout.removeAllComponents(); - contentLayout.addComponent(new Label("No content")); - updatePerformanceReporting("No content", 100, 100); - } + new Button("Clear content", event -> { + contentLayout.removeAllComponents(); + contentLayout.addComponent(new Label("No content")); + updatePerformanceReporting("No content", 100, 100); })); HorizontalLayout intermediateLayout = new HorizontalLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/performance/ThreadMemoryLeaksTest.java b/uitest/src/main/java/com/vaadin/tests/performance/ThreadMemoryLeaksTest.java index 735f88da26..dcb8710b16 100644 --- a/uitest/src/main/java/com/vaadin/tests/performance/ThreadMemoryLeaksTest.java +++ b/uitest/src/main/java/com/vaadin/tests/performance/ThreadMemoryLeaksTest.java @@ -33,13 +33,10 @@ public class ThreadMemoryLeaksTest extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { label = new Label(String.format("%d workers", workers)); addComponent(label); - addComponent(new Button("Add worker", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - new Worker(); - workers++; - label.setValue(String.format("%d workers", workers)); - } + addComponent(new Button("Add worker", event -> { + new Worker(); + workers++; + label.setValue(String.format("%d workers", workers)); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java index 738315cc7f..1e526d3d43 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java +++ b/uitest/src/main/java/com/vaadin/tests/push/BarInUIDL.java @@ -20,8 +20,6 @@ import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; @Push(transport = Transport.STREAMING) @@ -35,13 +33,8 @@ public class BarInUIDL extends AbstractReindeerTestUI { */ @Override protected void setup(VaadinRequest request) { - addButton("Click Me", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addComponent(new Label("Thank you for clicking | bar")); - } - }); - + addButton("Click Me", event -> addComponent( + new Label("Thank you for clicking | bar"))); } /* diff --git a/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java b/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java index 5b807092c3..c973bba648 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java +++ b/uitest/src/main/java/com/vaadin/tests/push/BasicPush.java @@ -23,7 +23,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @@ -60,13 +59,9 @@ public class BasicPush extends AbstractReindeerTestUI { addComponent(lbl); Button incrementButton = new Button("Increment", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - clientCounter++; - lbl.setValue(String.valueOf(clientCounter)); - } + event -> { + clientCounter++; + lbl.setValue(String.valueOf(clientCounter)); }); incrementButton.setId(INCREMENT_BUTTON_ID); addComponent(incrementButton); @@ -104,13 +99,10 @@ public class BasicPush extends AbstractReindeerTestUI { startTimer.setId(START_TIMER_ID); addComponent(startTimer); - Button stopTimer = new Button("Stop timer", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (task != null) { - task.cancel(); - task = null; - } + Button stopTimer = new Button("Stop timer", event -> { + if (task != null) { + task.cancel(); + task = null; } }); stopTimer.setId(STOP_TIMER_ID); diff --git a/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java index cf7c1eba80..3202e86bf9 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java +++ b/uitest/src/main/java/com/vaadin/tests/push/EnableDisablePush.java @@ -29,17 +29,14 @@ public class EnableDisablePush extends AbstractReindeerTestUI { while (true) { TimeUnit.MILLISECONDS.sleep(500); - access(new Runnable() { - @Override - public void run() { - log.log("Counter = " + c++); - if (c == 3) { - log.log("Disabling polling, enabling push"); - getPushConfiguration() - .setPushMode(PushMode.AUTOMATIC); - setPollInterval(-1); - log.log("Polling disabled, push enabled"); - } + access(() -> { + log.log("Counter = " + c++); + if (c == 3) { + log.log("Disabling polling, enabling push"); + getPushConfiguration() + .setPushMode(PushMode.AUTOMATIC); + setPollInterval(-1); + log.log("Polling disabled, push enabled"); } }); if (c == 3) { @@ -58,54 +55,39 @@ public class EnableDisablePush extends AbstractReindeerTestUI { getPushConfiguration().setPushMode(PushMode.AUTOMATIC); log.log("Push enabled"); - addComponent(new Button("Disable push", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - log.log("Disabling push"); - getPushConfiguration().setPushMode(PushMode.DISABLED); - log.log("Push disabled"); - } + addComponent(new Button("Disable push", event -> { + log.log("Disabling push"); + getPushConfiguration().setPushMode(PushMode.DISABLED); + log.log("Push disabled"); })); - addComponent(new Button("Enable push", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - log.log("Enabling push"); - getPushConfiguration().setPushMode(PushMode.AUTOMATIC); - log.log("Push enabled"); - } + addComponent(new Button("Enable push", event -> { + log.log("Enabling push"); + getPushConfiguration().setPushMode(PushMode.AUTOMATIC); + log.log("Push enabled"); })); - addComponent(new Button("Disable polling", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - log.log("Disabling poll"); - setPollInterval(-1); - log.log("Poll disabled"); - } + addComponent(new Button("Disable polling", even -> { + log.log("Disabling poll"); + setPollInterval(-1); + log.log("Poll disabled"); })); - addComponent(new Button("Enable polling", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - log.log("Enabling poll"); - setPollInterval(1000); - log.log("Poll enabled"); - } + addComponent(new Button("Enable polling", event -> { + log.log("Enabling poll"); + setPollInterval(1000); + log.log("Poll enabled"); })); addComponent( new Button("Disable push, re-enable from background thread", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - log.log("Disabling push, enabling polling"); - getPushConfiguration() - .setPushMode(PushMode.DISABLED); - setPollInterval(1000); - timer.schedule(new CounterTask(), new Date()); - log.log("Push disabled, polling enabled"); - } + event -> { + log.log("Disabling push, enabling polling"); + getPushConfiguration() + .setPushMode(PushMode.DISABLED); + setPollInterval(1000); + timer.schedule(new CounterTask(), new Date()); + log.log("Push disabled, polling enabled"); })); addComponent(log); diff --git a/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java b/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java index 3908c7a48b..fcc4b5d018 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java +++ b/uitest/src/main/java/com/vaadin/tests/push/ManualLongPollingPushUI.java @@ -24,7 +24,6 @@ import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.ui.Transport; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; @Push(value = PushMode.MANUAL, transport = Transport.LONG_POLLING) public class ManualLongPollingPushUI extends AbstractTestUIWithLog { @@ -34,61 +33,38 @@ public class ManualLongPollingPushUI extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { Button b = new Button("Manual push after 1s", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - executor.submit(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - access(new Runnable() { - - @Override - public void run() { - log("Logged after 1s, followed by manual push"); - push(); - } - }); - - } + event -> { + executor.submit(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + access(() -> { + log("Logged after 1s, followed by manual push"); + push(); }); - } + }); }); addComponent(b); b = new Button("Double manual push after 1s", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - executor.submit(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - access(new Runnable() { - - @Override - public void run() { - log("First message logged after 1s, followed by manual push"); - push(); - log("Second message logged after 1s, followed by manual push"); - push(); - } - }); - - } + event -> { + executor.submit(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + access(() -> { + log("First message logged after 1s, followed by manual push"); + push(); + log("Second message logged after 1s, followed by manual push"); + push(); }); - } + }); }); addComponent(b); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java b/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java index b4a23ba5d5..3367859fe1 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushConfiguration.java @@ -23,7 +23,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; public class PushConfiguration extends AbstractReindeerTestUI { @@ -36,12 +35,9 @@ public class PushConfiguration extends AbstractReindeerTestUI { @Override public void run() { - access(new Runnable() { - @Override - public void run() { - counter2++; - serverCounterLabel.setValue("" + counter2); - } + access(() -> { + counter2++; + serverCounterLabel.setValue("" + counter2); }); } }; @@ -60,13 +56,8 @@ public class PushConfiguration extends AbstractReindeerTestUI { .setCaption("Client counter (click 'increment' to update):"); addComponent(clientCounterLabel); - addComponent(new Button("Increment", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - clientCounterLabel.setValue("" + counter++); - } - })); + addComponent(new Button("Increment", + event -> clientCounterLabel.setValue("" + counter++))); spacer(); @@ -75,13 +66,9 @@ public class PushConfiguration extends AbstractReindeerTestUI { "Server counter (updates each 1s by server thread) :"); addComponent(serverCounterLabel); - addComponent(new Button("Reset", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - counter2 = 0; - serverCounterLabel.setValue("0"); - } + addComponent(new Button("Reset", event ->{ + counter2 = 0; + serverCounterLabel.setValue("0"); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java b/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java index 34c4449556..63a380b991 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushConfigurator.java @@ -28,15 +28,11 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.ui.Transport; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PushConfiguration; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.TextField; @@ -111,41 +107,28 @@ public class PushConfigurator extends VerticalLayout { * @since */ private void listeners() { - pushMode.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - ui.getPushConfiguration() - .setPushMode((PushMode) pushMode.getValue()); - refreshStatus(); - } + pushMode.addValueChangeListener(event -> { + ui.getPushConfiguration() + .setPushMode((PushMode) pushMode.getValue()); + refreshStatus(); }); - transport.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Transport t = (Transport) transport.getValue(); - ui.getPushConfiguration().setTransport(t); - refreshStatus(); - } + transport.addValueChangeListener(event -> { + Transport t = (Transport) transport.getValue(); + ui.getPushConfiguration().setTransport(t); + refreshStatus(); }); - fallbackTransport.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Transport t = (Transport) fallbackTransport.getValue(); - ui.getPushConfiguration().setFallbackTransport(t); - refreshStatus(); - } + fallbackTransport.addValueChangeListener(event -> { + Transport t = (Transport) fallbackTransport.getValue(); + ui.getPushConfiguration().setFallbackTransport(t); + refreshStatus(); }); - set.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ui.getPushConfiguration().setParameter(parameter.getValue(), - value.getValue()); - refreshStatus(); - } + set.addClickListener(event -> { + ui.getPushConfiguration().setParameter(parameter.getValue(), + value.getValue()); + refreshStatus(); }); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java index 82b922db37..a94c3c0698 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java @@ -12,8 +12,6 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.v7.data.util.AbstractInMemoryContainer; import com.vaadin.v7.data.util.BeanContainer; -import com.vaadin.v7.event.ItemClickEvent; -import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.ui.Table; public class PushErrorHandling extends AbstractReindeerTestUI { @@ -43,36 +41,29 @@ public class PushErrorHandling extends AbstractReindeerTestUI { view.setImmediate(true); view.setSizeFull(); - view.addItemClickListener(new ItemClickListener() { + view.addItemClickListener(event -> { + BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>> metaContainer = new BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>>( + AbstractInMemoryContainer.class) { + @Override + public Collection<String> getContainerPropertyIds() { + List<String> cpropIds = new ArrayList<>( + super.getContainerPropertyIds()); + cpropIds.add("testid"); + return cpropIds; + } - @Override - public void itemClick(ItemClickEvent event) { - BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>> metaContainer - = new BeanContainer<String, AbstractInMemoryContainer<?, ?, ?>>( - AbstractInMemoryContainer.class) { - @Override - public Collection<String> getContainerPropertyIds() { - List<String> cpropIds = new ArrayList<>( - super.getContainerPropertyIds()); - cpropIds.add("testid"); - return cpropIds; - } - - @Override - public Class<?> getType(Object propertyId) { - ((Object) null).hashCode(); - return super.getType(propertyId); - } - }; - view.setContainerDataSource(metaContainer); - - } + @Override + public Class<?> getType(Object propertyId) { + ((Object) null).hashCode(); + return super.getType(propertyId); + } + }; + view.setContainerDataSource(metaContainer); }); view.addContainerProperty("Column", String.class, "Click for NPE"); view.addItem(new Object()); addComponent(view); - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java b/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java index b7ce646526..30de763aa4 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushFromInit.java @@ -43,12 +43,7 @@ public class PushFromInit extends AbstractTestUIWithLog { class RunBeforeInitEnds implements Runnable { @Override public void run() { - access(new Runnable() { - @Override - public void run() { - log(LOG_DURING_INIT); - } - }); + access(() -> log(LOG_DURING_INIT)); } } @@ -60,12 +55,7 @@ public class PushFromInit extends AbstractTestUIWithLog { } catch (InterruptedException e) { e.printStackTrace(); } - access(new Runnable() { - @Override - public void run() { - log(LOG_AFTER_INIT); - } - }); + access(() -> log(LOG_AFTER_INIT)); } } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java b/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java index 8617d8f88d..c8d3e4b79a 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushLargeData.java @@ -26,8 +26,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.UI; import com.vaadin.v7.ui.TextField; @@ -77,20 +75,15 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { Button b = new Button("Start pushing"); b.setId("startButton"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Integer pushSize = (Integer) dataSize.getConvertedValue(); - Integer pushInterval = (Integer) interval.getConvertedValue(); - Integer pushDuration = (Integer) duration.getConvertedValue(); - PushRunnable r = new PushRunnable(getUI(), pushSize, - pushInterval, pushDuration); - executor.execute(r); - log.log("Starting push, size: " + pushSize + ", interval: " - + pushInterval + "ms, duration: " + pushDuration - + "ms"); - } + b.addClickListener(event -> { + Integer pushSize = (Integer) dataSize.getConvertedValue(); + Integer pushInterval = (Integer) interval.getConvertedValue(); + Integer pushDuration = (Integer) duration.getConvertedValue(); + PushRunnable r = new PushRunnable(getUI(), pushSize, pushInterval, + pushDuration); + executor.execute(r); + log.log("Starting push, size: " + pushSize + ", interval: " + + pushInterval + "ms, duration: " + pushDuration + "ms"); }); addComponent(b); addComponent(dataLabel); @@ -132,16 +125,13 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { int packageIndex = 1; while (System.currentTimeMillis() < endTime) { final int idx = packageIndex++; - ui.access(new Runnable() { - @Override - public void run() { - PushLargeData pushUi = (PushLargeData) ui; - // Using description as it is not rendered to the DOM - // immediately - pushUi.getDataLabel().setDescription( - System.currentTimeMillis() + ": " + data); - pushUi.log("Package " + idx + " pushed"); - } + ui.access(() -> { + PushLargeData pushUi = (PushLargeData) ui; + // Using description as it is not rendered to the DOM + // immediately + pushUi.getDataLabel().setDescription( + System.currentTimeMillis() + ": " + data); + pushUi.log("Package " + idx + " pushed"); }); try { Thread.sleep(interval); @@ -149,12 +139,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { return; } } - ui.access(new Runnable() { - @Override - public void run() { - PushLargeData pushUi = (PushLargeData) ui; - pushUi.log("Push complete"); - } + ui.access(() -> { + PushLargeData pushUi = (PushLargeData) ui; + pushUi.log("Push complete"); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java index ff2389b5a4..b8163e09c8 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java @@ -1,15 +1,11 @@ package com.vaadin.tests.push; import com.vaadin.annotations.Push; -import com.vaadin.server.SessionDestroyEvent; -import com.vaadin.server.SessionDestroyListener; import com.vaadin.server.VaadinRequest; import com.vaadin.server.WrappedSession; import com.vaadin.shared.ui.ui.Transport; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @Push(transport = Transport.WEBSOCKET) @@ -35,85 +31,58 @@ public class PushWebsocketDeadlockUI extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { WrappedSession wrappedSession = getSession().getSession(); request.getService() - .addSessionDestroyListener(new SessionDestroyListener() { - @Override - public void sessionDestroy(SessionDestroyEvent e) { - System.out.println( - "Session " + e.getSession() + " destroyed"); - } - }); + .addSessionDestroyListener(event -> System.out.println( + "Session " + event.getSession() + " destroyed")); final Label l = new Label("Session timeout is " + wrappedSession.getMaxInactiveInterval() + "s"); addComponents(l); Button button = new Button("Invalidate session"); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent e) { - System.out.println( - "invalidating " + getSession() + " for http session " - + getSession().getSession().getId()); - getSession().getSession().invalidate(); - System.out.println("invalidated " + getSession()); - } + button.addClickListener(event -> { + System.out.println("invalidating " + getSession() + + " for http session " + getSession().getSession().getId()); + getSession().getSession().invalidate(); + System.out.println("invalidated " + getSession()); }); addComponents(button); button = new Button("Close UI"); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent e) { - System.out.println("closing UI " + getUIId() + " in session " - + getSession() + " for http session " - + getSession().getSession().getId()); - close(); - } + button.addClickListener(event -> { + System.out.println("closing UI " + getUIId() + " in session " + + getSession() + " for http session " + + getSession().getSession().getId()); + close(); }); addComponents(button); button = new Button("Schedule Close UI (5s delay)"); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent e) { - new Thread(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - // Breakpoint here - access(new Runnable() { - @Override - public void run() { - close(); - System.out.println("closing UI " + getUIId() - + " in session " + getSession() - + " for http session " - + getSession().getSession().getId()); - - } - }); - - } - }).start(); - } - }); - addComponents(button); - button = new Button("Slow (5s) operation"); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent e) { + button.addClickListener(event -> { + new Thread(() -> { try { Thread.sleep(5000); - } catch (InterruptedException e1) { - e1.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } - addComponent(new Label("Slow operation done")); + // Breakpoint here + access(() -> { + close(); + System.out + .println("closing UI " + getUIId() + " in session " + + getSession() + " for http session " + + getSession().getSession().getId()); + }); + }).start(); + }); + addComponents(button); + button = new Button("Slow (5s) operation"); + button.addClickListener(event -> { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); } + addComponent(new Label("Slow operation done")); }); addComponents(button); - } } diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java b/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java index f7d36980c0..a9b688626a 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushWithPreserveOnRefresh.java @@ -5,8 +5,6 @@ import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.util.Log; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @PreserveOnRefresh @@ -23,13 +21,8 @@ public class PushWithPreserveOnRefresh extends AbstractReindeerTestUI { addComponent(new Label("UI id: " + getUIId())); addComponent(log); - addButton("click me", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log.log("Button has been clicked " + (++times) + " times"); - } - }); + addButton("click me", event -> log + .log("Button has been clicked " + (++times) + " times")); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java b/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java index 1bfc95254b..74b0711eb2 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java +++ b/uitest/src/main/java/com/vaadin/tests/push/RefreshCloseConnection.java @@ -38,12 +38,7 @@ public class RefreshCloseConnection extends AbstractTestUIWithLog { new Thread() { @Override public void run() { - accessSynchronously(new Runnable() { - @Override - public void run() { - log("Push"); - } - }); + accessSynchronously(() -> log("Push")); } }.start(); } diff --git a/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java b/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java index 72119a18a6..31bb2f34bf 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java +++ b/uitest/src/main/java/com/vaadin/tests/push/RoundTripTest.java @@ -21,8 +21,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.RoundTripTester; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.v7.ui.TextField; @Widgetset(TestingWidgetSet.NAME) @@ -47,15 +45,9 @@ public class RoundTripTest extends AbstractReindeerTestUI { } Button start = new Button("Start test"); - start.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - roundTripTester.start( - (Integer) testDuration.getConvertedValue(), - (Integer) payloadSize.getConvertedValue()); - } - }); + start.addClickListener(event -> roundTripTester.start( + (Integer) testDuration.getConvertedValue(), + (Integer) payloadSize.getConvertedValue())); addComponent(roundTripTester); addComponent(start); diff --git a/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java b/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java index f27845e478..37b893bcd4 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java +++ b/uitest/src/main/java/com/vaadin/tests/push/TablePushStreaming.java @@ -49,26 +49,17 @@ public class TablePushStreaming extends AbstractReindeerTestUI { final Table t = new Table("The table"); t.setContainerDataSource(generateContainer(10, 10, iteration++)); t.setSizeFull(); - Runnable r = new Runnable() { - - @Override - public void run() { - for (int i = 0; i < 99; i++) { - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - access(new Runnable() { - - @Override - public void run() { - t.setContainerDataSource(generateContainer( - t.getVisibleColumns().length, t.size(), - iteration++)); - } - }); + Runnable r = () -> { + for (int i = 0; i < 99; i++) { + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); } + access(() -> + t.setContainerDataSource( + generateContainer(t.getVisibleColumns().length, + t.size(), iteration++))); } }; Thread tr = new Thread(r); diff --git a/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java b/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java index bd022cae76..2a7c6bd163 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java +++ b/uitest/src/main/java/com/vaadin/tests/push/TogglePush.java @@ -22,7 +22,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.shared.communication.PushMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; @@ -52,29 +51,16 @@ public class TogglePush extends AbstractReindeerTestUI { addComponent(pushSetting); addComponent( - new Button("Update counter now", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - updateCounter(); - } - })); + new Button("Update counter now", event -> updateCounter())); addComponent(new Button("Update counter in 1 sec", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - new Timer().schedule(new TimerTask() { - @Override - public void run() { - access(new Runnable() { - @Override - public void run() { - updateCounter(); - } - }); - } - }, 1000); - } + event -> { + new Timer().schedule(new TimerTask() { + @Override + public void run() { + access(() -> updateCounter()); + } + }, 1000); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/requesthandlers/CommunicationError.java b/uitest/src/main/java/com/vaadin/tests/requesthandlers/CommunicationError.java index 9af80625cf..1ca6ca52cc 100644 --- a/uitest/src/main/java/com/vaadin/tests/requesthandlers/CommunicationError.java +++ b/uitest/src/main/java/com/vaadin/tests/requesthandlers/CommunicationError.java @@ -28,7 +28,6 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServletRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -68,21 +67,17 @@ public class CommunicationError extends UIProvider { @Override protected void setup(VaadinRequest request) { Button button = new Button("Send bad request", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - try { - // An unparseable response will cause - // communication error - PrintWriter writer = VaadinService - .getCurrentResponse().getWriter(); - writer.write("for(;;)[{FOOBAR}]"); - writer.flush(); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } + event -> { + try { + // An unparseable response will cause + // communication error + PrintWriter writer = VaadinService + .getCurrentResponse().getWriter(); + writer.write("for(;;)[{FOOBAR}]"); + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); } }); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java b/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java index 142ab9c9a7..a41f13def5 100644 --- a/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java +++ b/uitest/src/main/java/com/vaadin/tests/resources/DownloadLargeFileResource.java @@ -8,7 +8,6 @@ import java.io.IOException; import com.vaadin.server.FileResource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class DownloadLargeFileResource extends TestBase { @@ -19,13 +18,7 @@ public class DownloadLargeFileResource extends TestBase { protected void setup() { Button b = new Button("Download a " + String.format("%.1f", fileSize / 1024.0 / 1024.0) + "MB file", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - download(); - } - }); + event -> download()); addComponent(b); } @@ -35,7 +28,6 @@ public class DownloadLargeFileResource extends TestBase { } getMainWindow().open(hugeFileResource); - } private void createFile() { diff --git a/uitest/src/main/java/com/vaadin/tests/resources/DownloadWithPush.java b/uitest/src/main/java/com/vaadin/tests/resources/DownloadWithPush.java index 6f2e39d2ac..13bb890d9b 100644 --- a/uitest/src/main/java/com/vaadin/tests/resources/DownloadWithPush.java +++ b/uitest/src/main/java/com/vaadin/tests/resources/DownloadWithPush.java @@ -7,11 +7,9 @@ import com.vaadin.annotations.Push; import com.vaadin.server.DownloadStream; import com.vaadin.server.Resource; import com.vaadin.server.StreamResource; -import com.vaadin.server.StreamResource.StreamSource; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; @Push public class DownloadWithPush extends AbstractTestUIWithLog { @@ -66,22 +64,13 @@ public class DownloadWithPush extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { Button b = new Button("Download a " + String.format("%.1f", fileSize / 1024.0 / 1024.0) + "MB file", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getUI().getPage().open(hugeFileResource, "", false); - } - }); + event -> getUI().getPage().open(hugeFileResource, "", false)); addComponent(b); } private Resource createResource() { - Resource hugeFileResource = new DownloadResoure(new StreamSource() { - @Override - public InputStream getStream() { - return new GeneratedStream(fileSize); - } - }, "hugefile.txt"); + Resource hugeFileResource = new DownloadResoure( + () -> new GeneratedStream(fileSize), "hugefile.txt"); return hugeFileResource; } diff --git a/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java b/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java index 81aa197a48..3b87334b47 100644 --- a/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java +++ b/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java @@ -6,7 +6,6 @@ import com.vaadin.server.FileResource; import com.vaadin.server.VaadinService; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class NonExistingFileResource extends TestBase { @@ -21,16 +20,11 @@ public class NonExistingFileResource extends TestBase { private Button createButton(final String filename) { Button b = new Button("Download " + filename); - b.addClickListener(new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - FileResource res = new FileResource( - new File(VaadinService.getCurrent().getBaseDirectory() - + "/" + filename)); - getMainWindow().open(res); - - } + b.addClickListener(event -> { + FileResource res = new FileResource( + new File(VaadinService.getCurrent().getBaseDirectory() + "/" + + filename)); + getMainWindow().open(res); }); return b; } diff --git a/uitest/src/main/java/com/vaadin/tests/resources/ResourceDownload.java b/uitest/src/main/java/com/vaadin/tests/resources/ResourceDownload.java index e7b652d8d1..c97856e2fa 100644 --- a/uitest/src/main/java/com/vaadin/tests/resources/ResourceDownload.java +++ b/uitest/src/main/java/com/vaadin/tests/resources/ResourceDownload.java @@ -8,54 +8,26 @@ import com.vaadin.server.StreamResource; import com.vaadin.server.StreamResource.StreamSource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; public class ResourceDownload extends TestBase { @Override public void setup() { - Button b = new Button("Download (_new)", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - download("_new"); - } - }); + Button b = new Button("Download (_new)", event -> download("_new")); addComponent(b); - b = new Button("Download (_blank)", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - download("_blank"); - } - }); + b = new Button("Download (_blank)", event -> download("_blank")); addComponent(b); - b = new Button("Download ()", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - download(""); - } - }); + b = new Button("Download ()", event -> download("")); addComponent(b); - b = new Button("Download (_top)", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - download("_top"); - } - }); + b = new Button("Download (_top)", event -> download("_top")); addComponent(b); - b = new Button("Test", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ResourceDownload.this.getMainWindow() - .showNotification("Still working"); - } - - }); + b = new Button("Test", event -> ResourceDownload.this.getMainWindow() + .showNotification("Still working")); addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/rpclogger/RPCLoggerUI.java b/uitest/src/main/java/com/vaadin/tests/rpclogger/RPCLoggerUI.java index eb43486eb6..0d7a4ea8e7 100644 --- a/uitest/src/main/java/com/vaadin/tests/rpclogger/RPCLoggerUI.java +++ b/uitest/src/main/java/com/vaadin/tests/rpclogger/RPCLoggerUI.java @@ -28,8 +28,6 @@ import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.ui.Notification.Type; import com.vaadin.v7.ui.ListSelect; @@ -63,12 +61,8 @@ public class RPCLoggerUI extends AbstractTestUIWithLog implements ErrorHandler { s.addItem("bar"); addComponent(s); - addComponent(new Button("Action, which will fail", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - throw new RuntimeException("Something went wrong"); - } + addComponent(new Button("Action, which will fail", event -> { + throw new RuntimeException("Something went wrong"); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/serialization/ChangeStateWhenReattaching.java b/uitest/src/main/java/com/vaadin/tests/serialization/ChangeStateWhenReattaching.java index 6d8f95bcb3..be7a8d6448 100644 --- a/uitest/src/main/java/com/vaadin/tests/serialization/ChangeStateWhenReattaching.java +++ b/uitest/src/main/java/com/vaadin/tests/serialization/ChangeStateWhenReattaching.java @@ -19,21 +19,17 @@ package com.vaadin.tests.serialization; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class ChangeStateWhenReattaching extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { Button button = new Button("Reattach and remove caption", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Button button = event.getButton(); - removeComponent(button); - addComponent(button); - button.setCaption(null); - } + event -> { + Button b = event.getButton(); + removeComponent(b); + addComponent(b); + b.setCaption(null); }); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/serialization/EncodeResultDisplay.java b/uitest/src/main/java/com/vaadin/tests/serialization/EncodeResultDisplay.java index 8b939564b5..2beafec9d5 100644 --- a/uitest/src/main/java/com/vaadin/tests/serialization/EncodeResultDisplay.java +++ b/uitest/src/main/java/com/vaadin/tests/serialization/EncodeResultDisplay.java @@ -21,7 +21,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.client.EncoderResultDisplayConnector; -import com.vaadin.tests.widgetset.client.EncoderResultDisplayConnector.ReportRpc; @Widgetset(TestingWidgetSet.NAME) public class EncodeResultDisplay extends AbstractTestUIWithLog { @@ -41,12 +40,9 @@ public class EncodeResultDisplay extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { log.setNumberLogRows(false); - new EncoderResultDisplayExtension(new ReportRpc() { - @Override - public void report(String name, String encodedValue) { - log(name + ": " + encodedValue); - } - }).extend(this); + new EncoderResultDisplayExtension( + (name, encodedValue) -> log(name + ": " + encodedValue)) + .extend(this); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/serialization/NoLayout.java b/uitest/src/main/java/com/vaadin/tests/serialization/NoLayout.java index 4aefc15665..dcf4bf2e6c 100644 --- a/uitest/src/main/java/com/vaadin/tests/serialization/NoLayout.java +++ b/uitest/src/main/java/com/vaadin/tests/serialization/NoLayout.java @@ -21,7 +21,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.LayoutDetector; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.JavaScript; @@ -44,42 +43,22 @@ public class NoLayout extends AbstractReindeerTestUI { addComponent(uiPolling); addComponent( - new Button("Change regular state", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - event.getButton().setCaption( - String.valueOf(System.currentTimeMillis())); - } - })); + new Button("Change regular state", + event -> event.getButton().setCaption( + String.valueOf(System.currentTimeMillis())))); addComponent(new Button("Change @NoLayout state", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - event.getButton().setDescription( - String.valueOf(System.currentTimeMillis())); - } - })); - addComponent(new Button("Do regular RPC", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - JavaScript.eval(""); - } - })); + event -> event.getButton().setDescription( + String.valueOf(System.currentTimeMillis())))); + addComponent( + new Button("Do regular RPC", event -> JavaScript.eval(""))); - addComponent(new Button("Do @NoLayout RPC", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - layoutDetector.doNoLayoutRpc(); - } - })); + addComponent(new Button("Do @NoLayout RPC", + event -> layoutDetector.doNoLayoutRpc())); addComponent(new Button("Update LegacyComponent", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - // Assumes UI is a LegacyComponent - markAsDirty(); - } + event -> { + // Assumes UI is a LegacyComponent + markAsDirty(); })); } diff --git a/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java b/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java index ebca101d08..c6bd024e14 100644 --- a/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java +++ b/uitest/src/main/java/com/vaadin/tests/smoke/GridSmoke.java @@ -18,7 +18,6 @@ package com.vaadin.tests.smoke; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.Grid.SelectionMode; @@ -37,13 +36,8 @@ public class GridSmoke extends AbstractReindeerTestUI { addComponent(grid); - addComponent(new Button("Add new row", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.addRow("Dolor", Integer.valueOf(3)); - } - })); - + addComponent(new Button("Add new row", + event -> grid.addRow("Dolor", Integer.valueOf(3)))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java index 5c42c445c0..cc0e8ef619 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java @@ -5,7 +5,6 @@ import java.util.Locale; import com.vaadin.server.ThemeResource; import com.vaadin.server.UserError; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; @@ -102,12 +101,8 @@ public class ButtonsTest extends com.vaadin.server.LegacyApplication { b.setTabIndex(1); main.addComponent(b); - Button c = new Button("toggle enabled", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - b.setEnabled(!b.isEnabled()); - } - }); + Button c = new Button("toggle enabled", + event -> b.setEnabled(!b.isEnabled())); main.addComponent(c); } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/CSSInjectTest.java b/uitest/src/main/java/com/vaadin/tests/themes/CSSInjectTest.java index 4d0891a2d5..8ed4ad92c3 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/CSSInjectTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/CSSInjectTest.java @@ -10,7 +10,6 @@ import com.vaadin.server.StreamResource; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.v7.ui.TextArea; @@ -42,46 +41,33 @@ public class CSSInjectTest extends TestBase { cssToInject.setImmediate(true); addComponent(cssToInject); - Button inject = new Button("Inject!", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - stylesheet.add(cssToInject.getValue()); - cssToInject.setValue(""); - } + Button inject = new Button("Inject!", event -> { + stylesheet.add(cssToInject.getValue()); + cssToInject.setValue(""); }); addComponent(inject); Button injectRandom = new Button("Inject as resource!", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - - final String css = cssToInject.getValue(); + event -> { + final String css = cssToInject.getValue(); - stylesheet.add(new StreamResource( - new StreamResource.StreamSource() { + stylesheet.add(new StreamResource( + new StreamResource.StreamSource() { - @Override - public InputStream getStream() { - return new ByteArrayInputStream( - css.getBytes()); - } - }, UUID.randomUUID() + ".css")); + @Override + public InputStream getStream() { + return new ByteArrayInputStream( + css.getBytes()); + } + }, UUID.randomUUID() + ".css")); - cssToInject.setValue(""); - } + cssToInject.setValue(""); }); addComponent(injectRandom); addComponent( - new Button("Inject initial again!", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - stylesheet.add(initialResource); - } - })); + new Button("Inject initial again!", + event -> stylesheet.add(initialResource))); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/themes/LegacyComponentThemeChange.java b/uitest/src/main/java/com/vaadin/tests/themes/LegacyComponentThemeChange.java index d289787adf..bf0903b67b 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/LegacyComponentThemeChange.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/LegacyComponentThemeChange.java @@ -23,8 +23,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.util.PersonContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.MenuBar; @@ -44,13 +42,7 @@ public class LegacyComponentThemeChange extends AbstractTestUIWithLog { for (final String theme : new String[] { "reindeer", "runo" }) { Button b = new Button(theme); b.setId(theme + ""); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getUI().setTheme(theme); - } - }); + b.addClickListener(event -> getUI().setTheme(theme)); hl.addComponent(b); } vl.addComponent(hl); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeFavicon.java b/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeFavicon.java index 417081f40e..41973f90e3 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeFavicon.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeFavicon.java @@ -20,19 +20,13 @@ import java.util.Arrays; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; public class ThemeChangeFavicon extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { for (final String theme : Arrays.asList("valo", "reindeer")) { - addComponent(new Button(theme, new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - setTheme(theme); - } - })); + addComponent(new Button(theme, event -> setTheme(theme))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeOnTheFly.java b/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeOnTheFly.java index 7e41e535fd..d74090b64b 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeOnTheFly.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/ThemeChangeOnTheFly.java @@ -21,8 +21,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.util.PersonContainer; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Image; @@ -36,15 +34,8 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - addButton("Inject blue background", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getPage().getStyles() - .add(".v-app { background: blue !important;}"); - - } - }); + addButton("Inject blue background", event -> getPage().getStyles() + .add(".v-app { background: blue !important;}")); GridLayout gl = new GridLayout(2, 4); gl.setCaption("Change theme by clicking a button"); @@ -52,13 +43,7 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog { "chameleon", "base", null }) { Button b = new Button(theme); b.setId(theme + ""); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getUI().setTheme(theme); - } - }); + b.addClickListener(event -> getUI().setTheme(theme)); gl.addComponent(b); } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/chameleon/ChameleonNotification.java b/uitest/src/main/java/com/vaadin/tests/themes/chameleon/ChameleonNotification.java index ee626ef5f0..3ad348962f 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/chameleon/ChameleonNotification.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/chameleon/ChameleonNotification.java @@ -3,7 +3,6 @@ package com.vaadin.tests.themes.chameleon; import com.vaadin.annotations.Theme; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.Notification; import com.vaadin.v7.ui.themes.ChameleonTheme; @@ -12,13 +11,10 @@ public class ChameleonNotification extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - addButton("Notification", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - Notification notification = new Notification("Notification"); - notification.setDelayMsec(30000); - notification.show(getUI().getPage()); - } + addButton("Notification", event -> { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(30000); + notification.show(getUI().getPage()); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java index 9d735ad2e2..d3ba3f2588 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java @@ -12,8 +12,6 @@ import com.vaadin.data.ValidationException; import com.vaadin.navigator.View; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.CssLayout; import com.vaadin.ui.FormLayout; @@ -25,8 +23,6 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.themes.ValoTheme; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.fieldgroup.FieldGroup; import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException; import com.vaadin.v7.data.util.BeanItem; @@ -334,62 +330,28 @@ public class CalendarTest extends GridLayout implements View { } private void initNavigationButtons() { - monthButton = new Button("Month", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - switchToMonthView(); - } - }); - - weekButton = new Button("Week", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - // simulate week click - WeekClickHandler handler = (WeekClickHandler) calendarComponent - .getHandler(WeekClick.EVENT_ID); - handler.weekClick(new WeekClick(calendarComponent, - calendar.get(GregorianCalendar.WEEK_OF_YEAR), - calendar.get(GregorianCalendar.YEAR))); - } - }); - - dayButton = new Button("Day", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - // simulate day click - BasicDateClickHandler handler = (BasicDateClickHandler) calendarComponent - .getHandler(DateClickEvent.EVENT_ID); - handler.dateClick(new DateClickEvent(calendarComponent, - calendar.getTime())); - } + monthButton = new Button("Month", event -> switchToMonthView()); + + weekButton = new Button("Week", event -> { + // simulate week click + WeekClickHandler handler = (WeekClickHandler) calendarComponent + .getHandler(WeekClick.EVENT_ID); + handler.weekClick(new WeekClick(calendarComponent, + calendar.get(GregorianCalendar.WEEK_OF_YEAR), + calendar.get(GregorianCalendar.YEAR))); }); - nextButton = new Button("Next", new Button.ClickListener() { - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - handleNextButtonClick(); - } + dayButton = new Button("Day", event -> { + // simulate day click + BasicDateClickHandler handler = (BasicDateClickHandler) calendarComponent + .getHandler(DateClickEvent.EVENT_ID); + handler.dateClick( + new DateClickEvent(calendarComponent, calendar.getTime())); }); - prevButton = new Button("Prev", new Button.ClickListener() { - private static final long serialVersionUID = 1L; + nextButton = new Button("Next", event -> handleNextButtonClick()); - @Override - public void buttonClick(ClickEvent event) { - handlePreviousButtonClick(); - } - }); + prevButton = new Button("Prev", event -> handlePreviousButtonClick()); } private void initHideWeekEndButton() { @@ -425,21 +387,15 @@ public class CalendarTest extends GridLayout implements View { public void initAddNewEventButton() { addNewEvent = new Button("Add new event"); - addNewEvent.addClickListener(new Button.ClickListener() { + addNewEvent.addClickListener(event -> { + Date start = getToday(); + start.setHours(0); + start.setMinutes(0); + start.setSeconds(0); - private static final long serialVersionUID = -8307244759142541067L; + Date end = getEndOfDay(calendar, start); - @Override - public void buttonClick(ClickEvent event) { - Date start = getToday(); - start.setHours(0); - start.setMinutes(0); - start.setSeconds(0); - - Date end = getEndOfDay(calendar, start); - - showEventPopup(createNewEvent(start, end), true); - } + showEventPopup(createNewEvent(start, end), true); }); } @@ -666,16 +622,8 @@ public class CalendarTest extends GridLayout implements View { s.select(DEFAULT_ITEMID); } s.setImmediate(true); - s.addValueChangeListener(new ValueChangeListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void valueChange(ValueChangeEvent event) { - - updateCalendarTimeZone(event.getProperty().getValue()); - } - }); + s.addValueChangeListener(event -> updateCalendarTimeZone( + event.getProperty().getValue())); return s; } @@ -694,15 +642,8 @@ public class CalendarTest extends GridLayout implements View { s.select(DEFAULT_ITEMID); s.setImmediate(true); - s.addValueChangeListener(new ValueChangeListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void valueChange(ValueChangeEvent event) { - updateCalendarFormat(event.getProperty().getValue()); - } - }); + s.addValueChangeListener( + event -> updateCalendarFormat(event.getProperty().getValue())); return s; } @@ -722,15 +663,8 @@ public class CalendarTest extends GridLayout implements View { s.select(getLocale()); s.setImmediate(true); - s.addValueChangeListener(new ValueChangeListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void valueChange(ValueChangeEvent event) { - updateCalendarLocale((Locale) event.getProperty().getValue()); - } - }); + s.addValueChangeListener(event -> updateCalendarLocale( + (Locale) event.getProperty().getValue())); return s; } @@ -882,48 +816,19 @@ public class CalendarTest extends GridLayout implements View { scheduleEventFieldLayout.setMargin(false); layout.addComponent(scheduleEventFieldLayout); - applyEventButton = new Button("Apply", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - try { - commitCalendarEvent(); - } catch (CommitException | ValidationException e) { - e.printStackTrace(); - } + applyEventButton = new Button("Apply", event -> { + try { + commitCalendarEvent(); + } catch (CommitException | ValidationException e) { + e.printStackTrace(); } }); applyEventButton.addStyleName(ValoTheme.BUTTON_PRIMARY); - Button cancel = new Button("Cancel", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - discardCalendarEvent(); - } - }); - deleteEventButton = new Button("Delete", new ClickListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void buttonClick(ClickEvent event) { - deleteCalendarEvent(); - } - }); + Button cancel = new Button("Cancel", event -> discardCalendarEvent()); + deleteEventButton = new Button("Delete", + event -> deleteCalendarEvent()); deleteEventButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); - scheduleEventPopup.addCloseListener(new Window.CloseListener() { - - private static final long serialVersionUID = 1L; - - @Override - public void windowClose(Window.CloseEvent e) { - discardCalendarEvent(); - } - }); + scheduleEventPopup.addCloseListener(event -> discardCalendarEvent()); HorizontalLayout buttons = new HorizontalLayout(); buttons.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java index b5cb23a867..bf5d3986fe 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java @@ -29,8 +29,6 @@ import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.ErrorLevel; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; @@ -43,14 +41,10 @@ import com.vaadin.ui.MenuBar.MenuItem; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; -import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; -import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.themes.ValoTheme; public class CommonParts extends VerticalLayout implements View { @@ -85,37 +79,28 @@ public class CommonParts extends VerticalLayout implements View { group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); content.addComponent(group); Button loading = new Button("0.8"); - loading.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - Thread.sleep(800); - } catch (InterruptedException e) { - } + loading.addClickListener(event -> { + try { + Thread.sleep(800); + } catch (InterruptedException e) { } }); group.addComponent(loading); Button delay = new Button("3"); - delay.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - } + delay.addClickListener(event -> { + try { + Thread.sleep(3000); + } catch (InterruptedException e) { } }); group.addComponent(delay); Button wait = new Button("15"); - wait.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - Thread.sleep(15000); - } catch (InterruptedException e) { - } + wait.addClickListener(event -> { + try { + Thread.sleep(15000); + } catch (InterruptedException e) { } }); wait.addStyleName("last"); @@ -180,24 +165,20 @@ public class CommonParts extends VerticalLayout implements View { description.setWidth("100%"); addComponent(description); - Command typeCommand = new Command() { - @Override - public void menuSelected(MenuItem selectedItem) { - if (selectedItem.getText().equals("Humanized")) { - typeString = ""; - notification.setStyleName(styleString.trim()); - } else { - typeString = selectedItem.getText() - .toLowerCase(Locale.ROOT); - notification.setStyleName( - (typeString + " " + styleString.trim()) - .trim()); - } - for (MenuItem item : type.getItems()) { - item.setChecked(false); - } - selectedItem.setChecked(true); + Command typeCommand = selectedItem -> { + if (selectedItem.getText().equals("Humanized")) { + typeString = ""; + notification.setStyleName(styleString.trim()); + } else { + typeString = selectedItem.getText() + .toLowerCase(Locale.ROOT); + notification.setStyleName( + (typeString + " " + styleString.trim()).trim()); + } + for (MenuItem item : type.getItems()) { + item.setChecked(false); } + selectedItem.setChecked(true); }; type.setCaption("Type"); @@ -211,26 +192,22 @@ public class CommonParts extends VerticalLayout implements View { addComponent(type); type.addStyleName(ValoTheme.MENUBAR_SMALL); - Command styleCommand = new Command() { - @Override - public void menuSelected(MenuItem selectedItem) { - styleString = ""; - for (MenuItem item : style.getItems()) { - if (item.isChecked()) { - styleString += " " + item.getText() - .toLowerCase(Locale.ROOT); - } - } - if (!styleString.trim().isEmpty()) { - notification.setStyleName( - (typeString + " " + styleString.trim()) - .trim()); - } else if (!typeString.isEmpty()) { - notification.setStyleName(typeString.trim()); - } else { - notification.setStyleName(null); + Command styleCommand = selectedItem -> { + styleString = ""; + for (MenuItem item : style.getItems()) { + if (item.isChecked()) { + styleString += " " + + item.getText().toLowerCase(Locale.ROOT); } } + if (!styleString.trim().isEmpty()) { + notification.setStyleName( + (typeString + " " + styleString.trim()).trim()); + } else if (!typeString.isEmpty()) { + notification.setStyleName(typeString.trim()); + } else { + notification.setStyleName(null); + } }; style.setCaption("Additional style"); @@ -264,12 +241,7 @@ public class CommonParts extends VerticalLayout implements View { delay.setValue("1000"); group.addComponent(delay); - Button clear = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - delay.setValue(""); - } - }); + Button clear = new Button("", event -> delay.setValue("")); clear.setIcon(VaadinIcons.CLOSE_CIRCLE); clear.addStyleName("last"); clear.addStyleName(ValoTheme.BUTTON_SMALL); @@ -282,96 +254,68 @@ public class CommonParts extends VerticalLayout implements View { addComponent(grid); grid.setSpacing(true); - Button pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.TOP_LEFT); - notification.show(Page.getCurrent()); - } + Button pos = new Button("", event -> { + notification.setPosition(Position.TOP_LEFT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.TOP_CENTER); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.TOP_CENTER); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.TOP_RIGHT); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.TOP_RIGHT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.MIDDLE_LEFT); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.MIDDLE_LEFT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.MIDDLE_CENTER); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.MIDDLE_CENTER); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.MIDDLE_RIGHT); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.MIDDLE_RIGHT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.BOTTOM_LEFT); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.BOTTOM_LEFT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.BOTTOM_CENTER); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.BOTTOM_CENTER); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - notification.setPosition(Position.BOTTOM_RIGHT); - notification.show(Page.getCurrent()); - } + pos = new Button("", event -> { + notification.setPosition(Position.BOTTOM_RIGHT); + notification.show(Page.getCurrent()); }); pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - } }; p.setContent(content); @@ -489,15 +433,11 @@ public class CommonParts extends VerticalLayout implements View { "One more"); tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR); tabs.addSelectedTabChangeListener( - new SelectedTabChangeListener() { - @Override - public void selectedTabChange( - SelectedTabChangeEvent event) { - try { - Thread.sleep(600); - } catch (InterruptedException e) { - e.printStackTrace(); - } + event -> { + try { + Thread.sleep(600); + } catch (InterruptedException e) { + e.printStackTrace(); } }); content = tabs; @@ -570,48 +510,43 @@ public class CommonParts extends VerticalLayout implements View { win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); - Command optionsCommand = new Command() { - @Override - public void menuSelected(MenuItem selectedItem) { - if (selectedItem.getText().equals("Footer")) { - footerVisible = selectedItem.isChecked(); - } - if (selectedItem.getText().equals("Auto Height")) { - autoHeight = selectedItem.isChecked(); - if (!autoHeight) { - win.setHeight(prevHeight); - } else { - prevHeight = win.getHeight() - + win.getHeightUnits().toString(); - win.setHeight(null); - } - } - if (selectedItem.getText().equals("Tabs")) { - tabsVisible = selectedItem.isChecked(); - } - - if (selectedItem.getText().equals("Top Toolbar")) { - toolbarVisible = selectedItem.isChecked(); + Command optionsCommand = selectedItem -> { + if (selectedItem.getText().equals("Footer")) { + footerVisible = selectedItem.isChecked(); + } + if (selectedItem.getText().equals("Auto Height")) { + autoHeight = selectedItem.isChecked(); + if (!autoHeight) { + win.setHeight(prevHeight); + } else { + prevHeight = win.getHeight() + + win.getHeightUnits().toString(); + win.setHeight(null); } + } + if (selectedItem.getText().equals("Tabs")) { + tabsVisible = selectedItem.isChecked(); + } - if (selectedItem.getText().equals("Footer Toolbar")) { - footerToolbar = selectedItem.isChecked(); - } + if (selectedItem.getText().equals("Top Toolbar")) { + toolbarVisible = selectedItem.isChecked(); + } - if (selectedItem.getText() - .equals("Top Toolbar layout")) { - toolbarLayout = selectedItem.isChecked(); - } + if (selectedItem.getText().equals("Footer Toolbar")) { + footerToolbar = selectedItem.isChecked(); + } - if (selectedItem.getText() - .equals("Borderless Toolbars")) { - toolbarStyle = selectedItem.isChecked() - ? ValoTheme.MENUBAR_BORDERLESS - : null; - } + if (selectedItem.getText().equals("Top Toolbar layout")) { + toolbarLayout = selectedItem.isChecked(); + } - win.setContent(windowContent()); + if (selectedItem.getText().equals("Borderless Toolbars")) { + toolbarStyle = selectedItem.isChecked() + ? ValoTheme.MENUBAR_BORDERLESS + : null; } + + win.setContent(windowContent()); }; MenuBar options = new MenuBar(); @@ -638,20 +573,17 @@ public class CommonParts extends VerticalLayout implements View { options.addStyleName(ValoTheme.MENUBAR_SMALL); addComponent(options); - Command optionsCommand2 = new Command() { - @Override - public void menuSelected(MenuItem selectedItem) { - if (selectedItem.getText().equals("Caption")) { - win.setCaption( - selectedItem.isChecked() ? "Window Caption" - : null); - } else if (selectedItem.getText().equals("Closable")) { - win.setClosable(selectedItem.isChecked()); - } else if (selectedItem.getText().equals("Resizable")) { - win.setResizable(selectedItem.isChecked()); - } else if (selectedItem.getText().equals("Modal")) { - win.setModal(selectedItem.isChecked()); - } + Command optionsCommand2 = selectedItem -> { + if (selectedItem.getText().equals("Caption")) { + win.setCaption( + selectedItem.isChecked() ? "Window Caption" + : null); + } else if (selectedItem.getText().equals("Closable")) { + win.setClosable(selectedItem.isChecked()); + } else if (selectedItem.getText().equals("Resizable")) { + win.setResizable(selectedItem.isChecked()); + } else if (selectedItem.getText().equals("Modal")) { + win.setModal(selectedItem.isChecked()); } }; @@ -668,14 +600,11 @@ public class CommonParts extends VerticalLayout implements View { addComponent(options); final Button show = new Button("Open Window", - new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getUI().addWindow(win); - win.center(); - win.focus(); - event.getButton().setEnabled(false); - } + event -> { + getUI().addWindow(win); + win.center(); + win.focus(); + event.getButton().setEnabled(false); }); show.addStyleName(ValoTheme.BUTTON_PRIMARY); addComponent(show); @@ -685,17 +614,11 @@ public class CommonParts extends VerticalLayout implements View { event -> win.setVisible(!hidden.getValue())); addComponent(hidden); - win.addCloseListener(new CloseListener() { - @Override - public void windowClose(CloseEvent e) { - show.setEnabled(true); - } - }); + win.addCloseListener(event -> show.setEnabled(true)); } }; p.setContent(content); return p; - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java index 33776be726..cfe1452f1f 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java @@ -26,8 +26,6 @@ import com.vaadin.shared.ui.datefield.DateResolution; import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CssLayout; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; @@ -74,12 +72,8 @@ public class DateFields extends VerticalLayout implements View { final TestDateField date2 = new TestDateField(); group.addComponent(date2); - Button today = new Button("Today", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - date2.setValue(LocalDate.now()); - } - }); + Button today = new Button("Today", + event -> date2.setValue(LocalDate.now())); group.addComponent(today); date = new TestDateField("Default resolution, explicit size"); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/Dragging.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/Dragging.java index daa04f903c..0cd492e913 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/Dragging.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/Dragging.java @@ -34,7 +34,6 @@ import com.vaadin.shared.ui.dd.HorizontalDropLocation; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.CustomComponent; @@ -153,12 +152,7 @@ public class Dragging extends VerticalLayout implements View { buttonLayout.setSpacing(false); buttonLayout.setMargin(false); final Button button = new Button("Button"); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - Notification.show("Button clicked"); - } - }); + button.addClickListener(event -> Notification.show("Button clicked")); buttonLayout.addComponent(button); buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER); components.add(buttonLayout); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java index 2533e7bb02..e87bbb186b 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java @@ -26,8 +26,6 @@ import com.vaadin.tests.components.TestDateField; import com.vaadin.ui.AbstractDateField; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; @@ -156,22 +154,19 @@ public class Forms extends VerticalLayout implements View { bio.setReadOnly(true); - Button edit = new Button("Edit", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (readOnly) { - bio.setReadOnly(false); - form.removeStyleName(ValoTheme.FORMLAYOUT_LIGHT); - event.getButton().setCaption("Save"); - event.getButton().addStyleName(ValoTheme.BUTTON_PRIMARY); - } else { - bio.setReadOnly(true); - form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); - event.getButton().setCaption("Edit"); - event.getButton().removeStyleName(ValoTheme.BUTTON_PRIMARY); - } - readOnly = !readOnly; + Button edit = new Button("Edit", event -> { + if (readOnly) { + bio.setReadOnly(false); + form.removeStyleName(ValoTheme.FORMLAYOUT_LIGHT); + event.getButton().setCaption("Save"); + event.getButton().addStyleName(ValoTheme.BUTTON_PRIMARY); + } else { + bio.setReadOnly(true); + form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); + event.getButton().setCaption("Edit"); + event.getButton().removeStyleName(ValoTheme.BUTTON_PRIMARY); } + readOnly = !readOnly; }); HorizontalLayout footer = new HorizontalLayout(); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/GridDisabled.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/GridDisabled.java index f65ff23efb..cbdd9e5834 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/GridDisabled.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/GridDisabled.java @@ -2,7 +2,6 @@ package com.vaadin.tests.themes.valo; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; import com.vaadin.v7.ui.Grid; public class GridDisabled extends AbstractTestUI { @@ -17,11 +16,6 @@ public class GridDisabled extends AbstractTestUI { addComponent(grid); - addButton("Disable", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - grid.setEnabled(!grid.isEnabled()); - } - }); + addButton("Disable", event -> grid.setEnabled(!grid.isEnabled())); } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/NotificationStyle.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/NotificationStyle.java index de9da7330f..393d5bd19f 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/NotificationStyle.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/NotificationStyle.java @@ -18,7 +18,6 @@ package com.vaadin.tests.themes.valo; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; /** @@ -31,32 +30,24 @@ public class NotificationStyle extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { Button button = new Button("Show notification with h1", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification notification = new Notification( - "<p>Caption</p>", - "<div style='display:inline-block;'><h1>Description</h1>" - + "<p class='tested-p'>tested p</p></div>"); - notification.setHtmlContentAllowed(true); - notification.setDelayMsec(50000); - notification.show(getPage()); - } + event -> { + Notification notification = new Notification( + "<p>Caption</p>", + "<div style='display:inline-block;'><h1>Description</h1>" + + "<p class='tested-p'>tested p</p></div>"); + notification.setHtmlContentAllowed(true); + notification.setDelayMsec(50000); + notification.show(getPage()); }); addComponent(button); button = new Button("Show notification with p", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification notification = new Notification( - "<p>Caption</p>", - "Description text<p class='tested-p'>tested p text</p>"); - notification.setHtmlContentAllowed(true); - notification.setDelayMsec(50000); - notification.show(getPage()); - } + event -> { + Notification notification = new Notification( + "<p>Caption</p>", + "Description text<p class='tested-p'>tested p text</p>"); + notification.setHtmlContentAllowed(true); + notification.setDelayMsec(50000); + notification.show(getPage()); }); addComponent(button); } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/Sliders.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/Sliders.java index 1e4aeefe43..21cbc7a271 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/Sliders.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/Sliders.java @@ -173,16 +173,13 @@ public class Sliders extends VerticalLayout implements View { while (true) { try { Thread.sleep(1000); - getUI().access(new Runnable() { - @Override - public void run() { - pb.setValue(progress); - pb2.setValue(progress); - if (progress > 1) { - progress = 0; - } else { - progress += 0.2 * Math.random(); - } + getUI().access(() -> { + pb.setValue(progress); + pb2.setValue(progress); + if (progress > 1) { + progress = 0; + } else { + progress += 0.2 * Math.random(); } }); } catch (InterruptedException e) { diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/Tabsheets.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/Tabsheets.java index 13ec24f895..673828f064 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/Tabsheets.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/Tabsheets.java @@ -23,8 +23,6 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; -import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; @@ -160,14 +158,11 @@ public class Tabsheets extends VerticalLayout implements View { } } - ts.addSelectedTabChangeListener(new SelectedTabChangeListener() { - @Override - public void selectedTabChange(SelectedTabChangeEvent event) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + ts.addSelectedTabChangeListener(event -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java index 4f9046b485..f32d86a22b 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/ValoThemeUI.java @@ -36,8 +36,6 @@ import com.vaadin.server.WebBrowser; import com.vaadin.shared.ui.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CssLayout; @@ -51,8 +49,6 @@ import com.vaadin.ui.themes.ValoTheme; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.Container.Hierarchical; import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.util.HierarchicalContainer; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.ui.NativeSelect; @@ -163,7 +159,6 @@ public class ValoThemeUI extends UI { menu.removeStyleName("valo-menu-visible"); } }); - } private boolean browserCantRenderFontsConsistently() { @@ -242,14 +237,11 @@ public class ValoThemeUI extends UI { menu.addComponent(top); menu.addComponent(createThemeSelect()); - Button showMenu = new Button("Menu", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (menu.getStyleName().contains("valo-menu-visible")) { - menu.removeStyleName("valo-menu-visible"); - } else { - menu.addStyleName("valo-menu-visible"); - } + Button showMenu = new Button("Menu", event -> { + if (menu.getStyleName().contains("valo-menu-visible")) { + menu.removeStyleName("valo-menu-visible"); + } else { + menu.addStyleName("valo-menu-visible"); } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); @@ -313,12 +305,8 @@ public class ValoThemeUI extends UI { label.setSizeUndefined(); menuItemsLayout.addComponent(label); } - Button b = new Button(item.getValue(), new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - navigator.navigateTo(item.getKey()); - } - }); + Button b = new Button(item.getValue(), + event -> navigator.navigateTo(item.getKey())); if (count == 2) { b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>"); @@ -359,12 +347,7 @@ public class ValoThemeUI extends UI { } ns.setValue("tests-valo"); - ns.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - setTheme((String) ns.getValue()); - } - }); + ns.addValueChangeListener(event -> setTheme((String) ns.getValue())); return ns; } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowTitleOverflow.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowTitleOverflow.java index 0f6940ee97..c2de26f115 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowTitleOverflow.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowTitleOverflow.java @@ -2,41 +2,21 @@ package com.vaadin.tests.themes.valo; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; import com.vaadin.ui.Window; public class WindowTitleOverflow extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - addButton("Open Resizable", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - addWindow(getWindow(true, false)); - } - }); - - addButton("Open Closable", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - addWindow(getWindow(false, true)); - } - }); - - addButton("Open Resizable and Closable", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - addWindow(getWindow(true, true)); - } - }); + addButton("Open Resizable", event -> addWindow(getWindow(true, false))); + + addButton("Open Closable", event -> addWindow(getWindow(false, true))); + + addButton("Open Resizable and Closable", + event -> addWindow(getWindow(true, true))); addButton("Open Non-Resizable and Non-Closable", - new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - addWindow(getWindow(false, false)); - } - }); + event -> addWindow(getWindow(false, false))); } private Window getWindow(boolean resizable, boolean closable) { diff --git a/uitest/src/main/java/com/vaadin/tests/tooltip/TooltipConfiguration.java b/uitest/src/main/java/com/vaadin/tests/tooltip/TooltipConfiguration.java index cd93b93d41..a9ddb9f1bb 100644 --- a/uitest/src/main/java/com/vaadin/tests/tooltip/TooltipConfiguration.java +++ b/uitest/src/main/java/com/vaadin/tests/tooltip/TooltipConfiguration.java @@ -4,8 +4,6 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUIWithLog; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.NativeButton; -import com.vaadin.v7.data.Property; -import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.ui.TextField; public class TooltipConfiguration extends AbstractReindeerTestUIWithLog { @@ -30,63 +28,46 @@ public class TooltipConfiguration extends AbstractReindeerTestUIWithLog { closeTimeout = createIntegerTextField("Close timeout", getState().tooltipConfiguration.closeTimeout); - closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (closeTimeout.getConvertedValue() != null) { - getTooltipConfiguration().setCloseTimeout( - (Integer) closeTimeout.getConvertedValue()); - } + closeTimeout.addValueChangeListener(event -> { + if (closeTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setCloseTimeout( + (Integer) closeTimeout.getConvertedValue()); } }); maxWidth = createIntegerTextField("Max width", getState().tooltipConfiguration.maxWidth); - maxWidth.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (maxWidth.getConvertedValue() != null) { - getTooltipConfiguration().setMaxWidth( - (Integer) maxWidth.getConvertedValue()); - } + maxWidth.addValueChangeListener(event -> { + if (maxWidth.getConvertedValue() != null) { + getTooltipConfiguration() + .setMaxWidth((Integer) maxWidth.getConvertedValue()); } }); openDelay = createIntegerTextField("Open delay", getState().tooltipConfiguration.openDelay); - openDelay.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (openDelay.getConvertedValue() != null) { - getTooltipConfiguration().setOpenDelay( - (Integer) openDelay.getConvertedValue()); - } + openDelay.addValueChangeListener(event -> { + if (openDelay.getConvertedValue() != null) { + getTooltipConfiguration() + .setOpenDelay((Integer) openDelay.getConvertedValue()); } }); quickOpenDelay = createIntegerTextField("Quick open delay", getState().tooltipConfiguration.quickOpenDelay); quickOpenDelay - .addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (quickOpenDelay.getConvertedValue() != null) { - getTooltipConfiguration() - .setQuickOpenDelay((Integer) quickOpenDelay - .getConvertedValue()); - } + .addValueChangeListener(event -> { + if (quickOpenDelay.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenDelay( + (Integer) quickOpenDelay.getConvertedValue()); } }); quickOpenTimeout = createIntegerTextField("Quick open timeout", getState().tooltipConfiguration.quickOpenTimeout); quickOpenTimeout - .addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (quickOpenTimeout.getConvertedValue() != null) { - getTooltipConfiguration().setQuickOpenTimeout( - (Integer) quickOpenTimeout - .getConvertedValue()); - } + .addValueChangeListener(event -> { + if (quickOpenTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenTimeout( + (Integer) quickOpenTimeout.getConvertedValue()); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java b/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java index bdc021868d..d8855c4d65 100644 --- a/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java +++ b/uitest/src/main/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdate.java @@ -1,12 +1,10 @@ package com.vaadin.tests.urifragments; import com.vaadin.server.Page; -import com.vaadin.server.Page.UriFragmentChangedEvent; import com.vaadin.server.Page.UriFragmentChangedListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -26,18 +24,15 @@ public class FragmentHandlingAndAsynchUIUpdate extends AbstractTestUIWithLog { button.setId(BUTTON_ID); - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Label c = new Label("Thank you for clicking"); - c.setId(String.valueOf(fragmentId)); - getLayout().addComponent(c); - - log(String.format("Button was clicked for fragmentId %s", - fragmentId)); - Page.getCurrent().setUriFragment( - String.format(FRAG_NAME_TPL, fragmentId++)); - } + button.addClickListener(event -> { + Label c = new Label("Thank you for clicking"); + c.setId(String.valueOf(fragmentId)); + getLayout().addComponent(c); + + log(String.format("Button was clicked for fragmentId %s", + fragmentId)); + Page.getCurrent() + .setUriFragment(String.format(FRAG_NAME_TPL, fragmentId++)); }); getLayout().addComponent(button); @@ -47,41 +42,33 @@ public class FragmentHandlingAndAsynchUIUpdate extends AbstractTestUIWithLog { } private UriFragmentChangedListener createUriFragmentChangedListener() { - return new UriFragmentChangedListener() { + return event -> { + log(String.format("uriFragmentChanged %s", event.getUriFragment())); - @Override - public void uriFragmentChanged( - final UriFragmentChangedEvent event) { - - log(String.format("uriFragmentChanged %s", - event.getUriFragment())); - - if (!event.getUriFragment().startsWith("FRAG")) { - return; - } + if (!event.getUriFragment().startsWith("FRAG")) { + return; + } - final String frag = event.getUriFragment().substring(4); + final String frag = event.getUriFragment().substring(4); - Component fragComp = null; - for (Component comp : getLayout()) { - if (comp.getId() != null && comp instanceof Label - && comp.getId().equals(frag)) { - fragComp = comp; - break; - } + Component fragComp = null; + for (Component comp : getLayout()) { + if (comp.getId() != null && comp instanceof Label + && comp.getId().equals(frag)) { + fragComp = comp; + break; } + } - if (fragComp == null) { - return; - } - final Label fragLabel = (Label) fragComp; + if (fragComp == null) { + return; + } + final Label fragLabel = (Label) fragComp; - createThread(frag, fragLabel).start(); + createThread(frag, fragLabel).start(); - fragLabel.setCaption( - String.format("Thread running for %s!", frag)); - UI.getCurrent().setPollInterval(1000); - } + fragLabel.setCaption(String.format("Thread running for %s!", frag)); + UI.getCurrent().setPollInterval(1000); }; } @@ -96,24 +83,19 @@ public class FragmentHandlingAndAsynchUIUpdate extends AbstractTestUIWithLog { e.printStackTrace(); } - UI.getCurrent().access(new Runnable() { - - @Override - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - log(String.format( - "setCaption in synch mode for fragment %s", - frag)); - java.util.Random rand = new java.util.Random(); - fragLabel.setCaption( - String.format("Thread finished on %s (%s)", - frag, rand.nextInt())); + UI.getCurrent().access(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); } + + log(String.format( + "setCaption in synch mode for fragment %s", frag)); + java.util.Random rand = new java.util.Random(); + fragLabel.setCaption( + String.format("Thread finished on %s (%s)", frag, + rand.nextInt())); }); }; diff --git a/uitest/src/main/java/com/vaadin/tests/urifragments/SettingNullFragment.java b/uitest/src/main/java/com/vaadin/tests/urifragments/SettingNullFragment.java index 3b58e59fdc..1dc0332b19 100644 --- a/uitest/src/main/java/com/vaadin/tests/urifragments/SettingNullFragment.java +++ b/uitest/src/main/java/com/vaadin/tests/urifragments/SettingNullFragment.java @@ -4,7 +4,6 @@ import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; @SuppressWarnings("serial") public class SettingNullFragment extends AbstractReindeerTestUI { @@ -23,19 +22,11 @@ public class SettingNullFragment extends AbstractReindeerTestUI { Button button2 = new Button("Set Null Fragment"); button2.setId(BUTTON_NULL_FRAGMENT_ID); - button1.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Page.getCurrent().setUriFragment(FRAG_1_URI); - } - }); - - button2.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Page.getCurrent().setUriFragment(null); - } - }); + button1.addClickListener( + event -> Page.getCurrent().setUriFragment(FRAG_1_URI)); + + button2.addClickListener( + event -> Page.getCurrent().setUriFragment(null)); getLayout().addComponent(button1); getLayout().addComponent(button2); diff --git a/uitest/src/main/java/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java b/uitest/src/main/java/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java index 1e00412466..b5db41c761 100644 --- a/uitest/src/main/java/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java +++ b/uitest/src/main/java/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java @@ -36,15 +36,12 @@ public class BootstrapModifyUI extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { Button c = new Button("Add bootstrap listener", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getSession().addBootstrapListener( - createBootstrapListener()); - event.getButton().setEnabled(false); - getSession().setAttribute(INSTALLED_ATRIBUTE_NAME, - Boolean.TRUE); - } + event->{ + getSession().addBootstrapListener( + createBootstrapListener()); + event.getButton().setEnabled(false); + getSession().setAttribute(INSTALLED_ATRIBUTE_NAME, + Boolean.TRUE); }); addComponent(c); c.setEnabled( diff --git a/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java b/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java index 3734581ef2..7309d1b038 100644 --- a/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java +++ b/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java @@ -23,7 +23,7 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Validator; +import com.vaadin.v7.data.Validator.InvalidValueException; import com.vaadin.v7.data.validator.StringLengthValidator; import com.vaadin.v7.ui.AbstractField; import com.vaadin.v7.ui.ComboBox; @@ -66,18 +66,13 @@ public class FieldErrorIndication extends AbstractReindeerTestUI { TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect"); twinColSelect.addItem("ok"); twinColSelect.addItem("error"); - twinColSelect.addValidator(new Validator() { - - @Override - public void validate(Object value) throws InvalidValueException { - if (value instanceof Set && ((Set) value).size() == 1 - && ((Set) value).contains("ok")) { - return; - } - - throw new InvalidValueException("fail"); + twinColSelect.addValidator(value -> { + if (value instanceof Set && ((Set) value).size() == 1 + && ((Set) value).contains("ok")) { + return; } + throw new InvalidValueException("fail"); }); twinColSelect.setValue("error"); diff --git a/uitest/src/main/java/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java b/uitest/src/main/java/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java index ec3a9e1b7c..0014186fee 100644 --- a/uitest/src/main/java/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java +++ b/uitest/src/main/java/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java @@ -3,8 +3,6 @@ package com.vaadin.tests.validation; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.CheckBox; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.Validator; import com.vaadin.v7.data.validator.IntegerValidator; import com.vaadin.v7.data.validator.StringLengthValidator; @@ -32,12 +30,8 @@ public class ValidationOfRequiredEmptyFields extends AbstractReindeerTestUI { requiredErrorInput = new TextField("Required error message"); requiredErrorInput.setImmediate(true); - requiredErrorInput.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - tf.setRequiredError(requiredErrorInput.getValue()); - } - }); + requiredErrorInput.addValueChangeListener( + event -> tf.setRequiredError(requiredErrorInput.getValue())); integerValidatorInput = new CheckBox("Integer validator"); integerValidatorInput.addValueChangeListener(event -> { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ConnectorBundleStatusDisplayConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ConnectorBundleStatusDisplayConnector.java index 7af1a56237..5065ea79b8 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ConnectorBundleStatusDisplayConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ConnectorBundleStatusDisplayConnector.java @@ -34,12 +34,8 @@ public class ConnectorBundleStatusDisplayConnector extends AbstractComponentConn protected void init() { super.init(); registerRpc(ConnectorBundleStatusRpc.class, - new ConnectorBundleStatusRpc() { - @Override - public void updateStatus() { - ConnectorBundleStatusDisplayConnector.this.updateStatus(); - } - }); + () -> ConnectorBundleStatusDisplayConnector.this + .updateStatus()); updateStatus(); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/CustomUIConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/CustomUIConnector.java index 0443d94663..c688c8b2e2 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/CustomUIConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/CustomUIConnector.java @@ -27,14 +27,11 @@ public class CustomUIConnector extends UIConnector { @Override protected void init() { super.init(); - registerRpc(CustomUIConnectorRpc.class, new CustomUIConnectorRpc() { - @Override - public void test() { - SpanElement span = Document.get().createSpanElement(); - span.setInnerText("This is the " - + CustomUIConnector.this.getClass().getSimpleName()); - Document.get().getBody().insertFirst(span); - } + registerRpc(CustomUIConnectorRpc.class, () -> { + SpanElement span = Document.get().createSpanElement(); + span.setInnerText("This is the " + + CustomUIConnector.this.getClass().getSimpleName()); + Document.get().getBody().insertFirst(span); }); } } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java index debec7c73e..918cbd19e0 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java @@ -32,12 +32,9 @@ public class LayoutDetectorConnector extends AbstractComponentConnector super.init(); updateText(); - registerRpc(NoLayoutRpc.class, new NoLayoutRpc() { - @Override - public void doRpc() { - rpcCount++; - updateText(); - } + registerRpc(NoLayoutRpc.class, () -> { + rpcCount++; + updateText(); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java index 068896f323..8ab8b8dee9 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java @@ -21,8 +21,6 @@ import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.History; import com.google.gwt.user.client.ui.Button; @@ -122,13 +120,7 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector // Then add history change listener historyHandlerRegistration = History.addValueChangeHandler( - new ValueChangeHandler<String>() { - @Override - public void onValueChange( - ValueChangeEvent<String> event) { - updateFromHistoryToken(event.getValue()); - } - }); + event -> updateFromHistoryToken(event.getValue())); } else if (!useUriFragments && historyHandlerRegistration != null) { historyHandlerRegistration.removeHandler(); historyHandlerRegistration = null; diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java index a0f8fcba42..e65df5f14e 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java @@ -33,12 +33,7 @@ public class HelloWorldExtensionConnector extends AbstractExtensionConnector { @Override protected void init() { - registerRpc(GreetAgainRpc.class, new GreetAgainRpc() { - @Override - public void greetAgain() { - greet(); - } - }); + registerRpc(GreetAgainRpc.class, () -> greet()); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java index 4a099fa3ff..f680f40d79 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java @@ -23,12 +23,8 @@ public class MyComponentConnector extends AbstractComponentConnector { rpc.clicked(mouseDetails); }); - registerRpc(MyComponentClientRpc.class, new MyComponentClientRpc() { - @Override - public void alert(String message) { - Window.alert(message); - } - }); + registerRpc(MyComponentClientRpc.class, + message -> Window.alert(message)); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java index d243573d7c..e294fd951c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java @@ -16,7 +16,6 @@ package com.vaadin.tests.widgetset.client.v7.grid; import java.util.ArrayList; -import java.util.Comparator; import java.util.Date; import java.util.List; @@ -222,13 +221,8 @@ public class GridClientColumnRendererConnector // Make sorter sort the numbers in natural order sorter.setComparator( (Grid.Column<String, String>) grid.getColumn(0), - new Comparator<String>() { - @Override - public int compare(String o1, String o2) { - return Integer.parseInt(o1) - - Integer.parseInt(o2); - } - }); + (o1, o2) -> Integer.parseInt(o1) + - Integer.parseInt(o2)); // Sort along column 0 in ascending order grid.sort(grid.getColumn(0)); @@ -246,13 +240,8 @@ public class GridClientColumnRendererConnector // Make shuffler return random order shuffler.setComparator( (Grid.Column<String, String>) grid.getColumn(0), - new Comparator<String>() { - @Override - public int compare(String o1, String o2) { - return com.google.gwt.user.client.Random - .nextInt(3) - 1; - } - }); + (o1, o2) -> com.google.gwt.user.client.Random + .nextInt(3) - 1); // "Sort" (actually shuffle) along column 0 grid.sort(grid.getColumn(0)); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientDataSourcesWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientDataSourcesWidget.java index 9281002ae9..1491b1dc0e 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientDataSourcesWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientDataSourcesWidget.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; import com.google.gwt.core.client.Scheduler; -import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.vaadin.client.data.AbstractRemoteDataSource; import com.vaadin.v7.client.renderers.TextRenderer; import com.vaadin.v7.client.widgets.Grid; @@ -91,13 +90,8 @@ public class GridClientDataSourcesWidget result.size = size; result.rows = fetchRows(firstRowIndex, numberOfRows); - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - @Override - public void execute() { - callback.onResponse(result); - } - }); - + Scheduler.get() + .scheduleDeferred(() -> callback.onResponse(result)); } private List<String[]> fetchRows(int firstRowIndex, @@ -139,12 +133,8 @@ public class GridClientDataSourcesWidget protected void requestRows(int firstRowIndex, int numberOfRows, final RequestRowsCallback<String[]> callback) { - backend.query(firstRowIndex, numberOfRows, new RestCallback() { - @Override - public void onResponse(Backend.Result result) { - callback.onResponse(result.rows, result.size); - } - }); + backend.query(firstRowIndex, numberOfRows, + result -> callback.onResponse(result.rows, result.size)); } @Override @@ -157,9 +147,16 @@ public class GridClientDataSourcesWidget private RestishDataSource restishDataSource; - private final ScheduledCommand setRestishCommand = new ScheduledCommand() { - @Override - public void execute() { + public GridClientDataSourcesWidget() { + super(new Grid<String[]>()); + grid = getTestedWidget(); + + grid.getElement().getStyle().setZIndex(0); + grid.setHeight("400px"); + grid.setSelectionMode(SelectionMode.NONE); + addNorth(grid, 400); + + addMenuCommand("Use", () -> { for (Grid.Column<?, String[]> column : grid.getColumns()) { grid.removeColumn(column); } @@ -174,48 +171,22 @@ public class GridClientDataSourcesWidget return row[1]; } }); - } - }; - - public GridClientDataSourcesWidget() { - super(new Grid<String[]>()); - grid = getTestedWidget(); - - grid.getElement().getStyle().setZIndex(0); - grid.setHeight("400px"); - grid.setSelectionMode(SelectionMode.NONE); - addNorth(grid, 400); - - addMenuCommand("Use", setRestishCommand, "DataSources", "RESTish"); - addMenuCommand("Next request +10", new ScheduledCommand() { - @Override - public void execute() { - restishDataSource.backend.addRows(10); - } - }, "DataSources", "RESTish"); - addMenuCommand("Next request -10", new ScheduledCommand() { - @Override - public void execute() { - restishDataSource.backend.addRows(-10); - } - }, "DataSources", "RESTish"); - addMenuCommand("Push data change", new ScheduledCommand() { - @Override - public void execute() { - restishDataSource.backend.pushRowChanges(); - } - }, "DataSources", "RESTish"); - addMenuCommand("Push data change +10", new ScheduledCommand() { - @Override - public void execute() { - restishDataSource.backend.pushRowChanges(10); - } - }, "DataSources", "RESTish"); - addMenuCommand("Push data change -10", new ScheduledCommand() { - @Override - public void execute() { - restishDataSource.backend.pushRowChanges(-10); - } }, "DataSources", "RESTish"); + + addMenuCommand("Next request +10", + () -> restishDataSource.backend.addRows(10), "DataSources", + "RESTish"); + addMenuCommand("Next request -10", + () -> restishDataSource.backend.addRows(-10), "DataSources", + "RESTish"); + addMenuCommand("Push data change", + () -> restishDataSource.backend.pushRowChanges(), "DataSources", + "RESTish"); + addMenuCommand("Push data change +10", + () -> restishDataSource.backend.pushRowChanges(10), + "DataSources", "RESTish"); + addMenuCommand("Push data change -10", + () -> restishDataSource.backend.pushRowChanges(-10), + "DataSources", "RESTish"); } } diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeToolTips.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeToolTips.java index 58fffc82d1..320d44936e 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeToolTips.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeToolTips.java @@ -1,10 +1,8 @@ package com.vaadin.v7.tests.components.tree; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Component; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.util.HierarchicalContainer; -import com.vaadin.v7.ui.AbstractSelect; import com.vaadin.v7.ui.Tree; public class TreeToolTips extends TestBase { @@ -13,13 +11,9 @@ public class TreeToolTips extends TestBase { protected void setup() { final Tree tree = new Tree(null, createContainer()); tree.setItemDescriptionGenerator( - new AbstractSelect.ItemDescriptionGenerator() { - @Override - public String generateDescription(Component source, - Object itemId, Object propertyId) { - return "This is a tooltip for item id '" + itemId + "'"; - } - }); + (source, itemId, + propertyId) -> "This is a tooltip for item id '" + + itemId + "'"); for (Object rootItems : tree.rootItemIds()) { tree.expandItemsRecursively(rootItems); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/upload/TestFileUpload.java b/uitest/src/main/java/com/vaadin/v7/tests/components/upload/TestFileUpload.java index fc430b4838..444c8d8fca 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/upload/TestFileUpload.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/upload/TestFileUpload.java @@ -22,14 +22,7 @@ public class TestFileUpload extends TestBase implements Receiver { @Override protected void setup() { - Upload u = new Upload("Upload", new Upload.Receiver() { - - @Override - public OutputStream receiveUpload(String filename, - String mimeType) { - return baos; - } - }); + Upload u = new Upload("Upload", (filename, mimeType) -> baos); u.setId("UPL"); u.addFailedListener(new FailedListener() { diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java index 7f4b940bc3..f7de143287 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java @@ -28,9 +28,7 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.parallel.TestCategory; @@ -77,15 +75,11 @@ public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { public void gaveUpTheme() throws IOException { openTestURL("reconnectAttempts=3"); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - try { - return $(ButtonElement.class).first() != null; - } catch (Exception e) { - return false; - } + waitUntil(input -> { + try { + return $(ButtonElement.class).first() != null; + } catch (Exception e) { + return false; } }); @@ -98,20 +92,16 @@ public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { } private void waitForReconnectDialogWithText(final String text) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - try { - final WebElement reconnectDialog = findElement( - ReconnectDialogThemeTest.reconnectDialogBy); - return reconnectDialog.findElement(By.className("text")) - .getText().equals(text); - } catch (Exception e) { - return false; - } + waitUntil(input -> { + try { + final WebElement reconnectDialog = findElement( + ReconnectDialogThemeTest.reconnectDialogBy); + return reconnectDialog.findElement(By.className("text")) + .getText().equals(text); + } catch (Exception e) { + return false; } }, 10); - } private void assertHasManyColors(String message, diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java index ffbdf0dc0d..8e38b6780d 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java @@ -21,9 +21,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.jcraft.jsch.JSchException; import com.vaadin.testbench.elements.ButtonElement; @@ -67,14 +65,8 @@ public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { waitForReconnectDialogPresent(); final WebElement reconnectDialog = findElement( ReconnectDialogThemeTest.reconnectDialogBy); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return reconnectDialog.findElement(By.className("text")) - .getText().equals(text); - } - }, 10); - + waitUntil(input -> reconnectDialog.findElement(By.className("text")) + .getText().equals(text), 10); } private void waitForReconnectDialogToDisappear() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java index c13074b825..5327b4f83a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java @@ -17,9 +17,7 @@ package com.vaadin.tests.components.checkbox; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.LabelElement; @@ -52,11 +50,6 @@ public class CheckBoxRpcCountTest extends MultiBrowserTest { private void waitUntilLabelIsUpdated(final WebElement countElem, final String expectedText) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return countElem.getText().equals(expectedText); - } - }, 5); + waitUntil(input -> countElem.getText().equals(expectedText), 5); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java index c79120afd2..45d41556de 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java @@ -22,9 +22,7 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.ComboBoxElement; @@ -95,11 +93,6 @@ public class ComboBoxScrollingWithArrowsTest extends MultiBrowserTest { } private void waitUntilNextPageIsVisible() { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return getSelectedItemText().equals("item " + PAGESIZE); - } - }, 5); + waitUntil(input -> getSelectedItemText().equals("item " + PAGESIZE), 5); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java index 09d19ef81a..ba29ec807f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java @@ -9,10 +9,8 @@ import java.util.HashSet; import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.GridElement; @@ -475,13 +473,8 @@ public class GridSelectionTest extends GridBasicsTest { private void waitUntilCheckBoxValue(final WebElement checkBoxElememnt, final boolean expectedValue) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return expectedValue ? checkBoxElememnt.isSelected() - : !checkBoxElememnt.isSelected(); - } - }, 5); + waitUntil(input -> expectedValue ? checkBoxElememnt.isSelected() + : !checkBoxElememnt.isSelected(), 5); } private GridRowElement getRow(int i) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java index 4c78ab864f..528715c8e3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java @@ -21,9 +21,7 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridLayoutElement; @@ -52,12 +50,7 @@ public abstract class GridLayoutBaseTest extends MultiBrowserTest { private void waitUntilColumnAndRowAreHidden( final List<WebElement> slots4x4) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return getSlots(0).size() == slots4x4.size(); - } - }, 5); + waitUntil(input -> getSlots(0).size() == slots4x4.size(), 5); } private List<WebElement> getSlots(int index) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java index bd83dd6ec4..bf166caa55 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java @@ -21,13 +21,11 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.io.IOException; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class SelectAllConstantViewportTest extends MultiBrowserTest { @@ -41,13 +39,7 @@ public class SelectAllConstantViewportTest extends MultiBrowserTest { WebElement row = $(TableElement.class).first().getCell(190, 0); final WebElement scrollPositionDisplay = getDriver() .findElement(By.className("v-table-scrollposition")); - waitUntilNot(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return scrollPositionDisplay.isDisplayed(); - } - }, 10); + waitUntilNot(input -> scrollPositionDisplay.isDisplayed(), 10); int rowLocation = row.getLocation().getY(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllRowsTest.java index 8342cfa0fa..0e6b4f02cd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllRowsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SelectAllRowsTest.java @@ -24,15 +24,13 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -95,14 +93,11 @@ public class SelectAllRowsTest extends MultiBrowserTest { } private void waitUntilRowIsVisible(final int row) { - waitUntil(new ExpectedCondition<Object>() { - @Override - public Object apply(WebDriver input) { - try { - return getTable().getCell(row, 0) != null; - } catch (NoSuchElementException e) { - return false; - } + waitUntil(input -> { + try { + return getTable().getCell(row, 0) != null; + } catch (NoSuchElementException e) { + return false; } }); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableNavigationPageDownTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableNavigationPageDownTest.java index f7429d5e59..23f19c4e72 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableNavigationPageDownTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableNavigationPageDownTest.java @@ -85,12 +85,7 @@ public class TableNavigationPageDownTest extends MultiBrowserTest { private boolean waitUntilLastRowHasChanged(final int row) { try { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return row != getLastVisibleRowNumber(); - } - }, 1); + waitUntil(input -> row != getLastVisibleRowNumber(), 1); return true; } catch (Exception e) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java index c0ae0945ab..86dd8ea1d5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java @@ -18,9 +18,7 @@ package com.vaadin.tests.components.table; import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.TableElement; @@ -43,13 +41,7 @@ public class TableScrollUpOnSelectTest extends MultiBrowserTest { WebElement row = $(TableElement.class).first().getCell(49, 0); final WebElement scrollPositionDisplay = getDriver() .findElement(By.className("v-table-scrollposition")); - waitUntilNot(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return scrollPositionDisplay.isDisplayed(); - } - }, 10); + waitUntilNot(input -> scrollPositionDisplay.isDisplayed(), 10); int rowLocation = row.getLocation().getY(); row.click(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/ComboboxSelectedItemTextTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/ComboboxSelectedItemTextTest.java index 073fbf4abe..678a2a02c3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/ComboboxSelectedItemTextTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/ComboboxSelectedItemTextTest.java @@ -19,10 +19,8 @@ import java.io.IOException; import java.util.List; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.parallel.Browser; @@ -108,12 +106,9 @@ public class ComboboxSelectedItemTextTest extends MultiBrowserTest { } private void waitForPopup(final WebElement comboBox) { - waitUntilNot(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return comboBox.findElements(By.vaadin("#popup")).isEmpty(); - } - }, 10); + waitUntilNot( + input -> comboBox.findElements(By.vaadin("#popup")).isEmpty(), + 10); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowMoveListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowMoveListenerTest.java index 9e41137924..f4851865fa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowMoveListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowMoveListenerTest.java @@ -5,11 +5,9 @@ import static org.junit.Assert.assertNotEquals; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Point; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -46,12 +44,7 @@ public class WindowMoveListenerTest extends MultiBrowserTest { private void waitUntilWindowHasReseted(final WebElement window, final Point winPos) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return winPos.x == window.getLocation().x - && winPos.y == window.getLocation().y; - } - }, 5); + waitUntil(input -> winPos.x == window.getLocation().x + && winPos.y == window.getLocation().y, 5); } } diff --git a/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java b/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java index 3b241a49d8..a76fa2fe97 100644 --- a/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java @@ -17,8 +17,6 @@ package com.vaadin.tests.extensions; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.NotificationElement; @@ -32,17 +30,12 @@ public class NotificationCloseListenerTest extends MultiBrowserTest { $(NotificationElement.class).first().close(); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - try { - return $(CheckBoxElement.class).first().isChecked(); - } - catch (Exception e) { - e.printStackTrace(); - return false; - } + waitUntil(input -> { + try { + return $(CheckBoxElement.class).first().isChecked(); + } catch (Exception e) { + e.printStackTrace(); + return false; } }); } diff --git a/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java index cb88b05b7c..cbc265eedb 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/BasicPushTest.java @@ -17,9 +17,7 @@ package com.vaadin.tests.push; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.AbstractTB3Test; @@ -85,26 +83,16 @@ public abstract class BasicPushTest extends MultiBrowserTest { } protected void waitUntilClientCounterChanges(final int expectedValue) { - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getClientCounter(BasicPushTest.this) == expectedValue; - } - }, 10); + waitUntil( + input -> BasicPushTest + .getClientCounter(BasicPushTest.this) == expectedValue, + 10); } protected void waitUntilServerCounterChanges() { final int counter = BasicPushTest.getServerCounter(this); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getServerCounter(BasicPushTest.this) > counter; - } - }, 10); + waitUntil(input -> BasicPushTest + .getServerCounter(BasicPushTest.this) > counter, 10); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java b/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java index b6be0c4e1f..e6c1db4e18 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/ReconnectTest.java @@ -16,9 +16,7 @@ package com.vaadin.tests.push; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.jcraft.jsch.JSchException; import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; @@ -93,25 +91,15 @@ public abstract class ReconnectTest extends MultiBrowserTestWithProxy { private void waitUntilServerCounterChanges() { final int counter = BasicPushTest.getServerCounter(this); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getServerCounter(ReconnectTest.this) > counter; - } - }, 30); + waitUntil(input -> BasicPushTest + .getServerCounter(ReconnectTest.this) > counter, 30); } private void waitUntilClientCounterChanges(final int expectedValue) { - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getClientCounter(ReconnectTest.this) == expectedValue; - } - }, 5); + waitUntil( + input -> BasicPushTest + .getClientCounter(ReconnectTest.this) == expectedValue, + 5); } private void startTimer() { diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java index dccf8e3742..300eeb1ca6 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -203,13 +203,7 @@ public abstract class AbstractTB3Test extends ParallelTest { protected void waitForDebugMessage(final String expectedMessage, int timeout) { - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return hasDebugMessage(expectedMessage); - } - }, timeout); + waitUntil(input -> hasDebugMessage(expectedMessage), timeout); } protected void clearDebugMessages() { @@ -220,14 +214,11 @@ public abstract class AbstractTB3Test extends ParallelTest { protected void waitUntilRowIsVisible(final TableElement table, final int row) { - waitUntil(new ExpectedCondition<Object>() { - @Override - public Object apply(WebDriver input) { - try { - return table.getCell(row, 0) != null; - } catch (NoSuchElementException e) { - return false; - } + waitUntil(input -> { + try { + return table.getCell(row, 0) != null; + } catch (NoSuchElementException e) { + return false; } }); } @@ -836,12 +827,9 @@ public abstract class AbstractTB3Test extends ParallelTest { protected void openDebugLogTab() { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - WebElement element = getDebugLogButton(); - return element != null; - } + waitUntil(input -> { + WebElement element = getDebugLogButton(); + return element != null; }, 15); getDebugLogButton().click(); } @@ -1263,14 +1251,10 @@ public abstract class AbstractTB3Test extends ParallelTest { final WebElement rootDiv = findElement( By.xpath("//div[contains(@class,'v-app')]")); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - String rootClass = rootDiv.getAttribute("class").trim(); + waitUntil(input -> { + String rootClass = rootDiv.getAttribute("class").trim(); - return rootClass.contains(theme); - } + return rootClass.contains(theme); }, 30); } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/ParallelScheduler.java b/uitest/src/test/java/com/vaadin/tests/tb3/ParallelScheduler.java index e270e26c53..adc9e5408d 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/ParallelScheduler.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/ParallelScheduler.java @@ -18,7 +18,6 @@ package com.vaadin.tests.tb3; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -47,12 +46,9 @@ public class ParallelScheduler implements RunnerScheduler { @Override public void schedule(final Runnable childStatement) { - fResults.add(fService.submit(new Callable<Object>() { - @Override - public Object call() throws Exception { - childStatement.run(); - return null; - } + fResults.add(fService.submit(() -> { + childStatement.run(); + return null; })); } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/ScreenshotTB3Test.java index ffc4ec9043..b076ab3c5a 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/ScreenshotTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -17,7 +17,6 @@ package com.vaadin.tests.tb3; import java.io.File; -import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; @@ -480,16 +479,9 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { } final String errorBase = getScreenshotErrorBaseName(); - File[] files = errorDirectory.listFiles(new FileFilter() { - - @Override - public boolean accept(File pathname) { - String thisFile = pathname.getAbsolutePath(); - if (thisFile.startsWith(errorBase)) { - return true; - } - return false; - } + File[] files = errorDirectory.listFiles(pathname -> { + String thisFile = pathname.getAbsolutePath(); + return thisFile.startsWith(errorBase); }); for (File f : files) { f.delete(); diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/TB3TestLocator.java b/uitest/src/test/java/com/vaadin/tests/tb3/TB3TestLocator.java index a3267445b7..c38d1ff70e 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/TB3TestLocator.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/TB3TestLocator.java @@ -24,7 +24,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; @@ -85,13 +84,8 @@ public class TB3TestLocator { findClassesInJar(juc, basePackage, baseClass, classes); } - Collections.sort(classes, new Comparator<Class<? extends T>>() { - - @Override - public int compare(Class<? extends T> o1, Class<? extends T> o2) { - return o1.getName().compareTo(o2.getName()); - } - }); + Collections.sort(classes, + (o1, o2) -> o1.getName().compareTo(o2.getName())); return classes; } diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java index 6aa7a274be..1ac57abdff 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java @@ -21,7 +21,6 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedCondition; @@ -79,12 +78,6 @@ public class NotificationStyleTest extends MultiBrowserTest { } private ExpectedCondition<Boolean> notificationPresentCondition() { - return new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return isElementPresent(By.className("v-Notification")); - } - }; + return input -> isElementPresent(By.className("v-Notification")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdateTest.java b/uitest/src/test/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdateTest.java index 13b18de516..7833734b7c 100644 --- a/uitest/src/test/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdateTest.java +++ b/uitest/src/test/java/com/vaadin/tests/urifragments/FragmentHandlingAndAsynchUIUpdateTest.java @@ -22,9 +22,7 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -84,58 +82,42 @@ public class FragmentHandlingAndAsynchUIUpdateTest extends MultiBrowserTest { // begin to wait for setting 3th fragment and then click backward // history and then wait for 9th fragment - new Thread(new Runnable() { - - @Override - public void run() { - // wait for setting 3th fragment - assertFragment(String.format(FRAG_NAME_TPL, START_FRAG_ID + 3)); - // go back one time after we wait for 3th fragment and then we - // will see the "loss" of "forward history" - ((JavascriptExecutor) driver).executeScript("history.back()"); - - // now at some time new fragments will be set - // wait for last fragment setting.. - // of course forward history is empty now.. - assertFragment(String.format(FRAG_NAME_TPL, START_FRAG_ID + 9)); - } + new Thread(() -> { + // wait for setting 3th fragment + assertFragment(String.format(FRAG_NAME_TPL, START_FRAG_ID + 3)); + // go back one time after we wait for 3th fragment and then we + // will see the "loss" of "forward history" + ((JavascriptExecutor) driver).executeScript("history.back()"); + // now at some time new fragments will be set + // wait for last fragment setting.. + // of course forward history is empty now.. + assertFragment(String.format(FRAG_NAME_TPL, START_FRAG_ID + 9)); }).start(); // not wait for setting fragment in URI // (simulated situation when users clicks some times in row on // button) - new Thread(new Runnable() { - - @Override - public void run() { - for (int i = 0; i < 10; i++) { - getDriver() - .findElement( - By.id(FragmentHandlingAndAsynchUIUpdate.BUTTON_ID)) - .click(); - } - + new Thread(() -> { + for (int i = 0; i < 10; i++) { + getDriver() + .findElement(By.id( + FragmentHandlingAndAsynchUIUpdate.BUTTON_ID)) + .click(); } - }).start(); - } private void assertFragment(String fragment) { final String expectedText = fragment; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - String currentURL = getDriver().getCurrentUrl(); - String currentURIFragment = ""; - if (currentURL.contains("#") && !currentURL.endsWith("#")) { - currentURIFragment = currentURL.split("#")[1]; - } - return expectedText.equals(currentURIFragment); + waitUntil(input -> { + String currentURL = getDriver().getCurrentUrl(); + String currentURIFragment = ""; + if (currentURL.contains("#") && !currentURL.endsWith("#")) { + currentURIFragment = currentURL.split("#")[1]; } + return expectedText.equals(currentURIFragment); }, 20); } |