diff options
Diffstat (limited to 'uitest/src/main')
27 files changed, 175 insertions, 380 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java index 6193b4d5ee..4941994e73 100644 --- a/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java +++ b/uitest/src/main/java/com/vaadin/tests/application/NavigateWithOngoingXHR.java @@ -16,50 +16,43 @@ package com.vaadin.tests.application; -import java.io.IOException; import java.io.PrintWriter; import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Link; import com.vaadin.v7.shared.ui.progressindicator.ProgressIndicatorServerRpc; import com.vaadin.v7.ui.ProgressIndicator; public class NavigateWithOngoingXHR extends AbstractReindeerTestUI { - private final RequestHandler slowRequestHandler = new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - if ("/slowRequestHandler".equals(request.getPathInfo())) { - // Make the navigation request last longer to keep the - // communication error visible - // System.out.println("Got slow content request"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + private final RequestHandler slowRequestHandler = (session, request, + response) -> { + if ("/slowRequestHandler".equals(request.getPathInfo())) { + // Make the navigation request last longer to keep the + // communication error visible + // System.out.println("Got slow content request"); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } - if (request.getParameter("download") != null) { - response.setHeader("Content-Disposition", "attachment"); - } + if (request.getParameter("download") != null) { + response.setHeader("Content-Disposition", "attachment"); + } - response.setContentType("text/plain"); - PrintWriter writer = response.getWriter(); - writer.println("Loaded slowly"); - writer.close(); + response.setContentType("text/plain"); + PrintWriter writer = response.getWriter(); + writer.println("Loaded slowly"); + writer.close(); - // System.out.println("Finished slow content request"); + // System.out.println("Finished slow content request"); - return true; - } - return false; + return true; } + return false; }; @Override diff --git a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java index d100108c3c..5b9db4ea9c 100644 --- a/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java +++ b/uitest/src/main/java/com/vaadin/tests/applicationservlet/TestingServiceInitListener.java @@ -15,17 +15,12 @@ */ package com.vaadin.tests.applicationservlet; -import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import com.vaadin.server.ConnectorIdGenerationEvent; import com.vaadin.server.ConnectorIdGenerator; -import com.vaadin.server.RequestHandler; import com.vaadin.server.ServiceInitEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinServiceInitListener; -import com.vaadin.server.VaadinSession; public class TestingServiceInitListener implements VaadinServiceInitListener { @@ -37,14 +32,9 @@ public class TestingServiceInitListener implements VaadinServiceInitListener { public void serviceInit(ServiceInitEvent event) { initCount.incrementAndGet(); - event.addRequestHandler(new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - requestCount.incrementAndGet(); - return false; - } + event.addRequestHandler((session, request, response) -> { + requestCount.incrementAndGet(); + return false; }); event.addConnectorIdGenerator(new ConnectorIdGenerator() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java index 679ad6f18d..2f8cdae641 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java @@ -24,12 +24,9 @@ public class ResponseWritingErrorHandling extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - ErrorHandler errorHandler = new ErrorHandler() { - @Override - public void error(com.vaadin.server.ErrorEvent event) { - String message = event.getThrowable().getMessage(); - log(message); - } + ErrorHandler errorHandler = event -> { + String message = event.getThrowable().getMessage(); + log(message); }; Button button = new Button("Throw in beforeClientResponse") { diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java index 49745d96ca..94fd1b98e5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/TextFieldConversions.java @@ -2,8 +2,6 @@ package com.vaadin.tests.components.abstractfield; import java.util.Date; -import com.vaadin.server.ErrorEvent; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.UserError; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.ui.ComboBox; @@ -34,12 +32,7 @@ public class TextFieldConversions extends AbstractComponentDataBindingTest { tf = new TextField("TextField"); addComponent(tf); - tf.setErrorHandler(new ErrorHandler() { - - @Override - public void error(ErrorEvent event) { - tf.setComponentError(new UserError("Invalid value")); - } - }); + tf.setErrorHandler( + event -> tf.setComponentError(new UserError("Invalid value"))); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java index 95af0ad435..99ee908173 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/NewItemsESCPress.java @@ -1,7 +1,6 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; -import com.vaadin.v7.ui.AbstractSelect.NewItemHandler; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.TextArea; @@ -16,13 +15,10 @@ public class NewItemsESCPress extends TestBase { final ComboBox box = new ComboBox("New items are allowed"); box.setNewItemsAllowed(true); - box.setNewItemHandler(new NewItemHandler() { - @Override - public void addNewItem(String newItemCaption) { - String value = addedItems.getValue(); - addedItems.setValue(value + newItemCaption + "\n"); - box.addItem(newItemCaption); - } + box.setNewItemHandler(newItemCaption -> { + String value = addedItems.getValue(); + addedItems.setValue(value + newItemCaption + "\n"); + box.addItem(newItemCaption); }); box.setImmediate(true); addComponent(box); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java index 4c779c33f0..0d947c1dc7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.table; import java.lang.reflect.InvocationTargetException; import com.vaadin.event.ListenerMethod.MethodException; -import com.vaadin.server.ErrorEvent; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.ServerRpcManager.RpcInvocationException; import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.TestBase; @@ -118,25 +116,21 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { protected void setErrorHandler(boolean enabled) { if (enabled) { - VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() { - - @Override - public void error(ErrorEvent event) { - Throwable t = event.getThrowable(); - if (t instanceof RpcInvocationException) { + VaadinSession.getCurrent().setErrorHandler(event -> { + Throwable t = event.getThrowable(); + if (t instanceof RpcInvocationException) { + t = t.getCause(); + if (t instanceof InvocationTargetException) { t = t.getCause(); - if (t instanceof InvocationTargetException) { + if (t instanceof MethodException) { t = t.getCause(); - if (t instanceof MethodException) { - t = t.getCause(); - if (t instanceof CacheUpdateException) { - Table table = ((CacheUpdateException) t) - .getTable(); - table.removeAllItems(); - Notification.show( - "Problem updating table. Please try again later", - Notification.Type.ERROR_MESSAGE); - } + if (t instanceof CacheUpdateException) { + Table table = ((CacheUpdateException) t) + .getTable(); + table.removeAllItems(); + Notification.show( + "Problem updating table. Please try again later", + Notification.Type.ERROR_MESSAGE); } } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java index 6fa8511b0a..7c4a31bf05 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java @@ -4,9 +4,7 @@ import java.util.LinkedHashMap; import com.vaadin.server.Resource; import com.vaadin.tests.components.AbstractComponentContainerTest; -import com.vaadin.ui.Component; import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.CloseHandler; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.TabSheet.Tab; @@ -42,23 +40,14 @@ public class TabSheetTest<T extends TabSheet> extends @Override public void execute(T c, Boolean value, Object data) { if (value) { - c.setCloseHandler(new CloseHandler() { - @Override - public void onTabClose(TabSheet tabsheet, Component c) { - tabClosed(tabsheet, tabsheet.getTab(c)); - tabsheet.removeComponent(c); - } - + c.setCloseHandler((tabsheet, comp) -> { + tabClosed(tabsheet, tabsheet.getTab(comp)); + tabsheet.removeComponent(comp); }); } else { - c.setCloseHandler(new CloseHandler() { - @Override - public void onTabClose(TabSheet tabsheet, Component c) { - tabsheet.removeComponent(c); - } - }); + c.setCloseHandler( + (tabsheet, comp) -> tabsheet.removeComponent(comp)); } - } }; private Command<T, Boolean> setSelectedTabListener = new Command<T, Boolean>() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java index 76573d1f81..c57578824a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIInitException.java @@ -1,6 +1,5 @@ package com.vaadin.tests.components.ui; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Label; @@ -9,14 +8,9 @@ public class UIInitException extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { - setErrorHandler(new ErrorHandler() { - @Override - public void error(com.vaadin.server.ErrorEvent event) { - addComponent(new Label("An exception occurred: " - + event.getThrowable().getMessage())); - - } - }); + setErrorHandler( + event -> addComponent(new Label("An exception occurred: " + + event.getThrowable().getMessage()))); throw new RuntimeException("Catch me if you can"); } diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java b/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java index 06027bf820..4ffb0c2466 100644 --- a/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java +++ b/uitest/src/main/java/com/vaadin/tests/dd/DDTest1.java @@ -182,7 +182,6 @@ public class DDTest1 extends TestBase { copyChildren(source, target, childId); } } - } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java index 15c5196abd..38b8ba8859 100644 --- a/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java +++ b/uitest/src/main/java/com/vaadin/tests/errorhandler/ErrorHandlers.java @@ -38,15 +38,8 @@ public class ErrorHandlers extends AbstractReindeerTestUI { final VerticalLayout layoutWithErrorHandler = new VerticalLayout( runtimeExceptionOnClick(new Button("Error handler on parent"))); - ErrorHandler e = new ErrorHandler() { - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - layoutWithErrorHandler.addComponent( - new Label("Layout error: " + getErrorMessage(event))); - } - - }; + ErrorHandler e = event -> layoutWithErrorHandler.addComponent( + new Label("Layout error: " + getErrorMessage(event))); layoutWithErrorHandler.setErrorHandler(e); layoutWithErrorHandler.addComponent(notificationErrorHandler( npeOnClick(new Button("Error handler on button and parent")))); diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java index a24278de3f..e9e0b99ecf 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java @@ -1,7 +1,6 @@ package com.vaadin.tests.minitutorials.v7a1; import java.awt.image.BufferedImage; -import java.io.IOException; import javax.imageio.ImageIO; @@ -9,36 +8,30 @@ import com.vaadin.server.ExternalResource; import com.vaadin.server.RequestHandler; import com.vaadin.server.Resource; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Image; public class DynamicImageUI extends AbstractReindeerTestUI { public static final String IMAGE_URL = "myimage.png"; - private final RequestHandler requestHandler = new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - if (("/" + IMAGE_URL).equals(request.getPathInfo())) { - // Create an image, draw the "text" parameter to it and output - // it to the browser. - String text = request.getParameter("text"); - BufferedImage bi = new BufferedImage(100, 30, - BufferedImage.TYPE_3BYTE_BGR); - bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), - 10, 20); - response.setContentType("image/png"); - ImageIO.write(bi, "png", response.getOutputStream()); + private final RequestHandler requestHandler = (session, request, + response) -> { + if (("/" + IMAGE_URL).equals(request.getPathInfo())) { + // Create an image, draw the "text" parameter to it and output + // it to the browser. + String text = request.getParameter("text"); + BufferedImage bi = new BufferedImage(100, 30, + BufferedImage.TYPE_3BYTE_BGR); + bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), 10, + 20); + response.setContentType("image/png"); + ImageIO.write(bi, "png", response.getOutputStream()); - return true; - } - // If the URL did not match our image URL, let the other request - // handlers handle it - return false; + return true; } + // If the URL did not match our image URL, let the other request + // handlers handle it + return false; }; @Override diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java index 49ec4da0b2..985ede4aa7 100644 --- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java @@ -2,8 +2,6 @@ package com.vaadin.tests.minitutorials.v7a2; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.PushButton; @@ -26,12 +24,8 @@ public class MyPickerWidget extends ComplexPanel { add(textBox, getElement()); add(button, getElement()); - button.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - Window.alert("Calendar picker not yet supported!"); - } - }); + button.addClickHandler( + event -> Window.alert("Calendar picker not yet supported!")); } public void setButtonText(String buttonText, boolean adjustSpace) { diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java index 92f073aad4..82b922db37 100644 --- a/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/push/PushErrorHandling.java @@ -4,13 +4,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; import com.vaadin.shared.communication.PushMode; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.v7.data.util.AbstractInMemoryContainer; import com.vaadin.v7.data.util.BeanContainer; @@ -24,23 +22,16 @@ public class PushErrorHandling extends AbstractReindeerTestUI { protected void setup(VaadinRequest request) { getPushConfiguration().setPushMode(PushMode.AUTOMATIC); - VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() { - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - addComponent(new Label( - "An error! " + event.getThrowable().getMessage())); - System.err.println( - "An error! " + event.getThrowable().getMessage()); - } + VaadinSession.getCurrent().setErrorHandler(event -> { + addComponent( + new Label( + "An error! " + event.getThrowable().getMessage())); + System.err + .println("An error! " + event.getThrowable().getMessage()); }); - final Button button = new Button("Click for NPE!", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - ((String) null).length(); // Null-pointer exception - } + final Button button = new Button("Click for NPE!", event -> { + ((String) null).length(); // Null-pointer exception }); button.setId("npeButton"); addComponent(button); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java index ad5a13e744..9d735ad2e2 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java @@ -39,7 +39,6 @@ import com.vaadin.v7.ui.DateField; import com.vaadin.v7.ui.TextArea; import com.vaadin.v7.ui.TextField; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent; -import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClick; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClickHandler; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectEvent; import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectHandler; @@ -625,13 +624,9 @@ public class CalendarTest extends GridLayout implements View { } }); - calendarComponent.setHandler(new EventClickHandler() { - - @Override - public void eventClick(EventClick event) { - showEventPopup(event.getCalendarEvent(), false); - } - }); + calendarComponent + .setHandler((EventClickHandler) + event -> showEventPopup(event.getCalendarEvent(), false)); calendarComponent.setHandler(new BasicDateClickHandler() { @@ -644,13 +639,9 @@ public class CalendarTest extends GridLayout implements View { } }); - calendarComponent.setHandler(new RangeSelectHandler() { - - @Override - public void rangeSelect(RangeSelectEvent event) { - handleRangeSelect(event); - } - }); + calendarComponent + .setHandler( + (RangeSelectHandler) event -> handleRangeSelect(event)); } private ComboBox createTimeZoneSelect() { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java index ab300a9e81..4a4bb58488 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/ResizeTerrorizerControlConnector.java @@ -19,11 +19,8 @@ import java.util.Arrays; import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; @@ -63,14 +60,10 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector private IntegerBox endHeight = new IntegerBox(); private final Button terrorizeButton = new Button("Terrorize", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - terrorize(startWidth.getValue(), endWidth.getValue(), - startHeight.getValue(), endHeight.getValue(), - 1000); - } - }); + (ClickHandler) event -> terrorize(startWidth.getValue(), + endWidth.getValue(), startHeight.getValue(), + endHeight.getValue(), + 1000)); private HandlerRegistration historyHandlerRegistration; @@ -98,12 +91,9 @@ public class ResizeTerrorizerControlConnector extends AbstractComponentConnector // Emulate button click from enter on any of the text boxes for (IntegerBox box : Arrays.asList(startWidth, endWidth, startHeight, endHeight)) { - box.addKeyUpHandler(new KeyUpHandler() { - @Override - public void onKeyUp(KeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - terrorizeButton.click(); - } + box.addKeyUpHandler(event -> { + if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { + terrorizeButton.click(); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java index a212dcedfe..203e813a80 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java @@ -2,7 +2,6 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -41,47 +40,35 @@ public class RunOverflowFixConnector overflowY.addStyleName("third-scrollbar"); Button runFix = new Button("Click to runWebkitOverflowAutoFix", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - overflow.getElement().getStyle() - .setOverflow(Style.Overflow.SCROLL); - WidgetUtil.runWebkitOverflowAutoFix( - overflow.getElement()); - - overflowX.getElement().getStyle() - .setOverflowX(Style.Overflow.HIDDEN); - WidgetUtil.runWebkitOverflowAutoFix( - overflowX.getElement()); - - overflowY.getElement().getStyle() - .setOverflowY(Style.Overflow.HIDDEN); - WidgetUtil.runWebkitOverflowAutoFix( - overflowY.getElement()); - } + (ClickHandler) event -> { + overflow.getElement().getStyle() + .setOverflow(Style.Overflow.SCROLL); + WidgetUtil.runWebkitOverflowAutoFix(overflow.getElement()); + + overflowX.getElement().getStyle() + .setOverflowX(Style.Overflow.HIDDEN); + WidgetUtil.runWebkitOverflowAutoFix(overflowX.getElement()); + + overflowY.getElement().getStyle() + .setOverflowY(Style.Overflow.HIDDEN); + WidgetUtil.runWebkitOverflowAutoFix(overflowY.getElement()); }); runFix.addStyleName("run-button-one"); getWidget().add(runFix); Button runFix2 = new Button("Click to runWebkitOverflowAutoFix 2", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - overflow.getElement().getStyle() - .setOverflow(Style.Overflow.VISIBLE); - WidgetUtil.runWebkitOverflowAutoFix( - overflow.getElement()); - - overflowX.getElement().getStyle() - .setOverflowX(Style.Overflow.SCROLL); - WidgetUtil.runWebkitOverflowAutoFix( - overflowX.getElement()); - - overflowY.getElement().getStyle() - .setOverflowY(Style.Overflow.AUTO); - WidgetUtil.runWebkitOverflowAutoFix( - overflowY.getElement()); - } + (ClickHandler) event -> { + overflow.getElement().getStyle() + .setOverflow(Style.Overflow.VISIBLE); + WidgetUtil.runWebkitOverflowAutoFix(overflow.getElement()); + + overflowX.getElement().getStyle() + .setOverflowX(Style.Overflow.SCROLL); + WidgetUtil.runWebkitOverflowAutoFix(overflowX.getElement()); + + overflowY.getElement().getStyle() + .setOverflowY(Style.Overflow.AUTO); + WidgetUtil.runWebkitOverflowAutoFix(overflowY.getElement()); }); runFix2.addStyleName("run-button-two"); getWidget().add(runFix2); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java index 17d27feed2..07eba9accc 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/WidgetUtilTestWidget.java @@ -22,7 +22,6 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.BorderStyle; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.WidgetUtil; @@ -43,12 +42,7 @@ public class WidgetUtilTestWidget extends Widget { root.addClassName("v-widget-util-test"); setElement(root); - addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - showSizes(); - } - }, ClickEvent.getType()); + addDomHandler(event -> showSizes(), ClickEvent.getType()); } public void construct(boolean inline) { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java index bb3b09aedf..1c626ba73d 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java @@ -19,8 +19,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.google.gwt.core.shared.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.VButton; import com.vaadin.shared.ui.Connect; @@ -60,13 +58,8 @@ public class CsrfButtonConnector extends AbstractComponentConnector { getWidget().getElement().setId(ID); getWidget().setText(csrfTokenInfo()); - getWidget().addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - getWidget().setText(csrfTokenInfo()); - } - }); + getWidget() + .addClickHandler(event -> getWidget().setText(csrfTokenInfo())); } private String csrfTokenInfo() { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java index 030fbe8110..336d48ccdf 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/extension/BrowserContextMenuExtensionConnector.java @@ -16,7 +16,6 @@ package com.vaadin.tests.widgetset.client.extension; import com.google.gwt.event.dom.client.ContextMenuEvent; -import com.google.gwt.event.dom.client.ContextMenuHandler; import com.vaadin.client.ServerConnector; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.ui.AbstractComponentConnector; @@ -32,13 +31,9 @@ public class BrowserContextMenuExtensionConnector @Override protected void extend(ServerConnector target) { - getParent().getWidget().addDomHandler(new ContextMenuHandler() { - - @Override - public void onContextMenu(ContextMenuEvent event) { - // Stop context click events from propagating. - event.stopPropagation(); - } + getParent().getWidget().addDomHandler(event -> { + // Stop context click events from propagating. + event.stopPropagation(); }, ContextMenuEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java index b5e1e824eb..f7f385e154 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java @@ -18,8 +18,6 @@ package com.vaadin.tests.widgetset.client.grid; import java.util.ArrayList; import java.util.List; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Button; import com.vaadin.client.data.DataChangeHandler; import com.vaadin.client.data.DataSource; @@ -110,13 +108,7 @@ public class GridCellFocusOnResetSizeWidget final MyDataSource dataSource = new MyDataSource(); grid.setDataSource(dataSource); Button widget = new Button("Change Container Size"); - widget.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - dataSource.changeSize(); - } - }); + widget.addClickHandler(event -> dataSource.changeSize()); addNorth(grid, 400); addNorth(widget, 50); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java index 478ac51fde..4a06cb9914 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java @@ -19,8 +19,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.google.gwt.core.shared.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DialogBox; @@ -66,14 +64,7 @@ public class GwtRpcButtonConnector extends AbstractComponentConnector { log("GwtRpcButtonTestConnector init"); getWidget().setText("Click me"); - getWidget().addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - doRPC(); - } - - }); + getWidget().addClickHandler(event -> doRPC()); } /** diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java index aee16c334d..4a099fa3ff 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a2/MyComponentConnector.java @@ -1,7 +1,5 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a2; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.annotations.OnStateChange; @@ -18,16 +16,12 @@ public class MyComponentConnector extends AbstractComponentConnector { this); public MyComponentConnector() { - getWidget().addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - - final MouseEventDetails mouseDetails = MouseEventDetailsBuilder - .buildMouseEventDetails(event.getNativeEvent(), - getWidget().getElement()); + getWidget().addClickHandler(event -> { + final MouseEventDetails mouseDetails = MouseEventDetailsBuilder + .buildMouseEventDetails(event.getNativeEvent(), + getWidget().getElement()); - rpc.clicked(mouseDetails); - } + rpc.clicked(mouseDetails); }); registerRpc(MyComponentClientRpc.class, new MyComponentClientRpc() { @Override diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java index 3ac0db54fa..b093917cf9 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/CapsLockWarningConnector.java @@ -1,7 +1,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a3; import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; @@ -22,14 +21,11 @@ public class CapsLockWarningConnector extends AbstractExtensionConnector { warning.setOwner(passwordWidget); warning.add(new HTML("Caps Lock is enabled!")); - passwordWidget.addDomHandler(new KeyPressHandler() { - @Override - public void onKeyPress(KeyPressEvent event) { - if (isEnabled() && isCapsLockOn(event)) { - warning.showRelativeTo(passwordWidget); - } else { - warning.hide(); - } + passwordWidget.addDomHandler(event -> { + if (isEnabled() && isCapsLockOn(event)) { + warning.showRelativeTo(passwordWidget); + } else { + warning.hide(); } }, KeyPressEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java index cbe12b57a2..15e703e9b2 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7a3/ClientSideModule.java @@ -17,8 +17,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a3; import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.RootPanel; @@ -38,14 +36,11 @@ public class ClientSideModule implements EntryPoint { vp.add(button); RootPanel.get().add(vp); - button.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if ("GWT User".equals(nameField.getText())) { - Window.alert("User OK"); - } else { - Window.alert("Unauthorized user"); - } + button.addClickHandler(event -> { + if ("GWT User".equals(nameField.getText())) { + Window.alert("User OK"); + } else { + Window.alert("Unauthorized user"); } }); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java index d8d1f43c32..a2091f1d0c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java @@ -1,7 +1,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7b1; import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; @@ -25,18 +24,15 @@ public class CapsLockWarningWithRpcConnector warning.setOwner(passwordWidget); warning.add(new HTML("Caps Lock is enabled!")); - passwordWidget.addDomHandler(new KeyPressHandler() { - @Override - public void onKeyPress(KeyPressEvent event) { - if (isEnabled() && isCapsLockOn(event)) { - warning.showRelativeTo(passwordWidget); - rpc.isCapsLockEnabled(true); // Added to send message to the - // server - } else { - warning.hide(); - rpc.isCapsLockEnabled(false); // Added to send message to - // the server - } + passwordWidget.addDomHandler(event -> { + if (isEnabled() && isCapsLockOn(event)) { + warning.showRelativeTo(passwordWidget); + // Added to send message to the server + rpc.isCapsLockEnabled(true); + } else { + warning.hide(); + // Added to send message to the server + rpc.isCapsLockEnabled(false); } }, KeyPressEvent.getType()); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java index d41df99886..0fb967610c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridBasicClientFeaturesWidget.java @@ -27,7 +27,6 @@ import java.util.logging.Logger; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuHandler; @@ -79,8 +78,6 @@ import com.vaadin.v7.client.widget.grid.events.GridKeyUpEvent; import com.vaadin.v7.client.widget.grid.events.HeaderKeyDownHandler; import com.vaadin.v7.client.widget.grid.events.HeaderKeyPressHandler; import com.vaadin.v7.client.widget.grid.events.HeaderKeyUpHandler; -import com.vaadin.v7.client.widget.grid.events.ScrollEvent; -import com.vaadin.v7.client.widget.grid.events.ScrollHandler; import com.vaadin.v7.client.widget.grid.selection.SelectionModel; import com.vaadin.v7.client.widget.grid.selection.SelectionModel.None; import com.vaadin.v7.client.widgets.Grid; @@ -450,14 +447,10 @@ public class GridBasicClientFeaturesWidget if (scrollHandler != null) { return; } - scrollHandler = grid.addScrollHandler(new ScrollHandler() { - @Override - public void onScroll(ScrollEvent event) { - @SuppressWarnings("hiding") - final Grid<?> grid = (Grid<?>) event.getSource(); - label.setText("scrollTop: " + grid.getScrollTop() - + ", scrollLeft: " + grid.getScrollLeft()); - } + scrollHandler = grid.addScrollHandler(event -> { + final Grid<?> grid = (Grid<?>) event.getSource(); + label.setText("scrollTop: " + grid.getScrollTop() + + ", scrollLeft: " + grid.getScrollLeft()); }); } }, listenersPath); @@ -526,26 +519,22 @@ public class GridBasicClientFeaturesWidget addMenuCommand("Add context menu listener", new ScheduledCommand() { HandlerRegistration handler = null; - ContextMenuHandler contextMenuHandler = new ContextMenuHandler() { - - @Override - public void onContextMenu(ContextMenuEvent event) { - event.preventDefault(); - final String location; - EventCellReference<?> cellRef = grid.getEventCell(); - if (cellRef.isHeader()) { - location = "header"; - } else if (cellRef.isBody()) { - location = "body"; - } else if (cellRef.isFooter()) { - location = "footer"; - } else { - location = "somewhere"; - } - - getLogger().info("Prevented opening a context menu in grid " - + location); + ContextMenuHandler contextMenuHandler = event -> { + event.preventDefault(); + final String location; + EventCellReference<?> cellRef = grid.getEventCell(); + if (cellRef.isHeader()) { + location = "header"; + } else if (cellRef.isBody()) { + location = "body"; + } else if (cellRef.isFooter()) { + location = "footer"; + } else { + location = "somewhere"; } + + getLogger().info( + "Prevented opening a context menu in grid " + location); }; @Override @@ -913,13 +902,7 @@ public class GridBasicClientFeaturesWidget @Override public void execute() { final Button button = new Button("Button Header"); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); grid.getHeaderRow(0).getCell(column).setWidget(button); } }, "Component", "Columns", "Column " + i, "Header Type"); @@ -942,13 +925,7 @@ public class GridBasicClientFeaturesWidget @Override public void execute() { final Button button = new Button("Button Footer"); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); grid.getFooterRow(0).getCell(column).setWidget(button); } }, "Component", "Columns", "Column " + i, "Footer Type"); @@ -1459,12 +1436,8 @@ public class GridBasicClientFeaturesWidget final Label label = new Label("Row: " + rowIndex + "."); Button button = new Button("Button", - new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - label.setText("clicked"); - } - }); + (ClickHandler) event -> label + .setText("clicked")); panel.add(label); panel.add(button); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java index a651da1a44..d243573d7c 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/v7/grid/GridClientColumnRendererConnector.java @@ -22,8 +22,6 @@ import java.util.List; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.Button; @@ -280,13 +278,7 @@ public class GridClientColumnRendererConnector @Override public Button createWidget() { final Button button = new Button(""); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - button.setText("Clicked"); - } - }); + button.addClickHandler(event -> button.setText("Clicked")); return button; } |