Also use "event" as the name for eventstags/8.2.0.alpha3
@@ -56,7 +56,6 @@ public class DependencyLoader { | |||
// The show must go on | |||
onLoad(event); | |||
} | |||
}; | |||
/** |
@@ -32,7 +32,6 @@ import com.vaadin.client.communication.JavaScriptMethodInvocation; | |||
import com.vaadin.client.communication.ServerRpcQueue; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.shared.JavaScriptConnectorState; | |||
import com.vaadin.shared.communication.MethodInvocation; | |||
@@ -261,13 +260,8 @@ public class JavaScriptConnectorHelper { | |||
if (listener == null) { | |||
LayoutManager layoutManager = LayoutManager | |||
.get(connector.getConnection()); | |||
listener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
invokeElementResizeCallback(e.getElement(), | |||
callbackFunction); | |||
} | |||
}; | |||
listener = event -> invokeElementResizeCallback(event.getElement(), | |||
callbackFunction); | |||
layoutManager.addElementResizeListener(element, listener); | |||
elementListeners.put(callbackFunction, listener); | |||
} |
@@ -25,8 +25,6 @@ import com.google.gwt.storage.client.Storage; | |||
import com.google.gwt.user.client.Window.Location; | |||
import com.google.gwt.user.client.rpc.AsyncCallback; | |||
import com.vaadin.client.ui.VNotification; | |||
import com.vaadin.client.ui.VNotification.EventListener; | |||
import com.vaadin.client.ui.VNotification.HideEvent; | |||
/** | |||
* Class that enables SuperDevMode using a ?superdevmode parameter in the url. | |||
@@ -99,13 +97,9 @@ public class SuperDevMode { | |||
private void failed() { | |||
VNotification n = new VNotification(); | |||
n.addEventListener(new EventListener() { | |||
@Override | |||
public void notificationHidden(HideEvent event) { | |||
recompileWidgetsetAndStartInDevMode(serverUrl); | |||
} | |||
}); | |||
n.addEventListener( | |||
event -> recompileWidgetsetAndStartInDevMode( | |||
serverUrl)); | |||
n.show("Recompilation failed.<br/>" | |||
+ "Make sure CodeServer is running, " | |||
+ "check its output and click to retry", |
@@ -29,7 +29,6 @@ import com.vaadin.client.ServerConnector; | |||
import com.vaadin.client.WidgetUtil; | |||
import com.vaadin.client.data.DataChangeHandler; | |||
import com.vaadin.client.extensions.AbstractExtensionConnector; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.client.widget.grid.HeightAwareDetailsGenerator; | |||
import com.vaadin.client.widgets.Grid; | |||
@@ -58,14 +57,10 @@ public class DetailsManagerConnector extends AbstractExtensionConnector { | |||
private Registration dataChangeRegistration; | |||
private final Map<Element, ScheduledCommand> elementToResizeCommand = new HashMap<Element, Scheduler.ScheduledCommand>(); | |||
private final ElementResizeListener detailsRowResizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
if (elementToResizeCommand.containsKey(e.getElement())) { | |||
Scheduler.get().scheduleFinally( | |||
elementToResizeCommand.get(e.getElement())); | |||
} | |||
private final ElementResizeListener detailsRowResizeListener = event -> { | |||
if (elementToResizeCommand.containsKey(event.getElement())) { | |||
Scheduler.get().scheduleFinally( | |||
elementToResizeCommand.get(event.getElement())); | |||
} | |||
}; | |||
@@ -178,19 +178,11 @@ public class HierarchySection implements Section { | |||
} | |||
}); | |||
hierarchyPanel.addListener(new SelectConnectorListener() { | |||
@Override | |||
public void select(ServerConnector connector, Element element) { | |||
printState(connector, true); | |||
} | |||
}); | |||
hierarchyPanel.addListener( | |||
(connector, element) -> printState(connector, true)); | |||
analyzeLayoutsPanel.addListener(new SelectConnectorListener() { | |||
@Override | |||
public void select(ServerConnector connector, Element element) { | |||
printState(connector, true); | |||
} | |||
}); | |||
analyzeLayoutsPanel.addListener( | |||
(connector, element) -> printState(connector, true)); | |||
content.setStylePrimaryName(VDebugWindow.STYLENAME + "-hierarchy"); | |||
@@ -16,8 +16,6 @@ | |||
package com.vaadin.client.ui; | |||
import com.google.gwt.event.dom.client.DomEvent; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel.FocusOutListener; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel.SubmitListener; | |||
/** | |||
@@ -46,12 +44,9 @@ public abstract class VAbstractDateFieldCalendar<PANEL extends VAbstractCalendar | |||
} | |||
}); | |||
calendarPanel.setFocusOutListener(new FocusOutListener() { | |||
@Override | |||
public boolean onFocusOut(DomEvent<?> event) { | |||
updateValueFromPanel(); | |||
return false; | |||
} | |||
calendarPanel.setFocusOutListener(event -> { | |||
updateValueFromPanel(); | |||
return false; | |||
}); | |||
} | |||
@@ -24,7 +24,6 @@ import com.google.gwt.aria.client.Roles; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.event.dom.client.ClickEvent; | |||
import com.google.gwt.event.dom.client.ClickHandler; | |||
import com.google.gwt.event.dom.client.DomEvent; | |||
import com.google.gwt.event.dom.client.KeyCodes; | |||
import com.google.gwt.event.dom.client.MouseOutEvent; | |||
import com.google.gwt.event.dom.client.MouseOutHandler; | |||
@@ -47,7 +46,6 @@ import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.client.BrowserInfo; | |||
import com.vaadin.client.ComputedStyle; | |||
import com.vaadin.client.VConsole; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel.FocusOutListener; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel.SubmitListener; | |||
import com.vaadin.client.ui.aria.AriaHelper; | |||
import com.vaadin.shared.ui.datefield.TextualDateFieldState; | |||
@@ -141,13 +139,10 @@ public abstract class VAbstractPopupCalendar<PANEL extends VAbstractCalendarPane | |||
calendar = calendarPanel; | |||
calendar.setParentField(this); | |||
calendar.setFocusOutListener(new FocusOutListener() { | |||
@Override | |||
public boolean onFocusOut(DomEvent<?> event) { | |||
event.preventDefault(); | |||
closeCalendarPanel(); | |||
return true; | |||
} | |||
calendar.setFocusOutListener(event -> { | |||
event.preventDefault(); | |||
closeCalendarPanel(); | |||
return true; | |||
}); | |||
// FIXME: Problem is, that the element with the provided id does not |
@@ -270,7 +270,8 @@ public abstract class VDateField<R extends Enum<R>> extends FlowPanel | |||
public void sendBufferedValues() { | |||
rpc.update(bufferedDateString, | |||
bufferedResolutions.entrySet().stream().collect(Collectors | |||
.toMap(e -> e.getKey().name(), e -> e.getValue()))); | |||
.toMap(e -> e.getKey().name(), | |||
e -> e.getValue()))); | |||
bufferedDateString = null; | |||
bufferedResolutions.clear(); | |||
} |
@@ -23,7 +23,6 @@ import java.util.List; | |||
import com.google.gwt.aria.client.Roles; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NativeEvent; | |||
import com.google.gwt.event.dom.client.KeyCodes; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
@@ -34,7 +33,6 @@ import com.google.gwt.user.client.ui.HTML; | |||
import com.google.gwt.user.client.ui.Label; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.client.AnimationUtil; | |||
import com.vaadin.client.AnimationUtil.AnimationEndListener; | |||
import com.vaadin.client.ApplicationConnection; | |||
import com.vaadin.client.BrowserInfo; | |||
import com.vaadin.client.WidgetUtil; | |||
@@ -297,14 +295,10 @@ public class VNotification extends VOverlay { | |||
if (getStyleName() | |||
.contains(VOverlay.ADDITIONAL_CLASSNAME_ANIMATE_IN)) { | |||
AnimationUtil.addAnimationEndListener(getElement(), | |||
new AnimationEndListener() { | |||
@Override | |||
public void onAnimationEnd(NativeEvent event) { | |||
if (AnimationUtil.getAnimationName(event) | |||
.contains( | |||
VOverlay.ADDITIONAL_CLASSNAME_ANIMATE_IN)) { | |||
VNotification.this.hide(); | |||
} | |||
event -> { | |||
if (AnimationUtil.getAnimationName(event).contains( | |||
VOverlay.ADDITIONAL_CLASSNAME_ANIMATE_IN)) { | |||
VNotification.this.hide(); | |||
} | |||
}); | |||
} else { |
@@ -21,7 +21,6 @@ import com.vaadin.client.ApplicationConnection; | |||
import com.vaadin.client.UIDL; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel; | |||
import com.vaadin.client.ui.VAbstractCalendarPanel.FocusChangeListener; | |||
import com.vaadin.client.ui.VAbstractDateFieldCalendar; | |||
import com.vaadin.shared.ui.datefield.InlineDateFieldState; | |||
@@ -50,25 +49,22 @@ public abstract class AbstractInlineDateFieldConnector<PANEL extends VAbstractCa | |||
protected void updateListeners() { | |||
if (isResolutionMonthOrHigher()) { | |||
getWidget().calendarPanel | |||
.setFocusChangeListener(new FocusChangeListener() { | |||
@Override | |||
public void focusChanged(Date date) { | |||
Date date2 = new Date(); | |||
if (getWidget().calendarPanel.getDate() != null) { | |||
date2.setTime(getWidget().calendarPanel | |||
.getDate().getTime()); | |||
} | |||
/* | |||
* Update the value of calendarPanel | |||
*/ | |||
date2.setYear(date.getYear()); | |||
date2.setMonth(date.getMonth()); | |||
getWidget().calendarPanel.setDate(date2); | |||
/* | |||
* Then update the value from panel to server | |||
*/ | |||
getWidget().updateValueFromPanel(); | |||
.setFocusChangeListener(date -> { | |||
Date date2 = new Date(); | |||
if (getWidget().calendarPanel.getDate() != null) { | |||
date2.setTime(getWidget().calendarPanel.getDate() | |||
.getTime()); | |||
} | |||
/* | |||
* Update the value of calendarPanel | |||
*/ | |||
date2.setYear(date.getYear()); | |||
date2.setMonth(date.getMonth()); | |||
getWidget().calendarPanel.setDate(date2); | |||
/* | |||
* Then update the value from panel to server | |||
*/ | |||
getWidget().updateValueFromPanel(); | |||
}); | |||
} else { | |||
getWidget().calendarPanel.setFocusChangeListener(null); |
@@ -19,7 +19,6 @@ import java.util.Date; | |||
import com.vaadin.client.DateTimeService; | |||
import com.vaadin.client.ui.VDateTimeCalendarPanel; | |||
import com.vaadin.client.ui.VDateTimeCalendarPanel.TimeChangeListener; | |||
import com.vaadin.client.ui.VPopupTimeCalendar; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.datefield.DateTimeResolution; | |||
@@ -58,29 +57,24 @@ public class DateTimeFieldConnector extends | |||
if (getWidget().getCurrentResolution() | |||
.compareTo(DateTimeResolution.DAY) < 0) { | |||
getWidget().calendar | |||
.setTimeChangeListener(new TimeChangeListener() { | |||
@Override | |||
public void changed(int hour, int min, int sec, | |||
int msec) { | |||
Date d = getWidget().getDate(); | |||
if (d == null) { | |||
// date currently null, use the value from | |||
// calendarPanel | |||
// (~ client time at the init of the widget) | |||
d = (Date) getWidget().calendar.getDate() | |||
.clone(); | |||
} | |||
d.setHours(hour); | |||
d.setMinutes(min); | |||
d.setSeconds(sec); | |||
DateTimeService.setMilliseconds(d, msec); | |||
.setTimeChangeListener((hour, min, sec, msec) -> { | |||
Date d = getWidget().getDate(); | |||
if (d == null) { | |||
// date currently null, use the value from | |||
// calendarPanel | |||
// (~ client time at the init of the widget) | |||
d = (Date) getWidget().calendar.getDate().clone(); | |||
} | |||
d.setHours(hour); | |||
d.setMinutes(min); | |||
d.setSeconds(sec); | |||
DateTimeService.setMilliseconds(d, msec); | |||
// Always update time changes to the server | |||
getWidget().updateValue(d); | |||
// Always update time changes to the server | |||
getWidget().updateValue(d); | |||
// Update text field | |||
getWidget().buildDate(); | |||
} | |||
// Update text field | |||
getWidget().buildDate(); | |||
}); | |||
} | |||
} |
@@ -19,7 +19,6 @@ import java.util.Date; | |||
import com.vaadin.client.DateTimeService; | |||
import com.vaadin.client.ui.VDateTimeCalendarPanel; | |||
import com.vaadin.client.ui.VDateTimeCalendarPanel.TimeChangeListener; | |||
import com.vaadin.client.ui.VDateTimeFieldCalendar; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.datefield.DateTimeResolution; | |||
@@ -52,27 +51,23 @@ public class InlineDateTimeFieldConnector extends | |||
if (getWidget().getCurrentResolution() | |||
.compareTo(DateTimeResolution.DAY) < 0) { | |||
getWidget().calendarPanel | |||
.setTimeChangeListener(new TimeChangeListener() { | |||
@Override | |||
public void changed(int hour, int min, int sec, | |||
int msec) { | |||
Date d = getWidget().getDate(); | |||
if (d == null) { | |||
// date currently null, use the value from | |||
// calendarPanel | |||
// (~ client time at the init of the widget) | |||
d = (Date) getWidget().calendarPanel.getDate() | |||
.clone(); | |||
} | |||
d.setHours(hour); | |||
d.setMinutes(min); | |||
d.setSeconds(sec); | |||
DateTimeService.setMilliseconds(d, msec); | |||
// Always update time changes to the server | |||
getWidget().calendarPanel.setDate(d); | |||
getWidget().updateValueFromPanel(); | |||
.setTimeChangeListener((hour, min, sec, msec) -> { | |||
Date d = getWidget().getDate(); | |||
if (d == null) { | |||
// date currently null, use the value from | |||
// calendarPanel | |||
// (~ client time at the init of the widget) | |||
d = (Date) getWidget().calendarPanel.getDate() | |||
.clone(); | |||
} | |||
d.setHours(hour); | |||
d.setMinutes(min); | |||
d.setSeconds(sec); | |||
DateTimeService.setMilliseconds(d, msec); | |||
// Always update time changes to the server | |||
getWidget().calendarPanel.setDate(d); | |||
getWidget().updateValueFromPanel(); | |||
}); | |||
} | |||
} |
@@ -80,16 +80,13 @@ public abstract class TextualDateConnector<PANEL extends VAbstractCalendarPanel< | |||
protected void updateListeners() { | |||
FocusChangeListener listener; | |||
if (isResolutionMonthOrHigher()) { | |||
listener = new FocusChangeListener() { | |||
@Override | |||
public void focusChanged(Date date) { | |||
if (isResolutionMonthOrHigher()) { | |||
getWidget().updateValue(date); | |||
getWidget().buildDate(); | |||
Date date2 = getWidget().calendar.getDate(); | |||
date2.setYear(date.getYear()); | |||
date2.setMonth(date.getMonth()); | |||
} | |||
listener = date -> { | |||
if (isResolutionMonthOrHigher()) { | |||
getWidget().updateValue(date); | |||
getWidget().buildDate(); | |||
Date date2 = getWidget().calendar.getDate(); | |||
date2.setYear(date.getYear()); | |||
date2.setMonth(date.getMonth()); | |||
} | |||
}; | |||
} else { |
@@ -19,7 +19,6 @@ import com.google.gwt.dom.client.DivElement; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.EventListener; | |||
import com.vaadin.client.WidgetUtil; | |||
import com.vaadin.client.ui.dd.DragAndDropHandler.DragAndDropCallback; | |||
@@ -170,12 +169,9 @@ public class DragHandle { | |||
dndHandler = new DragAndDropHandler(); | |||
DOM.sinkEvents(element, Event.ONMOUSEDOWN | Event.ONTOUCHSTART); | |||
DOM.setEventListener(element, new EventListener() { | |||
@Override | |||
public void onBrowserEvent(Event event) { | |||
dndHandler.onDragStartOnDraggableElement(event, dndCallback); | |||
event.stopPropagation(); | |||
} | |||
DOM.setEventListener(element, event -> { | |||
dndHandler.onDragStartOnDraggableElement(event, dndCallback); | |||
event.stopPropagation(); | |||
}); | |||
} | |||
@@ -19,7 +19,6 @@ import com.google.gwt.dom.client.Element; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.ui.AbstractComponentConnector; | |||
import com.vaadin.client.ui.VFlash; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.shared.ui.AbstractEmbeddedState; | |||
import com.vaadin.shared.ui.Connect; | |||
@@ -55,12 +54,10 @@ public class FlashConnector extends AbstractComponentConnector { | |||
getWidget().rebuildIfNeeded(); | |||
} | |||
private final ElementResizeListener listener = new ElementResizeListener() { | |||
public void onElementResize(ElementResizeEvent e) { | |||
Element slot = e.getElement().getParentElement(); | |||
getWidget().setSlotHeightAndWidth(slot.getOffsetHeight(), | |||
slot.getOffsetWidth()); | |||
} | |||
private final ElementResizeListener listener = event -> { | |||
Element slot = event.getElement().getParentElement(); | |||
getWidget().setSlotHeightAndWidth(slot.getOffsetHeight(), | |||
slot.getOffsetWidth()); | |||
}; | |||
@Override |
@@ -35,7 +35,6 @@ import com.vaadin.client.ui.VFormLayout; | |||
import com.vaadin.client.ui.VFormLayout.Caption; | |||
import com.vaadin.client.ui.VFormLayout.ErrorFlag; | |||
import com.vaadin.client.ui.VFormLayout.VFormLayoutTable; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.LayoutClickRpc; | |||
@@ -70,70 +69,62 @@ public class FormLayoutConnector extends AbstractLayoutConnector | |||
private Map<ComponentConnector, String> oldMaxWidths = null; | |||
private static final ElementResizeListener DUMMY_FIRST_CELL_RESIZE_LISTENER = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
// Ignore event, listener added just to make measurements available | |||
} | |||
private static final ElementResizeListener DUMMY_FIRST_CELL_RESIZE_LISTENER = event -> { | |||
// Ignore event, listener added just to make measurements available | |||
}; | |||
// Detects situations when there's something inside the FormLayout that | |||
// prevents it from shrinking | |||
private ElementResizeListener resizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
LayoutManager layoutManager = getLayoutManager(); | |||
double tableWidth = layoutManager | |||
.getOuterWidthDouble(getWidget().table.getElement()); | |||
double ownWidth = layoutManager | |||
.getInnerWidthDouble(getWidget().getElement()); | |||
if (ownWidth < tableWidth) { | |||
// Something inside the table prevents it from shrinking, | |||
// temporarily force column widths | |||
double excessWidth = tableWidth - ownWidth; | |||
// All td elements in the component column have the same width, | |||
// so we only need to check the width of the first one to know | |||
// how wide the column is. | |||
Element firstComponentTd = findFirstComponentTd(); | |||
if (firstComponentTd == null) { | |||
// Can't do anything if there are no rows | |||
return; | |||
} | |||
private ElementResizeListener resizeListener = event -> { | |||
LayoutManager layoutManager = getLayoutManager(); | |||
double tableWidth = layoutManager | |||
.getOuterWidthDouble(getWidget().table.getElement()); | |||
double ownWidth = layoutManager | |||
.getInnerWidthDouble(getWidget().getElement()); | |||
if (ownWidth < tableWidth) { | |||
// Something inside the table prevents it from shrinking, | |||
// temporarily force column widths | |||
double excessWidth = tableWidth - ownWidth; | |||
// All td elements in the component column have the same width, | |||
// so we only need to check the width of the first one to know | |||
// how wide the column is. | |||
Element firstComponentTd = findFirstComponentTd(); | |||
if (firstComponentTd == null) { | |||
// Can't do anything if there are no rows | |||
return; | |||
} | |||
double componentColWidth = layoutManager | |||
.getOuterWidthDouble(firstComponentTd); | |||
double componentColWidth = layoutManager | |||
.getOuterWidthDouble(firstComponentTd); | |||
if (componentColWidth == -1) { | |||
// Didn't get a proper width reading, best to not touch | |||
// anything | |||
return; | |||
} | |||
if (componentColWidth == -1) { | |||
// Didn't get a proper width reading, best to not touch | |||
// anything | |||
return; | |||
} | |||
// Restrict content td width | |||
// Round down to prevent interactions with fractional sizes of | |||
// other columns | |||
int targetWidth = (int) Math | |||
.floor(componentColWidth - excessWidth); | |||
// Restrict content td width | |||
// Round down to prevent interactions with fractional sizes of | |||
// other columns | |||
int targetWidth = (int) Math.floor(componentColWidth - excessWidth); | |||
// Target might be negative if captions are wider than the total | |||
// available width | |||
targetWidth = Math.max(0, targetWidth); | |||
// Target might be negative if captions are wider than the total | |||
// available width | |||
targetWidth = Math.max(0, targetWidth); | |||
if (oldMaxWidths == null) { | |||
oldMaxWidths = new HashMap<>(); | |||
} | |||
if (oldMaxWidths == null) { | |||
oldMaxWidths = new HashMap<>(); | |||
} | |||
for (ComponentConnector child : getChildComponents()) { | |||
Element childElement = child.getWidget().getElement(); | |||
if (!oldMaxWidths.containsKey(child)) { | |||
oldMaxWidths.put(child, | |||
childElement.getPropertyString("maxWidth")); | |||
} | |||
childElement.getStyle().setPropertyPx("maxWidth", | |||
targetWidth); | |||
layoutManager.reportOuterWidth(child, targetWidth); | |||
for (ComponentConnector child : getChildComponents()) { | |||
Element childElement = child.getWidget().getElement(); | |||
if (!oldMaxWidths.containsKey(child)) { | |||
oldMaxWidths.put(child, | |||
childElement.getPropertyString("maxWidth")); | |||
} | |||
childElement.getStyle().setPropertyPx("maxWidth", targetWidth); | |||
layoutManager.reportOuterWidth(child, targetWidth); | |||
} | |||
} | |||
}; |
@@ -54,7 +54,7 @@ public class NativeSelectConnector | |||
protected void init() { | |||
super.init(); | |||
selectionChangeRegistration = getWidget().getListBox() | |||
.addChangeHandler(e -> selectionRpc | |||
.addChangeHandler(event -> selectionRpc | |||
.select(getWidget().getListBox().getSelectedValue())); | |||
} | |||
@@ -57,7 +57,7 @@ public class RadioButtonGroupConnector | |||
super.init(); | |||
selectionChangeRegistration = getWidget().addSelectionChangeHandler( | |||
e -> selectionRpc.select(getRowKey(e))); | |||
event -> selectionRpc.select(getRowKey(event))); | |||
} | |||
@Override |
@@ -38,7 +38,6 @@ import com.vaadin.client.ui.HasRequiredIndicator; | |||
import com.vaadin.client.ui.Icon; | |||
import com.vaadin.client.ui.LayoutClickEventHandler; | |||
import com.vaadin.client.ui.aria.AriaHelper; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.shared.ComponentConstants; | |||
import com.vaadin.shared.communication.URLReference; | |||
@@ -96,73 +95,64 @@ public abstract class AbstractOrderedLayoutConnector | |||
} | |||
}; | |||
private ElementResizeListener slotCaptionResizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
private ElementResizeListener slotCaptionResizeListener = event -> { | |||
// Get all needed element references | |||
Element captionElement = e.getElement(); | |||
// Get all needed element references | |||
Element captionElement = event.getElement(); | |||
// Caption position determines if the widget element is the first or | |||
// last child inside the caption wrap | |||
CaptionPosition pos = getWidget().getCaptionPositionFromElement( | |||
captionElement.getParentElement()); | |||
// Caption position determines if the widget element is the first or | |||
// last child inside the caption wrap | |||
CaptionPosition pos = getWidget().getCaptionPositionFromElement( | |||
captionElement.getParentElement()); | |||
// The default is the last child | |||
Element widgetElement = captionElement.getParentElement() | |||
.getLastChild().cast(); | |||
// The default is the last child | |||
Element widgetElement = captionElement.getParentElement().getLastChild() | |||
.cast(); | |||
// ...but if caption position is bottom or right, the widget is the | |||
// first child | |||
if (pos == CaptionPosition.BOTTOM || pos == CaptionPosition.RIGHT) { | |||
widgetElement = captionElement.getParentElement() | |||
.getFirstChildElement().cast(); | |||
} | |||
// ...but if caption position is bottom or right, the widget is the | |||
// first child | |||
if (pos == CaptionPosition.BOTTOM || pos == CaptionPosition.RIGHT) { | |||
widgetElement = captionElement.getParentElement() | |||
.getFirstChildElement().cast(); | |||
} | |||
if (captionElement == widgetElement) { | |||
// Caption element already detached | |||
Slot slot = getWidget().getSlot(widgetElement); | |||
if (slot != null) { | |||
slot.setCaptionResizeListener(null); | |||
} | |||
return; | |||
if (captionElement == widgetElement) { | |||
// Caption element already detached | |||
Slot slot = getWidget().getSlot(widgetElement); | |||
if (slot != null) { | |||
slot.setCaptionResizeListener(null); | |||
} | |||
return; | |||
} | |||
String widgetWidth = widgetElement.getStyle().getWidth(); | |||
String widgetHeight = widgetElement.getStyle().getHeight(); | |||
String widgetWidth = widgetElement.getStyle().getWidth(); | |||
String widgetHeight = widgetElement.getStyle().getHeight(); | |||
if (widgetHeight.endsWith("%") && (pos == CaptionPosition.TOP | |||
|| pos == CaptionPosition.BOTTOM)) { | |||
getWidget().updateCaptionOffset(captionElement); | |||
} else if (widgetWidth.endsWith("%") && (pos == CaptionPosition.LEFT | |||
|| pos == CaptionPosition.RIGHT)) { | |||
getWidget().updateCaptionOffset(captionElement); | |||
} | |||
if (widgetHeight.endsWith("%") && (pos == CaptionPosition.TOP | |||
|| pos == CaptionPosition.BOTTOM)) { | |||
getWidget().updateCaptionOffset(captionElement); | |||
} else if (widgetWidth.endsWith("%") && (pos == CaptionPosition.LEFT | |||
|| pos == CaptionPosition.RIGHT)) { | |||
getWidget().updateCaptionOffset(captionElement); | |||
} | |||
updateLayoutHeight(); | |||
updateLayoutHeight(); | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
}; | |||
private ElementResizeListener childComponentResizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
updateLayoutHeight(); | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
private ElementResizeListener childComponentResizeListener = event -> { | |||
updateLayoutHeight(); | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
}; | |||
private ElementResizeListener spacingResizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
private ElementResizeListener spacingResizeListener = event -> { | |||
if (needsExpand()) { | |||
getWidget().updateExpandCompensation(); | |||
} | |||
}; | |||
@@ -21,7 +21,6 @@ import com.vaadin.client.communication.RpcProxy; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.ui.AbstractFieldConnector; | |||
import com.vaadin.client.ui.VSlider; | |||
import com.vaadin.client.ui.layout.ElementResizeEvent; | |||
import com.vaadin.client.ui.layout.ElementResizeListener; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.slider.SliderServerRpc; | |||
@@ -35,13 +34,8 @@ public class SliderConnector extends AbstractFieldConnector | |||
protected SliderServerRpc rpc = RpcProxy.create(SliderServerRpc.class, | |||
this); | |||
private final ElementResizeListener resizeListener = new ElementResizeListener() { | |||
@Override | |||
public void onElementResize(ElementResizeEvent e) { | |||
getWidget().iLayout(); | |||
} | |||
}; | |||
private final ElementResizeListener resizeListener = event -> getWidget() | |||
.iLayout(); | |||
@Override | |||
public void init() { |
@@ -31,7 +31,6 @@ import com.google.gwt.event.shared.HandlerManager; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.EventListener; | |||
import com.google.gwt.user.client.Timer; | |||
import com.vaadin.client.BrowserInfo; | |||
import com.vaadin.client.DeferredWorker; | |||
@@ -727,12 +726,9 @@ public abstract class ScrollbarBundle implements DeferredWorker { | |||
if (isInvisibleScrollbar) { | |||
Event.sinkEvents(root, Event.ONSCROLL); | |||
Event.setEventListener(root, new EventListener() { | |||
@Override | |||
public void onBrowserEvent(Event event) { | |||
invisibleScrollbarTemporaryResizer.show(); | |||
} | |||
}); | |||
Event.setEventListener(root, | |||
event -> invisibleScrollbarTemporaryResizer.show()); | |||
root.getStyle().setVisibility(Visibility.HIDDEN); | |||
} else { | |||
Event.sinkEvents(root, 0); |
@@ -72,7 +72,7 @@ public class OsgiUIProvider extends UIProvider { | |||
public UI createInstance(UICreateEvent event) { | |||
if (prototype) { | |||
UI ui = serviceObjects.getService(); | |||
ui.addDetachListener(e -> serviceObjects.ungetService(ui)); | |||
ui.addDetachListener(event2 -> serviceObjects.ungetService(ui)); | |||
return ui; | |||
} | |||
logService.ifPresent(log -> log.log(LogService.LOG_WARNING, |
@@ -121,7 +121,7 @@ public class Navigator implements Serializable { | |||
} | |||
if (navigator != null) { | |||
popStateListenerRegistration = ui.getPage().addPopStateListener( | |||
e -> navigator.navigateTo(getState())); | |||
event -> navigator.navigateTo(getState())); | |||
} | |||
} | |||
@@ -65,7 +65,7 @@ public class PushRequestHandler | |||
public PushRequestHandler(VaadinServletService service) | |||
throws ServiceException { | |||
service.addServiceDestroyListener(e -> destroy()); | |||
service.addServiceDestroyListener(event -> destroy()); | |||
final ServletConfig vaadinServletConfig = service.getServlet() | |||
.getServletConfig(); |
@@ -275,20 +275,21 @@ public class Tree<T> extends Composite | |||
treeGrid.setHeightUndefined(); | |||
treeGrid.setHeightMode(HeightMode.UNDEFINED); | |||
treeGrid.addExpandListener(e -> { | |||
fireExpandEvent(e.getExpandedItem(), e.isUserOriginated()); | |||
treeGrid.addExpandListener(event -> { | |||
fireExpandEvent(event.getExpandedItem(), event.isUserOriginated()); | |||
if (autoRecalculateWidth) { | |||
treeGrid.recalculateColumnWidths(); | |||
} | |||
}); | |||
treeGrid.addCollapseListener(e -> { | |||
fireCollapseEvent(e.getCollapsedItem(), e.isUserOriginated()); | |||
treeGrid.addCollapseListener(event -> { | |||
fireCollapseEvent(event.getCollapsedItem(), | |||
event.isUserOriginated()); | |||
if (autoRecalculateWidth) { | |||
treeGrid.recalculateColumnWidths(); | |||
} | |||
}); | |||
treeGrid.addItemClickListener(e -> fireEvent( | |||
new ItemClick<>(this, e.getItem(), e.getMouseEventDetails()))); | |||
treeGrid.addItemClickListener(event -> fireEvent(new ItemClick<>(this, | |||
event.getItem(), event.getMouseEventDetails()))); | |||
} | |||
/** |
@@ -277,8 +277,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { | |||
blueSlider = createRGBSlider("Blue", "blue"); | |||
setRgbSliderValues(color); | |||
redSlider.addValueChangeListener(e -> { | |||
double red = e.getValue(); | |||
redSlider.addValueChangeListener(event -> { | |||
double red = event.getValue(); | |||
if (!updatingColors) { | |||
Color newColor = new Color((int) red, selectedColor.getGreen(), | |||
selectedColor.getBlue()); | |||
@@ -288,8 +288,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { | |||
sliders.addComponent(redSlider); | |||
greenSlider.addValueChangeListener(e -> { | |||
double green = e.getValue(); | |||
greenSlider.addValueChangeListener(event -> { | |||
double green = event.getValue(); | |||
if (!updatingColors) { | |||
Color newColor = new Color(selectedColor.getRed(), (int) green, | |||
selectedColor.getBlue()); | |||
@@ -298,8 +298,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { | |||
}); | |||
sliders.addComponent(greenSlider); | |||
blueSlider.addValueChangeListener(e -> { | |||
double blue = e.getValue(); | |||
blueSlider.addValueChangeListener(event -> { | |||
double blue = event.getValue(); | |||
if (!updatingColors) { | |||
Color newColor = new Color(selectedColor.getRed(), | |||
selectedColor.getGreen(), (int) blue); |
@@ -283,6 +283,7 @@ public class EditorImpl<T> extends AbstractGridExtension<T> | |||
* if the {@code rowNumber} is not in the backing data provider | |||
* @see #setEnabled(boolean) | |||
*/ | |||
@Override | |||
public void editRow(int rowNumber) | |||
throws IllegalStateException, IllegalArgumentException { | |||
if (!isEnabled()) { |
@@ -86,7 +86,8 @@ public interface MultiSelectionModel<T> | |||
@Override | |||
public default Registration addSelectionListener( | |||
SelectionListener<T> listener) { | |||
return addMultiSelectionListener(e -> listener.selectionChange(e)); | |||
return addMultiSelectionListener( | |||
event -> listener.selectionChange(event)); | |||
} | |||
/** |
@@ -52,7 +52,8 @@ public interface SingleSelectionModel<T> extends GridSelectionModel<T>, | |||
@Override | |||
public default Registration addSelectionListener( | |||
SelectionListener<T> listener) { | |||
return addSingleSelectionListener(e -> listener.selectionChange(e)); | |||
return addSingleSelectionListener( | |||
event -> listener.selectionChange(event)); | |||
} | |||
/** |
@@ -75,7 +75,7 @@ public class DropTargetExtension<T extends AbstractComponent> | |||
protected void registerDropTargetRpc() { | |||
registerRpc( | |||
(DropTargetRpc) (types, data, dropEffect, mouseEventDetails) -> | |||
onDrop(types, data, | |||
onDrop(types, data, | |||
DropEffect.valueOf(dropEffect.toUpperCase(Locale.ROOT)), | |||
mouseEventDetails)); | |||
} |
@@ -50,7 +50,8 @@ public abstract class BinderTestBase<BINDER extends Binder<ITEM>, ITEM> implemen | |||
protected Validator<String> notEmpty = Validator.from(val -> !val.isEmpty(), | |||
EMPTY_ERROR_MESSAGE); | |||
protected Converter<String, Integer> stringToInteger = Converter.from( | |||
Integer::valueOf, String::valueOf, e -> NOT_NUMBER_ERROR_MESSAGE); | |||
Integer::valueOf, String::valueOf, | |||
e -> NOT_NUMBER_ERROR_MESSAGE); | |||
protected Validator<Integer> notNegative = Validator.from(x -> x >= 0, | |||
NEGATIVE_ERROR_MESSAGE); | |||
@@ -136,10 +136,10 @@ public class GridMultiSelectionModelTest { | |||
List<String> selectionChanges = new ArrayList<>(); | |||
Capture<List<String>> oldSelectionCapture = new Capture<>(); | |||
((MultiSelectionModelImpl<String>) customGrid.getSelectionModel()) | |||
.addMultiSelectionListener(e -> { | |||
selectionChanges.addAll(e.getValue()); | |||
.addMultiSelectionListener(event -> { | |||
selectionChanges.addAll(event.getValue()); | |||
oldSelectionCapture | |||
.setValue(new ArrayList<>(e.getOldSelection())); | |||
.setValue(new ArrayList<>(event.getOldSelection())); | |||
}); | |||
customGrid.getSelectionModel().select("Foo"); |
@@ -75,7 +75,7 @@ public class GridSingleSelectionModelTest { | |||
selectionChanges = new ArrayList<>(); | |||
selectionModel.addSingleSelectionListener( | |||
e -> selectionChanges.add(e.getValue())); | |||
event -> selectionChanges.add(event.getValue())); | |||
} | |||
@Test(expected = IllegalStateException.class) | |||
@@ -99,9 +99,9 @@ public class GridSingleSelectionModelTest { | |||
List<String> selectionChanges = new ArrayList<>(); | |||
List<String> oldSelectionValues = new ArrayList<>(); | |||
((SingleSelectionModelImpl<String>) customGrid.getSelectionModel()) | |||
.addSingleSelectionListener(e -> { | |||
selectionChanges.add(e.getValue()); | |||
oldSelectionValues.add(e.getOldValue()); | |||
.addSingleSelectionListener(event -> { | |||
selectionChanges.add(event.getValue()); | |||
oldSelectionValues.add(event.getOldValue()); | |||
}); | |||
customGrid.getSelectionModel().select("Foo"); |
@@ -34,8 +34,8 @@ public class TreeGridTest { | |||
treeData.addItem("Foo", "Baz"); | |||
treeGrid.setDataProvider(new TreeDataProvider<>(treeData)); | |||
treeGrid.addExpandListener(e -> expandEventFired = true); | |||
treeGrid.addCollapseListener(e -> collapseEventFired = true); | |||
treeGrid.addExpandListener(event -> expandEventFired = true); | |||
treeGrid.addCollapseListener(event -> collapseEventFired = true); | |||
// Test expand event | |||
assertFalse(expandEventFired); |
@@ -28,8 +28,8 @@ public class ExtendedDesignWithEmptyAnnotation | |||
customField.setPlaceholder("Something"); | |||
addComponent(customField); | |||
ok.addClickListener(e -> Notification.show("OK")); | |||
ok.addClickListener(event -> Notification.show("OK")); | |||
CaNCEL.addClickListener(e -> Notification.show("cancel")); | |||
CaNCEL.addClickListener(event -> Notification.show("cancel")); | |||
} | |||
} |
@@ -22,7 +22,7 @@ public class ButtonClickTest { | |||
public void clickDetachedButton() { | |||
Button b = new Button(); | |||
AtomicInteger counter = new AtomicInteger(0); | |||
b.addClickListener(e -> counter.incrementAndGet()); | |||
b.addClickListener(event -> counter.incrementAndGet()); | |||
b.click(); | |||
assertEquals(1, counter.get()); | |||
@@ -62,6 +62,6 @@ public class ButtonClickTest { | |||
private void addClickListener(Button b) { | |||
clicked = false; | |||
b.addClickListener(e -> clicked = true); | |||
b.addClickListener(event -> clicked = true); | |||
} | |||
} |
@@ -317,9 +317,9 @@ public class TabSheetTest { | |||
Button b3 = new Button("b3"); | |||
Button b4 = new Button("b4"); | |||
TestTabsheet tabsheet = new TestTabsheet(b1, b2, b3, b4); | |||
tabsheet.addSelectedTabChangeListener(e -> { | |||
userOriginated.set(e.isUserOriginated()); | |||
selected.set(e.getTabSheet().getSelectedTab()); | |||
tabsheet.addSelectedTabChangeListener(event -> { | |||
userOriginated.set(event.isUserOriginated()); | |||
selected.set(event.getTabSheet().getSelectedTab()); | |||
}); | |||
tabsheet.setSelectedTab(b2); |
@@ -220,7 +220,8 @@ public class AttachDetachWindowTest { | |||
final boolean[] eventFired = new boolean[1]; | |||
ui.addComponentAttachListener( | |||
e -> eventFired[0] = e.getAttachedComponent().equals(window)); | |||
event -> eventFired[0] = event.getAttachedComponent() | |||
.equals(window)); | |||
ui.addWindow(window); | |||
assertTrue("Attach event is not fired for added window", eventFired[0]); | |||
} | |||
@@ -232,7 +233,8 @@ public class AttachDetachWindowTest { | |||
final boolean[] eventFired = new boolean[1]; | |||
ui.addComponentDetachListener( | |||
e -> eventFired[0] = e.getDetachedComponent().equals(window)); | |||
event -> eventFired[0] = event.getDetachedComponent() | |||
.equals(window)); | |||
ui.addWindow(window); | |||
ui.removeWindow(window); | |||
@@ -1167,13 +1167,10 @@ public class NavigatorTest { | |||
AtomicReference<Map<String, String>> mapRef = new AtomicReference<>(); | |||
AtomicReference<Map<String, String>> mapRefB = new AtomicReference<>(); | |||
navigator.addViewChangeListener(new ViewChangeListener() { | |||
@Override | |||
public boolean beforeViewChange(ViewChangeEvent event) { | |||
mapRef.set(event.getParameterMap()); | |||
mapRefB.set(event.getParameterMap("b")); | |||
return true; | |||
} | |||
navigator.addViewChangeListener(event -> { | |||
mapRef.set(event.getParameterMap()); | |||
mapRefB.set(event.getParameterMap("b")); | |||
return true; | |||
}); | |||
navigator.navigateTo("view1"); |
@@ -84,8 +84,10 @@ public class AbstractSingleSelectTest { | |||
selectionChanges = new ArrayList<>(); | |||
oldSelections = new ArrayList<>(); | |||
listing.addSelectionListener(e -> selectionChanges.add(e.getValue())); | |||
listing.addSelectionListener(e -> oldSelections.add(e.getOldValue())); | |||
listing.addSelectionListener( | |||
event -> selectionChanges.add(event.getValue())); | |||
listing.addSelectionListener( | |||
event -> oldSelections.add(event.getOldValue())); | |||
} | |||
public static final Person PERSON_C = new Person("c", 3); |
@@ -50,7 +50,7 @@ public class CheckBoxTest { | |||
ui.setContent(cb); | |||
AtomicBoolean userOriginated = new AtomicBoolean(false); | |||
cb.addValueChangeListener( | |||
e -> userOriginated.set(e.isUserOriginated())); | |||
event -> userOriginated.set(event.isUserOriginated())); | |||
ComponentTest.syncToClient(cb); | |||
ServerRpcManager.getRpcProxy(cb, CheckBoxServerRpc.class) | |||
.setChecked(true, new MouseEventDetails()); | |||
@@ -69,7 +69,7 @@ public class CheckBoxTest { | |||
ui.setContent(cb); | |||
AtomicBoolean userOriginated = new AtomicBoolean(true); | |||
cb.addValueChangeListener( | |||
e -> userOriginated.set(e.isUserOriginated())); | |||
event -> userOriginated.set(event.isUserOriginated())); | |||
cb.setValue(true); | |||
assertFalse(userOriginated.get()); | |||
userOriginated.set(true); |
@@ -30,7 +30,7 @@ public class ComboBoxTest { | |||
// Reset value whenever it changes (in a real case, this listener would | |||
// do something with the selected value before discarding it) | |||
comboBox.addValueChangeListener(e -> comboBox.setValue(null)); | |||
comboBox.addValueChangeListener(event -> comboBox.setValue(null)); | |||
// "Attach" the component and initialize diffstate | |||
new MockUI().setContent(comboBox); |
@@ -20,7 +20,7 @@ public class MyVaadinUI extends UI { | |||
@Override | |||
protected void init(VaadinRequest request) { | |||
setContent(new Button("Click Me", | |||
e -> Notification.show(service.getText()))); | |||
event -> Notification.show(service.getText()))); | |||
} | |||
} |
@@ -57,6 +57,7 @@ public class LongPollingProxyServerIT extends AbstractIntegrationTest { | |||
@Parameter(1) | |||
public String path; | |||
@Override | |||
@Before | |||
public void setup() throws Exception { | |||
Assume.assumeTrue( |
@@ -15,17 +15,16 @@ | |||
*/ | |||
package com.vaadin.tests.integration.push; | |||
import java.util.Timer; | |||
import java.util.TimerTask; | |||
import com.vaadin.annotations.Push; | |||
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 java.util.Timer; | |||
import java.util.TimerTask; | |||
@Push | |||
public class BasicPush extends AbstractTestUI { | |||
@@ -59,13 +58,9 @@ public class BasicPush extends AbstractTestUI { | |||
addComponent(lbl); | |||
Button incrementButton = new Button("Increment", | |||
new 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); | |||
@@ -103,13 +98,10 @@ public class BasicPush extends AbstractTestUI { | |||
startTimer.setId(START_TIMER_ID); | |||
addComponent(startTimer); | |||
Button stopTimer = new Button("Stop timer", new 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); |
@@ -27,7 +27,7 @@ public class MyUI extends UI { | |||
name.setCaption("Type your name here:"); | |||
Button button = new Button("Click Me"); | |||
button.addClickListener(e -> layout.addComponent( | |||
button.addClickListener(event -> layout.addComponent( | |||
new Label("Thanks " + name.getValue() + ", it works!"))); | |||
layout.addComponents(name, button); |
@@ -23,7 +23,7 @@ public class MyUI extends UI { | |||
name.setCaption("Type your name here:"); | |||
Button button = new Button("Click Me"); | |||
button.addClickListener(e -> layout.addComponent( | |||
button.addClickListener(event -> layout.addComponent( | |||
new Label("Thanks " + name.getValue() + ", it works!"))); | |||
layout.addComponents(name, button); |
@@ -23,7 +23,7 @@ public class DefaultView extends VerticalLayout implements View { | |||
void init() { | |||
setId("default-view"); | |||
Button button = new Button("Click Me!", | |||
e -> Notification.show(service.getText())); | |||
event -> Notification.show(service.getText())); | |||
addComponent(button); | |||
} | |||
@@ -23,7 +23,7 @@ public class DefaultView extends VerticalLayout implements View { | |||
void init() { | |||
setId("default-view"); | |||
Button button = new Button("Click Me!", | |||
e -> Notification.show(service.getText())); | |||
event -> Notification.show(service.getText())); | |||
addComponent(button); | |||
} | |||
@@ -2,7 +2,6 @@ package com.vaadin.test.widgetset; | |||
import com.vaadin.server.VaadinRequest; | |||
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.UI; | |||
@@ -19,13 +18,9 @@ public abstract class AbstractTestWidgetSetUI extends UI { | |||
name.setCaption("Type your name here:"); | |||
Button button = new Button("Click Me"); | |||
button.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent clickEvent) { | |||
layout.addComponent( | |||
new Label("Thanks " + name.getValue() + ", it works!")); | |||
} | |||
}); | |||
button.addClickListener( | |||
event -> new Label( | |||
"Thanks " + name.getValue() + ", it works!")); | |||
getPage().getJavaScript().execute( | |||
"widgetsetinfo.innerText=document.querySelector('iframe').id;"); |
@@ -462,7 +462,8 @@ public class GridElement extends AbstractComponentElement { | |||
Optional<WebElement> toggleButton = getDriver() | |||
.findElement(By.className("v-grid-sidebar-content")) | |||
.findElements(By.className("column-hiding-toggle")).stream() | |||
.filter(e -> e.getText().equals(toggleCaption)).findAny(); | |||
.filter(e -> e.getText().equals(toggleCaption)) | |||
.findAny(); | |||
if (toggleButton.isPresent()) { | |||
toggleButton.ifPresent(e -> e.click()); | |||
} else { |
@@ -46,8 +46,6 @@ import com.vaadin.server.DeploymentConfiguration; | |||
import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.server.LegacyVaadinServlet; | |||
import com.vaadin.server.ServiceException; | |||
import com.vaadin.server.SessionInitEvent; | |||
import com.vaadin.server.SessionInitListener; | |||
import com.vaadin.server.SystemMessages; | |||
import com.vaadin.server.SystemMessagesInfo; | |||
import com.vaadin.server.SystemMessagesProvider; | |||
@@ -133,13 +131,8 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { | |||
@Override | |||
protected void servletInitialized() throws ServletException { | |||
super.servletInitialized(); | |||
getService().addSessionInitListener(new SessionInitListener() { | |||
@Override | |||
public void sessionInit(SessionInitEvent event) | |||
throws ServiceException { | |||
onVaadinSessionStarted(event.getRequest(), event.getSession()); | |||
} | |||
}); | |||
getService().addSessionInitListener( | |||
event -> onVaadinSessionStarted(event.getRequest(), event.getSession())); | |||
} | |||
private void addDirectories(File parent, LinkedHashSet<String> packages, |
@@ -48,6 +48,7 @@ import org.eclipse.jetty.server.Connector; | |||
import org.eclipse.jetty.server.Server; | |||
import org.eclipse.jetty.server.ServerConnector; | |||
import org.eclipse.jetty.util.Scanner; | |||
import org.eclipse.jetty.util.Scanner.BulkListener; | |||
import org.eclipse.jetty.util.log.JavaUtilLog; | |||
import org.eclipse.jetty.util.ssl.SslContextFactory; | |||
import org.eclipse.jetty.webapp.WebAppContext; | |||
@@ -249,15 +250,11 @@ public class DevelopmentServerLauncher { | |||
scanner.setScanInterval(interval); | |||
scanner.setRecursive(true); | |||
scanner.addListener(new Scanner.BulkListener() { | |||
@Override | |||
public void filesChanged(List<String> filenames) | |||
throws Exception { | |||
webappcontext.stop(); | |||
server.stop(); | |||
webappcontext.start(); | |||
server.start(); | |||
} | |||
scanner.addListener((BulkListener) e-> { | |||
webappcontext.stop(); | |||
server.stop(); | |||
webappcontext.start(); | |||
server.start(); | |||
}); | |||
scanner.setReportExistingFilesOnStartup(false); | |||
scanner.setFilenameFilter(new FilenameFilter() { |
@@ -32,15 +32,12 @@ import com.vaadin.server.FileResource; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.ui.BrowserFrame; | |||
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.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
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.data.util.BeanItemContainer; | |||
import com.vaadin.v7.ui.Table; | |||
@@ -208,20 +205,11 @@ public class ScreenshotBrowser extends UI { | |||
left.addComponent(createSpacer()); | |||
left.addComponent( | |||
new Button("Commit actions", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
commitActions(); | |||
} | |||
})); | |||
new Button("Commit actions", event -> commitActions())); | |||
left.addComponent(createSpacer()); | |||
left.addComponent(new Button("Refresh", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
refreshTableContainer(); | |||
} | |||
})); | |||
left.addComponent( | |||
new Button("Refresh", event -> refreshTableContainer())); | |||
Label expandSpacer = createSpacer(); | |||
left.addComponent(expandSpacer); | |||
@@ -253,12 +241,7 @@ public class ScreenshotBrowser extends UI { | |||
} | |||
private ClickListener createSetActionListener(final Action action) { | |||
return new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
setActions(action); | |||
} | |||
}; | |||
return event -> setActions(action); | |||
} | |||
public void setActions(final Action action) { | |||
@@ -289,15 +272,13 @@ public class ScreenshotBrowser extends UI { | |||
table.setHeight("100%"); | |||
table.setMultiSelect(true); | |||
table.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
@SuppressWarnings("unchecked") | |||
Collection<ComparisonFailure> selectedRows = (Collection<ComparisonFailure>) table | |||
.getValue(); | |||
table.addValueChangeListener(event -> { | |||
viewer.setItems(selectedRows); | |||
} | |||
@SuppressWarnings("unchecked") | |||
Collection<ComparisonFailure> selectedRows = (Collection<ComparisonFailure>) table | |||
.getValue(); | |||
viewer.setItems(selectedRows); | |||
}); | |||
table.addShortcutListener( |
@@ -21,8 +21,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.Button.ClickListener; | |||
import com.vaadin.ui.Window; | |||
/** | |||
@@ -42,36 +40,24 @@ public class WindowWaiAriaRoles extends AbstractReindeerTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button closeButton = new Button("Close windows"); | |||
closeButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
while (!windows.isEmpty()) { | |||
Window window = windows.pop(); | |||
removeWindow(window); | |||
} | |||
closeButton.addClickListener(event -> { | |||
while (!windows.isEmpty()) { | |||
Window window = windows.pop(); | |||
removeWindow(window); | |||
} | |||
}); | |||
Button regularButton = new Button("Regular"); | |||
regularButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Window regularWindow = new Window("Regular window"); | |||
openWindow(regularWindow); | |||
} | |||
regularButton.addClickListener(event -> { | |||
Window regularWindow = new Window("Regular window"); | |||
openWindow(regularWindow); | |||
}); | |||
Button alertButton = new Button("Alert"); | |||
alertButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Window alertWindow = new Window("Alert window"); | |||
alertWindow.setAssistiveRole(WindowRole.ALERTDIALOG); | |||
openWindow(alertWindow); | |||
} | |||
alertButton.addClickListener(event -> { | |||
Window alertWindow = new Window("Alert window"); | |||
alertWindow.setAssistiveRole(WindowRole.ALERTDIALOG); | |||
openWindow(alertWindow); | |||
}); | |||
addComponent(closeButton); | |||
addComponent(regularButton); |
@@ -4,7 +4,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
public class ActionsOnInvisibleComponents extends AbstractTestUIWithLog { | |||
@@ -19,36 +18,27 @@ public class ActionsOnInvisibleComponents extends AbstractTestUIWithLog { | |||
Button invisibleButton = new Button("Invisible button with shortcut"); | |||
invisibleButton.setClickShortcut(KeyCode.A); | |||
invisibleButton.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Click event for invisible button"); | |||
} | |||
}); | |||
invisibleButton | |||
.addClickListener( | |||
event -> log("Click event for invisible button")); | |||
invisibleButton.setVisible(false); | |||
addComponent(invisibleButton); | |||
Button disabledButton = new Button("Disabled button with shortcut"); | |||
disabledButton.setClickShortcut(KeyCode.B); | |||
disabledButton.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Click event for disabled button"); | |||
} | |||
}); | |||
disabledButton | |||
.addClickListener( | |||
event -> log("Click event for disabled button")); | |||
disabledButton.setEnabled(false); | |||
addComponent(disabledButton); | |||
Button enabledButton = new Button("Enabled button with shortcut"); | |||
enabledButton.setClickShortcut(KeyCode.C); | |||
enabledButton.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Click event for enabled button"); | |||
} | |||
}); | |||
enabledButton | |||
.addClickListener( | |||
event -> log("Click event for enabled button")); | |||
addComponent(enabledButton); | |||
} |
@@ -3,7 +3,6 @@ package com.vaadin.tests.application; | |||
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.ui.LegacyWindow; | |||
@@ -23,13 +22,9 @@ public class ApplicationCloseTest extends TestBase { | |||
addComponent(applications); | |||
Label thisApp = new Label("This applications: " + this); | |||
Button close = new Button("Close this", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
LegacyWindow ui = (LegacyWindow) event.getButton().getUI(); | |||
ui.getApplication().close(); | |||
} | |||
Button close = new Button("Close this", event -> { | |||
LegacyWindow ui = (LegacyWindow) event.getButton().getUI(); | |||
ui.getApplication().close(); | |||
}); | |||
StringBuilder sb = new StringBuilder(); |
@@ -20,16 +20,12 @@ import com.vaadin.server.VaadinServlet; | |||
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.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
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.TextField; | |||
/** | |||
@@ -77,13 +73,7 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
addComponent(createConfigPanel()); | |||
addComponent(createServerConfigPanel()); | |||
addComponent(new Button("Say hello", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Hello"); | |||
} | |||
})); | |||
addComponent(new Button("Say hello", event -> log("Hello"))); | |||
} | |||
/** | |||
@@ -100,25 +90,20 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
createTemporaryResponseCodeSetters("UIDL", uidlResponse)); | |||
vl.addComponent(createTemporaryResponseCodeSetters("Heartbeat", | |||
heartbeatResponse)); | |||
vl.addComponent(new Button("Activate", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (uidlResponse.code != null && uidlResponse.code != 200) { | |||
getServlet().setUIDLResponseCode(CommErrorEmulatorUI.this, | |||
uidlResponse.code, uidlResponse.time); | |||
log("Responding with " + uidlResponse.code | |||
+ " to UIDL requests for " + uidlResponse.time | |||
+ "s"); | |||
} | |||
if (heartbeatResponse.code != null | |||
&& heartbeatResponse.code != 200) { | |||
getServlet().setHeartbeatResponseCode( | |||
CommErrorEmulatorUI.this, heartbeatResponse.code, | |||
heartbeatResponse.time); | |||
log("Responding with " + heartbeatResponse.code | |||
+ " to heartbeat requests for " | |||
+ heartbeatResponse.time + "s"); | |||
} | |||
vl.addComponent(new Button("Activate", event -> { | |||
if (uidlResponse.code != null && uidlResponse.code != 200) { | |||
getServlet().setUIDLResponseCode(CommErrorEmulatorUI.this, | |||
uidlResponse.code, uidlResponse.time); | |||
log("Responding with " + uidlResponse.code | |||
+ " to UIDL requests for " + uidlResponse.time + "s"); | |||
} | |||
if (heartbeatResponse.code != null | |||
&& heartbeatResponse.code != 200) { | |||
getServlet().setHeartbeatResponseCode(CommErrorEmulatorUI.this, | |||
heartbeatResponse.code, heartbeatResponse.time); | |||
log("Responding with " + heartbeatResponse.code | |||
+ " to heartbeat requests for " + heartbeatResponse.time | |||
+ "s"); | |||
} | |||
})); | |||
@@ -134,13 +119,9 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
reconnectDialogMessage | |||
.setValue(getReconnectDialogConfiguration().getDialogText()); | |||
reconnectDialogMessage | |||
.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
.addValueChangeListener(event -> | |||
getReconnectDialogConfiguration().setDialogText( | |||
reconnectDialogMessage.getValue()); | |||
} | |||
}); | |||
reconnectDialogMessage.getValue())); | |||
final TextField reconnectDialogGaveUpMessage = new TextField( | |||
"Reconnect gave up message"); | |||
@@ -149,41 +130,29 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
reconnectDialogGaveUpMessage.setValue( | |||
getReconnectDialogConfiguration().getDialogTextGaveUp()); | |||
reconnectDialogGaveUpMessage | |||
.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
.addValueChangeListener(event -> | |||
getReconnectDialogConfiguration().setDialogTextGaveUp( | |||
reconnectDialogGaveUpMessage.getValue()); | |||
} | |||
}); | |||
reconnectDialogGaveUpMessage.getValue())); | |||
final TextField reconnectDialogReconnectAttempts = new TextField( | |||
"Reconnect attempts"); | |||
reconnectDialogReconnectAttempts.setConverter(Integer.class); | |||
reconnectDialogReconnectAttempts.setConvertedValue( | |||
getReconnectDialogConfiguration().getReconnectAttempts()); | |||
reconnectDialogReconnectAttempts | |||
.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
.addValueChangeListener(event -> | |||
getReconnectDialogConfiguration().setReconnectAttempts( | |||
(Integer) reconnectDialogReconnectAttempts | |||
.getConvertedValue()); | |||
} | |||
}); | |||
.getConvertedValue())); | |||
final TextField reconnectDialogReconnectInterval = new TextField( | |||
"Reconnect interval (ms)"); | |||
reconnectDialogReconnectInterval.setConverter(Integer.class); | |||
reconnectDialogReconnectInterval.setConvertedValue( | |||
getReconnectDialogConfiguration().getReconnectInterval()); | |||
reconnectDialogReconnectInterval | |||
.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
.addValueChangeListener(event -> | |||
getReconnectDialogConfiguration().setReconnectInterval( | |||
(Integer) reconnectDialogReconnectInterval | |||
.getConvertedValue()); | |||
} | |||
}); | |||
.getConvertedValue())); | |||
final TextField reconnectDialogGracePeriod = new TextField( | |||
"Reconnect dialog grace period (ms)"); | |||
@@ -191,14 +160,11 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
reconnectDialogGracePeriod.setConvertedValue( | |||
getReconnectDialogConfiguration().getDialogGracePeriod()); | |||
reconnectDialogGracePeriod | |||
.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
getReconnectDialogConfiguration().setDialogGracePeriod( | |||
.addValueChangeListener( | |||
event -> getReconnectDialogConfiguration() | |||
.setDialogGracePeriod( | |||
(Integer) reconnectDialogGracePeriod | |||
.getConvertedValue()); | |||
} | |||
}); | |||
.getConvertedValue())); | |||
final CheckBox reconnectDialogModal = new CheckBox( | |||
"Reconnect dialog modality"); | |||
@@ -235,20 +201,14 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog { | |||
timeField.setWidth("5em"); | |||
Label l3 = new Label("seconds"); | |||
responseCode.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Integer code = (Integer) responseCode.getConvertedValue(); | |||
response.code = code; | |||
} | |||
responseCode.addValueChangeListener(event -> { | |||
Integer code = (Integer) responseCode.getConvertedValue(); | |||
response.code = code; | |||
}); | |||
timeField.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Integer time = (Integer) timeField.getConvertedValue(); | |||
response.time = time; | |||
} | |||
timeField.addValueChangeListener(event -> { | |||
Integer time = (Integer) timeField.getConvertedValue(); | |||
response.time = time; | |||
}); | |||
hl.addComponents(l1, responseCode, l2, timeField, l3); |
@@ -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.Button.ClickEvent; | |||
import com.vaadin.ui.JavaScript; | |||
public class ConfirmBrowserTabClose extends AbstractTestUIWithLog { | |||
@@ -31,13 +30,7 @@ public class ConfirmBrowserTabClose extends AbstractTestUIWithLog { | |||
// 3. Choose to stay on the page after all | |||
// 4. Click the button | |||
// There should be no error | |||
Button b = new Button("Say hello", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Hello"); | |||
} | |||
}); | |||
Button b = new Button("Say hello", event -> log("Hello")); | |||
addComponent(b); | |||
JavaScript | |||
.eval("window.addEventListener('beforeunload', function (e) {" |
@@ -32,11 +32,11 @@ public class ConnectorBundleStatus extends AbstractTestUI { | |||
statusDisplay.setId("bundleStatus"); | |||
Button refreshButton = new Button("Refresh status", | |||
e -> statusDisplay.updateStatus()); | |||
event -> statusDisplay.updateStatus()); | |||
refreshButton.setId("refresh"); | |||
Button rtaButton = new Button("Add RichTextArea (in the lazy bundle)", | |||
e -> addComponent(new RichTextArea())); | |||
event -> addComponent(new RichTextArea())); | |||
rtaButton.setId("rta"); | |||
addComponents(statusDisplay, refreshButton, rtaButton); |
@@ -24,8 +24,6 @@ import com.vaadin.server.VaadinService; | |||
import com.vaadin.shared.JsonConstants; | |||
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; | |||
public class CriticalNotifications extends AbstractReindeerTestUI { | |||
@@ -43,91 +41,53 @@ public class CriticalNotifications extends AbstractReindeerTestUI { | |||
Button sessionExpired = new Button("Session expired"); | |||
addComponent(sessionExpired); | |||
sessionExpired.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
showCriticalNotification( | |||
systemMessages.getSessionExpiredCaption(), | |||
systemMessages.getSessionExpiredMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getSessionExpiredURL()); | |||
} | |||
}); | |||
sessionExpired.addClickListener(event -> | |||
showCriticalNotification(systemMessages.getSessionExpiredCaption(), | |||
systemMessages.getSessionExpiredMessage(), getDetailsMessage(), | |||
systemMessages.getSessionExpiredURL())); | |||
Button authenticationError = new Button("Authentication error"); | |||
addComponent(authenticationError); | |||
authenticationError.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
showCriticalNotification( | |||
systemMessages.getAuthenticationErrorCaption(), | |||
systemMessages.getAuthenticationErrorMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getAuthenticationErrorURL()); | |||
} | |||
}); | |||
authenticationError.addClickListener(event -> | |||
showCriticalNotification(systemMessages.getAuthenticationErrorCaption(), | |||
systemMessages.getAuthenticationErrorMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getAuthenticationErrorURL())); | |||
Button communicationError = new Button("Communication error"); | |||
addComponent(communicationError); | |||
communicationError.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
showCriticalNotification( | |||
systemMessages.getCommunicationErrorCaption(), | |||
systemMessages.getCommunicationErrorMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getCommunicationErrorURL()); | |||
} | |||
}); | |||
communicationError.addClickListener(event -> | |||
showCriticalNotification(systemMessages.getCommunicationErrorCaption(), | |||
systemMessages.getCommunicationErrorMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getCommunicationErrorURL())); | |||
Button internalError = new Button("Internal error"); | |||
addComponent(internalError); | |||
internalError.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
showCriticalNotification( | |||
systemMessages.getInternalErrorCaption(), | |||
systemMessages.getInternalErrorMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getInternalErrorURL()); | |||
} | |||
}); | |||
internalError.addClickListener(event -> | |||
showCriticalNotification(systemMessages.getInternalErrorCaption(), | |||
systemMessages.getInternalErrorMessage(), getDetailsMessage(), | |||
systemMessages.getInternalErrorURL())); | |||
Button cookiesDisabled = new Button("Cookies disabled"); | |||
addComponent(cookiesDisabled); | |||
cookiesDisabled.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
showCriticalNotification( | |||
systemMessages.getCookiesDisabledCaption(), | |||
systemMessages.getCookiesDisabledMessage(), | |||
getDetailsMessage(), | |||
systemMessages.getCookiesDisabledURL()); | |||
} | |||
}); | |||
cookiesDisabled.addClickListener(event -> showCriticalNotification( | |||
systemMessages.getCookiesDisabledCaption(), | |||
systemMessages.getCookiesDisabledMessage(), getDetailsMessage(), | |||
systemMessages.getCookiesDisabledURL())); | |||
Button custom = new Button("Custom"); | |||
addComponent(custom); | |||
custom.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
custom.addClickListener( | |||
event -> | |||
showCriticalNotification("Custom caption", "Custom message", | |||
"Custom details", "custom url"); | |||
} | |||
}); | |||
"Custom details", "custom url")); | |||
} | |||
protected String getDetailsMessage() { | |||
if (includeDetails.getValue()) { | |||
return "Some details for the error"; | |||
} else { | |||
return null; | |||
} | |||
return null; | |||
} | |||
protected void showCriticalNotification(String caption, String message, |
@@ -22,7 +22,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.ui.Label; | |||
public class DetachOldUIOnReload extends AbstractTestUIWithLog { | |||
@@ -32,19 +31,11 @@ public class DetachOldUIOnReload extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
addComponent(new Label("This is UI " + getUIId())); | |||
addComponent(new Button("Reload page", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getPage().reload(); | |||
} | |||
})); | |||
addComponent(new Button("Reload page", event -> getPage().reload())); | |||
addComponent(new Button("Read log messages from session", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
for (String message : getSessionMessages(false)) { | |||
log(message); | |||
} | |||
event -> { | |||
for (String message : getSessionMessages(false)) { | |||
log(message); | |||
} | |||
})); | |||
} |
@@ -3,8 +3,6 @@ package com.vaadin.tests.application; | |||
import com.vaadin.event.ShortcutAction.KeyCode; | |||
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.FormLayout; | |||
import com.vaadin.ui.HorizontalLayout; | |||
@@ -50,15 +48,12 @@ public class ErrorInUnloadEvent extends AbstractTestCase { | |||
formLayout.addComponent(login); | |||
mainWindow.setContent(formLayout); | |||
login.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(final ClickEvent event) { | |||
String username = userField.getValue(); | |||
String password = passwordField.getValue(); | |||
login.addClickListener(event -> { | |||
String username = userField.getValue(); | |||
String password = passwordField.getValue(); | |||
user = username; | |||
showMainWindow(); | |||
} | |||
user = username; | |||
showMainWindow(); | |||
}); | |||
} | |||
@@ -82,13 +77,9 @@ public class ErrorInUnloadEvent extends AbstractTestCase { | |||
title.addStyleName("header-title"); | |||
header.addComponent(title); | |||
Button logout = new Button("Logout"); | |||
logout.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(final ClickEvent event) { | |||
user = null; | |||
showLoginWindow(); | |||
} | |||
logout.addClickListener(event -> { | |||
user = null; | |||
showLoginWindow(); | |||
}); | |||
header.addComponent(logout); | |||
return header; |
@@ -18,7 +18,6 @@ package com.vaadin.tests.application; | |||
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.Component; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -51,19 +50,9 @@ public class MissingHierarchyDetection extends AbstractReindeerTestUIWithLog { | |||
protected void setup(VaadinRequest request) { | |||
addComponent(brokenLayout); | |||
addComponent(normalLayout); | |||
addComponent(new Button("Toggle properly", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
toggle(true); | |||
} | |||
})); | |||
addComponent(new Button("Toggle properly", event -> toggle(true))); | |||
addComponent( | |||
new Button("Toggle improperly", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
toggle(false); | |||
} | |||
})); | |||
new Button("Toggle improperly", event -> toggle(false))); | |||
} | |||
private void toggle(boolean properly) { |
@@ -18,8 +18,6 @@ package com.vaadin.tests.application; | |||
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; | |||
public class ReconnectDialogUI extends AbstractReindeerTestUIWithLog { | |||
@@ -30,13 +28,7 @@ public class ReconnectDialogUI extends AbstractReindeerTestUIWithLog { | |||
.parseInt(request.getParameter("reconnectAttempts"))); | |||
} | |||
Button b = new Button("Say hello"); | |||
b.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Hello from the server"); | |||
} | |||
}); | |||
b.addClickListener(event -> log("Hello from the server")); | |||
addComponent(b); | |||
} |
@@ -1,8 +1,6 @@ | |||
package com.vaadin.tests.application; | |||
import com.vaadin.annotations.PreserveOnRefresh; | |||
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.Label; | |||
@@ -18,13 +16,7 @@ public class RefreshStatePreserve extends AbstractTestUIWithLog { | |||
log("Initial fragment: " + getPage().getUriFragment()); | |||
getPage().addUriFragmentChangedListener( | |||
new UriFragmentChangedListener() { | |||
@Override | |||
public void uriFragmentChanged( | |||
UriFragmentChangedEvent event) { | |||
log("Fragment changed to " + event.getUriFragment()); | |||
} | |||
}); | |||
event -> log("Fragment changed to " + event.getUriFragment())); | |||
} | |||
@Override |
@@ -18,21 +18,16 @@ 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.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
public class ResynchronizeUI extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button b = new Button("Resynchronize", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
// Theme change is currently the only operation which always | |||
// does resynchronize | |||
setTheme("runo"); | |||
log("Set theme to runo"); | |||
} | |||
Button b = new Button("Resynchronize", event -> { | |||
// Theme change is currently the only operation which always | |||
// does resynchronize | |||
setTheme("runo"); | |||
log("Set theme to runo"); | |||
}); | |||
addComponent(b); | |||
} |
@@ -17,7 +17,6 @@ package com.vaadin.tests.application; | |||
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.UI; | |||
@@ -26,12 +25,8 @@ public class TerminalErrorNotification extends TestBase { | |||
@Override | |||
protected void setup() { | |||
Button button = new Button("Throw exception", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
throw new RuntimeException("You asked for it"); | |||
} | |||
event -> { | |||
throw new RuntimeException("You asked for it"); | |||
}); | |||
addComponent(button); |
@@ -8,7 +8,6 @@ import com.vaadin.tests.components.AbstractTestCase; | |||
import com.vaadin.tests.integration.FlagSeResource; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Embedded; | |||
import com.vaadin.ui.LegacyWindow; | |||
import com.vaadin.ui.UI; | |||
@@ -67,12 +66,8 @@ public class ThreadLocalInstances extends AbstractTestCase { | |||
public ThreadLocalInstances() { | |||
mainWindow.addComponent(log); | |||
mainWindow.addComponent(new Embedded("Icon", resource)); | |||
mainWindow.addComponent(new Button("Sync", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
reportCurrentStatus("button listener"); | |||
} | |||
})); | |||
mainWindow.addComponent(new Button("Sync", | |||
event -> reportCurrentStatus("button listener"))); | |||
reportStatus("class init", staticInitApplication, staticInitRoot); | |||
reportCurrentStatus("app constructor"); |
@@ -18,8 +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.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.JavaScriptFunction; | |||
import elemental.json.JsonArray; | |||
@@ -58,14 +56,8 @@ public class TimingInfoReported extends AbstractTestUIWithLog { | |||
} | |||
}); | |||
getPage().getJavaScript().execute(reportTimings); | |||
Button b = new Button("test request", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getPage().getJavaScript().execute(reportTimings); | |||
} | |||
}); | |||
Button b = new Button("test request", | |||
event -> getPage().getJavaScript().execute(reportTimings)); | |||
addComponent(b); | |||
} | |||
} |
@@ -19,7 +19,6 @@ package com.vaadin.tests.application; | |||
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; | |||
public class VaadinSessionAttribute extends AbstractReindeerTestUI { | |||
@@ -32,16 +31,12 @@ public class VaadinSessionAttribute extends AbstractReindeerTestUI { | |||
getSession().setAttribute(Integer.class, Integer.valueOf(42 * 2)); | |||
addComponent( | |||
new Button("Show attribute values", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Notification notification = new Notification( | |||
getSession().getAttribute(ATTR_NAME) + " & " | |||
+ getSession() | |||
.getAttribute(Integer.class)); | |||
notification.setDelayMsec(Notification.DELAY_FOREVER); | |||
notification.show(getPage()); | |||
} | |||
new Button("Show attribute values", event -> { | |||
Notification notification = new Notification( | |||
getSession().getAttribute(ATTR_NAME) + " & " | |||
+ getSession().getAttribute(Integer.class)); | |||
notification.setDelayMsec(Notification.DELAY_FOREVER); | |||
notification.show(getPage()); | |||
})); | |||
} | |||
@@ -3,7 +3,6 @@ package com.vaadin.tests.application; | |||
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 WebBrowserSize extends AbstractReindeerTestUI { | |||
@@ -17,15 +16,11 @@ public class WebBrowserSize extends AbstractReindeerTestUI { | |||
final Label browserSizeLabel = new Label("n/a"); | |||
browserSizeLabel.setCaption("Client (browser window) size"); | |||
final Button update = new Button("Refresh", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x " | |||
+ getBrowser().getScreenHeight()); | |||
browserSizeLabel.setValue(getPage().getBrowserWindowWidth() | |||
+ " x " + getPage().getBrowserWindowHeight()); | |||
} | |||
final Button update = new Button("Refresh", event -> { | |||
screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x " | |||
+ getBrowser().getScreenHeight()); | |||
browserSizeLabel.setValue(getPage().getBrowserWindowWidth() + " x " | |||
+ getPage().getBrowserWindowHeight()); | |||
}); | |||
addComponent(update); |
@@ -6,8 +6,6 @@ import java.util.TimeZone; | |||
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 WebBrowserTimeZone extends AbstractReindeerTestUI { | |||
@@ -25,29 +23,24 @@ public class WebBrowserTimeZone extends AbstractReindeerTestUI { | |||
"Browser to Europe/Helsinki offset difference"); | |||
final Label containsLabel = addLabel("Browser could be in Helsinki"); | |||
addButton("Get TimeZone from browser", new Button.ClickListener() { | |||
addButton("Get TimeZone from browser", event -> { | |||
TimeZone hkiTZ = TimeZone.getTimeZone("Europe/Helsinki"); | |||
int hkiOffset = hkiTZ.getOffset(new Date().getTime()); | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
TimeZone hkiTZ = TimeZone.getTimeZone("Europe/Helsinki"); | |||
int hkiOffset = hkiTZ.getOffset(new Date().getTime()); | |||
int browserOffset = getBrowser().getTimezoneOffset(); | |||
int browserRawOffset = getBrowser().getRawTimezoneOffset(); | |||
String[] tzs = TimeZone.getAvailableIDs(browserRawOffset); | |||
int browserOffset = getBrowser().getTimezoneOffset(); | |||
int browserRawOffset = getBrowser().getRawTimezoneOffset(); | |||
String[] tzs = TimeZone.getAvailableIDs(browserRawOffset); | |||
boolean contains = Arrays.asList(tzs).contains(hkiTZ.getID()); | |||
boolean contains = Arrays.asList(tzs).contains(hkiTZ.getID()); | |||
offsetLabel.setValue(String.valueOf(browserOffset)); | |||
rawOffsetLabel.setValue(String.valueOf(browserRawOffset)); | |||
diffLabel.setValue(String.valueOf(browserOffset - hkiOffset)); | |||
containsLabel.setValue(contains ? "Yes" : "No"); | |||
dstDiffLabel | |||
.setValue(String.valueOf(getBrowser().getDSTSavings())); | |||
dstInEffectLabel | |||
.setValue(getBrowser().isDSTInEffect() ? "Yes" : "No"); | |||
curDateLabel.setValue(getBrowser().getCurrentDate().toString()); | |||
} | |||
offsetLabel.setValue(String.valueOf(browserOffset)); | |||
rawOffsetLabel.setValue(String.valueOf(browserRawOffset)); | |||
diffLabel.setValue(String.valueOf(browserOffset - hkiOffset)); | |||
containsLabel.setValue(contains ? "Yes" : "No"); | |||
dstDiffLabel.setValue(String.valueOf(getBrowser().getDSTSavings())); | |||
dstInEffectLabel | |||
.setValue(getBrowser().isDSTInEffect() ? "Yes" : "No"); | |||
curDateLabel.setValue(getBrowser().getCurrentDate().toString()); | |||
}); | |||
} | |||
@@ -20,8 +20,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.GridLayout; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -57,54 +55,44 @@ public class Calc extends AbstractReindeerTestUI { | |||
addCommentButton = new Button("Add Comment"); | |||
addCommentButton.setWidth("100%"); | |||
addCommentButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
final Window w = new Window("Add comment"); | |||
VerticalLayout vl = new VerticalLayout(); | |||
vl.setMargin(true); | |||
final TextField tf = new TextField(); | |||
tf.setSizeFull(); | |||
vl.addComponent(tf); | |||
HorizontalLayout hl = new HorizontalLayout(); | |||
Button okButton = new Button("OK"); | |||
okButton.setWidth("100%"); | |||
okButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
addRow("[ " + tf.getValue() + " ]"); | |||
tf.setValue(""); | |||
w.close(); | |||
removeWindow(w); | |||
} | |||
}); | |||
Button cancelButton = new Button("Cancel"); | |||
cancelButton.setWidth("100%"); | |||
cancelButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tf.setValue(""); | |||
w.close(); | |||
removeWindow(w); | |||
} | |||
}); | |||
hl.addComponent(cancelButton); | |||
hl.addComponent(okButton); | |||
hl.setSpacing(true); | |||
hl.setWidth("100%"); | |||
vl.addComponent(hl); | |||
vl.setSpacing(true); | |||
w.setContent(vl); | |||
addWindow(w); | |||
} | |||
addCommentButton.addClickListener(event -> { | |||
final Window w = new Window("Add comment"); | |||
VerticalLayout vl = new VerticalLayout(); | |||
vl.setMargin(true); | |||
final TextField tf = new TextField(); | |||
tf.setSizeFull(); | |||
vl.addComponent(tf); | |||
HorizontalLayout hl = new HorizontalLayout(); | |||
Button okButton = new Button("OK"); | |||
okButton.setWidth("100%"); | |||
okButton.addClickListener(event2 -> { | |||
addRow("[ " + tf.getValue() + " ]"); | |||
tf.setValue(""); | |||
w.close(); | |||
removeWindow(w); | |||
}); | |||
Button cancelButton = new Button("Cancel"); | |||
cancelButton.setWidth("100%"); | |||
cancelButton.addClickListener(event2 -> { | |||
tf.setValue(""); | |||
w.close(); | |||
removeWindow(w); | |||
}); | |||
hl.addComponent(cancelButton); | |||
hl.addComponent(okButton); | |||
hl.setSpacing(true); | |||
hl.setWidth("100%"); | |||
vl.addComponent(hl); | |||
vl.setSpacing(true); | |||
w.setContent(vl); | |||
addWindow(w); | |||
}); | |||
addComponent(addCommentButton); | |||
@@ -231,21 +219,18 @@ public class Calc extends AbstractReindeerTestUI { | |||
// Create a button and use this application for event handling | |||
Button button = new Button(caption); | |||
button.setWidth("40px"); | |||
button.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
// Get the button that was clicked | |||
Button button = event.getButton(); | |||
button.addClickListener(event -> { | |||
// Get the button that was clicked | |||
Button b = event.getButton(); | |||
// Get the requested operation from the button caption | |||
char requestedOperation = button.getCaption().charAt(0); | |||
// Get the requested operation from the button caption | |||
char requestedOperation = b.getCaption().charAt(0); | |||
// Calculate the new value | |||
double newValue = calculate(requestedOperation); | |||
// Calculate the new value | |||
double newValue = calculate(requestedOperation); | |||
// Update the result label with the new value | |||
display.setValue("" + newValue); | |||
} | |||
// Update the result label with the new value | |||
display.setValue("" + newValue); | |||
}); | |||
button.setId("button_" + caption); | |||
@@ -4,8 +4,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.LegacyWindow; | |||
public class ChangeSessionId extends AbstractTestCase { | |||
@@ -20,30 +18,20 @@ public class ChangeSessionId extends AbstractTestCase { | |||
mainWindow.addComponent(log); | |||
mainWindow.addComponent(loginButton); | |||
mainWindow.addComponent( | |||
new Button("Show session id", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
logSessionId(); | |||
} | |||
})); | |||
new Button("Show session id", event -> logSessionId())); | |||
setMainWindow(mainWindow); | |||
loginButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
String oldSessionId = getSessionId(); | |||
VaadinService | |||
.reinitializeSession(VaadinService.getCurrentRequest()); | |||
String newSessionId = getSessionId(); | |||
if (oldSessionId.equals(newSessionId)) { | |||
log.log("FAILED! Both old and new session id is " | |||
+ newSessionId); | |||
} else { | |||
log.log("Session id changed successfully from " | |||
+ oldSessionId + " to " + newSessionId); | |||
} | |||
loginButton.addClickListener(event -> { | |||
String oldSessionId = getSessionId(); | |||
VaadinService | |||
.reinitializeSession(VaadinService.getCurrentRequest()); | |||
String newSessionId = getSessionId(); | |||
if (oldSessionId.equals(newSessionId)) { | |||
log.log("FAILED! Both old and new session id is " | |||
+ newSessionId); | |||
} else { | |||
log.log("Session id changed successfully from " + oldSessionId | |||
+ " to " + newSessionId); | |||
} | |||
}); | |||
logSessionId(); |
@@ -18,7 +18,6 @@ package com.vaadin.tests.applicationcontext; | |||
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.Label; | |||
/** | |||
@@ -40,13 +39,7 @@ public class CleanupBrokenUI extends AbstractTestUIWithLog { | |||
} | |||
}); | |||
addComponent(new Button("Ping", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("pong"); | |||
} | |||
})); | |||
addComponent(new Button("Ping", event -> log("pong"))); | |||
} | |||
private void logUIs() { |
@@ -26,7 +26,6 @@ import com.vaadin.server.WrappedHttpSession; | |||
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.UI; | |||
public class CloseSession extends AbstractReindeerTestUI { | |||
@@ -68,84 +67,59 @@ public class CloseSession extends AbstractReindeerTestUI { | |||
addComponent(log); | |||
addComponent( | |||
new Button("Close VaadinServiceSession and redirect elsewhere", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
// Assuming Vaadin is deployed to the root | |||
// context | |||
getPage().setLocation( | |||
"/statictestfiles/static.html"); | |||
getSession().close(); | |||
} | |||
event -> { | |||
// Assuming Vaadin is deployed to the root | |||
// context | |||
getPage().setLocation( | |||
"/statictestfiles/static.html"); | |||
getSession().close(); | |||
})); | |||
addComponent(new Button("Close VaadinServiceSession and reopen page", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getPage().setLocation(reopenUrl); | |||
getSession().close(); | |||
} | |||
event -> { | |||
getPage().setLocation(reopenUrl); | |||
getSession().close(); | |||
})); | |||
addComponent(new Button("Just close VaadinSession", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getSession().close(); | |||
} | |||
})); | |||
event -> getSession().close())); | |||
addComponent(new Button("Just close HttpSession", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getSession().getSession().invalidate(); | |||
} | |||
})); | |||
event -> getSession().getSession().invalidate())); | |||
addComponent(new Button("Invalidate HttpSession and reopen page", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VaadinService.getCurrentRequest().getWrappedSession() | |||
.invalidate(); | |||
getPage().setLocation(reopenUrl); | |||
} | |||
event -> { | |||
VaadinService.getCurrentRequest().getWrappedSession() | |||
.invalidate(); | |||
getPage().setLocation(reopenUrl); | |||
})); | |||
addComponent(new Button("Invalidate HttpSession and redirect elsewhere", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VaadinService.getCurrentRequest().getWrappedSession() | |||
.invalidate(); | |||
getPage().setLocation("/statictestfiles/static.html"); | |||
} | |||
event -> { | |||
VaadinService.getCurrentRequest().getWrappedSession() | |||
.invalidate(); | |||
getPage().setLocation("/statictestfiles/static.html"); | |||
})); | |||
addComponent(new Button("Invalidate HttpSession in a background thread", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
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()); | |||
event -> { | |||
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(); | |||
} | |||
}); | |||
t.start(); | |||
} | |||
System.out | |||
.println("Invalidating session from thread " | |||
+ session.getId()); | |||
session.invalidate(); | |||
System.out | |||
.println("Invalidated session from thread " | |||
+ session.getId()); | |||
} | |||
}); | |||
t.start(); | |||
})); | |||
} | |||
@@ -21,8 +21,6 @@ import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.VaadinService; | |||
import com.vaadin.server.VaadinSession; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.UI; | |||
public class CloseUI extends AbstractTestUIWithLog { | |||
@@ -53,53 +51,33 @@ public class CloseUI extends AbstractTestUIWithLog { | |||
log("Same WrappedSession id? " + oldSessionId.equals(sessionId)); | |||
} | |||
addButton("Log 'hello'", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Hello"); | |||
} | |||
}); | |||
addButton("Close UI", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
close(); | |||
} | |||
}); | |||
addButton("Log 'hello'", event -> log("Hello")); | |||
addButton("Close UI", event -> close()); | |||
addButton("Close UI (background)", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
new UIRunSafelyThread(CloseUI.this) { | |||
@Override | |||
protected void runSafely() { | |||
close(); | |||
} | |||
}.start(); | |||
} | |||
addButton("Close UI (background)", event -> { | |||
new UIRunSafelyThread(CloseUI.this) { | |||
@Override | |||
protected void runSafely() { | |||
close(); | |||
} | |||
}.start(); | |||
}); | |||
addButton("Close UI and redirect to /statictestfiles/static.html", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getPage().setLocation("/statictestfiles/static.html"); | |||
close(); | |||
} | |||
event -> { | |||
getPage().setLocation("/statictestfiles/static.html"); | |||
close(); | |||
}); | |||
addButton( | |||
"Close UI and redirect to /statictestfiles/static.html (background)", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
new UIRunSafelyThread(CloseUI.this) { | |||
@Override | |||
protected void runSafely() { | |||
getPage().setLocation( | |||
"/statictestfiles/static.html"); | |||
close(); | |||
} | |||
}.start(); | |||
} | |||
event -> { | |||
new UIRunSafelyThread(CloseUI.this) { | |||
@Override | |||
protected void runSafely() { | |||
getPage().setLocation( | |||
"/statictestfiles/static.html"); | |||
close(); | |||
} | |||
}.start(); | |||
}); | |||
} |
@@ -17,21 +17,13 @@ package com.vaadin.tests.applicationservlet; | |||
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 SessionExpiration extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
getSession().getSession().setMaxInactiveInterval(2); | |||
addButton("Click to avoid expiration", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Clicked"); | |||
} | |||
}); | |||
addButton("Click to avoid expiration", event -> log("Clicked")); | |||
} | |||
@Override |
@@ -8,10 +8,6 @@ import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.server.VaadinService; | |||
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.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.NativeSelect; | |||
import elemental.json.JsonObject; | |||
@@ -47,25 +43,17 @@ public class SystemMessages extends AbstractReindeerTestUI { | |||
localeSelect.addItem(new Locale("en", "US")); | |||
localeSelect.addItem(new Locale("fi", "FI")); | |||
localeSelect.addItem(Locale.GERMANY); | |||
localeSelect.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Locale locale = (Locale) localeSelect.getValue(); | |||
setLocale(locale); | |||
} | |||
localeSelect.addValueChangeListener(event -> { | |||
Locale locale = (Locale) localeSelect.getValue(); | |||
setLocale(locale); | |||
}); | |||
localeSelect.setValue(new Locale("fi", "FI")); | |||
addComponent(localeSelect); | |||
final MyButton failButton = new MyButton(); | |||
failButton.setCaption("Generate server side error"); | |||
failButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
failButton.fail = true; | |||
failButton.markAsDirty(); | |||
} | |||
failButton.addClickListener(event -> { | |||
failButton.fail = true; | |||
failButton.markAsDirty(); | |||
}); | |||
addComponent(failButton); | |||
@@ -19,7 +19,6 @@ package com.vaadin.tests.browserfeatures; | |||
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.UI; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -51,14 +50,8 @@ public class WebkitScrollbarTest extends AbstractReindeerTestUI { | |||
gl.setMargin(true); | |||
final Button testButton = new Button("Open Window", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
UI.getCurrent().addWindow(testWindow); | |||
} | |||
}); | |||
event -> UI.getCurrent().addWindow(testWindow)); | |||
uiLayout.addComponent(testButton); | |||
} | |||
@Override |
@@ -4,8 +4,6 @@ import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.AbsoluteLayout; | |||
import com.vaadin.ui.AbsoluteLayout.ComponentPosition; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Label; | |||
public class AbsoluteLayoutCorrectPositioningOfHiddenField extends TestBase { | |||
@@ -25,19 +23,15 @@ public class AbsoluteLayoutCorrectPositioningOfHiddenField extends TestBase { | |||
abs.addComponent(l, "top:20px;left:20px"); | |||
final Button action = new Button("Set visible"); | |||
action.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (l.isVisible()) { | |||
l.setValue("Top 70, Left 20"); | |||
ComponentPosition position = abs.getPosition(l); | |||
position.setCSSString("top:70px;left:20px;"); | |||
abs.setPosition(l, position); | |||
} else { | |||
l.setVisible(true); | |||
action.setCaption("Move down"); | |||
} | |||
action.addClickListener(event -> { | |||
if (l.isVisible()) { | |||
l.setValue("Top 70, Left 20"); | |||
ComponentPosition position = abs.getPosition(l); | |||
position.setCSSString("top:70px;left:20px;"); | |||
abs.setPosition(l, position); | |||
} else { | |||
l.setVisible(true); | |||
action.setCaption("Move down"); | |||
} | |||
}); | |||
action.setId("actionButton"); |
@@ -21,7 +21,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
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.Embedded; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.HorizontalLayout; | |||
@@ -71,12 +70,7 @@ public class AbsoluteLayoutHideComponent extends AbstractReindeerTestUI { | |||
btnLogin.setCaption("Login"); | |||
btnLogin.setWidth("-1px"); | |||
btnLogin.setHeight("-1px"); | |||
btnLogin.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(Button.ClickEvent event) { | |||
login(); | |||
} | |||
}); | |||
btnLogin.addClickListener(event -> login()); | |||
layoutLogin.addComponent(btnLogin); | |||
for (int index = 0; index < layoutLogin.getComponentCount(); index++) { | |||
@@ -110,29 +104,17 @@ public class AbsoluteLayoutHideComponent extends AbstractReindeerTestUI { | |||
GridLayout gridButtons = new GridLayout(2, 3); | |||
Button btn1 = new Button("Button one"); | |||
btn1.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
} | |||
btn1.addClickListener(event -> { | |||
}); | |||
gridButtons.addComponent(btn1, 0, 0); | |||
Button btn2 = new Button("Button two"); | |||
btn2.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
} | |||
btn2.addClickListener(event -> { | |||
}); | |||
gridButtons.addComponent(btn2, 0, 1); | |||
Button btn3 = new Button("Button three"); | |||
btn3.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
} | |||
btn3.addClickListener(event -> { | |||
}); | |||
gridButtons.addComponent(btn3, 1, 0); | |||
@@ -3,7 +3,6 @@ package com.vaadin.tests.components.absolutelayout; | |||
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.Component; | |||
import com.vaadin.ui.NativeButton; | |||
@@ -24,12 +23,8 @@ public class AbsoluteLayoutPrimaryStylename extends TestBase { | |||
addComponent(layout); | |||
addComponent(new Button("Change primary stylename", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
layout.setPrimaryStyleName("my-second-absolute-layout"); | |||
} | |||
})); | |||
event -> layout | |||
.setPrimaryStyleName("my-second-absolute-layout"))); | |||
} | |||
@Override |
@@ -3,7 +3,6 @@ package com.vaadin.tests.components.absolutelayout; | |||
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.ComponentContainer; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -20,13 +19,7 @@ public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase { | |||
al.setHeight("200px"); | |||
testButton = new Button("Click to move to inner layout", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
vl.addComponent(testButton); | |||
} | |||
}); | |||
event -> vl.addComponent(testButton)); | |||
al.addComponent(testButton); | |||
@@ -36,13 +29,7 @@ public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase { | |||
addComponent(al); | |||
Button b = new Button("Repaint inner layout", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
vl.markAsDirty(); | |||
} | |||
}); | |||
event -> vl.markAsDirty()); | |||
addComponent(b); | |||
} |
@@ -18,7 +18,6 @@ package com.vaadin.tests.components.abstractcomponent; | |||
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; | |||
@@ -34,20 +33,6 @@ public class ChangeHierarchyBeforeResponse extends AbstractReindeerTestUI { | |||
} | |||
}; | |||
private Button buttonToAdd = new Button("Added from beforeClientResponse", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
layout.addComponent(labelToRemove); | |||
} | |||
}) { | |||
@Override | |||
public void beforeClientResponse(boolean initial) { | |||
super.beforeClientResponse(initial); | |||
setCaption("Add label to layout"); | |||
} | |||
}; | |||
private Label labelToRemove = new Label("Label to remove") { | |||
int count = 0; | |||
@@ -61,6 +46,15 @@ public class ChangeHierarchyBeforeResponse extends AbstractReindeerTestUI { | |||
} | |||
}; | |||
private Button buttonToAdd = new Button("Added from beforeClientResponse", | |||
event -> layout.addComponent(labelToRemove)) { | |||
@Override | |||
public void beforeClientResponse(boolean initial) { | |||
super.beforeClientResponse(initial); | |||
setCaption("Add label to layout"); | |||
} | |||
}; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
layout.addComponent(labelToRemove); |
@@ -15,33 +15,21 @@ | |||
*/ | |||
package com.vaadin.tests.components.abstractcomponent; | |||
import com.vaadin.event.ContextClickEvent; | |||
import com.vaadin.event.ContextClickEvent.ContextClickListener; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
public class ContextClickUI extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final ContextClickListener listener = new ContextClickListener() { | |||
@Override | |||
public void contextClick(ContextClickEvent event) { | |||
log("Received context click at (" + event.getClientX() + ", " | |||
final ContextClickListener listener = event -> log( | |||
"Received context click at (" + event.getClientX() + ", " | |||
+ event.getClientY() + ")"); | |||
} | |||
}; | |||
getUI().addContextClickListener(listener); | |||
addComponent(new Button("Remove listener", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getUI().removeContextClickListener(listener); | |||
} | |||
})); | |||
addComponent(new Button("Remove listener", | |||
event -> getUI().removeContextClickListener(listener))); | |||
} | |||
} |
@@ -18,7 +18,6 @@ package com.vaadin.tests.components.abstractcomponent; | |||
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; | |||
@@ -43,19 +42,15 @@ public class PrimaryStyle extends AbstractReindeerTestUI { | |||
addComponent(tf); | |||
Button updateButton = new Button("Update styles", | |||
new Button.ClickListener() { | |||
event -> { | |||
label.setPrimaryStyleName("updated"); | |||
label.setStyleName("correctly"); | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
label.setPrimaryStyleName("updated"); | |||
label.setStyleName("correctly"); | |||
button.setPrimaryStyleName("updated"); | |||
button.setStyleName("correctly"); | |||
button.setPrimaryStyleName("updated"); | |||
button.setStyleName("correctly"); | |||
tf.setPrimaryStyleName("updated"); | |||
tf.setStyleName("correctly"); | |||
} | |||
tf.setPrimaryStyleName("updated"); | |||
tf.setStyleName("correctly"); | |||
}); | |||
updateButton.setId("update-button"); | |||
addComponent(updateButton); |
@@ -35,13 +35,10 @@ public class ResponseWritingErrorHandling extends AbstractTestUIWithLog { | |||
Button button = new Button("Throw in beforeClientResponse") { | |||
private boolean throwInBeforeClientResponse = false; | |||
{ | |||
addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
throwInBeforeClientResponse = true; | |||
// Make sure beforeClientResponse is called | |||
markAsDirty(); | |||
} | |||
addClickListener(event -> { | |||
throwInBeforeClientResponse = true; | |||
// Make sure beforeClientResponse is called | |||
markAsDirty(); | |||
}); | |||
} | |||
@@ -22,7 +22,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.tests.widgetset.TestingWidgetSet; | |||
import com.vaadin.tests.widgetset.server.UseStateFromHierachyComponent; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Label; | |||
@Widgetset(TestingWidgetSet.NAME) | |||
@@ -34,12 +33,8 @@ public class UseStateFromHierachy extends AbstractReindeerTestUI { | |||
component.setContent(new Label("Content child")); | |||
addComponent(component); | |||
addComponent(new Button("Remove component", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
removeComponent(component); | |||
} | |||
})); | |||
addComponent(new Button("Remove component", | |||
event -> removeComponent(component))); | |||
} | |||
@Override |
@@ -44,13 +44,8 @@ public abstract class AbstractComponentDataBindingTest extends TestBase | |||
((Container.Sortable) cb.getContainerDataSource()) | |||
.sort(new Object[] { CAPTION }, new boolean[] { true }); | |||
cb.setImmediate(true); | |||
cb.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
updateLocale((Locale) localeSelect.getValue()); | |||
} | |||
}); | |||
cb.addValueChangeListener( | |||
event -> updateLocale((Locale) localeSelect.getValue())); | |||
return cb; | |||
} | |||
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.abstractfield; | |||
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.v7.data.util.ObjectProperty; | |||
import com.vaadin.v7.data.validator.StringLengthValidator; | |||
@@ -32,35 +30,30 @@ public class AbstractFieldCommitWithInvalidValues extends TestBase { | |||
tf.setBuffered(true); | |||
tf.setRequired(true); | |||
Button b = new Button("Commit", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
try { | |||
tf.commit(); | |||
if (tf.isValid()) { | |||
getMainWindow().showNotification( | |||
"OK! Form validated and no error was thrown", | |||
Notification.TYPE_HUMANIZED_MESSAGE); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Form is invalid but no exception was thrown", | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} | |||
} catch (Exception e) { | |||
if (tf.isValid()) { | |||
getMainWindow().showNotification( | |||
"Form is valid but an exception was thrown", | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} else { | |||
getMainWindow().showNotification( | |||
"OK! Error was thrown for an invalid input", | |||
Notification.TYPE_HUMANIZED_MESSAGE); | |||
Button b = new Button("Commit", event -> { | |||
try { | |||
tf.commit(); | |||
if (tf.isValid()) { | |||
getMainWindow().showNotification( | |||
"OK! Form validated and no error was thrown", | |||
Notification.TYPE_HUMANIZED_MESSAGE); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Form is invalid but no exception was thrown", | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} | |||
} catch (Exception e) { | |||
if (tf.isValid()) { | |||
getMainWindow().showNotification( | |||
"Form is valid but an exception was thrown", | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} else { | |||
getMainWindow().showNotification( | |||
"OK! Error was thrown for an invalid input", | |||
Notification.TYPE_HUMANIZED_MESSAGE); | |||
} | |||
} | |||
} | |||
}); | |||
addComponent(tf); |
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.abstractfield; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Component.Event; | |||
import com.vaadin.ui.Component.Listener; | |||
import com.vaadin.v7.data.util.ObjectProperty; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -32,12 +30,7 @@ public class AbstractFieldDataSourceReadOnly extends TestBase { | |||
// Button | |||
Button button = new Button("Make data source read-only"); | |||
button.addListener(new Listener() { | |||
@Override | |||
public void componentEvent(Event event) { | |||
stateHolder.buttonClicked(); | |||
} | |||
}); | |||
button.addListener(event -> stateHolder.buttonClicked()); | |||
// Input field | |||
TextField input = new TextField("Field"); |
@@ -3,7 +3,6 @@ package com.vaadin.tests.components.abstractfield; | |||
import java.util.Date; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.data.util.ObjectProperty; | |||
import com.vaadin.v7.ui.PopupDateField; | |||
@@ -22,14 +21,7 @@ public class DateFieldBasedOnLong extends AbstractComponentDataBindingTest { | |||
property.setValue(new Date(2011 - 1900, 4, 6).getTime()); | |||
addComponent(new Button("Set property value to 10000L", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
property.setValue(10000L); | |||
} | |||
})); | |||
event -> property.setValue(10000L))); | |||
} | |||
} |
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.abstractfield; | |||
import com.vaadin.tests.components.TestBase; | |||
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.ObjectProperty; | |||
import com.vaadin.v7.data.validator.DoubleValidator; | |||
import com.vaadin.v7.data.validator.IntegerValidator; | |||
@@ -32,18 +30,14 @@ public class IntegerDoubleFieldsWithDataSource extends TestBase { | |||
final TextField tf = new TextField("Enter an integer"); | |||
tf.setPropertyDataSource(new ObjectProperty<>(new Integer(2))); | |||
tf.setImmediate(true); | |||
tf.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
try { | |||
log.log("Value for " + tf.getCaption() + " changed to " | |||
+ tf.getValue()); | |||
log.log("Converted value is " + tf.getConvertedValue()); | |||
} catch (Exception e) { | |||
// TODO: handle exception | |||
e.printStackTrace(); | |||
} | |||
tf.addValueChangeListener(event -> { | |||
try { | |||
log.log("Value for " + tf.getCaption() + " changed to " | |||
+ tf.getValue()); | |||
log.log("Converted value is " + tf.getConvertedValue()); | |||
} catch (Exception e) { | |||
// TODO: handle exception | |||
e.printStackTrace(); | |||
} | |||
}); | |||
@@ -2,7 +2,6 @@ package com.vaadin.tests.components.abstractfield; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -27,18 +26,14 @@ public class IntegerFieldWithoutDataSource extends TestBase { | |||
final TextField tf = new TextField("Enter an integer"); | |||
tf.setConverter(Integer.class); | |||
tf.setImmediate(true); | |||
tf.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
try { | |||
log.log("Value for " + tf.getCaption() + " changed to " | |||
+ tf.getValue()); | |||
log.log("Converted value is " + tf.getConvertedValue()); | |||
} catch (Exception e) { | |||
// TODO: handle exception | |||
e.printStackTrace(); | |||
} | |||
tf.addValueChangeListener(event -> { | |||
try { | |||
log.log("Value for " + tf.getCaption() + " changed to " | |||
+ tf.getValue()); | |||
log.log("Converted value is " + tf.getConvertedValue()); | |||
} catch (Exception e) { | |||
// TODO: handle exception | |||
e.printStackTrace(); | |||
} | |||
}); | |||
@@ -4,8 +4,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; | |||
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.TextField; | |||
public class ShortcutAddAndRemove extends AbstractTestUIWithLog { | |||
@@ -16,28 +14,17 @@ public class ShortcutAddAndRemove extends AbstractTestUIWithLog { | |||
protected void setup(VaadinRequest request) { | |||
final Button logButton = new Button("Log a row (enter shortcut)"); | |||
logButton.setClickShortcut(KeyCode.ENTER); | |||
logButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log.log("Log button was clicked"); | |||
} | |||
}); | |||
logButton.addClickListener(event -> log.log("Log button was clicked")); | |||
final Button removeShortcut = new Button("Remove shortcut"); | |||
removeShortcut.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
logButton.removeClickShortcut(); | |||
logButton.setCaption("Log a row (no shortcut)"); | |||
} | |||
removeShortcut.addClickListener(event -> { | |||
logButton.removeClickShortcut(); | |||
logButton.setCaption("Log a row (no shortcut)"); | |||
}); | |||
final Button addShortcut = new Button("Add shortcut"); | |||
addShortcut.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
logButton.setClickShortcut(KeyCode.ENTER); | |||
logButton.setCaption("Log a row (enter shortcut)"); | |||
} | |||
addShortcut.addClickListener(event -> { | |||
logButton.setClickShortcut(KeyCode.ENTER); | |||
logButton.setCaption("Log a row (enter shortcut)"); | |||
}); | |||
addComponent(log); | |||
addComponent(logButton); |
@@ -19,18 +19,11 @@ import com.vaadin.event.ShortcutAction.KeyCode; | |||
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; | |||
public class ShortcutWhenBodyFocused extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button b = new Button("Hello", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
log("Hello clicked"); | |||
} | |||
}); | |||
Button b = new Button("Hello", event -> log("Hello clicked")); | |||
b.setClickShortcut(KeyCode.A); | |||
addComponent(b); | |||
@@ -5,8 +5,6 @@ import java.util.Date; | |||
import com.vaadin.server.ErrorEvent; | |||
import com.vaadin.server.ErrorHandler; | |||
import com.vaadin.server.UserError; | |||
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.ComboBox; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -29,14 +27,9 @@ public class TextFieldConversions extends AbstractComponentDataBindingTest { | |||
dataType.addItem(Date.class); | |||
dataType.addItem(String.class); | |||
dataType.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
dataType.addValueChangeListener(event -> | |||
tf.setPropertyDataSource(new ObjectProperty<>(o, | |||
(Class<Object>) dataType.getValue())); | |||
} | |||
}); | |||
(Class<Object>) dataType.getValue()))); | |||
addComponent(dataType); | |||
tf = new TextField("TextField"); |