@@ -60,21 +60,11 @@ public class ConnectorBundle { | |||
static final String OLD_RENDERER_CONNECTOR_NAME = "com.vaadin.v7.client.connectors.AbstractRendererConnector"; | |||
public static final Comparator<JClassType> jClassComparator = new Comparator<JClassType>() { | |||
@Override | |||
public int compare(JClassType o1, JClassType o2) { | |||
return o1.getQualifiedSourceName() | |||
.compareTo(o2.getQualifiedSourceName()); | |||
} | |||
}; | |||
public static final Comparator<JClassType> jClassComparator = (o1, o2) -> o1 | |||
.getQualifiedSourceName().compareTo(o2.getQualifiedSourceName()); | |||
public static final Comparator<JMethod> jMethodComparator = new Comparator<JMethod>() { | |||
@Override | |||
public int compare(JMethod o1, JMethod o2) { | |||
return o1.getReadableDeclaration() | |||
.compareTo(o2.getReadableDeclaration()); | |||
} | |||
}; | |||
public static final Comparator<JMethod> jMethodComparator = (o1, o2) -> o1 | |||
.getReadableDeclaration().compareTo(o2.getReadableDeclaration()); | |||
private final String name; | |||
private final ConnectorBundle previousBundle; | |||
@@ -85,12 +75,7 @@ public class ConnectorBundle { | |||
private final Set<JType> needsSerializeSupport = new HashSet<>(); | |||
private final Map<JType, GeneratedSerializer> serializers = new TreeMap<>( | |||
new Comparator<JType>() { | |||
@Override | |||
public int compare(JType o1, JType o2) { | |||
return o1.toString().compareTo(o2.toString()); | |||
} | |||
}); | |||
(o1, o2) -> o1.toString().compareTo(o2.toString())); | |||
private final Map<JClassType, Map<JMethod, Set<MethodAttribute>>> methodAttributes = new TreeMap<>( | |||
jClassComparator); |
@@ -60,28 +60,25 @@ public class WidgetsetCompiler { | |||
// thread and cannot be changed in JRE 1.5 (see | |||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6316197) | |||
Runnable runCompiler = new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
// GWTCompiler.main(args); | |||
// avoid warnings | |||
Runnable runCompiler = () -> { | |||
try { | |||
// GWTCompiler.main(args); | |||
// avoid warnings | |||
String wsname = args[args.length - 1]; | |||
String wsname = args[args.length - 1]; | |||
// TODO expecting this is launched via eclipse WTP | |||
// project | |||
System.out.println( | |||
"Updating GWT module description file..."); | |||
WidgetSetBuilder.updateWidgetSet(wsname); | |||
System.out.println("Done."); | |||
// TODO expecting this is launched via eclipse WTP | |||
// project | |||
System.out | |||
.println("Updating GWT module description file..."); | |||
WidgetSetBuilder.updateWidgetSet(wsname); | |||
System.out.println("Done."); | |||
System.out.println("Starting GWT compiler"); | |||
com.google.gwt.dev.Compiler.main(args); | |||
} catch (Throwable thr) { | |||
getLogger().log(Level.SEVERE, | |||
"Widgetset compilation failed", thr); | |||
} | |||
System.out.println("Starting GWT compiler"); | |||
com.google.gwt.dev.Compiler.main(args); | |||
} catch (Throwable thr) { | |||
getLogger().log(Level.SEVERE, | |||
"Widgetset compilation failed", thr); | |||
} | |||
}; | |||
Thread runThread = new Thread(runCompiler); |
@@ -460,12 +460,8 @@ public class ApplicationConnection implements HasHandlers { | |||
// correct place in the DOM | |||
if (!tooltipInitialized) { | |||
tooltipInitialized = true; | |||
ApplicationConfiguration.runWhenDependenciesLoaded(new Command() { | |||
@Override | |||
public void execute() { | |||
getVTooltip().initializeAssistiveTooltips(); | |||
} | |||
}); | |||
ApplicationConfiguration.runWhenDependenciesLoaded( | |||
() -> getVTooltip().initializeAssistiveTooltips()); | |||
} | |||
} | |||
@@ -19,7 +19,6 @@ package com.vaadin.client; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.LinkedHashMap; | |||
@@ -538,12 +537,8 @@ public class Profiler { | |||
rootNode.sumUpTotals(totals); | |||
List<Node> totalList = new ArrayList<>(totals.values()); | |||
Collections.sort(totalList, new Comparator<Node>() { | |||
@Override | |||
public int compare(Node o1, Node o2) { | |||
return (int) (o2.getTimeSpent() - o1.getTimeSpent()); | |||
} | |||
}); | |||
Collections.sort(totalList, | |||
(o1, o2) -> (int) (o2.getTimeSpent() - o1.getTimeSpent())); | |||
if (getConsumer() != null) { | |||
getConsumer().addProfilerData(stack.getFirst(), totalList); |
@@ -37,7 +37,6 @@ import com.google.gwt.dom.client.Touch; | |||
import com.google.gwt.event.dom.client.KeyEvent; | |||
import com.google.gwt.regexp.shared.MatchResult; | |||
import com.google.gwt.regexp.shared.RegExp; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.EventListener; | |||
@@ -425,14 +424,8 @@ public class WidgetUtil { | |||
* with overflow auto | |||
*/ | |||
public static void runWebkitOverflowAutoFixDeferred(final Element elem) { | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
WidgetUtil.runWebkitOverflowAutoFix(elem); | |||
} | |||
}); | |||
Scheduler.get().scheduleDeferred( | |||
() -> WidgetUtil.runWebkitOverflowAutoFix(elem)); | |||
} | |||
/** | |||
@@ -464,60 +457,54 @@ public class WidgetUtil { | |||
final int scrollleft = elem.getScrollLeft(); | |||
elem.getStyle().setProperty("overflow", "hidden"); | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
// Dough, Safari scroll auto means actually just a moped | |||
elem.getStyle().setProperty("overflow", originalOverflow); | |||
if (!originalOverflowX.isEmpty()) { | |||
elem.getStyle().setProperty("overflowX", | |||
originalOverflowX); | |||
} | |||
if (!originalOverflowY.isEmpty()) { | |||
elem.getStyle().setProperty("overflowY", | |||
originalOverflowY); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
// Dough, Safari scroll auto means actually just a moped | |||
elem.getStyle().setProperty("overflow", originalOverflow); | |||
if (!originalOverflowX.isEmpty()) { | |||
elem.getStyle().setProperty("overflowX", originalOverflowX); | |||
} | |||
if (!originalOverflowY.isEmpty()) { | |||
elem.getStyle().setProperty("overflowY", originalOverflowY); | |||
} | |||
if (scrolltop > 0 || elem.getScrollTop() > 0) { | |||
int scrollvalue = scrolltop; | |||
if (scrollvalue == 0) { | |||
// mysterious are the ways of webkits scrollbar | |||
// handling. In some cases webkit reports bad (0) | |||
// scrolltop before hiding the element temporary, | |||
// sometimes after. | |||
scrollvalue = elem.getScrollTop(); | |||
} | |||
// fix another bug where scrollbar remains in wrong | |||
// position | |||
elem.setScrollTop(scrollvalue - 1); | |||
elem.setScrollTop(scrollvalue); | |||
if (scrolltop > 0 || elem.getScrollTop() > 0) { | |||
int scrollvalue = scrolltop; | |||
if (scrollvalue == 0) { | |||
// mysterious are the ways of webkits scrollbar | |||
// handling. In some cases webkit reports bad (0) | |||
// scrolltop before hiding the element temporary, | |||
// sometimes after. | |||
scrollvalue = elem.getScrollTop(); | |||
} | |||
// fix another bug where scrollbar remains in wrong | |||
// position | |||
elem.setScrollTop(scrollvalue - 1); | |||
elem.setScrollTop(scrollvalue); | |||
} | |||
// fix for #6940 : Table horizontal scroll sometimes not | |||
// updated when collapsing/expanding columns | |||
// Also appeared in Safari 5.1 with webkit 534 (#7667) | |||
if ((BrowserInfo.get().isChrome() || (BrowserInfo.get() | |||
.isSafariOrIOS() | |||
&& BrowserInfo.get().getWebkitVersion() >= 534)) | |||
&& (scrollleft > 0 || elem.getScrollLeft() > 0)) { | |||
int scrollvalue = scrollleft; | |||
if (scrollvalue == 0) { | |||
// mysterious are the ways of webkits scrollbar | |||
// handling. In some cases webkit may report a bad | |||
// (0) scrollleft before hiding the element | |||
// temporary, sometimes after. | |||
scrollvalue = elem.getScrollLeft(); | |||
} | |||
// fix another bug where scrollbar remains in wrong | |||
// position | |||
elem.setScrollLeft(scrollvalue - 1); | |||
elem.setScrollLeft(scrollvalue); | |||
// fix for #6940 : Table horizontal scroll sometimes not | |||
// updated when collapsing/expanding columns | |||
// Also appeared in Safari 5.1 with webkit 534 (#7667) | |||
if ((BrowserInfo.get().isChrome() | |||
|| (BrowserInfo.get().isSafariOrIOS() | |||
&& BrowserInfo.get().getWebkitVersion() >= 534)) | |||
&& (scrollleft > 0 || elem.getScrollLeft() > 0)) { | |||
int scrollvalue = scrollleft; | |||
if (scrollvalue == 0) { | |||
// mysterious are the ways of webkits scrollbar | |||
// handling. In some cases webkit may report a bad | |||
// (0) scrollleft before hiding the element | |||
// temporary, sometimes after. | |||
scrollvalue = elem.getScrollLeft(); | |||
} | |||
// fix another bug where scrollbar remains in wrong | |||
// position | |||
elem.setScrollLeft(scrollvalue - 1); | |||
elem.setScrollLeft(scrollvalue); | |||
} | |||
}); | |||
} | |||
} | |||
public static void alert(String string) { |
@@ -156,10 +156,7 @@ public class AtmospherePushConnection implements PushConnection { | |||
return; | |||
} | |||
disconnect(new Command() { | |||
@Override | |||
public void execute() { | |||
} | |||
disconnect(() -> { | |||
}); | |||
}); | |||
config = createConfig(); | |||
@@ -182,17 +179,8 @@ public class AtmospherePushConnection implements PushConnection { | |||
url = ApplicationConstants.APP_PROTOCOL_PREFIX | |||
+ ApplicationConstants.PUSH_PATH; | |||
} | |||
runWhenAtmosphereLoaded(new Command() { | |||
@Override | |||
public void execute() { | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
connect(); | |||
} | |||
}); | |||
} | |||
}); | |||
runWhenAtmosphereLoaded( | |||
() -> Scheduler.get().scheduleDeferred(() -> connect())); | |||
} | |||
private void connect() { |
@@ -247,12 +247,7 @@ public class MessageHandler { | |||
.getApplicationState() == ApplicationState.INITIALIZING) { | |||
// Application is starting up for the first time | |||
connection.setApplicationRunning(true); | |||
connection.executeWhenCSSLoaded(new Command() { | |||
@Override | |||
public void execute() { | |||
handleJSON(json); | |||
} | |||
}); | |||
connection.executeWhenCSSLoaded(() -> handleJSON(json)); | |||
} else { | |||
getLogger().warning( | |||
"Ignored received message because application has already been stopped"); |
@@ -19,7 +19,6 @@ import java.util.logging.Logger; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.core.client.Scheduler; | |||
import com.google.gwt.user.client.Command; | |||
import com.vaadin.client.ApplicationConfiguration; | |||
import com.vaadin.client.ApplicationConnection; | |||
import com.vaadin.client.ApplicationConnection.RequestStartingEvent; | |||
@@ -199,26 +198,23 @@ public class MessageSender { | |||
push = GWT.create(PushConnection.class); | |||
push.init(connection, pushState); | |||
} else if (!enabled && push != null && push.isActive()) { | |||
push.disconnect(new Command() { | |||
@Override | |||
public void execute() { | |||
push = null; | |||
/* | |||
* If push has been enabled again while we were waiting for | |||
* the old connection to disconnect, now is the right time | |||
* to open a new connection | |||
*/ | |||
if (pushState.mode.isEnabled()) { | |||
setPushEnabled(true); | |||
} | |||
/* | |||
* Send anything that was enqueued while we waited for the | |||
* connection to close | |||
*/ | |||
if (getServerRpcQueue().isFlushPending()) { | |||
getServerRpcQueue().flush(); | |||
} | |||
push.disconnect(() -> { | |||
push = null; | |||
/* | |||
* If push has been enabled again while we were waiting for the | |||
* old connection to disconnect, now is the right time to open a | |||
* new connection | |||
*/ | |||
if (pushState.mode.isEnabled()) { | |||
setPushEnabled(true); | |||
} | |||
/* | |||
* Send anything that was enqueued while we waited for the | |||
* connection to close | |||
*/ | |||
if (getServerRpcQueue().isFlushPending()) { | |||
getServerRpcQueue().flush(); | |||
} | |||
}); | |||
} | |||
@@ -250,21 +246,18 @@ public class MessageSender { | |||
} | |||
// deferring to avoid flickering | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
if (!connection.isApplicationRunning() || !(hasActiveRequest() | |||
|| getServerRpcQueue().isFlushPending())) { | |||
getLoadingIndicator().hide(); | |||
// If on Liferay and session expiration management is in | |||
// use, extend session duration on each request. | |||
// Doing it here rather than before the request to improve | |||
// responsiveness. | |||
// Postponed until the end of the next request if other | |||
// requests still pending. | |||
extendLiferaySession(); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
if (!connection.isApplicationRunning() || !(hasActiveRequest() | |||
|| getServerRpcQueue().isFlushPending())) { | |||
getLoadingIndicator().hide(); | |||
// If on Liferay and session expiration management is in | |||
// use, extend session duration on each request. | |||
// Doing it here rather than before the request to improve | |||
// responsiveness. | |||
// Postponed until the end of the next request if other | |||
// requests still pending. | |||
extendLiferaySession(); | |||
} | |||
}); | |||
connection.fireEvent(new ResponseHandlingEndedEvent(connection)); |
@@ -24,8 +24,6 @@ import com.google.gwt.http.client.RequestException; | |||
import com.google.gwt.http.client.Response; | |||
import com.google.gwt.user.client.Timer; | |||
import com.google.gwt.user.client.Window; | |||
import com.google.gwt.user.client.Window.ClosingEvent; | |||
import com.google.gwt.user.client.Window.ClosingHandler; | |||
import com.vaadin.client.ApplicationConnection; | |||
import com.vaadin.client.ApplicationConnection.CommunicationHandler; | |||
import com.vaadin.client.ApplicationConnection.RequestStartingEvent; | |||
@@ -63,12 +61,8 @@ public class XhrConnection { | |||
private boolean webkitMaybeIgnoringRequests = false; | |||
public XhrConnection() { | |||
Window.addWindowClosingHandler(new ClosingHandler() { | |||
@Override | |||
public void onWindowClosing(ClosingEvent event) { | |||
webkitMaybeIgnoringRequests = true; | |||
} | |||
}); | |||
Window.addWindowClosingHandler( | |||
event -> webkitMaybeIgnoringRequests = true); | |||
} | |||
/** |
@@ -26,7 +26,6 @@ import com.google.gwt.event.dom.client.MouseOverEvent; | |||
import com.google.gwt.event.dom.client.MouseOverHandler; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Event.NativePreviewEvent; | |||
import com.google.gwt.user.client.Event.NativePreviewHandler; | |||
import com.google.gwt.user.client.ui.Button; | |||
import com.google.gwt.user.client.ui.FlowPanel; | |||
@@ -193,60 +192,54 @@ public class TestBenchSection implements Section { | |||
content.add(w); | |||
} | |||
private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { | |||
@Override | |||
public void onPreviewNativeEvent(NativePreviewEvent event) { | |||
if (event.getTypeInt() == Event.ONKEYDOWN && event.getNativeEvent() | |||
.getKeyCode() == KeyCodes.KEY_ESCAPE) { | |||
stopFind(); | |||
Highlight.hideAll(); | |||
private final NativePreviewHandler highlightModeHandler = event -> { | |||
if (event.getTypeInt() == Event.ONKEYDOWN | |||
&& event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { | |||
stopFind(); | |||
Highlight.hideAll(); | |||
return; | |||
} | |||
if (event.getTypeInt() == Event.ONMOUSEMOVE | |||
|| event.getTypeInt() == Event.ONCLICK) { | |||
Element eventTarget = WidgetUtil.getElementFromPoint( | |||
event.getNativeEvent().getClientX(), | |||
event.getNativeEvent().getClientY()); | |||
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { | |||
if (isFindMode() && event.getTypeInt() == Event.ONCLICK) { | |||
stopFind(); | |||
event.cancel(); | |||
} | |||
return; | |||
} | |||
if (event.getTypeInt() == Event.ONMOUSEMOVE | |||
|| event.getTypeInt() == Event.ONCLICK) { | |||
Element eventTarget = WidgetUtil.getElementFromPoint( | |||
event.getNativeEvent().getClientX(), | |||
event.getNativeEvent().getClientY()); | |||
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { | |||
if (isFindMode() && event.getTypeInt() == Event.ONCLICK) { | |||
stopFind(); | |||
event.cancel(); | |||
} | |||
return; | |||
} | |||
// make sure that not finding the highlight element only | |||
Highlight.hideAll(); | |||
eventTarget = WidgetUtil.getElementFromPoint( | |||
event.getNativeEvent().getClientX(), | |||
event.getNativeEvent().getClientY()); | |||
ComponentConnector connector = findConnector(eventTarget); | |||
if (event.getTypeInt() == Event.ONMOUSEMOVE) { | |||
if (connector != null) { | |||
Highlight.showOnly(connector); | |||
event.cancel(); | |||
event.consume(); | |||
event.getNativeEvent().stopPropagation(); | |||
return; | |||
} | |||
} else if (event.getTypeInt() == Event.ONCLICK) { | |||
// make sure that not finding the highlight element only | |||
Highlight.hideAll(); | |||
eventTarget = WidgetUtil.getElementFromPoint( | |||
event.getNativeEvent().getClientX(), | |||
event.getNativeEvent().getClientY()); | |||
ComponentConnector connector = findConnector(eventTarget); | |||
if (event.getTypeInt() == Event.ONMOUSEMOVE) { | |||
if (connector != null) { | |||
Highlight.showOnly(connector); | |||
event.cancel(); | |||
event.consume(); | |||
event.getNativeEvent().stopPropagation(); | |||
if (connector != null) { | |||
Highlight.showOnly(connector); | |||
pickSelector(connector, eventTarget); | |||
return; | |||
} | |||
return; | |||
} | |||
} else if (event.getTypeInt() == Event.ONCLICK) { | |||
event.cancel(); | |||
event.consume(); | |||
event.getNativeEvent().stopPropagation(); | |||
if (connector != null) { | |||
Highlight.showOnly(connector); | |||
pickSelector(connector, eventTarget); | |||
return; | |||
} | |||
} | |||
event.cancel(); | |||
} | |||
event.cancel(); | |||
}; | |||
private ComponentConnector findConnector(Element element) { |
@@ -27,7 +27,6 @@ import com.google.gwt.dom.client.NativeEvent; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.dom.client.Style.Cursor; | |||
import com.google.gwt.dom.client.Style.Overflow; | |||
import com.google.gwt.event.dom.client.ClickEvent; | |||
import com.google.gwt.event.dom.client.ClickHandler; | |||
import com.google.gwt.event.dom.client.MouseDownEvent; | |||
import com.google.gwt.event.dom.client.MouseDownHandler; | |||
@@ -520,12 +519,9 @@ public final class VDebugWindow extends VOverlay { | |||
*/ | |||
public void addSection(final Section section) { | |||
Button b = section.getTabButton(); | |||
b.addClickHandler(new ClickHandler() { | |||
@Override | |||
public void onClick(ClickEvent event) { | |||
activateSection(section); | |||
writeStoredState(); | |||
} | |||
b.addClickHandler(event -> { | |||
activateSection(section); | |||
writeStoredState(); | |||
}); | |||
b.setStylePrimaryName(STYLENAME_TAB); | |||
tabs.add(b); | |||
@@ -792,17 +788,14 @@ public final class VDebugWindow extends VOverlay { | |||
FlowPanel size = new FlowPanel(); | |||
content.add(size); | |||
final ClickHandler sizeHandler = new ClickHandler() { | |||
@Override | |||
public void onClick(ClickEvent event) { | |||
for (int i = 0; i < sizes.length; i++) { | |||
Button b = sizes[i]; | |||
if (b == event.getSource()) { | |||
setSize(i); | |||
} | |||
final ClickHandler sizeHandler = event -> { | |||
for (int i = 0; i < sizes.length; i++) { | |||
Button b = sizes[i]; | |||
if (b == event.getSource()) { | |||
setSize(i); | |||
} | |||
hide(); | |||
} | |||
hide(); | |||
}; | |||
for (int i = 0; i < sizes.length; i++) { | |||
Button b = sizes[i]; | |||
@@ -813,17 +806,14 @@ public final class VDebugWindow extends VOverlay { | |||
FlowPanel mode = new FlowPanel(); | |||
content.add(mode); | |||
final ClickHandler modeHandler = new ClickHandler() { | |||
@Override | |||
public void onClick(ClickEvent event) { | |||
for (int i = 0; i < modes.length; i++) { | |||
Button b = modes[i]; | |||
if (b == event.getSource()) { | |||
setDevMode(i); | |||
} | |||
final ClickHandler modeHandler = event -> { | |||
for (int i = 0; i < modes.length; i++) { | |||
Button b = modes[i]; | |||
if (b == event.getSource()) { | |||
setDevMode(i); | |||
} | |||
hide(); | |||
} | |||
hide(); | |||
}; | |||
modes[getDevMode()].setActive(true); | |||
for (Button b : modes) { | |||
@@ -833,13 +823,10 @@ public final class VDebugWindow extends VOverlay { | |||
Button reset = new DebugButton(Icon.RESET, "Restore defaults.", | |||
" Reset"); | |||
reset.addClickHandler(new ClickHandler() { | |||
@Override | |||
public void onClick(ClickEvent event) { | |||
resetStoredState(); | |||
readStoredState(); | |||
hide(); | |||
} | |||
reset.addClickHandler(event -> { | |||
resetStoredState(); | |||
readStoredState(); | |||
hide(); | |||
}); | |||
content.add(reset); | |||
} |
@@ -38,12 +38,7 @@ public class JavaScriptManagerConnector extends AbstractExtensionConnector { | |||
@Override | |||
protected void init() { | |||
registerRpc(ExecuteJavaScriptRpc.class, new ExecuteJavaScriptRpc() { | |||
@Override | |||
public void executeJavaScript(String script) { | |||
eval(script); | |||
} | |||
}); | |||
registerRpc(ExecuteJavaScriptRpc.class, script -> eval(script)); | |||
} | |||
@Override |
@@ -20,7 +20,6 @@ import java.util.ArrayList; | |||
import com.google.gwt.core.client.Scheduler; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.ui.HasWidgets; | |||
@@ -136,15 +135,12 @@ public class ShortcutActionHandler { | |||
*/ | |||
client.flushActiveConnector(); | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
if (finalTarget != null) { | |||
client.updateVariable(paintableId, "actiontarget", | |||
finalTarget, false); | |||
} | |||
client.updateVariable(paintableId, "action", a.getKey(), true); | |||
Scheduler.get().scheduleDeferred(() -> { | |||
if (finalTarget != null) { | |||
client.updateVariable(paintableId, "actiontarget", finalTarget, | |||
false); | |||
} | |||
client.updateVariable(paintableId, "action", a.getKey(), true); | |||
}); | |||
} | |||
@@ -43,7 +43,6 @@ import com.google.gwt.event.dom.client.LoadHandler; | |||
import com.google.gwt.event.logical.shared.CloseEvent; | |||
import com.google.gwt.event.logical.shared.CloseHandler; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Window; | |||
import com.google.gwt.user.client.ui.MenuBar; | |||
@@ -137,45 +136,38 @@ public class VContextMenu extends VOverlay implements SubPartAware { | |||
// reset height (if it has been previously set explicitly) | |||
setHeight(""); | |||
setPopupPositionAndShow(new PositionCallback() { | |||
@Override | |||
public void setPosition(int offsetWidth, int offsetHeight) { | |||
// mac FF gets bad width due GWT popups overflow hacks, | |||
// re-determine width | |||
offsetWidth = menu.getOffsetWidth(); | |||
int left = VContextMenu.this.left; | |||
int top = VContextMenu.this.top; | |||
if (offsetWidth + left > Window.getClientWidth()) { | |||
left = left - offsetWidth; | |||
if (left < 0) { | |||
left = 0; | |||
} | |||
} | |||
if (offsetHeight + top > Window.getClientHeight()) { | |||
top = Math.max(0, Window.getClientHeight() - offsetHeight); | |||
} | |||
if (top == 0) { | |||
setHeight(Window.getClientHeight() + "px"); | |||
setPopupPositionAndShow((offsetWidth, offsetHeight) -> { | |||
// mac FF gets bad width due GWT popups overflow hacks, | |||
// re-determine width | |||
offsetWidth = menu.getOffsetWidth(); | |||
int menuLeft = VContextMenu.this.left; | |||
int menuTop = VContextMenu.this.top; | |||
if (offsetWidth + menuLeft > Window.getClientWidth()) { | |||
menuLeft = menuLeft - offsetWidth; | |||
if (menuLeft < 0) { | |||
menuLeft = 0; | |||
} | |||
setPopupPosition(left, top); | |||
/* | |||
* Move keyboard focus to menu, deferring the focus setting so | |||
* the focus is certainly moved to the menu in all browser after | |||
* the positioning has been done. | |||
*/ | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
// Focus the menu. | |||
menu.setFocus(true); | |||
// Unselect previously selected items | |||
menu.selectItem(null); | |||
} | |||
}); | |||
} | |||
if (offsetHeight + menuTop > Window.getClientHeight()) { | |||
menuTop = Math.max(0, Window.getClientHeight() - offsetHeight); | |||
} | |||
if (menuTop == 0) { | |||
setHeight(Window.getClientHeight() + "px"); | |||
} | |||
setPopupPosition(menuLeft, menuTop); | |||
/* | |||
* Move keyboard focus to menu, deferring the focus setting so the | |||
* focus is certainly moved to the menu in all browser after the | |||
* positioning has been done. | |||
*/ | |||
Scheduler.get().scheduleDeferred(() -> { | |||
// Focus the menu. | |||
menu.setFocus(true); | |||
// Unselect previously selected items | |||
menu.selectItem(null); | |||
}); | |||
}); | |||
} | |||
@@ -47,13 +47,7 @@ public class VCustomField extends VCustomComponent implements Focusable { | |||
*/ | |||
public void setFocusDelegate( | |||
final com.google.gwt.user.client.ui.Focusable focusDelegate) { | |||
this.focusDelegate = new Focusable() { | |||
@Override | |||
public void focus() { | |||
focusDelegate.setFocus(true); | |||
} | |||
}; | |||
this.focusDelegate = () -> focusDelegate.setFocus(true); | |||
} | |||
} |
@@ -28,7 +28,6 @@ import com.google.gwt.dom.client.NativeEvent; | |||
import com.google.gwt.event.dom.client.MouseDownEvent; | |||
import com.google.gwt.event.dom.client.MouseUpEvent; | |||
import com.google.gwt.event.dom.client.TouchStartEvent; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Timer; | |||
@@ -46,7 +45,6 @@ import com.vaadin.client.ValueMap; | |||
import com.vaadin.client.WidgetUtil; | |||
import com.vaadin.client.ui.dd.DDUtil; | |||
import com.vaadin.client.ui.dd.VAbstractDropHandler; | |||
import com.vaadin.client.ui.dd.VAcceptCallback; | |||
import com.vaadin.client.ui.dd.VDragAndDropManager; | |||
import com.vaadin.client.ui.dd.VDragEvent; | |||
import com.vaadin.client.ui.dd.VDropHandler; | |||
@@ -223,30 +221,23 @@ public class VDragAndDropWrapper extends VCustomComponent | |||
/** For internal use only. May be removed or replaced in the future. */ | |||
public void startNextUpload() { | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
if (!uploading) { | |||
if (!fileIds.isEmpty()) { | |||
uploading = true; | |||
final Integer fileId = fileIds.remove(0); | |||
VHtml5File file = files.remove(0); | |||
final String receiverUrl = client.translateVaadinUri( | |||
fileIdToReceiver.remove(fileId.toString())); | |||
ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR | |||
.create(); | |||
extendedXHR | |||
.setOnReadyStateChange(readyStateChangeHandler); | |||
extendedXHR.open("POST", receiverUrl); | |||
extendedXHR.postFile(file); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
if (!uploading) { | |||
if (!fileIds.isEmpty()) { | |||
uploading = true; | |||
final Integer fileId = fileIds.remove(0); | |||
VHtml5File file = files.remove(0); | |||
final String receiverUrl = client.translateVaadinUri( | |||
fileIdToReceiver.remove(fileId.toString())); | |||
ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR | |||
.create(); | |||
extendedXHR.setOnReadyStateChange(readyStateChangeHandler); | |||
extendedXHR.open("POST", receiverUrl); | |||
extendedXHR.postFile(file); | |||
} | |||
} | |||
}); | |||
} | |||
public boolean html5DragStart(VHtml5DragEvent event) { | |||
@@ -511,13 +502,7 @@ public class VDragAndDropWrapper extends VCustomComponent | |||
boolean detailsChanged = updateDropDetails(drag); | |||
if (detailsChanged) { | |||
currentlyValid = false; | |||
validate(new VAcceptCallback() { | |||
@Override | |||
public void accepted(VDragEvent event) { | |||
dragAccepted(drag); | |||
} | |||
}, drag); | |||
validate(event -> dragAccepted(drag), drag); | |||
} | |||
} | |||
@@ -259,12 +259,9 @@ public class VRichTextArea extends Composite implements Field, KeyPressHandler, | |||
@Override | |||
public void onKeyPress(KeyPressEvent event) { | |||
if (maxLength >= 0) { | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
if (rta.getHTML().length() > maxLength) { | |||
rta.setHTML(rta.getHTML().substring(0, maxLength)); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
if (rta.getHTML().length() > maxLength) { | |||
rta.setHTML(rta.getHTML().substring(0, maxLength)); | |||
} | |||
}); | |||
} |
@@ -231,12 +231,9 @@ public class VSlider extends SimpleFocusablePanel | |||
if (!isVertical()) { | |||
// Draw handle with a delay to allow base to gain maximum width | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
buildHandle(); | |||
setValue(value, false); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
buildHandle(); | |||
setValue(value, false); | |||
}); | |||
} else { | |||
buildHandle(); |
@@ -1347,15 +1347,9 @@ public class VTabsheet extends VTabsheetBase | |||
*/ | |||
final Style style = scroller.getStyle(); | |||
style.setProperty("whiteSpace", "normal"); | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
style.setProperty("whiteSpace", ""); | |||
} | |||
}); | |||
Scheduler.get().scheduleDeferred( | |||
() -> style.setProperty("whiteSpace", "")); | |||
} | |||
} | |||
/** For internal use only. May be removed or replaced in the future. */ |
@@ -23,7 +23,6 @@ import com.google.gwt.dom.client.DivElement; | |||
import com.google.gwt.dom.client.Document; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.FormElement; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Timer; | |||
import com.google.gwt.user.client.ui.FileUpload; | |||
@@ -253,35 +252,32 @@ public class VUpload extends SimplePanel { | |||
*/ | |||
private void onSubmitComplete() { | |||
/* Needs to be run dereferred to avoid various browser issues. */ | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
if (submitted) { | |||
if (client != null) { | |||
if (t != null) { | |||
t.cancel(); | |||
} | |||
VConsole.log("VUpload:Submit complete"); | |||
if (isAttached()) { | |||
// no need to call poll() if component is already | |||
// detached #8728 | |||
((UploadConnector) ConnectorMap.get(client) | |||
.getConnector(VUpload.this)) | |||
.getRpcProxy(UploadServerRpc.class) | |||
.poll(); | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
if (submitted) { | |||
if (client != null) { | |||
if (t != null) { | |||
t.cancel(); | |||
} | |||
VConsole.log("VUpload:Submit complete"); | |||
if (isAttached()) { | |||
// no need to call poll() if component is already | |||
// detached #8728 | |||
((UploadConnector) ConnectorMap.get(client) | |||
.getConnector(VUpload.this)) | |||
.getRpcProxy(UploadServerRpc.class) | |||
.poll(); | |||
} | |||
} | |||
rebuildPanel(); | |||
rebuildPanel(); | |||
submitted = false; | |||
enableUpload(); | |||
if (!isAttached()) { | |||
/* | |||
* Upload is complete when upload is already abandoned. | |||
*/ | |||
cleanTargetFrame(); | |||
} | |||
submitted = false; | |||
enableUpload(); | |||
if (!isAttached()) { | |||
/* | |||
* Upload is complete when upload is already abandoned. | |||
*/ | |||
cleanTargetFrame(); | |||
} | |||
} | |||
}); |
@@ -21,7 +21,6 @@ import static com.vaadin.client.WidgetUtil.isFocusedElementEditable; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.List; | |||
import com.google.gwt.aria.client.Id; | |||
@@ -45,7 +44,6 @@ import com.google.gwt.event.dom.client.ScrollEvent; | |||
import com.google.gwt.event.dom.client.ScrollHandler; | |||
import com.google.gwt.event.shared.HandlerManager; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Event.NativePreviewHandler; | |||
@@ -522,13 +520,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
public static void deferOrdering() { | |||
if (!orderingDefered) { | |||
orderingDefered = true; | |||
Scheduler.get().scheduleFinally(new Command() { | |||
@Override | |||
public void execute() { | |||
doServerSideOrdering(); | |||
VNotification.bringNotificationsToFront(); | |||
} | |||
Scheduler.get().scheduleFinally(() -> { | |||
doServerSideOrdering(); | |||
VNotification.bringNotificationsToFront(); | |||
}); | |||
} | |||
} | |||
@@ -536,26 +530,24 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
private static void doServerSideOrdering() { | |||
orderingDefered = false; | |||
VWindow[] array = windowOrder.toArray(new VWindow[windowOrder.size()]); | |||
Arrays.sort(array, new Comparator<VWindow>() { | |||
@Override | |||
public int compare(VWindow o1, VWindow o2) { | |||
/* | |||
* Order by modality, then by bringtofront sequence. | |||
*/ | |||
if (o1.vaadinModality && !o2.vaadinModality) { | |||
return 1; | |||
} else if (!o1.vaadinModality && o2.vaadinModality) { | |||
return -1; | |||
} else if (o1.bringToFrontSequence > o2.bringToFrontSequence) { | |||
return 1; | |||
} else if (o1.bringToFrontSequence < o2.bringToFrontSequence) { | |||
return -1; | |||
} else { | |||
return 0; | |||
} | |||
Arrays.sort(array, (o1, o2) -> { | |||
/* | |||
* Order by modality, then by bringtofront sequence. | |||
*/ | |||
if (o1.vaadinModality && !o2.vaadinModality) { | |||
return 1; | |||
} | |||
if (!o1.vaadinModality && o2.vaadinModality) { | |||
return -1; | |||
} | |||
if (o1.bringToFrontSequence > o2.bringToFrontSequence) { | |||
return 1; | |||
} | |||
if (o1.bringToFrontSequence < o2.bringToFrontSequence) { | |||
return -1; | |||
} | |||
return 0; | |||
}); | |||
for (VWindow w : array) { | |||
if (w.bringToFrontSequence != -1 || w.vaadinModality) { |
@@ -96,12 +96,7 @@ public abstract class VAbstractDropHandler implements VDropHandler { | |||
*/ | |||
@Override | |||
public void dragEnter(final VDragEvent drag) { | |||
validate(new VAcceptCallback() { | |||
@Override | |||
public void accepted(VDragEvent event) { | |||
dragAccepted(drag); | |||
} | |||
}, drag); | |||
validate(event -> dragAccepted(drag), drag); | |||
} | |||
/** | |||
@@ -116,12 +111,8 @@ public abstract class VAbstractDropHandler implements VDropHandler { | |||
protected abstract void dragAccepted(VDragEvent drag); | |||
protected void validate(final VAcceptCallback cb, final VDragEvent event) { | |||
Command checkCriteria = new Command() { | |||
@Override | |||
public void execute() { | |||
acceptCriteria.accept(event, criterioUIDL, cb); | |||
} | |||
}; | |||
Command checkCriteria = () -> acceptCriteria.accept(event, criterioUIDL, | |||
cb); | |||
VDragAndDropManager.get().executeWhenReady(checkCriteria); | |||
} | |||
@@ -139,15 +130,10 @@ public abstract class VAbstractDropHandler implements VDropHandler { | |||
return true; | |||
} else { | |||
validated = false; | |||
acceptCriteria.accept(drag, criterioUIDL, new VAcceptCallback() { | |||
@Override | |||
public void accepted(VDragEvent event) { | |||
validated = true; | |||
} | |||
}); | |||
acceptCriteria.accept(drag, criterioUIDL, | |||
event -> validated = true); | |||
return validated; | |||
} | |||
} | |||
/** |
@@ -39,12 +39,9 @@ public abstract class VAcceptCriterion { | |||
public void accept(final VDragEvent drag, UIDL configuration, | |||
final VAcceptCallback callback) { | |||
if (needsServerSideCheck(drag, configuration)) { | |||
VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { | |||
@Override | |||
public void handleResponse(boolean accepted, UIDL response) { | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
VDragEventServerCallback acceptCallback = (accepted, response) -> { | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
}; | |||
VDragAndDropManager.get().visitServer(acceptCallback); | |||
@@ -54,7 +51,6 @@ public abstract class VAcceptCriterion { | |||
callback.accepted(drag); | |||
} | |||
} | |||
} | |||
protected abstract boolean accept(VDragEvent drag, UIDL configuration); |
@@ -47,20 +47,16 @@ public class VLazyInitItemIdentifiers extends VAcceptCriterion { | |||
} | |||
} else { | |||
VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { | |||
@Override | |||
public void handleResponse(boolean accepted, UIDL response) { | |||
hashSet = new HashSet<>(); | |||
String[] stringArrayAttribute = response | |||
.getStringArrayAttribute("allowedIds"); | |||
for (String attribute : stringArrayAttribute) { | |||
hashSet.add(attribute); | |||
} | |||
loaded = true; | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
VDragEventServerCallback acceptCallback = (accepted, response) -> { | |||
hashSet = new HashSet<>(); | |||
String[] stringArrayAttribute = response | |||
.getStringArrayAttribute("allowedIds"); | |||
for (String attribute : stringArrayAttribute) { | |||
hashSet.add(attribute); | |||
} | |||
loaded = true; | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
}; | |||
@@ -46,12 +46,7 @@ public final class VNot extends VAcceptCriterion { | |||
b1 = false; | |||
VAcceptCallback accept1cb = new VAcceptCallback() { | |||
@Override | |||
public void accepted(VDragEvent event) { | |||
b1 = true; | |||
} | |||
}; | |||
VAcceptCallback accept1cb = event -> b1 = true; | |||
crit1.accept(drag, configuration.getChildUIDL(0), accept1cb); | |||
if (!b1) { |
@@ -32,12 +32,9 @@ public final class VServerAccept extends VAcceptCriterion { | |||
public void accept(final VDragEvent drag, UIDL configuration, | |||
final VAcceptCallback callback) { | |||
VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { | |||
@Override | |||
public void handleResponse(boolean accepted, UIDL response) { | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
VDragEventServerCallback acceptCallback = (accepted, response) -> { | |||
if (accepted) { | |||
callback.accepted(drag); | |||
} | |||
}; | |||
VDragAndDropManager.get().visitServer(acceptCallback); |
@@ -123,12 +123,7 @@ public class MenuBarConnector extends AbstractComponentConnector | |||
if (itemHasCommand || itemIsCheckable) { | |||
// Construct a command that fires onMenuClick(int) with the | |||
// item's id-number | |||
cmd = new Command() { | |||
@Override | |||
public void execute() { | |||
widget.hostReference.onMenuClick(itemId); | |||
} | |||
}; | |||
cmd = () -> widget.hostReference.onMenuClick(itemId); | |||
} | |||
} | |||
@@ -34,21 +34,18 @@ public class TabsheetConnector extends TabsheetBaseConnector | |||
implements SimpleManagedLayout, MayScrollChildren { | |||
public TabsheetConnector() { | |||
registerRpc(TabsheetClientRpc.class, new TabsheetClientRpc() { | |||
@Override | |||
public void revertToSharedStateSelection() { | |||
for (int i = 0; i < getState().tabs.size(); ++i) { | |||
final String key = getState().tabs.get(i).key; | |||
final boolean selected = key.equals(getState().selected); | |||
if (selected) { | |||
getWidget().waitingForResponse = false; | |||
getWidget().setActiveTabIndex(i); | |||
getWidget().selectTab(i); | |||
break; | |||
} | |||
registerRpc(TabsheetClientRpc.class, () -> { | |||
for (int i = 0; i < getState().tabs.size(); ++i) { | |||
final String key = getState().tabs.get(i).key; | |||
final boolean selected = key.equals(getState().selected); | |||
if (selected) { | |||
getWidget().waitingForResponse = false; | |||
getWidget().setActiveTabIndex(i); | |||
getWidget().selectTab(i); | |||
break; | |||
} | |||
renderContent(); | |||
} | |||
renderContent(); | |||
}); | |||
} | |||
@@ -39,7 +39,6 @@ import com.google.gwt.event.dom.client.KeyDownEvent; | |||
import com.google.gwt.event.dom.client.ScrollEvent; | |||
import com.google.gwt.event.dom.client.ScrollHandler; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.History; | |||
@@ -172,23 +171,20 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
getWidget().getElement().setScrollLeft(scrollLeft); | |||
} | |||
}); | |||
registerRpc(UIClientRpc.class, new UIClientRpc() { | |||
@Override | |||
public void uiClosed(final boolean sessionExpired) { | |||
Scheduler.get().scheduleDeferred(() -> { | |||
// Only notify user if we're still running and not e.g. | |||
// navigating away (#12298) | |||
if (getConnection().isApplicationRunning()) { | |||
if (sessionExpired) { | |||
getConnection().showSessionExpiredError(null); | |||
} else { | |||
getState().enabled = false; | |||
updateEnabledState(getState().enabled); | |||
} | |||
getConnection().setApplicationRunning(false); | |||
registerRpc(UIClientRpc.class, sessionExpired -> { | |||
Scheduler.get().scheduleDeferred(() -> { | |||
// Only notify user if we're still running and not e.g. | |||
// navigating away (#12298) | |||
if (getConnection().isApplicationRunning()) { | |||
if (sessionExpired) { | |||
getConnection().showSessionExpiredError(null); | |||
} else { | |||
getState().enabled = false; | |||
updateEnabledState(getState().enabled); | |||
} | |||
}); | |||
} | |||
getConnection().setApplicationRunning(false); | |||
} | |||
}); | |||
}); | |||
registerRpc(DebugWindowClientRpc.class, new DebugWindowClientRpc() { | |||
@@ -297,12 +293,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
// source will be opened to this browser window, but we may have | |||
// to finish rendering this window in case this is a download | |||
// (and window stays open). | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
VUI.goTo(url); | |||
} | |||
}); | |||
Scheduler.get().scheduleDeferred(() -> VUI.goTo(url)); | |||
} else if ("_self".equals(target)) { | |||
// This window is closing (for sure). Only other opens are | |||
// relevant in this change. See #3558, #2144 | |||
@@ -365,38 +356,34 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
if (uidl.hasAttribute("focused")) { | |||
// set focused component when render phase is finished | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
ComponentConnector connector = (ComponentConnector) uidl | |||
.getPaintableAttribute("focused", getConnection()); | |||
if (connector == null) { | |||
// Do not try to focus invisible components which not | |||
// present in UIDL | |||
return; | |||
} | |||
Scheduler.get().scheduleDeferred(() -> { | |||
ComponentConnector connector = (ComponentConnector) uidl | |||
.getPaintableAttribute("focused", getConnection()); | |||
if (connector == null) { | |||
// Do not try to focus invisible components which not | |||
// present in UIDL | |||
return; | |||
} | |||
final Widget toBeFocused = connector.getWidget(); | |||
/* | |||
* Two types of Widgets can be focused, either implementing | |||
* GWT Focusable of a thinner Vaadin specific Focusable | |||
* interface. | |||
*/ | |||
if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { | |||
final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; | |||
toBeFocusedWidget.setFocus(true); | |||
} else if (toBeFocused instanceof Focusable) { | |||
((Focusable) toBeFocused).focus(); | |||
} else { | |||
getLogger().severe( | |||
"Server is trying to set focus to the widget of connector " | |||
+ Util.getConnectorString(connector) | |||
+ " but it is not focusable. The widget should implement either " | |||
+ com.google.gwt.user.client.ui.Focusable.class | |||
.getName() | |||
+ " or " + Focusable.class.getName()); | |||
} | |||
final Widget toBeFocused = connector.getWidget(); | |||
/* | |||
* Two types of Widgets can be focused, either implementing GWT | |||
* Focusable of a thinner Vaadin specific Focusable interface. | |||
*/ | |||
if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { | |||
final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; | |||
toBeFocusedWidget.setFocus(true); | |||
} else if (toBeFocused instanceof Focusable) { | |||
((Focusable) toBeFocused).focus(); | |||
} else { | |||
getLogger().severe( | |||
"Server is trying to set focus to the widget of connector " | |||
+ Util.getConnectorString(connector) | |||
+ " but it is not focusable. The widget should implement either " | |||
+ com.google.gwt.user.client.ui.Focusable.class | |||
.getName() | |||
+ " or " + Focusable.class.getName()); | |||
} | |||
}); | |||
} | |||
@@ -757,12 +744,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
return; | |||
} | |||
Scheduler.get().scheduleDeferred(new Command() { | |||
@Override | |||
public void execute() { | |||
componentConnector.getWidget().getElement().scrollIntoView(); | |||
} | |||
}); | |||
Scheduler.get().scheduleDeferred(() -> componentConnector.getWidget() | |||
.getElement().scrollIntoView()); | |||
} | |||
@Override |
@@ -34,12 +34,7 @@ public class UploadConnector extends AbstractComponentConnector | |||
implements Paintable { | |||
public UploadConnector() { | |||
registerRpc(UploadClientRpc.class, new UploadClientRpc() { | |||
@Override | |||
public void submitUpload() { | |||
getWidget().submit(); | |||
} | |||
}); | |||
registerRpc(UploadClientRpc.class, () -> getWidget().submit()); | |||
} | |||
@Override |
@@ -240,13 +240,9 @@ public class FlyweightRow implements Row { | |||
assertSetup(); | |||
assert offset >= 0 && offset + numberOfCells <= cells | |||
.size() : "Invalid range of cells"; | |||
return new Iterable<FlyweightCell>() { | |||
@Override | |||
public Iterator<FlyweightCell> iterator() { | |||
return CellIterator.attached( | |||
return () -> CellIterator | |||
.attached( | |||
cells.subList(offset, offset + numberOfCells)); | |||
} | |||
}; | |||
} | |||
/** | |||
@@ -269,13 +265,9 @@ public class FlyweightRow implements Row { | |||
assertSetup(); | |||
assert offset >= 0 && offset + numberOfCells <= cells | |||
.size() : "Invalid range of cells"; | |||
return new Iterable<FlyweightCell>() { | |||
@Override | |||
public Iterator<FlyweightCell> iterator() { | |||
return CellIterator.unattached( | |||
return () -> CellIterator | |||
.unattached( | |||
cells.subList(offset, offset + numberOfCells)); | |||
} | |||
}; | |||
} | |||
/** |
@@ -380,39 +380,6 @@ public class AutoScroller { | |||
} | |||
} | |||
/** | |||
* This handler makes sure that pointer movements are handled. | |||
* <p> | |||
* Essentially, a native preview handler is registered (so that selection | |||
* gestures can happen outside of the selection column). The handler itself | |||
* makes sure that it's detached when the pointer is "lifted". | |||
*/ | |||
private final NativePreviewHandler scrollPreviewHandler = new NativePreviewHandler() { | |||
@Override | |||
public void onPreviewNativeEvent(final NativePreviewEvent event) { | |||
if (autoScroller == null) { | |||
stop(); | |||
return; | |||
} | |||
final NativeEvent nativeEvent = event.getNativeEvent(); | |||
int pageY = 0; | |||
int pageX = 0; | |||
switch (event.getTypeInt()) { | |||
case Event.ONMOUSEMOVE: | |||
case Event.ONTOUCHMOVE: | |||
pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent); | |||
pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent); | |||
autoScroller.updatePointerCoords(pageX, pageY); | |||
break; | |||
case Event.ONMOUSEUP: | |||
case Event.ONTOUCHEND: | |||
case Event.ONTOUCHCANCEL: | |||
stop(); | |||
break; | |||
} | |||
} | |||
}; | |||
/** The registration info for {@link #scrollPreviewHandler} */ | |||
private HandlerRegistration handlerRegistration; | |||
@@ -441,6 +408,37 @@ public class AutoScroller { | |||
private AutoScrollerCallback callback; | |||
/** | |||
* This handler makes sure that pointer movements are handled. | |||
* <p> | |||
* Essentially, a native preview handler is registered (so that selection | |||
* gestures can happen outside of the selection column). The handler itself | |||
* makes sure that it's detached when the pointer is "lifted". | |||
*/ | |||
private final NativePreviewHandler scrollPreviewHandler = event -> { | |||
if (autoScroller == null) { | |||
stop(); | |||
return; | |||
} | |||
final NativeEvent nativeEvent = event.getNativeEvent(); | |||
int pageY = 0; | |||
int pageX = 0; | |||
switch (event.getTypeInt()) { | |||
case Event.ONMOUSEMOVE: | |||
case Event.ONTOUCHMOVE: | |||
pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent); | |||
pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent); | |||
autoScroller.updatePointerCoords(pageX, pageY); | |||
break; | |||
case Event.ONMOUSEUP: | |||
case Event.ONTOUCHEND: | |||
case Event.ONTOUCHCANCEL: | |||
stop(); | |||
break; | |||
} | |||
}; | |||
/** | |||
* Creates a new instance for scrolling the given grid. | |||
* |
@@ -26,12 +26,7 @@ import com.google.gwt.user.client.ui.Widget; | |||
public interface DetailsGenerator { | |||
/** A details generator that provides no details. */ | |||
public static final DetailsGenerator NULL = new DetailsGenerator() { | |||
@Override | |||
public Widget getDetails(int rowIndex) { | |||
return null; | |||
} | |||
}; | |||
public static final DetailsGenerator NULL = rowIndex -> null; | |||
/** | |||
* This method is called for whenever a new details row needs to be |
@@ -133,45 +133,36 @@ public class ListSorter<T> { | |||
"Grid " + grid + " data source is not a ListDataSource!"); | |||
} | |||
((ListDataSource<T>) ds).sort(new Comparator<T>() { | |||
@Override | |||
@SuppressWarnings({ "rawtypes", "unchecked" }) | |||
public int compare(T a, T b) { | |||
for (SortOrder o : order) { | |||
Grid.Column column = o.getColumn(); | |||
Comparator cmp = ListSorter.this.comparators.get(column); | |||
int result = 0; | |||
Object valueA = column.getValue(a); | |||
Object valueB = column.getValue(b); | |||
if (cmp != null) { | |||
result = cmp.compare(valueA, valueB); | |||
} else { | |||
if (!(valueA instanceof Comparable)) { | |||
throw new IllegalStateException("Column " + column | |||
+ " has no assigned comparator and value " | |||
+ valueA + " isn't naturally comparable"); | |||
} | |||
result = ((Comparable) valueA).compareTo(valueB); | |||
} | |||
if (result != 0) { | |||
return o.getDirection() == SortDirection.ASCENDING | |||
? result | |||
: -result; | |||
((ListDataSource<T>) ds).sort((a, b) -> { | |||
for (SortOrder o : order) { | |||
Grid.Column column = o.getColumn(); | |||
Comparator cmp = comparators.get(column); | |||
int result = 0; | |||
Object valueA = column.getValue(a); | |||
Object valueB = column.getValue(b); | |||
if (cmp != null) { | |||
result = cmp.compare(valueA, valueB); | |||
} else { | |||
if (!(valueA instanceof Comparable)) { | |||
throw new IllegalStateException("Column " + column | |||
+ " has no assigned comparator and value " | |||
+ valueA + " isn't naturally comparable"); | |||
} | |||
result = ((Comparable) valueA).compareTo(valueB); | |||
} | |||
if (!order.isEmpty()) { | |||
return order.get(0) | |||
.getDirection() == SortDirection.ASCENDING | |||
? a.hashCode() - b.hashCode() | |||
: b.hashCode() - a.hashCode(); | |||
if (result != 0) { | |||
return o.getDirection() == SortDirection.ASCENDING ? result | |||
: -result; | |||
} | |||
return a.hashCode() - b.hashCode(); | |||
} | |||
if (!order.isEmpty()) { | |||
return order.get(0).getDirection() == SortDirection.ASCENDING | |||
? a.hashCode() - b.hashCode() | |||
: b.hashCode() - a.hashCode(); | |||
} | |||
return a.hashCode() - b.hashCode(); | |||
}); | |||
} | |||
} |
@@ -17,12 +17,8 @@ package com.vaadin.client.widget.grid.selection; | |||
import com.google.gwt.event.dom.client.KeyCodes; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.vaadin.client.widget.grid.DataAvailableEvent; | |||
import com.vaadin.client.widget.grid.DataAvailableHandler; | |||
import com.vaadin.client.widget.grid.events.BodyKeyDownHandler; | |||
import com.vaadin.client.widget.grid.events.BodyKeyUpHandler; | |||
import com.vaadin.client.widget.grid.events.GridKeyDownEvent; | |||
import com.vaadin.client.widget.grid.events.GridKeyUpEvent; | |||
import com.vaadin.client.widgets.Grid; | |||
import com.vaadin.shared.ui.grid.ScrollDestination; | |||
@@ -60,17 +56,12 @@ public class SpaceSelectHandler<T> { | |||
} | |||
scrollHandler = grid | |||
.addDataAvailableHandler(new DataAvailableHandler() { | |||
@Override | |||
public void onDataAvailable( | |||
DataAvailableEvent dataAvailableEvent) { | |||
if (dataAvailableEvent.getAvailableRows() | |||
.contains(rowIndex)) { | |||
setSelected(grid, rowIndex); | |||
scrollHandler.removeHandler(); | |||
scrollHandler = null; | |||
} | |||
.addDataAvailableHandler(dataAvailableEvent -> { | |||
if (dataAvailableEvent.getAvailableRows() | |||
.contains(rowIndex)) { | |||
setSelected(grid, rowIndex); | |||
scrollHandler.removeHandler(); | |||
scrollHandler = null; | |||
} | |||
}); | |||
grid.scrollToRow(rowIndex, ScrollDestination.ANY); | |||
@@ -104,13 +95,9 @@ public class SpaceSelectHandler<T> { | |||
this.grid = grid; | |||
spaceDownHandler = grid | |||
.addBodyKeyDownHandler(new SpaceKeyDownHandler()); | |||
spaceUpHandler = grid.addBodyKeyUpHandler(new BodyKeyUpHandler() { | |||
@Override | |||
public void onKeyUp(GridKeyUpEvent event) { | |||
if (event.getNativeKeyCode() == KeyCodes.KEY_SPACE) { | |||
spaceDown = false; | |||
} | |||
spaceUpHandler = grid.addBodyKeyUpHandler(event -> { | |||
if (event.getNativeKeyCode() == KeyCodes.KEY_SPACE) { | |||
spaceDown = false; | |||
} | |||
}); | |||
} |
@@ -5868,12 +5868,9 @@ public class Escalator extends Widget | |||
private void setupScrollbars(final Element root) { | |||
ScrollHandler scrollHandler = new ScrollHandler() { | |||
@Override | |||
public void onScroll(ScrollEvent event) { | |||
scroller.onScroll(); | |||
fireEvent(new ScrollEvent()); | |||
} | |||
ScrollHandler scrollHandler = event -> { | |||
scroller.onScroll(); | |||
fireEvent(new ScrollEvent()); | |||
}; | |||
int scrollbarThickness = WidgetUtil.getNativeScrollbarSize(); |
@@ -238,12 +238,7 @@ public class Overlay extends PopupPanel { | |||
if (left < 0) { | |||
// Would move left of screen, shrink to fit in window | |||
setOuterWidthThroughWidget(windowRight - windowLeft); | |||
runOnClose.add(new Command() { | |||
@Override | |||
public void execute() { | |||
getWidget().setWidth(""); | |||
} | |||
}); | |||
runOnClose.add(() -> getWidget().setWidth("")); | |||
left = 0; | |||
} | |||
} | |||
@@ -259,12 +254,7 @@ public class Overlay extends PopupPanel { | |||
if (top < 0) { | |||
// Would move above screen, shrink to fit in window | |||
setOuterHeightThroughWidget(windowBottom - windowTop); | |||
runOnClose.add(new Command() { | |||
@Override | |||
public void execute() { | |||
getWidget().setHeight(""); | |||
} | |||
}); | |||
runOnClose.add(() -> getWidget().setHeight("")); | |||
top = 0; | |||
} | |||
} |
@@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.Arrays; | |||
import java.util.Comparator; | |||
import org.easymock.EasyMock; | |||
import org.junit.Test; | |||
@@ -178,12 +177,7 @@ public class ListDataSourceTest { | |||
// TODO Should be simplified to sort(). No point in providing these | |||
// trivial comparators. | |||
ds.sort(new Comparator<Integer>() { | |||
@Override | |||
public int compare(Integer o1, Integer o2) { | |||
return o1.compareTo(o2); | |||
} | |||
}); | |||
ds.sort((o1, o2) -> o1.compareTo(o2)); | |||
assertTrue(Arrays.equals(ds.asList().toArray(), | |||
new Integer[] { 1, 2, 3, 3, 4 })); |
@@ -25,7 +25,6 @@ public class SerializationTest { | |||
} | |||
}); | |||
} | |||
} | |||
@Test |
@@ -121,36 +121,27 @@ public class TreeGrid<T> extends Grid<T> | |||
HierarchicalDataCommunicator<T> dataCommunicator) { | |||
super(propertySet, dataCommunicator); | |||
registerRpc(new NodeCollapseRpc() { | |||
@Override | |||
public void setNodeCollapsed(String rowKey, int rowIndex, | |||
boolean collapse, boolean userOriginated) { | |||
T item = getDataCommunicator().getKeyMapper().get(rowKey); | |||
if (collapse && getDataCommunicator().isExpanded(item)) { | |||
getDataCommunicator().doCollapse(item, | |||
Optional.of(rowIndex)); | |||
fireCollapseEvent( | |||
getDataCommunicator().getKeyMapper().get(rowKey), | |||
userOriginated); | |||
} else if (!collapse | |||
&& !getDataCommunicator().isExpanded(item)) { | |||
getDataCommunicator().doExpand(item, Optional.of(rowIndex)); | |||
fireExpandEvent( | |||
getDataCommunicator().getKeyMapper().get(rowKey), | |||
userOriginated); | |||
} | |||
registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse, | |||
userOriginated) -> { | |||
T item = getDataCommunicator().getKeyMapper().get(rowKey); | |||
if (collapse && getDataCommunicator().isExpanded(item)) { | |||
getDataCommunicator().doCollapse(item, Optional.of(rowIndex)); | |||
fireCollapseEvent( | |||
getDataCommunicator().getKeyMapper().get(rowKey), | |||
userOriginated); | |||
} else if (!collapse && !getDataCommunicator().isExpanded(item)) { | |||
getDataCommunicator().doExpand(item, Optional.of(rowIndex)); | |||
fireExpandEvent( | |||
getDataCommunicator().getKeyMapper().get(rowKey), | |||
userOriginated); | |||
} | |||
}); | |||
registerRpc(new FocusParentRpc() { | |||
@Override | |||
public void focusParent(String rowKey, int cellIndex) { | |||
Integer parentIndex = getDataCommunicator().getParentIndex( | |||
getDataCommunicator().getKeyMapper().get(rowKey)); | |||
if (parentIndex != null) { | |||
getRpcProxy(FocusRpc.class).focusCell(parentIndex, | |||
cellIndex); | |||
} | |||
registerRpc((FocusParentRpc) (rowKey, cellIndex) -> { | |||
Integer parentIndex = getDataCommunicator().getParentIndex( | |||
getDataCommunicator().getKeyMapper().get(rowKey)); | |||
if (parentIndex != null) { | |||
getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex); | |||
} | |||
}); | |||
} |
@@ -260,18 +260,14 @@ public abstract class UI extends AbstractSingleComponentContainer | |||
} | |||
}; | |||
private WindowOrderRpc windowOrderRpc = new WindowOrderRpc() { | |||
@Override | |||
public void windowOrderChanged(Map<Integer, Connector> windowOrders) { | |||
Map<Integer, Window> orders = new LinkedHashMap<>(); | |||
for (Entry<Integer, Connector> entry : windowOrders.entrySet()) { | |||
if (entry.getValue() instanceof Window) { | |||
orders.put(entry.getKey(), (Window) entry.getValue()); | |||
} | |||
private WindowOrderRpc windowOrderRpc = windowOrders -> { | |||
Map<Integer, Window> orders = new LinkedHashMap<>(); | |||
for (Entry<Integer, Connector> entry : windowOrders.entrySet()) { | |||
if (entry.getValue() instanceof Window) { | |||
orders.put(entry.getKey(), (Window) entry.getValue()); | |||
} | |||
fireWindowOrder(orders); | |||
} | |||
fireWindowOrder(orders); | |||
}; | |||
/** | |||
@@ -518,18 +514,15 @@ public abstract class UI extends AbstractSingleComponentContainer | |||
// on. | |||
getPushConfiguration().setPushMode(PushMode.DISABLED); | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
// This intentionally does disconnect without locking | |||
// the VaadinSession to avoid deadlocks where the server | |||
// uses a lock for the websocket connection | |||
// See https://dev.vaadin.com/ticket/18436 | |||
// The underlying problem is | |||
// https://dev.vaadin.com/ticket/16919 | |||
setPushConnection(null); | |||
} | |||
new Thread(() -> { | |||
// This intentionally does disconnect without locking | |||
// the VaadinSession to avoid deadlocks where the server | |||
// uses a lock for the websocket connection | |||
// See https://dev.vaadin.com/ticket/18436 | |||
// The underlying problem is | |||
// https://dev.vaadin.com/ticket/16919 | |||
setPushConnection(null); | |||
}).start(); | |||
} | |||
this.session = session; |
@@ -30,20 +30,15 @@ import com.vaadin.ui.AbstractField; | |||
*/ | |||
public class ColorPickerGradient extends AbstractField<Color> { | |||
private ColorPickerGradientServerRpc rpc = new ColorPickerGradientServerRpc() { | |||
@Override | |||
public void select(int cursorX, int cursorY) { | |||
setValue(converter.calculate(cursorX, cursorY), true); | |||
} | |||
}; | |||
/** The converter. */ | |||
private Coordinates2Color converter; | |||
/** The foreground color. */ | |||
private Color color; | |||
private ColorPickerGradientServerRpc rpc = (cursorX, | |||
cursorY) -> setValue(converter.calculate(cursorX, cursorY), true); | |||
private ColorPickerGradient() { | |||
registerRpc(rpc); | |||
// width and height must be set here instead of in theme, otherwise |
@@ -30,8 +30,6 @@ import org.junit.Test; | |||
import org.mockito.Mockito; | |||
import com.vaadin.server.DefaultDeploymentConfiguration; | |||
import com.vaadin.server.ErrorEvent; | |||
import com.vaadin.server.ErrorHandler; | |||
import com.vaadin.server.LegacyCommunicationManager; | |||
import com.vaadin.server.MockServletConfig; | |||
import com.vaadin.server.UIClassSelectionEvent; | |||
@@ -121,12 +119,7 @@ public class ServletUIInitHandlerTest { | |||
} | |||
}; | |||
ui.setErrorHandler(new ErrorHandler() { | |||
@Override | |||
public void error(ErrorEvent event) { | |||
errorHandlerCalls.incrementAndGet(); | |||
} | |||
}); | |||
ui.setErrorHandler(event -> errorHandlerCalls.incrementAndGet()); | |||
CommunicationMock mock = new CommunicationMock(ui); | |||
VaadinRequest initRequest = mock.createInitRequest(); |
@@ -87,41 +87,35 @@ public class UITest { | |||
final ConcurrentLinkedQueue<Exception> exceptions = new ConcurrentLinkedQueue<Exception>(); | |||
// Simulates the websocket close thread | |||
Runnable websocketClose = new Runnable() { | |||
@Override | |||
public void run() { | |||
externalLock.lock(); | |||
// Wait for disconnect thread to lock VaadinSession | |||
websocketReachedCheckpoint.countDown(); | |||
try { | |||
uiDisconnectReachedCheckpoint.await(); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
exceptions.add(e); | |||
return; | |||
} | |||
uiSession.lock(); | |||
externalLock.unlock(); | |||
Runnable websocketClose = () -> { | |||
externalLock.lock(); | |||
// Wait for disconnect thread to lock VaadinSession | |||
websocketReachedCheckpoint.countDown(); | |||
try { | |||
uiDisconnectReachedCheckpoint.await(); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
exceptions.add(e); | |||
return; | |||
} | |||
uiSession.lock(); | |||
externalLock.unlock(); | |||
}; | |||
Runnable disconnectPushFromUI = new Runnable() { | |||
@Override | |||
public void run() { | |||
uiSession.lock(); | |||
// Wait for websocket thread to lock external lock | |||
uiDisconnectReachedCheckpoint.countDown(); | |||
try { | |||
websocketReachedCheckpoint.await(); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
exceptions.add(e); | |||
return; | |||
} | |||
ui.setSession(null); | |||
uiSession.unlock(); | |||
Runnable disconnectPushFromUI = () -> { | |||
uiSession.lock(); | |||
// Wait for websocket thread to lock external lock | |||
uiDisconnectReachedCheckpoint.countDown(); | |||
try { | |||
websocketReachedCheckpoint.await(); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
exceptions.add(e); | |||
return; | |||
} | |||
ui.setSession(null); | |||
uiSession.unlock(); | |||
}; | |||
Thread websocketThread = new Thread(websocketClose); |
@@ -496,35 +496,29 @@ public class GridElement extends AbstractComponentElement { | |||
* @return an iterable of all the data rows in the grid. | |||
*/ | |||
public Iterable<GridRowElement> getRows() { | |||
return new Iterable<GridElement.GridRowElement>() { | |||
return () -> new Iterator<GridElement.GridRowElement>() { | |||
int nextIndex = 0; | |||
@Override | |||
public GridRowElement next() { | |||
return getRow(nextIndex++); | |||
} | |||
@Override | |||
public Iterator<GridRowElement> iterator() { | |||
return new Iterator<GridElement.GridRowElement>() { | |||
int nextIndex = 0; | |||
@Override | |||
public GridRowElement next() { | |||
return getRow(nextIndex++); | |||
} | |||
@Override | |||
public boolean hasNext() { | |||
try { | |||
getRow(nextIndex); | |||
return true; | |||
} catch (Exception e) { | |||
return false; | |||
} | |||
} | |||
@Override | |||
public void remove() { | |||
throw new UnsupportedOperationException( | |||
"remove not supported"); | |||
} | |||
}; | |||
public boolean hasNext() { | |||
try { | |||
getRow(nextIndex); | |||
return true; | |||
} catch (Exception e) { | |||
return false; | |||
} | |||
} | |||
@Override | |||
public void remove() { | |||
throw new UnsupportedOperationException("remove not supported"); | |||
} | |||
}; | |||
} | |||
} |
@@ -47,7 +47,6 @@ import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.server.LegacyVaadinServlet; | |||
import com.vaadin.server.ServiceException; | |||
import com.vaadin.server.SystemMessages; | |||
import com.vaadin.server.SystemMessagesInfo; | |||
import com.vaadin.server.SystemMessagesProvider; | |||
import com.vaadin.server.UIClassSelectionEvent; | |||
import com.vaadin.server.UICreateEvent; | |||
@@ -452,22 +451,16 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { | |||
deploymentConfiguration); | |||
final SystemMessagesProvider provider = service | |||
.getSystemMessagesProvider(); | |||
service.setSystemMessagesProvider(new SystemMessagesProvider() { | |||
@Override | |||
public SystemMessages getSystemMessages( | |||
SystemMessagesInfo systemMessagesInfo) { | |||
if (systemMessagesInfo.getRequest() == null) { | |||
return provider.getSystemMessages(systemMessagesInfo); | |||
} | |||
Object messages = systemMessagesInfo.getRequest() | |||
.getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY); | |||
if (messages instanceof SystemMessages) { | |||
return (SystemMessages) messages; | |||
} | |||
service.setSystemMessagesProvider(systemMessagesInfo -> { | |||
if (systemMessagesInfo.getRequest() == null) { | |||
return provider.getSystemMessages(systemMessagesInfo); | |||
} | |||
Object messages = systemMessagesInfo.getRequest() | |||
.getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY); | |||
if (messages instanceof SystemMessages) { | |||
return (SystemMessages) messages; | |||
} | |||
return provider.getSystemMessages(systemMessagesInfo); | |||
}); | |||
return service; | |||
} |
@@ -17,7 +17,6 @@ | |||
package com.vaadin.launcher; | |||
import java.io.File; | |||
import java.io.FilenameFilter; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.net.InetAddress; | |||
@@ -257,12 +256,8 @@ public class DevelopmentServerLauncher { | |||
server.start(); | |||
}); | |||
scanner.setReportExistingFilesOnStartup(false); | |||
scanner.setFilenameFilter(new FilenameFilter() { | |||
@Override | |||
public boolean accept(File folder, String name) { | |||
return name.endsWith(".class"); | |||
} | |||
}); | |||
scanner.setFilenameFilter( | |||
(folder, name) -> name.endsWith(".class")); | |||
scanner.setScanDirs(classFolders); | |||
scanner.start(); |
@@ -17,7 +17,6 @@ package com.vaadin.screenshotbrowser; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.FilenameFilter; | |||
import java.io.IOException; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
@@ -357,12 +356,8 @@ public class ScreenshotBrowser extends UI { | |||
private void refreshTableContainer() { | |||
File errorsDir = new File(screenshotDir, "errors"); | |||
File[] failures = errorsDir.listFiles(new FilenameFilter() { | |||
@Override | |||
public boolean accept(File dir, String name) { | |||
return name.endsWith(".html"); | |||
} | |||
}); | |||
File[] failures = errorsDir | |||
.listFiles((dir, name) -> name.endsWith(".html")); | |||
BeanItemContainer<ComparisonFailure> container = new BeanItemContainer<>( | |||
ComparisonFailure.class); |
@@ -18,7 +18,6 @@ package com.vaadin.tests; | |||
import com.vaadin.shared.ui.ContentMode; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Component.Event; | |||
import com.vaadin.ui.Component.Listener; | |||
import com.vaadin.ui.CustomLayout; | |||
@@ -56,13 +55,7 @@ public class CustomLayoutDemo extends com.vaadin.server.LegacyApplication | |||
private final PasswordField loginPwd = new PasswordField("Password"); | |||
private final Button loginButton = new Button("Login", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
loginClicked(); | |||
} | |||
}); | |||
event -> loginClicked()); | |||
private final Tree menu = new Tree(); | |||
@@ -2,7 +2,6 @@ package com.vaadin.tests; | |||
import com.vaadin.tests.components.TestDateField; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.v7.ui.AbstractSelect; | |||
@@ -53,12 +52,7 @@ public class FocusingComponents extends CustomComponent { | |||
} | |||
Button focus = new Button("focus"); | |||
focus.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
f.focus(); | |||
} | |||
}); | |||
focus.addClickListener(event -> f.focus()); | |||
lo.addComponent(focus); | |||
} |
@@ -58,10 +58,7 @@ public class ListenerOrder extends com.vaadin.server.LegacyApplication | |||
b1.addClickListener(mutualListener); | |||
b1.removeClickListener(b1Listener); | |||
// remove non-existing listener | |||
b1.removeClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
} | |||
b1.removeClickListener(event -> { | |||
}); | |||
// |
@@ -38,75 +38,60 @@ public class NativeWindowing extends LegacyApplication { | |||
setMainWindow(main); | |||
main.addComponent( | |||
new Button("Add new subwindow", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
final Window w = new Window( | |||
"sw " + System.currentTimeMillis(), layout); | |||
main.addWindow(w); | |||
w.setPositionX(100); | |||
w.setPositionY(100); | |||
w.setWidth("200px"); | |||
w.setHeight("200px"); | |||
w.setWidth("100px"); | |||
w.setHeight("400px"); | |||
final Button closebutton = new Button( | |||
"Close " + w.getCaption(), | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
main.removeWindow(w); | |||
} | |||
}); | |||
layout.addComponent(closebutton); | |||
layout.addComponent(new Label( | |||
"<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>", | |||
ContentMode.HTML)); | |||
} | |||
new Button("Add new subwindow", event -> { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
final Window w = new Window( | |||
"sw " + System.currentTimeMillis(), layout); | |||
main.addWindow(w); | |||
w.setPositionX(100); | |||
w.setPositionY(100); | |||
w.setWidth("200px"); | |||
w.setHeight("200px"); | |||
w.setWidth("100px"); | |||
w.setHeight("400px"); | |||
final Button closebutton = new Button( | |||
"Close " + w.getCaption(), | |||
clickEvent -> main.removeWindow(w)); | |||
layout.addComponent(closebutton); | |||
layout.addComponent(new Label( | |||
"<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>", | |||
ContentMode.HTML)); | |||
})); | |||
main.addComponent(new Button( | |||
"Open a currently uncreated application level window", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
try { | |||
main.open(new com.vaadin.server.ExternalResource( | |||
new URL(getURL(), | |||
"mainwin-" | |||
+ System.currentTimeMillis() | |||
+ "/")), | |||
null); | |||
} catch (final MalformedURLException e) { | |||
} | |||
event -> { | |||
try { | |||
main.open(new com.vaadin.server.ExternalResource( | |||
new URL(getURL(), "mainwin-" | |||
+ System.currentTimeMillis() + "/")), | |||
null); | |||
} catch (final MalformedURLException e) { | |||
} | |||
})); | |||
@@ -21,7 +21,6 @@ import java.util.List; | |||
import com.vaadin.ui.AbstractOrderedLayout; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -72,37 +71,31 @@ public class OrderedLayoutSwapComponents extends CustomComponent { | |||
ol.setId(name.replaceAll(" ", "")); | |||
ol.addComponent(new Label(name)); | |||
up = new Button("up"); | |||
up.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
int newIndex = order.indexOf(MyComponent.this) - 1; | |||
MyComponent old = order.get(newIndex); | |||
main.replaceComponent(old, MyComponent.this); | |||
order.remove(MyComponent.this); | |||
order.add(newIndex, MyComponent.this); | |||
if (newIndex == 0) { | |||
MyComponent.this.setMode(FIRST); | |||
} else { | |||
MyComponent.this.setMode(69); | |||
} | |||
up.addClickListener(event -> { | |||
int newIndex = order.indexOf(this) - 1; | |||
MyComponent old = order.get(newIndex); | |||
main.replaceComponent(old, this); | |||
order.remove(this); | |||
order.add(newIndex, this); | |||
if (newIndex == 0) { | |||
setMode(FIRST); | |||
} else { | |||
setMode(69); | |||
} | |||
}); | |||
ol.addComponent(up); | |||
down = new Button("down"); | |||
down.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
int newIndex = order.indexOf(MyComponent.this) + 1; | |||
MyComponent old = order.get(newIndex); | |||
main.replaceComponent(old, MyComponent.this); | |||
order.remove(MyComponent.this); | |||
order.add(newIndex, MyComponent.this); | |||
if (newIndex == order.size() - 1) { | |||
MyComponent.this.setMode(LAST); | |||
} else { | |||
MyComponent.this.setMode(69); | |||
} | |||
down.addClickListener(event -> { | |||
int newIndex = order.indexOf(MyComponent.this) + 1; | |||
MyComponent old = order.get(newIndex); | |||
main.replaceComponent(old, MyComponent.this); | |||
order.remove(MyComponent.this); | |||
order.add(newIndex, MyComponent.this); | |||
if (newIndex == order.size() - 1) { | |||
MyComponent.this.setMode(LAST); | |||
} else { | |||
MyComponent.this.setMode(69); | |||
} | |||
}); | |||
ol.addComponent(down); |
@@ -21,8 +21,6 @@ import java.util.Date; | |||
import com.vaadin.shared.ui.ContentMode; | |||
import com.vaadin.ui.AbstractOrderedLayout; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -30,7 +28,7 @@ import com.vaadin.ui.VerticalLayout; | |||
public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { | |||
private final AbstractOrderedLayout main; | |||
private final AbstractOrderedLayout testContainer; | |||
private final AbstractOrderedLayout testContainer = new VerticalLayout(); | |||
private Date startTime; | |||
@@ -49,24 +47,11 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { | |||
main.addComponent(result); | |||
main.addComponent( | |||
new Button("click when rendered", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
endTest(); | |||
} | |||
})); | |||
new Button("click when rendered", event -> endTest())); | |||
main.addComponent( | |||
new Button("Click for layout repaint (cached components)", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
testContainer.markAsDirty(); | |||
} | |||
})); | |||
testContainer = new VerticalLayout(); | |||
event -> testContainer.markAsDirty())); | |||
for (int i = 0; i < INITIAL_COMPONENTS; i++) { | |||
Label l = new Label("foo" + i); |
@@ -20,7 +20,6 @@ import java.util.Date; | |||
import com.vaadin.shared.ui.ContentMode; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -50,21 +49,11 @@ public class PerformanceTestSubTreeCaching extends CustomComponent { | |||
setCompositionRoot(main); | |||
addInfo(); | |||
Button b = new Button("start test", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
startTest(); | |||
} | |||
}); | |||
Button b = new Button("start test", event -> startTest()); | |||
b.setDescription( | |||
"Push this button to start test. A test label will be rendered above existing components."); | |||
main.addComponent(b); | |||
b = new Button("end test", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
endTest(); | |||
} | |||
}); | |||
b = new Button("end test", event -> endTest()); | |||
b.setDescription( | |||
"Push this button as soon as test componenet is rendered."); | |||
main.addComponent(b); |
@@ -3,8 +3,6 @@ package com.vaadin.tests; | |||
import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.ui.Accordion; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -72,26 +70,23 @@ public class ScrollbarStressTest extends LegacyApplication { | |||
height.addItem("500px"); | |||
height.setValue("100%"); | |||
final Button set = new Button("Set", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getTable = testComponent.getValue().equals("Table"); | |||
if (context.getValue() == "Main window") { | |||
drawInMainWindow(); | |||
} else if (context.getValue() == "Subwindow") { | |||
drawInSubwindow(); | |||
} else if (context.getValue() == "Panel") { | |||
drawInPanel(); | |||
} else if (context.getValue() == "Split Panel") { | |||
drawInSplitPanel(); | |||
} else if (context.getValue() == "TabSheet") { | |||
drawInTabSheet(false); | |||
} else if (context.getValue() == "Accordion") { | |||
drawInTabSheet(true); | |||
} else if (context.getValue() == "ExpandLayout") { | |||
drawInExpandLayout(); | |||
} | |||
final Button set = new Button("Set", event -> { | |||
getTable = testComponent.getValue().equals("Table"); | |||
if (context.getValue() == "Main window") { | |||
drawInMainWindow(); | |||
} else if (context.getValue() == "Subwindow") { | |||
drawInSubwindow(); | |||
} else if (context.getValue() == "Panel") { | |||
drawInPanel(); | |||
} else if (context.getValue() == "Split Panel") { | |||
drawInSplitPanel(); | |||
} else if (context.getValue() == "TabSheet") { | |||
drawInTabSheet(false); | |||
} else if (context.getValue() == "Accordion") { | |||
drawInTabSheet(true); | |||
} else if (context.getValue() == "ExpandLayout") { | |||
drawInExpandLayout(); | |||
} | |||
}); | |||
@@ -20,7 +20,6 @@ import java.util.Date; | |||
import java.util.Vector; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.ui.Table; | |||
@@ -47,16 +46,10 @@ public class StressComponentsInTable extends CustomComponent { | |||
for (int j = 0; j < cols; j++) { | |||
content.add(rndString()); | |||
} | |||
content.add(new Button("b" + i, new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Button b = event.getButton(); | |||
System.out | |||
.println(b.getCaption() + " click: " + new Date()); | |||
System.out.println(b.getUI().getSession()); | |||
} | |||
content.add(new Button("b" + i, event -> { | |||
Button b = event.getButton(); | |||
System.out.println(b.getCaption() + " click: " + new Date()); | |||
System.out.println(b.getUI().getSession()); | |||
})); | |||
t.addItem(content.toArray(), "" + i); | |||
} |
@@ -27,8 +27,6 @@ import java.util.Set; | |||
import com.vaadin.server.ExternalResource; | |||
import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.server.Page; | |||
import com.vaadin.server.Page.UriFragmentChangedEvent; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalSplitPanel; | |||
@@ -129,71 +127,65 @@ public class TestBench extends com.vaadin.server.LegacyApplication | |||
lo.addComponent(menu); | |||
mainWindow.getPage().addUriFragmentChangedListener( | |||
new Page.UriFragmentChangedListener() { | |||
@Override | |||
public void uriFragmentChanged( | |||
UriFragmentChangedEvent source) { | |||
String fragment = source.getUriFragment(); | |||
if (fragment != null && !fragment.isEmpty()) { | |||
// try to find a proper test class | |||
// exact match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getName(); | |||
if (string.equals(fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
event -> { | |||
String fragment = event.getUriFragment(); | |||
if (fragment != null && !fragment.isEmpty()) { | |||
// try to find a proper test class | |||
// exact match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getName(); | |||
if (string.equals(fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
} | |||
} | |||
// simple name match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string.equals(fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
// simple name match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string.equals(fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
} | |||
// ticket match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string | |||
.startsWith("Ticket" + fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
} | |||
// ticket match | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string.startsWith("Ticket" + fragment)) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
} | |||
} | |||
// just partly match lowercase | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string.toLowerCase(Locale.ROOT) | |||
.contains(fragment.toLowerCase( | |||
Locale.ROOT))) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
// just partly match lowercase | |||
for (Object next : menu.getItemIds()) { | |||
if (next instanceof Class) { | |||
Class<?> c = (Class<?>) next; | |||
String string = c.getSimpleName(); | |||
if (string.toLowerCase(Locale.ROOT).contains( | |||
fragment.toLowerCase(Locale.ROOT))) { | |||
menu.setValue(c); | |||
mainLayout.setSplitPosition(0); | |||
return; | |||
} | |||
} | |||
getMainWindow().showNotification( | |||
"No potential matc for #" + fragment); | |||
} | |||
getMainWindow().showNotification( | |||
"No potential matc for #" + fragment); | |||
} | |||
}); | |||
@@ -5,7 +5,6 @@ package com.vaadin.tests; | |||
import com.vaadin.server.Page; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -50,94 +49,55 @@ public class TestComponentAddAndRecursion extends CustomComponent { | |||
p3 = new Panel("p3", p3l); | |||
p2l.addComponent(p3); | |||
Button b = new Button("use gridlayout", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
p.setContent(new GridLayout()); | |||
p2.setContent(new GridLayout()); | |||
p3.setContent(new GridLayout()); | |||
} | |||
Button b = new Button("use gridlayout", event -> { | |||
p.setContent(new GridLayout()); | |||
p2.setContent(new GridLayout()); | |||
p3.setContent(new GridLayout()); | |||
}); | |||
main.addComponent(b); | |||
b = new Button("use orderedlayout", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
p.setContent(new VerticalLayout()); | |||
p2.setContent(new VerticalLayout()); | |||
p3.setContent(new VerticalLayout()); | |||
} | |||
b = new Button("use orderedlayout", event -> { | |||
p.setContent(new VerticalLayout()); | |||
p2.setContent(new VerticalLayout()); | |||
p3.setContent(new VerticalLayout()); | |||
}); | |||
main.addComponent(b); | |||
b = new Button("move B", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
p2l.addComponent(l2); | |||
} | |||
}); | |||
b = new Button("move B", event -> p2l.addComponent(l2)); | |||
main.addComponent(b); | |||
b = new Button("move p", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
p3l.addComponent(p); | |||
} | |||
}); | |||
b = new Button("move p", event -> p3l.addComponent(p)); | |||
main.addComponent(b); | |||
b = new Button("add to both", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Label l = new Label("both"); | |||
pl.addComponent(l); | |||
p2l.addComponent(l); | |||
} | |||
b = new Button("add to both", event -> { | |||
Label l = new Label("both"); | |||
pl.addComponent(l); | |||
p2l.addComponent(l); | |||
}); | |||
main.addComponent(b); | |||
b = new Button("recurse", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
try { | |||
p3l.addComponent(p2); | |||
new Notification("ERROR", "This should have failed", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} catch (Exception e) { | |||
new Notification("OK", "threw, as expected", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} | |||
b = new Button("recurse", event -> { | |||
try { | |||
p3l.addComponent(p2); | |||
new Notification("ERROR", "This should have failed", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} catch (Exception e) { | |||
new Notification("OK", "threw, as expected", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} | |||
}); | |||
main.addComponent(b); | |||
b = new Button("recurse2", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
Panel p = new Panel("dynamic", layout); | |||
layout.addComponent(p2); | |||
try { | |||
p3l.addComponent(p); | |||
new Notification("ERROR", "This should have failed", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} catch (Exception e) { | |||
new Notification("OK", "threw, as expected", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} | |||
b = new Button("recurse2", event -> { | |||
VerticalLayout layout = new VerticalLayout(); | |||
Panel p = new Panel("dynamic", layout); | |||
layout.addComponent(p2); | |||
try { | |||
p3l.addComponent(p); | |||
new Notification("ERROR", "This should have failed", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} catch (Exception e) { | |||
new Notification("OK", "threw, as expected", | |||
Notification.TYPE_ERROR_MESSAGE) | |||
.show(Page.getCurrent()); | |||
} | |||
}); | |||
main.addComponent(b); | |||
/* |
@@ -4,14 +4,12 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Container; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.util.ContainerHierarchicalWrapper; | |||
import com.vaadin.v7.data.util.ContainerOrderedWrapper; | |||
import com.vaadin.v7.data.util.IndexedContainer; | |||
@@ -69,14 +67,8 @@ public class TestContainerChanges extends CustomComponent { | |||
tbl2.setSelectable(true); | |||
tbl2.setMultiSelect(false); | |||
tbl2.setImmediate(true); | |||
tbl2.addListener(new Table.ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
System.err | |||
.println("Value now " + event.getProperty().getValue()); | |||
} | |||
}); | |||
tbl2.addValueChangeListener(event -> System.err | |||
.println("Value now " + event.getProperty().getValue())); | |||
tbl2.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); | |||
// non-ordered container will get wrapped | |||
tbl2.setContainerDataSource(hierarchical); | |||
@@ -84,97 +76,35 @@ public class TestContainerChanges extends CustomComponent { | |||
VerticalLayout buttons = new VerticalLayout(); | |||
v.addComponent(buttons); | |||
Button b = new Button("table.commit()", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tbl.commit(); | |||
} | |||
}); | |||
Button b = new Button("table.commit()", event -> tbl.commit()); | |||
buttons.addComponent(b); | |||
b = new Button("indexedcontainer.addItem()", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cont.addItem(new Integer(cnt++)); | |||
} | |||
}); | |||
event -> cont.addItem(new Integer(cnt++))); | |||
buttons.addComponent(b); | |||
b = new Button("indexedcontainer.addItem(null)", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cont.addItem(null); | |||
} | |||
}); | |||
event -> cont.addItem(null)); | |||
buttons.addComponent(b); | |||
b = new Button("indexedcontainer.removeItem(table.lastItemId()", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cont.removeItem(tbl.lastItemId()); | |||
} | |||
}); | |||
event -> cont.removeItem(tbl.lastItemId())); | |||
buttons.addComponent(b); | |||
b = new Button("indexedcontainer.addContainerProperty()", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cont.addContainerProperty("prop" + cnt, String.class, | |||
"#" + cnt++); | |||
} | |||
}); | |||
event -> cont.addContainerProperty("prop" + cnt, String.class, | |||
"#" + cnt++)); | |||
buttons.addComponent(b); | |||
b = new Button("indexedcontainer.clear()", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
cont.removeAllItems(); | |||
} | |||
}); | |||
b = new Button("indexedcontainer.clear()", | |||
event -> cont.removeAllItems()); | |||
buttons.addComponent(b); | |||
b = new Button("table.setContainerDataSource(indexedcontainer)", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tbl.setContainerDataSource(cont); | |||
} | |||
}); | |||
event -> tbl.setContainerDataSource(cont)); | |||
buttons.addComponent(b); | |||
b = new Button("table.setContainerDataSource(orderedwrapper)", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tbl.setContainerDataSource(ordered); | |||
} | |||
}); | |||
event -> tbl.setContainerDataSource(ordered)); | |||
buttons.addComponent(b); | |||
b = new Button("table.setContainerDataSource(hierarchicalwrapper)", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tbl.setContainerDataSource(hierarchical); | |||
} | |||
}); | |||
event -> tbl.setContainerDataSource(hierarchical)); | |||
buttons.addComponent(b); | |||
VerticalLayout pl = createPanelLayout(); |
@@ -24,8 +24,6 @@ import com.vaadin.shared.ui.datefield.DateResolution; | |||
import com.vaadin.tests.components.TestDateField; | |||
import com.vaadin.ui.AbstractDateField; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalSplitPanel; | |||
import com.vaadin.ui.Label; | |||
@@ -39,27 +37,14 @@ public class TestForBasicApplicationLayout extends CustomComponent { | |||
private final Button click; | |||
private final Button click2; | |||
private final TabSheet tab; | |||
private final TabSheet tab = new TabSheet(); | |||
public TestForBasicApplicationLayout() { | |||
click = new Button("Set height -1", new ClickListener() { | |||
click = new Button("Set height -1", event -> tab.setHeight(null)); | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tab.setHeight(null); | |||
} | |||
}); | |||
click2 = new Button("Set height 100%", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
tab.setHeight(100, TabSheet.UNITS_PERCENTAGE); | |||
} | |||
}); | |||
click2 = new Button("Set height 100%", | |||
event -> tab.setHeight(100, TabSheet.UNITS_PERCENTAGE)); | |||
final HorizontalSplitPanel sp = new HorizontalSplitPanel(); | |||
sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); | |||
@@ -72,7 +57,6 @@ public class TestForBasicApplicationLayout extends CustomComponent { | |||
final Panel p = new Panel("Accordion Panel", pl); | |||
p.setSizeFull(); | |||
tab = new TabSheet(); | |||
tab.setSizeFull(); | |||
VerticalLayout reportLayout = new VerticalLayout(); |
@@ -22,7 +22,6 @@ import java.util.List; | |||
import com.vaadin.server.ExternalResource; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
@@ -65,31 +64,15 @@ public class TestForChildComponentRendering extends CustomComponent { | |||
se.addItem("valinta1"); | |||
se.addItem("Valinta 2"); | |||
Button b = new Button("refresh view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
createNewView(); | |||
} | |||
}); | |||
Button b = new Button("refresh view", event -> createNewView()); | |||
main.addComponent(b); | |||
b = new Button("reorder view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
randomReorder(); | |||
} | |||
}); | |||
b = new Button("reorder view", event -> randomReorder()); | |||
main.addComponent(b); | |||
b = new Button("remove randomly one component", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
removeRandomComponent(); | |||
} | |||
}); | |||
event -> removeRandomComponent()); | |||
main.addComponent(b); | |||
} | |||
public void randomReorder() { |
@@ -17,7 +17,6 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.Label; | |||
@@ -72,30 +71,21 @@ public class TestForContainerFilterable extends CustomComponent { | |||
t.setContainerDataSource(ic); | |||
// Handler | |||
filterButton.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
ic.removeAllContainerFilters(); | |||
if (!fooFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("foo", fooFilter.getValue(), false, | |||
false); | |||
} | |||
if (!barFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("bar", barFilter.getValue(), true, | |||
true); | |||
} | |||
count.setValue("Rows in table: " + ic.size()); | |||
filterButton.addClickListener(event -> { | |||
ic.removeAllContainerFilters(); | |||
if (!fooFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("foo", fooFilter.getValue(), false, | |||
false); | |||
} | |||
if (!barFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("bar", barFilter.getValue(), true, true); | |||
} | |||
count.setValue("Rows in table: " + ic.size()); | |||
}); | |||
// Resetbutton | |||
lo.addComponent(new Button("Rebind table datasource", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
t.setContainerDataSource(ic); | |||
} | |||
})); | |||
event -> t.setContainerDataSource(ic))); | |||
} | |||
private String randomWord() { |
@@ -22,7 +22,6 @@ import java.util.List; | |||
import com.vaadin.server.ExternalResource; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.GridLayout; | |||
@@ -66,31 +65,15 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { | |||
main.addComponent(se, 0, 1, 1, 1); | |||
Button b = new Button("refresh view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
createNewView(); | |||
} | |||
}); | |||
Button b = new Button("refresh view", event -> createNewView()); | |||
main.addComponent(b); | |||
b = new Button("reorder view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
randomReorder(); | |||
} | |||
}); | |||
b = new Button("reorder view", event -> randomReorder()); | |||
main.addComponent(b); | |||
b = new Button("remove randomly one component", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
removeRandomComponent(); | |||
} | |||
}); | |||
event -> removeRandomComponent()); | |||
main.addComponent(b); | |||
} | |||
public void randomReorder() { |
@@ -38,75 +38,60 @@ public class TestForNativeWindowing extends LegacyApplication { | |||
setMainWindow(main); | |||
main.addComponent( | |||
new Button("Add new subwindow", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
final Window w = new Window( | |||
"sw " + System.currentTimeMillis(), layout); | |||
main.addWindow(w); | |||
w.setPositionX(100); | |||
w.setPositionY(100); | |||
w.setWidth("200px"); | |||
w.setHeight("200px"); | |||
w.setWidth("100px"); | |||
w.setHeight("400px"); | |||
final Button closebutton = new Button( | |||
"Close " + w.getCaption(), | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
main.removeWindow(w); | |||
} | |||
}); | |||
layout.addComponent(closebutton); | |||
layout.addComponent(new Label( | |||
"<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>", | |||
ContentMode.HTML)); | |||
} | |||
new Button("Add new subwindow", event -> { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
final Window w = new Window( | |||
"sw " + System.currentTimeMillis(), layout); | |||
main.addWindow(w); | |||
w.setPositionX(100); | |||
w.setPositionY(100); | |||
w.setWidth("200px"); | |||
w.setHeight("200px"); | |||
w.setWidth("100px"); | |||
w.setHeight("400px"); | |||
final Button closebutton = new Button( | |||
"Close " + w.getCaption(), | |||
clickEvent -> main.removeWindow(w)); | |||
layout.addComponent(closebutton); | |||
layout.addComponent(new Label( | |||
"<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>" | |||
+ "<p>Lorem ipsum dolor sit amet.</p>", | |||
ContentMode.HTML)); | |||
})); | |||
main.addComponent(new Button( | |||
"Open a currently uncreated application level window", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
try { | |||
main.open(new com.vaadin.server.ExternalResource( | |||
new URL(getURL(), | |||
"mainwin-" | |||
+ System.currentTimeMillis() | |||
+ "/")), | |||
null); | |||
} catch (final MalformedURLException e) { | |||
} | |||
event -> { | |||
try { | |||
main.open(new com.vaadin.server.ExternalResource( | |||
new URL(getURL(), "mainwin-" | |||
+ System.currentTimeMillis() + "/")), | |||
null); | |||
} catch (final MalformedURLException e) { | |||
} | |||
})); | |||
@@ -17,8 +17,6 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CustomComponent; | |||
@@ -93,14 +91,8 @@ public class TestForPreconfiguredComponents extends CustomComponent { | |||
"OptionGroup + multiselect manually (configured from select)"); | |||
main.addComponent(test); | |||
final Button b = new Button("refresh view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
createNewView(); | |||
} | |||
}); | |||
final Button b = new Button("refresh view", event -> createNewView()); | |||
main.addComponent(b); | |||
} | |||
public static void fillSelect(AbstractSelect s, int items) { | |||
@@ -150,12 +142,9 @@ public class TestForPreconfiguredComponents extends CustomComponent { | |||
final VerticalLayout statusLayout = new VerticalLayout(); | |||
final Panel status = new Panel("Events", statusLayout); | |||
final Button clear = new Button("clear event log"); | |||
clear.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
statusLayout.removeAllComponents(); | |||
statusLayout.addComponent(ol2); | |||
} | |||
clear.addClickListener(event -> { | |||
statusLayout.removeAllComponents(); | |||
statusLayout.addComponent(ol2); | |||
}); | |||
ol2.addComponent(clear); | |||
final Button commit = new Button("commit changes"); | |||
@@ -167,15 +156,11 @@ public class TestForPreconfiguredComponents extends CustomComponent { | |||
ol.addComponent(status); | |||
t.addListener(new Listener() { | |||
@Override | |||
public void componentEvent(Event event) { | |||
statusLayout | |||
.addComponent(new Label(event.getClass().getName())); | |||
// TODO should not use LegacyField.toString() | |||
statusLayout.addComponent( | |||
new Label("selected: " + event.getSource().toString())); | |||
} | |||
t.addListener(event -> { | |||
statusLayout.addComponent(new Label(event.getClass().getName())); | |||
// TODO should not use LegacyField.toString() | |||
statusLayout.addComponent( | |||
new Label("selected: " + event.getSource().toString())); | |||
}); | |||
return new Panel(ol); |
@@ -30,7 +30,6 @@ import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.server.StreamResource; | |||
import com.vaadin.shared.ui.ContentMode; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Layout; | |||
import com.vaadin.ui.LegacyWindow; | |||
@@ -80,35 +79,20 @@ public class TestForStyledUpload extends LegacyApplication | |||
up.addSucceededListener(this); | |||
up.addStartedListener(this); | |||
up.addProgressListener(new Upload.ProgressListener() { | |||
up.addProgressListener((readBytes, contentLenght) -> { | |||
pi.setValue(new Float(readBytes / (float) contentLenght)); | |||
@Override | |||
public void updateProgress(long readBytes, long contentLenght) { | |||
pi.setValue(new Float(readBytes / (float) contentLenght)); | |||
refreshMemUsage(); | |||
transferred.setValue( | |||
"Transferred " + readBytes + " of " + contentLenght); | |||
} | |||
refreshMemUsage(); | |||
transferred.setValue( | |||
"Transferred " + readBytes + " of " + contentLenght); | |||
}); | |||
final Button b = new Button("Update status", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
readState(); | |||
} | |||
}); | |||
event -> readState()); | |||
final Button c = new Button("Update status with gc", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
gc(); | |||
} | |||
}); | |||
evenet -> gc()); | |||
main.addComponent(up); | |||
l = new Label("Idle"); | |||
@@ -127,27 +111,15 @@ public class TestForStyledUpload extends LegacyApplication | |||
main.addComponent(status); | |||
Button cancel = new Button("Cancel current upload"); | |||
cancel.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
buffer.cancel(); | |||
} | |||
}); | |||
cancel.addClickListener(event -> buffer.cancel()); | |||
main.addComponent(cancel); | |||
final Button restart = new Button("Restart demo application"); | |||
restart.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
TestForStyledUpload.this.close(); | |||
} | |||
}); | |||
restart.addClickListener(event -> TestForStyledUpload.this.close()); | |||
main.addComponent(restart); | |||
main.addComponent(b); | |||
main.addComponent(c); | |||
} | |||
public void gc() { |
@@ -21,7 +21,6 @@ import java.util.Vector; | |||
import com.vaadin.server.UserError; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Layout; | |||
@@ -117,14 +116,8 @@ public class TestForTablesInitialColumnWidthLogicRendering | |||
t.setWidth("200px"); | |||
main.addComponent(t); | |||
final Button b = new Button("refresh view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
createNewView(); | |||
} | |||
}); | |||
final Button b = new Button("refresh view", event -> createNewView()); | |||
main.addComponent(b); | |||
} | |||
public static Table getTestTable(int cols, int rows) { | |||
@@ -139,14 +132,8 @@ public class TestForTablesInitialColumnWidthLogicRendering | |||
for (int j = 0; j < cols; j++) { | |||
content.add(rndString()); | |||
} | |||
Button button = new Button("b", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
System.out.println("b click"); | |||
} | |||
}); | |||
Button button = new Button("b", | |||
event -> System.out.println("b click")); | |||
button.setDescription("Yep yep"); | |||
button.setComponentError(new UserError("Error")); | |||
content.add(button); |
@@ -20,8 +20,6 @@ import com.vaadin.event.Action; | |||
import com.vaadin.event.Action.Handler; | |||
import com.vaadin.ui.AbstractOrderedLayout; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.HorizontalLayout; | |||
@@ -100,14 +98,8 @@ public class TestForTrees extends CustomComponent implements Handler { | |||
main.addComponent(ol); | |||
contextTree = t; | |||
final Button b = new Button("refresh view", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
createNewView(); | |||
} | |||
}); | |||
final Button b = new Button("refresh view", event -> createNewView()); | |||
main.addComponent(b); | |||
} | |||
public Tree createTestTree() { | |||
@@ -148,12 +140,9 @@ public class TestForTrees extends CustomComponent implements Handler { | |||
statusLayout.setMargin(true); | |||
final Panel status = new Panel("Events", statusLayout); | |||
final Button clear = new Button("c"); | |||
clear.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
statusLayout.removeAllComponents(); | |||
statusLayout.addComponent(clear); | |||
} | |||
clear.addClickListener(event -> { | |||
statusLayout.removeAllComponents(); | |||
statusLayout.addComponent(clear); | |||
}); | |||
statusLayout.addComponent(clear); | |||
@@ -162,15 +151,11 @@ public class TestForTrees extends CustomComponent implements Handler { | |||
ol.addComponent(status); | |||
t.addListener(new Listener() { | |||
@Override | |||
public void componentEvent(Event event) { | |||
statusLayout | |||
.addComponent(new Label(event.getClass().getName())); | |||
// TODO should not use LegacyField.toString() | |||
statusLayout.addComponent( | |||
new Label("selected: " + event.getSource().toString())); | |||
} | |||
t.addListener((Listener) event -> { | |||
statusLayout.addComponent(new Label(event.getClass().getName())); | |||
// TODO should not use LegacyField.toString() | |||
statusLayout.addComponent( | |||
new Label("selected: " + event.getSource().toString())); | |||
}); | |||
return ol; |
@@ -31,7 +31,6 @@ import java.lang.management.MemoryMXBean; | |||
import com.vaadin.server.StreamResource; | |||
import com.vaadin.shared.ui.ContentMode; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
@@ -40,12 +39,7 @@ import com.vaadin.ui.LegacyWindow; | |||
import com.vaadin.ui.Link; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.ui.Upload; | |||
import com.vaadin.ui.Upload.FinishedEvent; | |||
import com.vaadin.ui.Upload.StartedEvent; | |||
import com.vaadin.ui.Upload.StartedListener; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.ui.AbstractField; | |||
import com.vaadin.v7.ui.ProgressIndicator; | |||
import com.vaadin.v7.ui.Select; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -106,130 +100,88 @@ public class TestForUpload extends CustomComponent | |||
up = new Upload("Upload", buffer); | |||
up.setImmediateMode(true); | |||
up.addListener(new Listener() { | |||
private static final long serialVersionUID = -8319074730512324303L; | |||
@Override | |||
public void componentEvent(Event event) { | |||
// print out all events fired by upload for debug purposes | |||
System.out.println("Upload fired event | " + event); | |||
} | |||
}); | |||
up.addStartedListener(new StartedListener() { | |||
private static final long serialVersionUID = 5508883803861085154L; | |||
@Override | |||
public void uploadStarted(StartedEvent event) { | |||
pi.setVisible(true); | |||
pi2.setVisible(true); | |||
l.setValue("Started uploading file " + event.getFilename()); | |||
textFieldValue | |||
.setValue(" TestFields value at the upload start is:" | |||
+ textField.getValue()); | |||
} | |||
}); | |||
up.addFinishedListener(new Upload.FinishedListener() { | |||
private static final long serialVersionUID = -3773034195991947371L; | |||
@Override | |||
public void uploadFinished(FinishedEvent event) { | |||
pi.setVisible(false); | |||
pi2.setVisible(false); | |||
if (event instanceof Upload.FailedEvent) { | |||
Exception reason = ((Upload.FailedEvent) event).getReason(); | |||
l.setValue( | |||
"Finished with failure ( " + reason + " ), idle"); | |||
} else if (event instanceof Upload.SucceededEvent) { | |||
l.setValue("Finished with succes, idle"); | |||
} else { | |||
l.setValue("Finished with unknow event"); | |||
} | |||
statusLayout.removeAllComponents(); | |||
final InputStream stream = buffer.getStream(); | |||
if (stream == null) { | |||
statusLayout.addComponent(new Label( | |||
"Upload finished, but output buffer is null")); | |||
} else { | |||
statusLayout.addComponent( | |||
new Label("<b>Name:</b> " + event.getFilename(), | |||
ContentMode.HTML)); | |||
statusLayout.addComponent( | |||
new Label("<b>Mimetype:</b> " + event.getMIMEType(), | |||
ContentMode.HTML)); | |||
statusLayout.addComponent(new Label( | |||
"<b>Size:</b> " + event.getLength() + " bytes.", | |||
ContentMode.HTML)); | |||
statusLayout.addComponent(new Link( | |||
"Download " + buffer.getFileName(), | |||
new StreamResource(buffer, buffer.getFileName()))); | |||
statusLayout.setVisible(true); | |||
} | |||
setBuffer(); | |||
} | |||
}); | |||
up.addProgressListener(new Upload.ProgressListener() { | |||
@Override | |||
public void updateProgress(long readBytes, long contentLenght) { | |||
pi2.setValue(new Float(readBytes / (float) contentLenght)); | |||
refreshMemUsage(); | |||
} | |||
}); | |||
final Button b = new Button("Reed state from upload", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
readState(); | |||
} | |||
}); | |||
event -> readState()); | |||
final Button c = new Button("Force GC", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
gc(); | |||
} | |||
}); | |||
final Button c = new Button("Force GC", event -> gc()); | |||
main.addComponent(b); | |||
main.addComponent(c); | |||
main.addComponent(beSluggish); | |||
main.addComponent(throwExecption); | |||
main.addComponent(interrupt); | |||
interrupt.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
up.interruptUpload(); | |||
} | |||
}); | |||
interrupt.addClickListener(event -> up.interruptUpload()); | |||
uploadBufferSelector = new Select("StreamVariable type"); | |||
uploadBufferSelector.setImmediate(true); | |||
uploadBufferSelector.addItem("memory"); | |||
uploadBufferSelector.setValue("memory"); | |||
uploadBufferSelector.addItem("tempfile"); | |||
uploadBufferSelector | |||
.addListener(new AbstractField.ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
setBuffer(); | |||
} | |||
}); | |||
uploadBufferSelector.addValueChangeListener(event -> setBuffer()); | |||
main.addComponent(uploadBufferSelector); | |||
main.addComponent(up); | |||
l = new Label("Idle"); | |||
main.addComponent(l); | |||
up.addListener((Listener) event -> { | |||
// print out all events fired by upload for debug purposes | |||
System.out.println("Upload fired event | " + event); | |||
}); | |||
up.addStartedListener(event -> { | |||
pi.setVisible(true); | |||
pi2.setVisible(true); | |||
l.setValue("Started uploading file " + event.getFilename()); | |||
textFieldValue.setValue(" TestFields value at the upload start is:" | |||
+ textField.getValue()); | |||
}); | |||
up.addFinishedListener(event -> { | |||
pi.setVisible(false); | |||
pi2.setVisible(false); | |||
if (event instanceof Upload.FailedEvent) { | |||
Exception reason = ((Upload.FailedEvent) event).getReason(); | |||
l.setValue("Finished with failure ( " + reason + " ), idle"); | |||
} else if (event instanceof Upload.SucceededEvent) { | |||
l.setValue("Finished with succes, idle"); | |||
} else { | |||
l.setValue("Finished with unknow event"); | |||
} | |||
statusLayout.removeAllComponents(); | |||
final InputStream stream = buffer.getStream(); | |||
if (stream == null) { | |||
statusLayout.addComponent(new Label( | |||
"Upload finished, but output buffer is null")); | |||
} else { | |||
statusLayout.addComponent( | |||
new Label("<b>Name:</b> " + event.getFilename(), | |||
ContentMode.HTML)); | |||
statusLayout.addComponent( | |||
new Label("<b>Mimetype:</b> " + event.getMIMEType(), | |||
ContentMode.HTML)); | |||
statusLayout.addComponent(new Label( | |||
"<b>Size:</b> " + event.getLength() + " bytes.", | |||
ContentMode.HTML)); | |||
statusLayout.addComponent(new Link( | |||
"Download " + buffer.getFileName(), | |||
new StreamResource(buffer, buffer.getFileName()))); | |||
statusLayout.setVisible(true); | |||
} | |||
setBuffer(); | |||
}); | |||
up.addProgressListener((readBytes, contentLength) -> { | |||
pi2.setValue(new Float(readBytes / (float) contentLength)); | |||
refreshMemUsage(); | |||
}); | |||
pi.setVisible(false); | |||
pi.setPollingInterval(1000); | |||
main.addComponent(pi); | |||
@@ -246,13 +198,9 @@ public class TestForUpload extends CustomComponent | |||
main.addComponent(status); | |||
final Button restart = new Button("R"); | |||
restart.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
LegacyWindow window = (LegacyWindow) event.getButton().getUI(); | |||
window.getApplication().close(); | |||
} | |||
restart.addClickListener(event -> { | |||
LegacyWindow window = (LegacyWindow) event.getButton().getUI(); | |||
window.getApplication().close(); | |||
}); | |||
main.addComponent(restart); | |||
@@ -17,7 +17,6 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -29,42 +28,16 @@ public class TestForWindowOpen extends CustomComponent { | |||
final VerticalLayout main = new VerticalLayout(); | |||
setCompositionRoot(main); | |||
main.addComponent( | |||
new Button("Open in this window", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
UI.getCurrent().getPage() | |||
.setLocation("http://www.google.com"); | |||
} | |||
})); | |||
main.addComponent(new Button("Open in this window", event -> UI | |||
.getCurrent().getPage().setLocation("http://www.google.com"))); | |||
main.addComponent(new Button("Open in target \"mytarget\"", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
UI.getCurrent().getPage().open("http://www.google.com", | |||
"mytarget"); | |||
} | |||
})); | |||
event -> UI.getCurrent().getPage().open("http://www.google.com", | |||
"mytarget"))); | |||
main.addComponent(new Button("Open in target \"secondtarget\"", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
UI.getCurrent().getPage().open("http://www.google.com", | |||
"secondtarget"); | |||
} | |||
})); | |||
event -> UI.getCurrent().getPage().open("http://www.google.com", | |||
"secondtarget"))); | |||
} | |||
} |
@@ -17,8 +17,6 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Label; | |||
@@ -26,8 +24,6 @@ import com.vaadin.ui.Slider; | |||
import com.vaadin.ui.UI; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.AbstractSelect; | |||
import com.vaadin.v7.ui.OptionGroup; | |||
import com.vaadin.v7.ui.Select; | |||
@@ -47,69 +43,57 @@ public class TestForWindowing extends CustomComponent { | |||
main.addComponent(asModal); | |||
final Button create = new Button("Create a new window", | |||
new ClickListener() { | |||
event -> { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
Window w = new Window("Testing Window", layout); | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
Window w = new Window("Testing Window", layout); | |||
if (asModal.getValue().booleanValue()) { | |||
w.setModal(true); | |||
} | |||
if (asModal.getValue().booleanValue()) { | |||
w.setModal(true); | |||
AbstractSelect s1 = new OptionGroup(); | |||
s1.setCaption("1. Select output format"); | |||
s1.addItem("Excel sheet"); | |||
s1.addItem("CSV plain text"); | |||
s1.setValue("Excel sheet"); | |||
s1.setImmediate(true); | |||
s2 = new Select(); | |||
s2.addItem("Separate by comma (,)"); | |||
s2.addItem("Separate by colon (:)"); | |||
s2.addItem("Separate by semicolon (;)"); | |||
s2.setEnabled(false); | |||
s1.addValueChangeListener(valueChangeEvent -> { | |||
String v = (String) valueChangeEvent.getProperty() | |||
.getValue(); | |||
if (v.equals("CSV plain text")) { | |||
s2.setEnabled(true); | |||
} else { | |||
s2.setEnabled(false); | |||
} | |||
}); | |||
AbstractSelect s1 = new OptionGroup(); | |||
s1.setCaption("1. Select output format"); | |||
s1.addItem("Excel sheet"); | |||
s1.addItem("CSV plain text"); | |||
s1.setValue("Excel sheet"); | |||
s1.setImmediate(true); | |||
s2 = new Select(); | |||
s2.addItem("Separate by comma (,)"); | |||
s2.addItem("Separate by colon (:)"); | |||
s2.addItem("Separate by semicolon (;)"); | |||
s2.setEnabled(false); | |||
s1.addListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
String v = (String) event.getProperty() | |||
.getValue(); | |||
if (v.equals("CSV plain text")) { | |||
s2.setEnabled(true); | |||
} else { | |||
s2.setEnabled(false); | |||
} | |||
} | |||
}); | |||
layout.addComponent(s1); | |||
layout.addComponent(s2); | |||
Slider s = new Slider(); | |||
s.setCaption("Volume"); | |||
s.setMax(13); | |||
s.setMin(12); | |||
s.setResolution(2); | |||
// s.setOrientation(Slider.ORIENTATION_VERTICAL); | |||
// s.setArrows(false); | |||
layout.addComponent(s); | |||
UI.getCurrent().addWindow(w); | |||
layout.addComponent(s1); | |||
layout.addComponent(s2); | |||
} | |||
Slider s = new Slider(); | |||
s.setCaption("Volume"); | |||
s.setMax(13); | |||
s.setMin(12); | |||
s.setResolution(2); | |||
// s.setOrientation(Slider.ORIENTATION_VERTICAL); | |||
// s.setArrows(false); | |||
layout.addComponent(s); | |||
UI.getCurrent().addWindow(w); | |||
}); | |||
main.addComponent(create); | |||
setCompositionRoot(main); | |||
} | |||
} |
@@ -17,8 +17,6 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.LegacyWindow; | |||
@@ -62,17 +60,13 @@ public class TestSetVisibleAndCaching | |||
selectPanel(selectedPanel); | |||
buttonNextPanel.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
selectedPanel++; | |||
if (selectedPanel > 2) { | |||
selectedPanel = 0; | |||
} | |||
selectPanel(selectedPanel); | |||
buttonNextPanel.addClickListener(event -> { | |||
selectedPanel++; | |||
if (selectedPanel > 2) { | |||
selectedPanel = 0; | |||
} | |||
selectPanel(selectedPanel); | |||
}); | |||
} | |||
private VerticalLayout wrapInPanelLayout(Component component) { |
@@ -26,7 +26,6 @@ import com.vaadin.server.LegacyApplication; | |||
import com.vaadin.server.ThemeResource; | |||
import com.vaadin.ui.AbstractComponent; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.ComponentContainer; | |||
import com.vaadin.ui.Embedded; | |||
@@ -36,7 +35,6 @@ import com.vaadin.ui.LegacyWindow; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Container; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.util.IndexedContainer; | |||
import com.vaadin.v7.shared.ui.combobox.FilteringMode; | |||
import com.vaadin.v7.ui.AbstractSelect; | |||
@@ -70,35 +68,29 @@ public class TestSizeableIncomponents extends LegacyApplication { | |||
select.setWidth("400px"); | |||
prev = new Button("<<-|"); | |||
prev.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Object cur = select.getValue(); | |||
Testable prev = (Testable) cont.prevItemId(cur); | |||
if (prev == null) { | |||
getMainWindow().showNotification("No more test cases"); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Selected test:" + prev.getTestableName()); | |||
select.setValue(prev); | |||
select.markAsDirty(); | |||
} | |||
prev.addClickListener(event -> { | |||
Object cur = select.getValue(); | |||
Testable prev = (Testable) cont.prevItemId(cur); | |||
if (prev == null) { | |||
getMainWindow().showNotification("No more test cases"); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Selected test:" + prev.getTestableName()); | |||
select.setValue(prev); | |||
select.markAsDirty(); | |||
} | |||
}); | |||
next = new Button("|->>"); | |||
next.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Object cur = select.getValue(); | |||
Testable next = (Testable) cont.nextItemId(cur); | |||
if (next == null) { | |||
getMainWindow().showNotification("No more test cases"); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Selected test:" + next.getTestableName()); | |||
select.setValue(next); | |||
select.markAsDirty(); | |||
} | |||
next.addClickListener(event -> { | |||
Object cur = select.getValue(); | |||
Testable next = (Testable) cont.nextItemId(cur); | |||
if (next == null) { | |||
getMainWindow().showNotification("No more test cases"); | |||
} else { | |||
getMainWindow().showNotification( | |||
"Selected test:" + next.getTestableName()); | |||
select.setValue(next); | |||
select.markAsDirty(); | |||
} | |||
}); | |||
@@ -109,21 +101,17 @@ public class TestSizeableIncomponents extends LegacyApplication { | |||
main.addComponent(controllers); | |||
select.setContainerDataSource(cont); | |||
select.addListener(new ComboBox.ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
Testable t = (Testable) select.getValue(); | |||
if (t != null) { | |||
testPanelLayout.removeAllComponents(); | |||
try { | |||
Component c = t.getComponent(); | |||
if (c != null) { | |||
testPanelLayout.addComponent(c); | |||
} | |||
} catch (InstantiationException | |||
| IllegalAccessException e) { | |||
e.printStackTrace(); | |||
select.addValueChangeListener(event -> { | |||
Testable t = (Testable) select.getValue(); | |||
if (t != null) { | |||
testPanelLayout.removeAllComponents(); | |||
try { | |||
Component c = t.getComponent(); | |||
if (c != null) { | |||
testPanelLayout.addComponent(c); | |||
} | |||
} catch (InstantiationException | IllegalAccessException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
}); |
@@ -9,7 +9,6 @@ import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.Enumeration; | |||
import java.util.List; | |||
import java.util.jar.JarEntry; | |||
@@ -94,14 +93,9 @@ public class VaadinClasses { | |||
findPackages(juc, basePackage, baseClass, classes); | |||
} | |||
Collections.sort(classes, new Comparator<Class<? extends T>>() { | |||
Collections.sort(classes, | |||
(o1, o2) -> o1.getName().compareTo(o2.getName())); | |||
@Override | |||
public int compare(Class<? extends T> o1, Class<? extends T> o2) { | |||
return o1.getName().compareTo(o2.getName()); | |||
} | |||
}); | |||
return classes; | |||
} | |||
@@ -110,18 +110,15 @@ public class CommErrorEmulatorServlet extends VaadinServlet { | |||
"Responding with " + responseCode + " to UIDL requests for " | |||
+ ui + " for the next " + delay + "s"); | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
Thread.sleep(delay * 1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Handing UIDL requests normally again"); | |||
uidlResponseCode.remove(ui); | |||
new Thread(() -> { | |||
try { | |||
Thread.sleep(delay * 1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Handing UIDL requests normally again"); | |||
uidlResponseCode.remove(ui); | |||
}).start(); | |||
} | |||
@@ -133,18 +130,14 @@ public class CommErrorEmulatorServlet extends VaadinServlet { | |||
+ " to heartbeat requests for " + ui + " for the next " + delay | |||
+ "s"); | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
Thread.sleep(delay * 1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Handing heartbeat requests normally again"); | |||
heartbeatResponseCode.remove(ui); | |||
new Thread(() -> { | |||
try { | |||
Thread.sleep(delay * 1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Handing heartbeat requests normally again"); | |||
heartbeatResponseCode.remove(ui); | |||
}).start(); | |||
} | |||
@@ -59,19 +59,16 @@ public class NavigateWithOngoingXHR extends AbstractReindeerTestUI { | |||
protected void setup(VaadinRequest request) { | |||
addComponent(new ProgressIndicator() { | |||
{ | |||
registerRpc(new ProgressIndicatorServerRpc() { | |||
@Override | |||
public void poll() { | |||
// System.out.println("Pausing poll request"); | |||
try { | |||
// Make the XHR request last longer to make it | |||
// easier to click the link at the right moment. | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
// System.out.println("Continuing poll request"); | |||
registerRpc((ProgressIndicatorServerRpc) () -> { | |||
// System.out.println("Pausing poll request"); | |||
try { | |||
// Make the XHR request last longer to make it | |||
// easier to click the link at the right moment. | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
// System.out.println("Continuing poll request"); | |||
}); | |||
setPollingInterval(3000); | |||
} |
@@ -18,7 +18,6 @@ package com.vaadin.tests.application; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.JavaScriptFunction; | |||
import elemental.json.JsonArray; | |||
@@ -31,29 +30,24 @@ public class TimingInfoReported extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
getPage().getJavaScript().addFunction("report", | |||
new JavaScriptFunction() { | |||
arguments -> { | |||
log("Got: " + arguments.toJson()); | |||
JsonArray values = arguments.getArray(0); | |||
@Override | |||
public void call(JsonArray arguments) { | |||
log("Got: " + arguments.toJson()); | |||
JsonArray values = arguments.getArray(0); | |||
if (values.length() != 5) { | |||
log("ERROR: expected 5 values, got " + values.length()); | |||
return; | |||
} | |||
if (values.length() != 5) { | |||
log("ERROR: expected 5 values, got " | |||
+ values.length()); | |||
for (int i = 0; i < values.length(); i++) { | |||
if (i < 0 || i > 10000) { | |||
log("ERROR: expected value " + i | |||
+ " to be between 0 and 10000, was " | |||
+ values.getNumber(i)); | |||
return; | |||
} | |||
for (int i = 0; i < values.length(); i++) { | |||
if (i < 0 || i > 10000) { | |||
log("ERROR: expected value " + i | |||
+ " to be between 0 and 10000, was " | |||
+ values.getNumber(i)); | |||
return; | |||
} | |||
} | |||
log("Timings ok"); | |||
} | |||
log("Timings ok"); | |||
}); | |||
getPage().getJavaScript().execute(reportTimings); | |||
Button b = new Button("test request", |
@@ -100,24 +100,17 @@ public class CloseSession extends AbstractReindeerTestUI { | |||
final HttpSession session = ((WrappedHttpSession) VaadinService | |||
.getCurrentRequest().getWrappedSession()) | |||
.getHttpSession(); | |||
Thread t = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out | |||
.println("Invalidating session from thread " | |||
+ session.getId()); | |||
session.invalidate(); | |||
System.out | |||
.println("Invalidated session from thread " | |||
+ session.getId()); | |||
Thread t = new Thread(() -> { | |||
try { | |||
Thread.sleep(1000); | |||
} catch (InterruptedException e) { | |||
e.printStackTrace(); | |||
} | |||
System.out.println("Invalidating session from thread " | |||
+ session.getId()); | |||
session.invalidate(); | |||
System.out.println("Invalidated session from thread " | |||
+ session.getId()); | |||
}); | |||
t.start(); | |||
})); |
@@ -11,13 +11,7 @@ public abstract class UIRunSafelyThread extends Thread { | |||
@Override | |||
public void run() { | |||
ui.accessSynchronously(new Runnable() { | |||
@Override | |||
public void run() { | |||
runSafely(); | |||
} | |||
}); | |||
ui.accessSynchronously(() -> runSafely()); | |||
} | |||
protected abstract void runSafely(); |
@@ -17,7 +17,6 @@ package com.vaadin.tests.applicationservlet; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import com.vaadin.server.ConnectorIdGenerationEvent; | |||
import com.vaadin.server.ConnectorIdGenerator; | |||
import com.vaadin.server.ServiceInitEvent; | |||
import com.vaadin.server.VaadinServiceInitListener; | |||
@@ -37,13 +36,10 @@ public class TestingServiceInitListener implements VaadinServiceInitListener { | |||
return false; | |||
}); | |||
event.addConnectorIdGenerator(new ConnectorIdGenerator() { | |||
@Override | |||
public String generateConnectorId( | |||
ConnectorIdGenerationEvent event) { | |||
connectorIdCount.incrementAndGet(); | |||
return ConnectorIdGenerator.generateDefaultConnectorId(event); | |||
} | |||
event.addConnectorIdGenerator(connectorIdGenerationEvent -> { | |||
connectorIdCount.incrementAndGet(); | |||
return ConnectorIdGenerator | |||
.generateDefaultConnectorId(connectorIdGenerationEvent); | |||
}); | |||
} | |||
@@ -1,7 +1,6 @@ | |||
package com.vaadin.tests.components; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.ui.PopupDateField; | |||
public class AddRemoveSetStyleNamesTest extends TestBase { | |||
@@ -24,15 +23,11 @@ public class AddRemoveSetStyleNamesTest extends TestBase { | |||
popupDateField.setRequiredError("abcd"); | |||
addComponent(popupDateField); | |||
listener = new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
String style = (String) event.getButton().getData(); | |||
setComponentsStyle(style, | |||
!popupDateField.getStyleName().contains(style), | |||
event.getButton()); | |||
} | |||
listener = event -> { | |||
String style = (String) event.getButton().getData(); | |||
setComponentsStyle(style, | |||
!popupDateField.getStyleName().contains(style), | |||
event.getButton()); | |||
}; | |||
button1 = new Button("Add style1", listener); | |||
@@ -43,19 +38,15 @@ public class AddRemoveSetStyleNamesTest extends TestBase { | |||
button2.setData(style2); | |||
addComponent(button2); | |||
button3 = new Button("Set thestyle", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (popupDateField.getStyleName().contains(thestyle)) { | |||
popupDateField.removeStyleName(thestyle); | |||
button3.setCaption("Set thestyle"); | |||
} else { | |||
popupDateField.setStyleName(thestyle); | |||
button1.setCaption("Add style1"); | |||
button2.setCaption("Add style2"); | |||
button3.setCaption("Remove thestyle"); | |||
} | |||
button3 = new Button("Set thestyle", event -> { | |||
if (popupDateField.getStyleName().contains(thestyle)) { | |||
popupDateField.removeStyleName(thestyle); | |||
button3.setCaption("Set thestyle"); | |||
} else { | |||
popupDateField.setStyleName(thestyle); | |||
button1.setCaption("Add style1"); | |||
button2.setCaption("Add style2"); | |||
button3.setCaption("Remove thestyle"); | |||
} | |||
}); | |||
addComponent(button3); |
@@ -1,8 +1,6 @@ | |||
package com.vaadin.tests.components; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.CustomComponent; | |||
import com.vaadin.ui.Layout; | |||
import com.vaadin.ui.Panel; | |||
@@ -57,25 +55,20 @@ public class CustomComponentwithUndefinedSize extends TestBase { | |||
widePanel.setHeight("200px"); | |||
layout.addComponent(widePanel); | |||
Button button = new Button("Change panel size", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
switch (step++ % 4) { | |||
case 0: | |||
widePanel.setWidth("200px"); | |||
break; | |||
case 1: | |||
widePanel.setHeight("2000px"); | |||
break; | |||
case 2: | |||
widePanel.setWidth("2000px"); | |||
break; | |||
case 3: | |||
widePanel.setHeight("200px"); | |||
break; | |||
} | |||
event -> { | |||
switch (step++ % 4) { | |||
case 0: | |||
widePanel.setWidth("200px"); | |||
break; | |||
case 1: | |||
widePanel.setHeight("2000px"); | |||
break; | |||
case 2: | |||
widePanel.setWidth("2000px"); | |||
break; | |||
case 3: | |||
widePanel.setHeight("200px"); | |||
break; | |||
} | |||
}); | |||
panelLayout.addComponent(button); |
@@ -1,8 +1,6 @@ | |||
package com.vaadin.tests.components; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.Panel; | |||
import com.vaadin.ui.TabSheet; | |||
@@ -31,35 +29,14 @@ public class DisableEnableCascade extends TestBase { | |||
addComponent(outerPanel); | |||
enableDisablePanelButton = new Button("Disable panel", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(outerPanel, enableDisablePanelButton); | |||
} | |||
}); | |||
event -> enableDisable(outerPanel, enableDisablePanelButton)); | |||
enableDisableTabSheetButton = new Button("Disable TabSheet", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(innerTabsheet, | |||
enableDisableTabSheetButton); | |||
} | |||
}); | |||
event -> enableDisable(innerTabsheet, | |||
enableDisableTabSheetButton)); | |||
enableDisableButtonButton = new Button("Disable Button", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(button, enableDisableButtonButton); | |||
} | |||
}); | |||
event -> enableDisable(button, enableDisableButtonButton)); | |||
addComponent(enableDisablePanelButton); | |||
addComponent(enableDisableTabSheetButton); |
@@ -3,8 +3,6 @@ package com.vaadin.tests.components; | |||
import java.util.Iterator; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.NativeButton; | |||
import com.vaadin.ui.Panel; | |||
@@ -53,63 +51,38 @@ public class DisableEnableCascadeStyles extends TestBase { | |||
addComponent(outerPanel); | |||
enableDisablePanelButton = new Button("Disable panel", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(outerPanel, enableDisablePanelButton); | |||
} | |||
}); | |||
event -> enableDisable(outerPanel, enableDisablePanelButton)); | |||
enableDisableTabSheetButton = new Button("Disable TabSheet", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(innerTabsheet, | |||
enableDisableTabSheetButton); | |||
} | |||
}); | |||
event -> enableDisable(innerTabsheet, | |||
enableDisableTabSheetButton)); | |||
enableDisableLayoutButton = new Button("Disable Tab content (Layout)", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
enableDisable(layout, enableDisableLayoutButton); | |||
} | |||
}); | |||
event -> enableDisable(layout, enableDisableLayoutButton)); | |||
enableDisableComponentsButton = new Button("Disable Layout Components", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
for (Iterator<Component> i = layout | |||
.getComponentIterator(); i.hasNext();) { | |||
final Component c = i.next(); | |||
if (c.isEnabled()) { | |||
c.setEnabled(false); | |||
c.setCaption(c.getCaption().replace("enabled", | |||
"disabled")); | |||
} else { | |||
c.setEnabled(true); | |||
c.setCaption(c.getCaption().replace("disabled", | |||
"enabled")); | |||
} | |||
} | |||
if (layout.getComponent(0).isEnabled()) { | |||
enableDisableComponentsButton.setCaption( | |||
enableDisableComponentsButton.getCaption() | |||
.replace("Enable", "Disable")); | |||
event -> { | |||
for (Iterator<Component> i = layout | |||
.getComponentIterator(); i.hasNext();) { | |||
final Component c = i.next(); | |||
if (c.isEnabled()) { | |||
c.setEnabled(false); | |||
c.setCaption(c.getCaption().replace("enabled", | |||
"disabled")); | |||
} else { | |||
enableDisableComponentsButton.setCaption( | |||
enableDisableComponentsButton.getCaption() | |||
.replace("Disable", "Enable")); | |||
c.setEnabled(true); | |||
c.setCaption(c.getCaption().replace("disabled", | |||
"enabled")); | |||
} | |||
} | |||
if (layout.getComponent(0).isEnabled()) { | |||
enableDisableComponentsButton.setCaption( | |||
enableDisableComponentsButton.getCaption() | |||
.replace("Enable", "Disable")); | |||
} else { | |||
enableDisableComponentsButton.setCaption( | |||
enableDisableComponentsButton.getCaption() | |||
.replace("Disable", "Enable")); | |||
} | |||
}); | |||
addComponent(enableDisablePanelButton); | |||
addComponent(enableDisableTabSheetButton); |
@@ -39,8 +39,6 @@ import com.vaadin.server.VaadinResponse; | |||
import com.vaadin.tests.components.embedded.EmbeddedPdf; | |||
import com.vaadin.ui.AbstractComponent; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.HorizontalLayout; | |||
@@ -106,26 +104,17 @@ public class FileDownloaderUI extends AbstractTestUIWithLog { | |||
addComponent(downloadUtf8File); | |||
addComponent( | |||
new Button("Remove first download button", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
Layout parent = (Layout) firstDownloadComponent | |||
.getParent(); | |||
parent.removeComponent(firstDownloadComponent); | |||
} | |||
new Button("Remove first download button", event -> { | |||
Layout parent = (Layout) firstDownloadComponent.getParent(); | |||
parent.removeComponent(firstDownloadComponent); | |||
})); | |||
addComponent( | |||
new Button("Detach FileDownloader from first download button", | |||
new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
FileDownloader e = (FileDownloader) firstDownloadComponent | |||
.getExtensions().iterator().next(); | |||
e.remove(); | |||
log("FileDownload detached"); | |||
} | |||
event -> { | |||
FileDownloader e = (FileDownloader) firstDownloadComponent | |||
.getExtensions().iterator().next(); | |||
e.remove(); | |||
log("FileDownload detached"); | |||
})); | |||
} | |||
@@ -152,11 +141,7 @@ public class FileDownloaderUI extends AbstractTestUIWithLog { | |||
new FileDownloader(resource).extend(c); | |||
if (c instanceof Button) { | |||
((Button) c).addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
} | |||
((Button) c).addClickListener(event -> { | |||
}); | |||
} | |||
} catch (Exception e) { |
@@ -2,9 +2,7 @@ package com.vaadin.tests.components; | |||
import java.util.Date; | |||
import com.vaadin.event.FieldEvents.BlurEvent; | |||
import com.vaadin.event.FieldEvents.BlurListener; | |||
import com.vaadin.event.FieldEvents.FocusEvent; | |||
import com.vaadin.event.FieldEvents.FocusListener; | |||
import com.vaadin.ui.AbstractDateField; | |||
import com.vaadin.ui.Button; | |||
@@ -21,25 +19,19 @@ import com.vaadin.v7.ui.OptionGroup; | |||
public class FocusAndBlurListeners extends TestBase { | |||
private FocusListener focusListener = new FocusListener() { | |||
private VerticalLayout messages = new VerticalLayout(); | |||
@Override | |||
public void focus(FocusEvent event) { | |||
Label msg = new Label(new Date() + " Focused " | |||
+ event.getComponent().getCaption()); | |||
messages.addComponentAsFirst(msg); | |||
} | |||
private FocusListener focusListener = event -> { | |||
Label msg = new Label( | |||
new Date() + " Focused " + event.getComponent().getCaption()); | |||
messages.addComponentAsFirst(msg); | |||
}; | |||
private BlurListener blurListener = new BlurListener() { | |||
@Override | |||
public void blur(BlurEvent event) { | |||
Label msg = new Label(new Date() + " Blurred " | |||
+ event.getComponent().getCaption()); | |||
messages.addComponentAsFirst(msg); | |||
} | |||
private BlurListener blurListener = event -> { | |||
Label msg = new Label( | |||
new Date() + " Blurred " + event.getComponent().getCaption()); | |||
messages.addComponentAsFirst(msg); | |||
}; | |||
private VerticalLayout messages = new VerticalLayout(); | |||
@Override | |||
protected void setup() { | |||
@@ -78,7 +70,6 @@ public class FocusAndBlurListeners extends TestBase { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
ogm.addItem("newItem" + i++); | |||
} | |||
}); | |||
@@ -5,7 +5,6 @@ import java.util.Arrays; | |||
import com.vaadin.event.ShortcutAction.KeyCode; | |||
import com.vaadin.event.ShortcutAction.ModifierKey; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.v7.ui.Select; | |||
import com.vaadin.v7.ui.TextField; | |||
@@ -19,22 +18,12 @@ public class FocusFromShortcutAction extends TestBase { | |||
addComponent(select); | |||
addComponent(text); | |||
Button focusText = new Button("Focus text", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
text.focus(); | |||
} | |||
}); | |||
Button focusText = new Button("Focus text", event -> text.focus()); | |||
focusText.setClickShortcut(KeyCode.T, ModifierKey.ALT); | |||
addComponent(focusText); | |||
Button focusSelect = new Button("Focus select", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
select.focus(); | |||
} | |||
}); | |||
event -> select.focus()); | |||
focusSelect.setClickShortcut(KeyCode.S, ModifierKey.ALT); | |||
addComponent(focusSelect); | |||
} |
@@ -1,7 +1,6 @@ | |||
package com.vaadin.tests.components; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.HorizontalLayout; | |||
import com.vaadin.ui.VerticalLayout; | |||
@@ -26,13 +25,8 @@ public class HierarchyChangeForRemovedComponentContainers extends TestBase { | |||
compose(); | |||
addComponent(new Button("Replace layout with button", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
compose2(); | |||
} | |||
})); | |||
addComponent( | |||
new Button("Replace layout with button", event -> compose2())); | |||
} | |||
private void compose() { |
@@ -4,15 +4,10 @@ import java.util.Arrays; | |||
import com.vaadin.ui.AbsoluteLayout; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.HasComponents.ComponentAttachEvent; | |||
import com.vaadin.ui.HasComponents.ComponentAttachListener; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.Notification; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.Property.ValueChangeEvent; | |||
import com.vaadin.v7.data.Property.ValueChangeListener; | |||
import com.vaadin.v7.ui.OptionGroup; | |||
public class LayoutAttachListenerInfo extends TestBase { | |||
@@ -26,18 +21,13 @@ public class LayoutAttachListenerInfo extends TestBase { | |||
Arrays.asList("AbsoluteLayout", "OrderedLayout", "GridLayout")); | |||
layouts.select("AbsoluteLayout"); | |||
layouts.setImmediate(true); | |||
layouts.addValueChangeListener(new ValueChangeListener() { | |||
@Override | |||
public void valueChange(ValueChangeEvent event) { | |||
if (event.getProperty().getValue().equals("AbsoluteLayout")) { | |||
testAbsoluteLayout(); | |||
} else if (event.getProperty().getValue() | |||
.equals("OrderedLayout")) { | |||
testOrderedLayout(); | |||
} else if (event.getProperty().getValue() | |||
.equals("GridLayout")) { | |||
testGridLayout(); | |||
} | |||
layouts.addValueChangeListener(event -> { | |||
if (event.getProperty().getValue().equals("AbsoluteLayout")) { | |||
testAbsoluteLayout(); | |||
} else if (event.getProperty().getValue().equals("OrderedLayout")) { | |||
testOrderedLayout(); | |||
} else if (event.getProperty().getValue().equals("GridLayout")) { | |||
testGridLayout(); | |||
} | |||
}); | |||
@@ -65,28 +55,19 @@ public class LayoutAttachListenerInfo extends TestBase { | |||
final AbsoluteLayout a = new AbsoluteLayout(); | |||
a.setWidth("300px"); | |||
a.setHeight("300px"); | |||
a.addComponentAttachListener(new ComponentAttachListener() { | |||
@Override | |||
public void componentAttachedToContainer( | |||
ComponentAttachEvent event) { | |||
AbsoluteLayout layout = (AbsoluteLayout) event.getContainer(); | |||
AbsoluteLayout.ComponentPosition position = layout | |||
.getPosition(event.getAttachedComponent()); | |||
getMainWindow().showNotification( | |||
"Attached to " + position.getCSSString(), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} | |||
a.addComponentAttachListener(event -> { | |||
AbsoluteLayout layout = (AbsoluteLayout) event.getContainer(); | |||
AbsoluteLayout.ComponentPosition position = layout | |||
.getPosition(event.getAttachedComponent()); | |||
getMainWindow().showNotification( | |||
"Attached to " + position.getCSSString(), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
}); | |||
content.addComponent(a); | |||
content.addComponent(new Button("Attach label to layout", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
a.addComponent(new Label("X"), "top:50px;left:50px"); | |||
} | |||
})); | |||
event -> a.addComponent(new Label("X"), "top:50px;left:50px"))); | |||
} | |||
private void testOrderedLayout() { | |||
@@ -95,27 +76,17 @@ public class LayoutAttachListenerInfo extends TestBase { | |||
final VerticalLayout v = new VerticalLayout(); | |||
v.setWidth("300px"); | |||
v.setHeight("300px"); | |||
v.addComponentAttachListener(new ComponentAttachListener() { | |||
@Override | |||
public void componentAttachedToContainer( | |||
ComponentAttachEvent event) { | |||
VerticalLayout layout = (VerticalLayout) event.getContainer(); | |||
getMainWindow().showNotification( | |||
"Attached to index " + layout.getComponentIndex( | |||
event.getAttachedComponent()), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} | |||
v.addComponentAttachListener(event -> { | |||
VerticalLayout layout = (VerticalLayout) event.getContainer(); | |||
getMainWindow().showNotification( | |||
"Attached to index " + layout | |||
.getComponentIndex(event.getAttachedComponent()), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
}); | |||
content.addComponent(v); | |||
content.addComponent(new Button("Attach label to layout", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
v.addComponent(new Label("X")); | |||
} | |||
})); | |||
event -> v.addComponent(new Label("X")))); | |||
} | |||
private void testGridLayout() { | |||
@@ -125,28 +96,18 @@ public class LayoutAttachListenerInfo extends TestBase { | |||
g.setWidth("300px"); | |||
g.setHeight("300px"); | |||
g.setHideEmptyRowsAndColumns(true); | |||
g.addComponentAttachListener(new ComponentAttachListener() { | |||
@Override | |||
public void componentAttachedToContainer( | |||
ComponentAttachEvent event) { | |||
GridLayout layout = (GridLayout) event.getContainer(); | |||
GridLayout.Area area = layout | |||
.getComponentArea(event.getAttachedComponent()); | |||
getMainWindow().showNotification( | |||
"Attached to " + area.getColumn1() + "," | |||
+ area.getRow1(), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
} | |||
g.addComponentAttachListener(event -> { | |||
GridLayout layout = (GridLayout) event.getContainer(); | |||
GridLayout.Area area = layout | |||
.getComponentArea(event.getAttachedComponent()); | |||
getMainWindow().showNotification( | |||
"Attached to " + area.getColumn1() + "," + area.getRow1(), | |||
Notification.TYPE_ERROR_MESSAGE); | |||
}); | |||
content.addComponent(g); | |||
content.addComponent(new Button("Attach label to layout", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
g.addComponent(new Label("X"), 2, 3); | |||
} | |||
})); | |||
event -> g.addComponent(new Label("X"), 2, 3))); | |||
} | |||
} |
@@ -7,7 +7,6 @@ import java.util.concurrent.TimeUnit; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.GridLayout; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.ProgressBar; | |||
@@ -52,12 +51,9 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { | |||
Button closeB = new Button( | |||
"2. Click to close after the progress is updated"); | |||
closeB.setId("closeWindow"); | |||
closeB.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
w2.close(); | |||
w2 = null; | |||
} | |||
closeB.addClickListener(clickEvent -> { | |||
w2.close(); | |||
w2 = null; | |||
}); | |||
glo.addComponent(closeB); | |||
addWindow(w2); | |||
@@ -67,26 +63,18 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { | |||
}); | |||
Button openWin = new Button("3. Finally, Click to open a new Window"); | |||
openWin.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
w = new Window("test"); | |||
w.setWidth("300px"); | |||
w.setHeight("300px"); | |||
w.setContent(new VerticalLayout( | |||
new Label("simple test label component"))); | |||
w.center(); | |||
getUI().addWindow(w); | |||
} | |||
openWin.addClickListener(event -> { | |||
w = new Window("test"); | |||
w.setWidth("300px"); | |||
w.setHeight("300px"); | |||
w.setContent(new VerticalLayout( | |||
new Label("simple test label component"))); | |||
w.center(); | |||
getUI().addWindow(w); | |||
}); | |||
Button stopPolling = new Button("Stop polling", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
setPollInterval(-1); | |||
} | |||
}); | |||
Button stopPolling = new Button("Stop polling", | |||
event -> setPollInterval(-1)); | |||
layout.addComponents(button, openWin, stopPolling); | |||
} | |||
@@ -95,12 +83,7 @@ public class NoLayoutUpdateWhichNeedsLayout extends UI { | |||
@Override | |||
public void run() { | |||
getUI().access(new Runnable() { | |||
@Override | |||
public void run() { | |||
updateProgresBar(50); | |||
} | |||
}); | |||
getUI().access(() -> updateProgresBar(50)); | |||
} | |||
}; | |||
ScheduledExecutorService worker = Executors |
@@ -7,8 +7,6 @@ import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
import com.vaadin.ui.Label; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.event.ItemClickEvent; | |||
import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; | |||
import com.vaadin.v7.ui.Table; | |||
import com.vaadin.v7.ui.Table.RowHeaderMode; | |||
@@ -17,14 +15,7 @@ public class SaneErrors extends AbstractReindeerTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final Button b = new Button("Show me my NPE!"); | |||
b.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
throwError(); | |||
} | |||
}); | |||
b.addClickListener(event -> throwError()); | |||
/* | |||
* Errors from "legacy variable changes" | |||
@@ -32,12 +23,7 @@ public class SaneErrors extends AbstractReindeerTestUI { | |||
final Table table = new Table(); | |||
table.addItem("Show me my NPE!"); | |||
table.setRowHeaderMode(RowHeaderMode.ID); | |||
table.addItemClickListener(new ItemClickListener() { | |||
@Override | |||
public void itemClick(ItemClickEvent event) { | |||
throwError(); | |||
} | |||
}); | |||
table.addItemClickListener(event -> throwError()); | |||
final VerticalLayout content = new VerticalLayout(b, table); | |||
@@ -14,7 +14,6 @@ import com.vaadin.tests.util.PersonContainer; | |||
import com.vaadin.tests.util.TestUtils; | |||
import com.vaadin.ui.Accordion; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.CssLayout; | |||
import com.vaadin.ui.HorizontalSplitPanel; | |||
@@ -78,19 +77,9 @@ public class TouchScrollables extends TestBase { | |||
final Label l = l50; | |||
Button button = new Button("Scroll to label 50", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
getLayout().getUI().scrollIntoView(l); | |||
} | |||
}); | |||
event -> getLayout().getUI().scrollIntoView(l)); | |||
cssLayout.addComponent(button); | |||
button = new Button("Scroll to 100px", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
p.setScrollTop(100); | |||
} | |||
}); | |||
button = new Button("Scroll to 100px", event -> p.setScrollTop(100)); | |||
cssLayout.addComponent(button); | |||
cssLayout.addComponent(p); | |||
return cssLayout; | |||
@@ -118,27 +107,20 @@ public class TouchScrollables extends TestBase { | |||
final Table table = new Table(); | |||
Button button = new Button("Toggle lazyloading"); | |||
button.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
if (table.getCacheRate() == 100) { | |||
table.setCacheRate(2); | |||
table.setPageLength(15); | |||
} else { | |||
table.setCacheRate(100); | |||
table.setHeight("400px"); | |||
} | |||
button.addClickListener(event -> { | |||
if (table.getCacheRate() == 100) { | |||
table.setCacheRate(2); | |||
table.setPageLength(15); | |||
} else { | |||
table.setCacheRate(100); | |||
table.setHeight("400px"); | |||
} | |||
}); | |||
cssLayout.addComponent(button); | |||
button = new Button("Toggle selectable"); | |||
button.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
table.setSelectable(!table.isSelectable()); | |||
} | |||
}); | |||
button.addClickListener( | |||
event -> table.setSelectable(!table.isSelectable())); | |||
cssLayout.addComponent(button); | |||
table.addContainerProperty("foo", String.class, "bar"); | |||
@@ -162,17 +144,14 @@ public class TouchScrollables extends TestBase { | |||
} | |||
private Component getSubWindowTest() { | |||
Button b = new Button("Open subwindow", new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
Window w = new Window("Subwindow", layout); | |||
w.center(); | |||
w.setHeight("200px"); | |||
layout.addComponent(getBigComponent()); | |||
getMainWindow().addWindow(w); | |||
} | |||
Button b = new Button("Open subwindow", event -> { | |||
VerticalLayout layout = new VerticalLayout(); | |||
layout.setMargin(true); | |||
Window w = new Window("Subwindow", layout); | |||
w.center(); | |||
w.setHeight("200px"); | |||
layout.addComponent(getBigComponent()); | |||
getMainWindow().addWindow(w); | |||
}); | |||
return b; | |||
} |
@@ -81,15 +81,11 @@ public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> { | |||
private void createItemStyleGeneratorAction(String category) { | |||
LinkedHashMap<String, ItemStyleGenerator> options = new LinkedHashMap<>(); | |||
options.put("-", null); | |||
options.put("Bold fives", new ItemStyleGenerator() { | |||
@Override | |||
public String getStyle(ComboBox source, Object itemId) { | |||
if (String.valueOf(itemId).indexOf('5') != -1) { | |||
return "bold"; | |||
} else { | |||
return null; | |||
} | |||
options.put("Bold fives", (source, itemId) -> { | |||
if (String.valueOf(itemId).indexOf('5') != -1) { | |||
return "bold"; | |||
} | |||
return null; | |||
}); | |||
createSelectAction("Item style generator", category, options, "-", | |||
itemStyleGeneratorCommand); |
@@ -64,20 +64,17 @@ public class ComboPushTiming extends TestBase { | |||
} | |||
private void changeValue(final ComboBox cb) { | |||
executor.execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
VaadinSession.getCurrent().lock(); | |||
try { | |||
cb.setEnabled(true); | |||
cb.setValue("B"); | |||
cb.setEnabled(true); | |||
// If this isn't sent by push or poll in the background, the | |||
// problem will go away | |||
} finally { | |||
VaadinSession.getCurrent().unlock(); | |||
} | |||
executor.execute(() -> { | |||
VaadinSession.getCurrent().lock(); | |||
try { | |||
cb.setEnabled(true); | |||
cb.setValue("B"); | |||
cb.setEnabled(true); | |||
// If this isn't sent by push or poll in the background, the | |||
// problem will go away | |||
} finally { | |||
VaadinSession.getCurrent().unlock(); | |||
} | |||
}); | |||
} |
@@ -38,12 +38,7 @@ public class DateFieldPopupClosingOnDetach extends AbstractReindeerTestUI { | |||
@Override | |||
public void run() { | |||
getUI().access(new Runnable() { | |||
@Override | |||
public void run() { | |||
removeComponent(df); | |||
} | |||
}); | |||
getUI().access(() -> removeComponent(df)); | |||
} | |||
}; | |||
new Timer(true).schedule(removeTask, 1000); |
@@ -19,35 +19,6 @@ import com.vaadin.ui.VerticalLayout; | |||
@Push | |||
public class GridFastAsyncUpdate extends AbstractTestUI { | |||
private final Runnable addRowsTask = new Runnable() { | |||
@Override | |||
public void run() { | |||
System.out.println("Logging..."); | |||
try { | |||
Random random = new Random(); | |||
while (!Thread.currentThread().isInterrupted()) { | |||
Thread.sleep(random.nextInt(100)); | |||
GridFastAsyncUpdate.this.access(() -> { | |||
++counter; | |||
Item item = new Item(counter, | |||
(Calendar.getInstance().getTimeInMillis() | |||
- loggingStart), | |||
Level.INFO.toString(), "Message"); | |||
items.add(item); | |||
grid.setItems(items); | |||
if (grid != null && !scrollLock) { | |||
grid.scrollToEnd(); | |||
} | |||
}); | |||
} | |||
} catch (InterruptedException e) { | |||
System.out.println("logging thread interrupted"); | |||
} | |||
} | |||
}; | |||
private int counter; | |||
private List<Item> items = new LinkedList<>(); | |||
@@ -55,6 +26,32 @@ public class GridFastAsyncUpdate extends AbstractTestUI { | |||
private long loggingStart; | |||
private volatile boolean scrollLock = false; | |||
private final Runnable addRowsTask = () -> { | |||
System.out.println("Logging..."); | |||
try { | |||
Random random = new Random(); | |||
while (!Thread.currentThread().isInterrupted()) { | |||
Thread.sleep(random.nextInt(100)); | |||
GridFastAsyncUpdate.this.access(() -> { | |||
++counter; | |||
Item item = new Item(counter, | |||
(Calendar.getInstance().getTimeInMillis() | |||
- loggingStart), | |||
Level.INFO.toString(), "Message"); | |||
items.add(item); | |||
grid.setItems(items); | |||
if (grid != null && !scrollLock) { | |||
grid.scrollToEnd(); | |||
} | |||
}); | |||
} | |||
} catch (InterruptedException e) { | |||
System.out.println("logging thread interrupted"); | |||
} | |||
}; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
final VerticalLayout layout = new VerticalLayout(); |
@@ -33,7 +33,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.AbstractJavaScriptComponent; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.HasComponents; | |||
import com.vaadin.ui.JavaScriptFunction; | |||
@@ -173,12 +172,8 @@ public class BasicJavaScriptComponent extends AbstractReindeerTestUI { | |||
addComponent(c); | |||
Button removeButton = new Button("Remove component", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
removeComponent(c); | |||
} | |||
}); | |||
event -> removeComponent(c)); | |||
removeButton.setId("RemoveButton"); | |||
addComponent(removeButton); | |||
} |
@@ -21,8 +21,6 @@ import com.vaadin.shared.ui.JavaScriptComponentState; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.AbstractJavaScriptComponent; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.Button.ClickListener; | |||
public class JavaScriptNoLayoutHandlingUI extends AbstractTestUIWithLog { | |||
@@ -54,15 +52,8 @@ public class JavaScriptNoLayoutHandlingUI extends AbstractTestUIWithLog { | |||
final MyJsComponent myComponent = new MyJsComponent(); | |||
myComponent.setId("js"); | |||
addComponent(myComponent); | |||
addComponent(new Button("Send update", new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
myComponent.getState().aaa++; | |||
} | |||
})); | |||
addComponent(new Button("Send update", | |||
event -> myComponent.getState().aaa++)); | |||
} | |||
} |