import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.dom.client.Element;
import com.google.gwt.logging.client.LogConfiguration;
* element into which the application should be rendered.
*/
public static void startApplication(final String applicationId) {
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- Profiler.enter("ApplicationConfiguration.startApplication");
- ApplicationConfiguration appConf = getConfigFromDOM(
- applicationId);
- ApplicationConnection a = GWT
- .create(ApplicationConnection.class);
- a.init(widgetSet, appConf);
- runningApplications.add(a);
- Profiler.leave("ApplicationConfiguration.startApplication");
-
- a.start();
- }
+ Scheduler.get().scheduleDeferred(() -> {
+ Profiler.enter("ApplicationConfiguration.startApplication");
+ ApplicationConfiguration appConf = getConfigFromDOM(applicationId);
+ ApplicationConnection a = GWT.create(ApplicationConnection.class);
+ a.init(widgetSet, appConf);
+ runningApplications.add(a);
+ Profiler.leave("ApplicationConfiguration.startApplication");
+
+ a.start();
});
}
public void scheduleDeferred(ScheduledCommand cmd) {
deferredCommandTrackers++;
super.scheduleDeferred(cmd);
- super.scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- deferredCommandTrackers--;
- }
- });
+ super.scheduleDeferred(() -> deferredCommandTrackers--);
}
public boolean hasWorkQueued() {
- boolean hasWorkQueued = (deferredCommandTrackers != 0);
- return hasWorkQueued;
+ return deferredCommandTrackers != 0;
}
}
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
}
if (highlightedPid != null && highlightedPid.equals(uidl.getId())) {
getElement().getStyle().setBackgroundColor("#fdd");
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- getElement().scrollIntoView();
- }
- });
+ Scheduler.get()
+ .scheduleDeferred(() -> getElement().scrollIntoView());
}
}
}
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
com.google.gwt.dom.client.Element el, String p)
/*-{
try {
-
+
if (el.currentStyle) {
// IE
return el.currentStyle[p];
} catch (e) {
return "";
}
-
+
}-*/;
/**
try {
el.focus();
} catch (e) {
-
+
}
}-*/;
((Focusable) targetWidget).focus();
}
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- try {
- target.dispatchEvent(createMouseDownEvent);
- target.dispatchEvent(createMouseUpEvent);
- target.dispatchEvent(createMouseClickEvent);
- } catch (Exception e) {
- }
-
+ Scheduler.get().scheduleDeferred(() -> {
+ try {
+ target.dispatchEvent(createMouseDownEvent);
+ target.dispatchEvent(createMouseUpEvent);
+ target.dispatchEvent(createMouseClickEvent);
+ } catch (Exception e) {
}
});
-
}
/**
if ($wnd.document.activeElement) {
return $wnd.document.activeElement;
}
-
+
return null;
}-*/;
/*-{
var top = elem.offsetTop;
var height = elem.offsetHeight;
-
+
if (elem.parentNode != elem.offsetParent) {
top -= elem.parentNode.offsetTop;
}
-
+
var cur = elem.parentNode;
while (cur && (cur.nodeType == 1)) {
if (top < cur.scrollTop) {
if (top + height > cur.scrollTop + cur.clientHeight) {
cur.scrollTop = (top + height) - cur.clientHeight;
}
-
+
var offsetTop = cur.offsetTop;
if (cur.parentNode != cur.offsetParent) {
offsetTop -= cur.parentNode.offsetTop;
}
-
+
top += offsetTop - cur.scrollTop;
cur = cur.parentNode;
}
}
var heightWithoutBorder = cloneElement.offsetHeight;
parentElement.removeChild(cloneElement);
-
+
return heightWithBorder - heightWithoutBorder;
}
}-*/;
package com.vaadin.client.communication;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.Document;
getElement().getStyle().setVisibility(Visibility.HIDDEN);
setStyleName(STYLE_RECONNECTING, true);
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- getElement().getStyle().setVisibility(Visibility.VISIBLE);
- setStyleName(STYLE_RECONNECTING, false);
- hide();
-
- }
+ Scheduler.get().scheduleDeferred(() -> {
+ getElement().getStyle().setVisibility(Visibility.VISIBLE);
+ setStyleName(STYLE_RECONNECTING, false);
+ hide();
});
}
}
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Widget;
ConnectorBundleLoader.get().ensureDeferredBundleLoaded();
if (Profiler.isEnabled()) {
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- Profiler.logTimings();
- Profiler.reset();
- }
+ Scheduler.get().scheduleDeferred(() -> {
+ Profiler.logTimings();
+ Profiler.reset();
});
}
}
Scheduler.get().scheduleFinally(scheduledFlushCommand);
}
- private final ScheduledCommand scheduledFlushCommand = new ScheduledCommand() {
- @Override
- public void execute() {
- flushScheduled = false;
- if (!isFlushPending()) {
- // Somebody else cleared the queue before we had the chance
- return;
- }
- connection.getMessageSender().sendInvocationsToServer();
+ private final ScheduledCommand scheduledFlushCommand = () -> {
+ flushScheduled = false;
+ if (!isFlushPending()) {
+ // Somebody else cleared the queue before we had the chance
+ return;
}
+ connection.getMessageSender().sendInvocationsToServer();
};
/**
private ScheduledCommand createResizeCommand(final int rowIndex,
final Element element) {
- return new ScheduledCommand() {
-
- @Override
- public void execute() {
- // It should not be possible to get here without calculating
- // the spacerCellBorderHeights or without having the details
- // row open, nor for this command to be triggered while
- // layout is running, but it's safer to check anyway.
- if (spacerCellBorderHeights != null
- && !getLayoutManager().isLayoutRunning()
- && getDetailsComponentConnectorId(
- rowIndex) != null) {
- double height = getLayoutManager().getOuterHeightDouble(
- element) + spacerCellBorderHeights;
- getWidget().setDetailsHeight(rowIndex, height);
- }
+ return () -> {
+ // It should not be possible to get here without calculating
+ // the spacerCellBorderHeights or without having the details
+ // row open, nor for this command to be triggered while
+ // layout is running, but it's safer to check anyway.
+ if (spacerCellBorderHeights != null
+ && !getLayoutManager().isLayoutRunning()
+ && getDetailsComponentConnectorId(rowIndex) != null) {
+ double height = getLayoutManager().getOuterHeightDouble(
+ element) + spacerCellBorderHeights;
+ getWidget().setDetailsHeight(rowIndex, height);
}
};
}
private CacheStrategy cacheStrategy = new CacheStrategy.DefaultCacheStrategy();
- private final ScheduledCommand coverageChecker = new ScheduledCommand() {
- @Override
- public void execute() {
- coverageCheckPending = false;
- checkCacheCoverage();
- }
+ private final ScheduledCommand coverageChecker = () -> {
+ coverageCheckPending = false;
+ checkCacheCoverage();
};
private Map<Object, Integer> pinnedCounts = new HashMap<>();
import com.google.gwt.core.client.Duration;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
* Finalize initialization when all entry points have had the chance to
* e.g. register new sections.
*/
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- readStoredState();
-
- Window.addResizeHandler(
- new com.google.gwt.event.logical.shared.ResizeHandler() {
+ Scheduler.get().scheduleFinally(() -> {
+ readStoredState();
- Timer t = new Timer() {
- @Override
- public void run() {
- applyPositionAndSize();
- }
- };
+ Window.addResizeHandler(
+ new com.google.gwt.event.logical.shared.ResizeHandler() {
+ Timer t = new Timer() {
@Override
- public void onResize(ResizeEvent event) {
- t.cancel();
- // TODO less
- t.schedule(1000);
+ public void run() {
+ applyPositionAndSize();
}
- });
- }
+ };
+
+ @Override
+ public void onResize(ResizeEvent event) {
+ t.cancel();
+ // TODO less
+ t.schedule(1000);
+ }
+ });
});
}
import java.util.List;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style;
@Override
public void onScroll(ScrollEvent event) {
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- focusElement.getStyle().setTop(getScrollPosition(), Unit.PX);
- focusElement.getStyle().setLeft(getHorizontalScrollPosition(),
- Unit.PX);
- }
+ Scheduler.get().scheduleDeferred(() -> {
+ focusElement.getStyle().setTop(getScrollPosition(), Unit.PX);
+ focusElement.getStyle().setLeft(getHorizontalScrollPosition(),
+ Unit.PX);
});
}
public com.google.gwt.user.client.Element getFocusElement() {
if (useFakeFocusElement()) {
return focusElement.cast();
- } else {
- return getElement();
}
+ return getElement();
}
}
package com.vaadin.client.ui;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.vaadin.client.BrowserInfo;
if (BrowserInfo.get().isIE()) {
// apply src later for IE, to ensure onload is fired
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- DOM.setElementProperty(getElement(), "src", imageUrl);
- }
- });
+ Scheduler.get().scheduleDeferred(() -> DOM
+ .setElementProperty(getElement(), "src", imageUrl));
}
DOM.setElementProperty(getElement(), "src", imageUrl);
import com.google.gwt.animation.client.AnimationScheduler;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.ui.VComboBox.JsniUtil::moveScrollFromEvent(*)(widget, deltaX, deltaY, e, e.deltaMode);
});
}-*/;
implements SubPartAware, LoadHandler {
private VLazyExecutor delayedImageLoadExecutioner = new VLazyExecutor(
- 100, new ScheduledCommand() {
-
- @Override
- public void execute() {
- debug("VComboBox.SM: delayedImageLoadExecutioner()");
- if (suggestionPopup.isVisible()
- && suggestionPopup.isAttached()) {
- setWidth("");
- getElement().getFirstChildElement().getStyle()
- .clearWidth();
- suggestionPopup
- .setPopupPositionAndShow(suggestionPopup);
- }
-
+ 100, () -> {
+ debug("VComboBox.SM: delayedImageLoadExecutioner()");
+ if (suggestionPopup.isVisible()
+ && suggestionPopup.isAttached()) {
+ setWidth("");
+ getElement().getFirstChildElement().getStyle()
+ .clearWidth();
+ suggestionPopup
+ .setPopupPositionAndShow(suggestionPopup);
}
});
package com.vaadin.client.ui;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.TableRowElement;
private Element focusedElement;
private VLazyExecutor delayedImageLoadExecutioner = new VLazyExecutor(100,
- new ScheduledCommand() {
- @Override
- public void execute() {
- imagesLoaded();
- }
- });
+ () -> imagesLoaded());
/**
* This method should be used only by Client object as only one per client
import java.util.Queue;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Overflow;
public boolean enabled = true;
private VLazyExecutor iconLoadedExecutioner = new VLazyExecutor(100,
- new ScheduledCommand() {
-
- @Override
- public void execute() {
- iLayout(true);
- }
- });
+ () -> iLayout(true));
/** For internal use only. May be removed or replaced in the future. */
public boolean openRootOnHover;
import java.util.Set;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
* could be no shortcutActionHandler set yet. So let's postpone
* search of shortcutActionHandler.
*/
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- try {
- if (shortcutActionHandler == null) {
- shortcutActionHandler = findShortcutActionHandler();
- }
- } finally {
- popupShowInProgress = false;
+ Scheduler.get().scheduleDeferred(() -> {
+ try {
+ if (shortcutActionHandler == null) {
+ shortcutActionHandler = findShortcutActionHandler();
}
+ } finally {
+ popupShowInProgress = false;
}
});
}
package com.vaadin.client.ui;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Overflow;
/* Temporary dragging/animation variables */
private boolean dragging = false;
- private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100,
- new ScheduledCommand() {
-
- @Override
- public void execute() {
- fireValueChanged();
- acceleration = 1;
- }
- });
+ private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100, () -> {
+ fireValueChanged();
+ acceleration = 1;
+ });
public VSlider() {
super();
getTab(tabsheet.activeTabIndex).recalculateCaptionWidth();
// Scroll the tab into view if it is not already, after layout
- Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
- @Override
- public void execute() {
- getTabsheet()
- .scrollIntoView(getTab(tabsheet.activeTabIndex));
- }
- });
+ Scheduler.get().scheduleFinally(() -> getTabsheet()
+ .scrollIntoView(getTab(tabsheet.activeTabIndex)));
}
public Tab navigateTab(int fromIndex, int toIndex) {
import java.util.List;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.HasScrollHandlers;
import com.google.gwt.event.dom.client.ScrollEvent;
private TouchScrollHandler touchScrollHandler;
private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200,
- new ScheduledCommand() {
-
- @Override
- public void execute() {
- performSizeCheck();
- }
-
- });
+ () -> performSizeCheck());
private Element storedFocus;
if (isAttached()) {
// no need to call poll() if component is already
// detached #8728
- ((UploadConnector) ConnectorMap.get(client).getConnector(VUpload.this))
- .getRpcProxy(UploadServerRpc.class).poll();
+ ((UploadConnector) ConnectorMap.get(client)
+ .getConnector(VUpload.this))
+ .getRpcProxy(UploadServerRpc.class)
+ .poll();
}
}
});
}
- ScheduledCommand startUploadCmd = new ScheduledCommand() {
-
- @Override
- public void execute() {
- element.submit();
- submitted = true;
-
- disableUpload();
-
- /*
- * Visit server a moment after upload has started to see possible
- * changes from UploadStarted event. Will be cleared on complete.
- *
- * Must get the id here as the upload can finish before the timer
- * expires and in that case nextUploadId has been updated and is
- * wrong.
- */
- final int thisUploadId = nextUploadId;
- t = new Timer() {
- @Override
- public void run() {
- // Only visit the server if the upload has not already
- // finished
- if (thisUploadId == nextUploadId) {
- VConsole.log(
- "Visiting server to see if upload started event changed UI.");
- client.updateVariable(paintableId, "pollForStart",
- thisUploadId, true);
- }
+ ScheduledCommand startUploadCmd = () -> {
+ element.submit();
+ submitted = true;
+
+ disableUpload();
+
+ /*
+ * Visit server a moment after upload has started to see possible
+ * changes from UploadStarted event. Will be cleared on complete.
+ *
+ * Must get the id here as the upload can finish before the timer
+ * expires and in that case nextUploadId has been updated and is wrong.
+ */
+ final int thisUploadId = nextUploadId;
+ t = new Timer() {
+ @Override
+ public void run() {
+ // Only visit the server if the upload has not already
+ // finished
+ if (thisUploadId == nextUploadId) {
+ VConsole.log(
+ "Visiting server to see if upload started event changed UI.");
+ client.updateVariable(paintableId, "pollForStart",
+ thisUploadId, true);
}
- };
- t.schedule(800);
- }
-
+ }
+ };
+ t.schedule(800);
};
/** For internal use only. May be removed or replaced in the future. */
import com.google.gwt.aria.client.RelevantValue;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
public int bringToFrontSequence = -1;
private VLazyExecutor delayedContentsSizeUpdater = new VLazyExecutor(200,
- new ScheduledCommand() {
-
- @Override
- public void execute() {
- updateContentsSize();
- }
- });
+ () -> updateContentsSize());
public VWindow() {
super(false, false); // no autohide, not modal
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.RepeatingCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
int currentY = WidgetUtil
.getTouchOrMouseClientY(
event.getNativeEvent());
- if (Math.abs(
- startX - currentX) > MINIMUM_DISTANCE_TO_START_DRAG
+ if (Math.abs(startX
+ - currentX) > MINIMUM_DISTANCE_TO_START_DRAG
|| Math.abs(startY
- currentY) > MINIMUM_DISTANCE_TO_START_DRAG) {
ensureDeferredRegistrationCleanup();
.getTransferable().getDragSource();
final ApplicationConnection client = currentDropHandler
.getApplicationConnection();
- Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
- @Override
- public boolean execute() {
- if (!client.getMessageSender().hasActiveRequest()) {
- removeActiveDragSourceStyleName(dragSource);
- return false;
- }
- return true;
+ Scheduler.get().scheduleFixedDelay(() -> {
+ if (!client.getMessageSender().hasActiveRequest()) {
+ removeActiveDragSourceStyleName(dragSource);
+ return false;
}
-
+ return true;
}, 30);
-
}
} else {
currentDropHandler.dragLeave(currentDrag);
}
/*
- * Remove class name indicating drag source when server visit is done
- * if server visit was not initiated. Otherwise it will be removed once
- * the server visit is done.
+ * Remove class name indicating drag source when server visit is done if
+ * server visit was not initiated. Otherwise it will be removed once the
+ * server visit is done.
*/
if (!sendTransferableToServer && currentDrag != null) {
removeActiveDragSourceStyleName(
import java.util.List;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Widget;
// updateExpandedSizes causes fixed size components to temporarily
// lose their size. updateExpandCompensation must be delayed until
// the browser has a chance to measure them.
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- getWidget().updateExpandCompensation();
- }
- });
+ Scheduler.get().scheduleFinally(
+ () -> getWidget().updateExpandCompensation());
} else {
getWidget().clearExpand();
}
import java.util.logging.Logger;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.HeadElement;
registerRpc(UIClientRpc.class, new UIClientRpc() {
@Override
public void uiClosed(final boolean sessionExpired) {
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- // Only notify user if we're still running and not eg.
- // navigating away (#12298)
- if (getConnection().isApplicationRunning()) {
- if (sessionExpired) {
- getConnection().showSessionExpiredError(null);
- } else {
- getState().enabled = false;
- updateEnabledState(getState().enabled);
- }
- getConnection().setApplicationRunning(false);
+ Scheduler.get().scheduleDeferred(() -> {
+ // Only notify user if we're still running and not eg.
+ // navigating away (#12298)
+ if (getConnection().isApplicationRunning()) {
+ if (sessionExpired) {
+ getConnection().showSessionExpiredError(null);
+ } else {
+ getState().enabled = false;
+ updateEnabledState(getState().enabled);
}
+ getConnection().setApplicationRunning(false);
}
});
}
if (firstPaint) {
// Queue the initial window size to be sent with the following
// request.
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- getWidget().sendClientResized();
- }
- });
+ Scheduler.get()
+ .scheduleDeferred(() -> getWidget().sendClientResized());
}
}
import java.util.logging.Logger;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
window.centered = state.centered;
// Ensure centering before setting visible (#16486)
if (window.centered && getState().windowMode != WindowMode.MAXIMIZED) {
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
-
- @Override
- public void execute() {
- getWidget().center();
- }
- });
+ Scheduler.get().scheduleFinally(() -> getWidget().center());
}
window.setVisible(true);
}
.isNativelySupported();
private class ScrollEventFirer {
- private final ScheduledCommand fireEventCommand = new ScheduledCommand() {
- @Override
- public void execute() {
-
- /*
- * Some kind of native-scroll-event related asynchronous problem
- * occurs here (at least on desktops) where the internal
- * bookkeeping isn't up to date with the real scroll position.
- * The weird thing is, that happens only once, and if you drag
- * scrollbar fast enough. After it has failed once, it never
- * fails again.
- *
- * Theory: the user drags the scrollbar, and this command is
- * executed before the browser has a chance to fire a scroll
- * event (which normally would correct this situation). This
- * would explain why slow scrolling doesn't trigger the problem,
- * while fast scrolling does.
- *
- * To make absolutely sure that we have the latest scroll
- * position, let's update the internal value.
- *
- * This might lead to a slight performance hit (on my computer
- * it was never more than 3ms on either of Chrome 38 or Firefox
- * 31). It also _slightly_ counteracts the purpose of the
- * internal bookkeeping. But since getScrollPos is called 3
- * times (on one direction) per scroll loop, it's still better
- * to have take this small penalty than removing it altogether.
- */
- updateScrollPosFromDom();
+ private final ScheduledCommand fireEventCommand = () -> {
+ /*
+ * Some kind of native-scroll-event related asynchronous problem
+ * occurs here (at least on desktops) where the internal bookkeeping
+ * isn't up to date with the real scroll position. The weird thing
+ * is, that happens only once, and if you drag scrollbar fast
+ * enough. After it has failed once, it never fails again.
+ *
+ * Theory: the user drags the scrollbar, and this command is
+ * executed before the browser has a chance to fire a scroll event
+ * (which normally would correct this situation). This would explain
+ * why slow scrolling doesn't trigger the problem, while fast
+ * scrolling does.
+ *
+ * To make absolutely sure that we have the latest scroll position,
+ * let's update the internal value.
+ *
+ * This might lead to a slight performance hit (on my computer it
+ * was never more than 3ms on either of Chrome 38 or Firefox 31). It
+ * also _slightly_ counteracts the purpose of the internal
+ * bookkeeping. But since getScrollPos is called 3 times (on one
+ * direction) per scroll loop, it's still better to have take this
+ * small penalty than removing it altogether.
+ */
+ updateScrollPosFromDom();
- getHandlerManager().fireEvent(new ScrollEvent());
- isBeingFired = false;
- }
+ getHandlerManager().fireEvent(new ScrollEvent());
+ isBeingFired = false;
};
private boolean isBeingFired;
}
/**
- * Helper class that helps to implement the WAI-ARIA functionality
- * for the Grid and TreeGrid component.
+ * Helper class that helps to implement the WAI-ARIA functionality for the
+ * Grid and TreeGrid component.
* <p>
* The following WAI-ARIA attributes are added through this class:
*
* <ul>
- * <li>aria-rowcount (since 8.2)</li>
+ * <li>aria-rowcount (since 8.2)</li>
* </ul>
*
* @since 8.2
public class AriaGridHelper {
/**
- * This field contains the total number of rows from the grid
- * including rows from thead, tbody and tfoot.
+ * This field contains the total number of rows from the grid including
+ * rows from thead, tbody and tfoot.
*
* @since 8.2
*/
* Adds the given numberOfRows to allRows and calls
* {@link #updateAriaRowCount()}.
*
- * @param numberOfRows number of rows that were added to the
- * grid
+ * @param numberOfRows
+ * number of rows that were added to the grid
*
* @since 8.2
*/
* Removes the given numberOfRows from allRows and calls
* {@link #updateAriaRowCount()}.
*
- * @param numberOfRows number of rows that were removed from
- * the grid
+ * @param numberOfRows
+ * number of rows that were removed from the grid
*
* @since 8.2
*/
}
/**
- * Sets the aria-rowcount attribute with the current value
- * of {@link AriaGridHelper#allRows} if the grid is attached
- * and {@link AriaGridHelper#allRows} > 0.
+ * Sets the aria-rowcount attribute with the current value of
+ * {@link AriaGridHelper#allRows} if the grid is attached and
+ * {@link AriaGridHelper#allRows} > 0.
*
* @since 8.2
*/
private boolean initialColumnSizesCalculated = false;
- public AbstractRowContainer(final TableSectionElement rowContainerElement) {
+ public AbstractRowContainer(
+ final TableSectionElement rowContainerElement) {
root = rowContainerElement;
}
}
public void autodetectRowHeightLater() {
- Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
- @Override
- public void execute() {
- if (defaultRowHeightShouldBeAutodetected && isAttached()) {
- autodetectRowHeightNow();
- defaultRowHeightShouldBeAutodetected = false;
- }
+ Scheduler.get().scheduleFinally(() -> {
+ if (defaultRowHeightShouldBeAutodetected && isAttached()) {
+ autodetectRowHeightNow();
+ defaultRowHeightShouldBeAutodetected = false;
}
});
}
private void fireRowHeightChangedEventFinally() {
if (!rowHeightChangedEventFired) {
rowHeightChangedEventFired = true;
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- fireEvent(new RowHeightChangedEvent());
- rowHeightChangedEventFired = false;
- }
+ Scheduler.get().scheduleFinally(() -> {
+ fireEvent(new RowHeightChangedEvent());
+ rowHeightChangedEventFired = false;
});
}
}
/** The height of the combined rows in the DOM. Never negative. */
private double heightOfSection = 0;
- public AbstractStaticRowContainer(final TableSectionElement headElement) {
+ public AbstractStaticRowContainer(
+ final TableSectionElement headElement) {
super(headElement);
}
private final AriaGridHelper ariaGridHelper = new AriaGridHelper();
private final HeaderRowContainer header = new HeaderRowContainer(headElem);
- private final BodyRowContainerImpl body = new BodyRowContainerImpl(bodyElem);
+ private final BodyRowContainerImpl body = new BodyRowContainerImpl(
+ bodyElem);
private final FooterRowContainer footer = new FooterRowContainer(footElem);
/**
private double delayToCancelTouchScroll = -1;
private boolean layoutIsScheduled = false;
- private ScheduledCommand layoutCommand = new ScheduledCommand() {
- @Override
- public void execute() {
- recalculateElementSizes();
- layoutIsScheduled = false;
- }
+ private ScheduledCommand layoutCommand = () -> {
+ recalculateElementSizes();
+ layoutIsScheduled = false;
};
private final ElementPositionBookkeeper positions = new ElementPositionBookkeeper();
* We either lost or gained a scrollbar. In any case, we
* need to change the height, if it's defined by rows.
*/
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
-
- @Override
- public void execute() {
- applyHeightByRows();
- queued = false;
- }
+ Scheduler.get().scheduleFinally(() -> {
+ applyHeightByRows();
+ queued = false;
});
}
});
public void scrollToRow(final int rowIndex,
final ScrollDestination destination, final int padding)
throws IndexOutOfBoundsException, IllegalArgumentException {
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- validateScrollDestination(destination, padding);
- verifyValidRowIndex(rowIndex);
- scroller.scrollToRow(rowIndex, destination, padding);
- }
+ Scheduler.get().scheduleFinally(() -> {
+ validateScrollDestination(destination, padding);
+ verifyValidRowIndex(rowIndex);
+ scroller.scrollToRow(rowIndex, destination, padding);
});
}
public void scrollToRowAndSpacer(final int rowIndex,
final ScrollDestination destination, final int padding)
throws IllegalArgumentException {
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- validateScrollDestination(destination, padding);
- if (rowIndex != -1) {
- verifyValidRowIndex(rowIndex);
- }
+ Scheduler.get().scheduleFinally(() -> {
+ validateScrollDestination(destination, padding);
+ if (rowIndex != -1) {
+ verifyValidRowIndex(rowIndex);
+ }
- // row range
- final Range rowRange;
- if (rowIndex != -1) {
- int rowTop = (int) Math.floor(body.getRowTop(rowIndex));
- int rowHeight = (int) Math.ceil(body.getDefaultRowHeight());
- rowRange = Range.withLength(rowTop, rowHeight);
- } else {
- rowRange = Range.withLength(0, 0);
- }
+ // row range
+ final Range rowRange;
+ if (rowIndex != -1) {
+ int rowTop = (int) Math.floor(body.getRowTop(rowIndex));
+ int rowHeight = (int) Math.ceil(body.getDefaultRowHeight());
+ rowRange = Range.withLength(rowTop, rowHeight);
+ } else {
+ rowRange = Range.withLength(0, 0);
+ }
- // get spacer
- final SpacerContainer.SpacerImpl spacer = body.spacerContainer
- .getSpacer(rowIndex);
+ // get spacer
+ final SpacerContainer.SpacerImpl spacer = body.spacerContainer
+ .getSpacer(rowIndex);
- if (rowIndex == -1 && spacer == null) {
- throw new IllegalArgumentException(
- "Cannot scroll to row index "
- + "-1, as there is no spacer open at that index.");
- }
+ if (rowIndex == -1 && spacer == null) {
+ throw new IllegalArgumentException("Cannot scroll to row index "
+ + "-1, as there is no spacer open at that index.");
+ }
- // make into target range
- final Range targetRange;
- if (spacer != null) {
- final int spacerTop = (int) Math.floor(spacer.getTop());
- final int spacerHeight = (int) Math
- .ceil(spacer.getHeight());
- Range spacerRange = Range.withLength(spacerTop,
- spacerHeight);
+ // make into target range
+ final Range targetRange;
+ if (spacer != null) {
+ final int spacerTop = (int) Math.floor(spacer.getTop());
+ final int spacerHeight = (int) Math.ceil(spacer.getHeight());
+ Range spacerRange = Range.withLength(spacerTop, spacerHeight);
- targetRange = rowRange.combineWith(spacerRange);
- } else {
- targetRange = rowRange;
- }
+ targetRange = rowRange.combineWith(spacerRange);
+ } else {
+ targetRange = rowRange;
+ }
- // get params
- int targetStart = targetRange.getStart();
- int targetEnd = targetRange.getEnd();
- double viewportStart = getScrollTop();
- double viewportEnd = viewportStart + body.getHeightOfSection();
+ // get params
+ int targetStart = targetRange.getStart();
+ int targetEnd = targetRange.getEnd();
+ double viewportStart = getScrollTop();
+ double viewportEnd = viewportStart + body.getHeightOfSection();
- double scrollPos = getScrollPos(destination, targetStart,
- targetEnd, viewportStart, viewportEnd, padding);
+ double scrollPos = getScrollPos(destination, targetStart, targetEnd,
+ viewportStart, viewportEnd, padding);
- setScrollTop(scrollPos);
- }
+ setScrollTop(scrollPos);
});
}
* (for example when updating cell values) we only get one actual
* refresh in the end.
*/
- Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
-
- @Override
- public void execute() {
- if (markAsDirty) {
- markAsDirty = false;
- getGrid().refreshHeader();
- }
+ Scheduler.get().scheduleFinally(() -> {
+ if (markAsDirty) {
+ markAsDirty = false;
+ getGrid().refreshHeader();
}
});
}
* (for example when updating cell values) we only get one actual
* refresh in the end.
*/
- Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
-
- @Override
- public void execute() {
+ Scheduler.get().scheduleFinally(() -> {
if (markAsDirty) {
markAsDirty = false;
getGrid().refreshFooter();
- }
}
});
}
if (grid.selectionColumn != null && grid.selectionColumn
.getRenderer() instanceof MultiSelectionRenderer) {
grid.refreshBody();
- HeaderCell cell = grid.getDefaultHeaderRow().getCell(grid.selectionColumn);
+ HeaderCell cell = grid.getDefaultHeaderRow()
+ .getCell(grid.selectionColumn);
if (cell.getType() == GridStaticCellType.WIDGET) { // if lazy provider, then no checkbox
CheckBox checkBox = (CheckBox) grid.getDefaultHeaderRow()
- .getCell(grid.selectionColumn).getWidget();
+ .getCell(grid.selectionColumn).getWidget();
checkBox.setEnabled(isEnabled);
}
}
final MenuItem item = getSelectedItem();
super.onBrowserEvent(event);
Scheduler.get()
- .scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- selectItem(item);
- focus();
- }
+ .scheduleDeferred(() -> {
+ selectItem(item);
+ focus();
});
} else {
super.onBrowserEvent(event);
}
}
-
};
KeyDownHandler keyDownHandler = new KeyDownHandler() {
super.onAttach();
// make sure the button will get correct height if the button should
// be visible when the grid is rendered the first time.
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
-
- @Override
- public void execute() {
- setHeightToHeaderCellHeight();
- }
- });
+ Scheduler.get()
+ .scheduleDeferred(() -> setHeightToHeaderCellHeight());
}
@Override
private MenuItem createToggle(final Column<?, T> column) {
MenuItem toggle = new MenuItem(createHTML(column), true,
- new ScheduledCommand() {
-
- @Override
- public void execute() {
- hidingColumn = true;
- column.setHidden(!column.isHidden(), true);
- hidingColumn = false;
- }
+ () -> {
+ hidingColumn = true;
+ column.setHidden(!column.isHidden(), true);
+ hidingColumn = false;
});
toggle.addStyleName("column-hiding-toggle");
columnToHidingToggleMap.put(column, toggle);
/**
* Request delayed refresh of all body rows.
- *
+ *
* @since 8.1
*/
public void requestRefreshBody() {
public HandlerRegistration addDataAvailableHandler(
final DataAvailableHandler handler) {
// Deferred call to handler with current row range
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
- @Override
- public void execute() {
- if (!dataSource.isWaitingForData()) {
- handler.onDataAvailable(
- new DataAvailableEvent(currentDataAvailable));
- }
+ Scheduler.get().scheduleFinally(() -> {
+ if (!dataSource.isWaitingForData()) {
+ handler.onDataAvailable(
+ new DataAvailableEvent(currentDataAvailable));
}
});
return addHandler(handler, DataAvailableEvent.TYPE);
/*
* Delay calculation to be deferred so Escalator can do it's magic.
*/
- Scheduler.get().scheduleFinally(new ScheduledCommand() {
-
- @Override
- public void execute() {
+ Scheduler.get().scheduleFinally(() -> {
if (escalator
.getInnerWidth() != autoColumnWidthsRecalculator.lastCalculatedInnerWidth) {
recalculateColumnWidths();
// off-by-one error which occurs when the user scrolls all the
// way to the bottom.
refreshBody();
- }
});
}
private void createFrozenMenu() {
String[] menupath = { FEATURES_MENU, "Frozen columns" };
- addMenuCommand("Freeze 1 column", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getColumnConfiguration().setFrozenColumnCount(1);
- }
- }, menupath);
- addMenuCommand("Freeze 0 columns", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getColumnConfiguration().setFrozenColumnCount(0);
- }
- }, menupath);
+ addMenuCommand("Freeze 1 column", () -> escalator
+ .getColumnConfiguration().setFrozenColumnCount(1), menupath);
+ addMenuCommand("Freeze 0 columns", () -> escalator
+ .getColumnConfiguration().setFrozenColumnCount(0), menupath);
}
private void createColspanMenu() {
String[] menupath = { FEATURES_MENU, "Column spanning" };
- addMenuCommand("Apply normal colspan", new ScheduledCommand() {
- @Override
- public void execute() {
- colspan = Colspan.NORMAL;
- refreshEscalator();
- }
+ addMenuCommand("Apply normal colspan", () -> {
+ colspan = Colspan.NORMAL;
+ refreshEscalator();
}, menupath);
- addMenuCommand("Apply crazy colspan", new ScheduledCommand() {
- @Override
- public void execute() {
- colspan = Colspan.CRAZY;
- refreshEscalator();
- }
+ addMenuCommand("Apply crazy colspan", () -> {
+ colspan = Colspan.CRAZY;
+ refreshEscalator();
}, menupath);
- addMenuCommand("Apply no colspan", new ScheduledCommand() {
- @Override
- public void execute() {
- colspan = Colspan.NONE;
- refreshEscalator();
- }
+ addMenuCommand("Apply no colspan", () -> {
+ colspan = Colspan.NONE;
+ refreshEscalator();
}, menupath);
}
private void createColumnsAndRowsMenu() {
String[] menupath = { COLUMNS_AND_ROWS_MENU };
- addMenuCommand("Add one of each row", new ScheduledCommand() {
- @Override
- public void execute() {
- insertRows(escalator.getHeader(), 0, 1);
- insertRows(escalator.getBody(), 0, 1);
- insertRows(escalator.getFooter(), 0, 1);
- }
+ addMenuCommand("Add one of each row", () -> {
+ insertRows(escalator.getHeader(), 0, 1);
+ insertRows(escalator.getBody(), 0, 1);
+ insertRows(escalator.getFooter(), 0, 1);
}, menupath);
- addMenuCommand("Remove one of each row", new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getHeader(), 0, 1);
- removeRows(escalator.getBody(), 0, 1);
- removeRows(escalator.getFooter(), 0, 1);
- }
+ addMenuCommand("Remove one of each row", () -> {
+ removeRows(escalator.getHeader(), 0, 1);
+ removeRows(escalator.getBody(), 0, 1);
+ removeRows(escalator.getFooter(), 0, 1);
}, menupath);
}
private void createGeneralMenu() {
String[] menupath = { GENERAL_MENU };
- addMenuCommand("Detach Escalator", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.removeFromParent();
- }
- }, menupath);
+ addMenuCommand("Detach Escalator", () -> escalator.removeFromParent(),
+ menupath);
- addMenuCommand("Attach Escalator", new ScheduledCommand() {
- @Override
- public void execute() {
- if (!escalator.isAttached()) {
- addNorth(escalator, 500);
- }
+ addMenuCommand("Attach Escalator", () -> {
+ if (!escalator.isAttached()) {
+ addNorth(escalator, 500);
}
}, menupath);
- addMenuCommand("Clear (columns, then rows)", new ScheduledCommand() {
- @Override
- public void execute() {
- resetColRow();
- }
+ addMenuCommand("Clear (columns, then rows)", () -> resetColRow(),
+ menupath);
+ addMenuCommand("Clear (rows, then columns)", () -> resetRowCol()
+
+ , menupath);
+ addMenuCommand("Populate Escalator (columns, then rows)", () -> {
+ resetColRow();
+ insertColumns(0, 10);
+ insertRows(escalator.getHeader(), 0, 1);
+ insertRows(escalator.getBody(), 0, 100);
+ insertRows(escalator.getFooter(), 0, 1);
}, menupath);
- addMenuCommand("Clear (rows, then columns)", new ScheduledCommand() {
- @Override
- public void execute() {
- resetRowCol();
- }
+ addMenuCommand("Populate Escalator (rows, then columns)", () -> {
+ resetColRow();
+ insertRows(escalator.getHeader(), 0, 1);
+ insertRows(escalator.getBody(), 0, 100);
+ insertRows(escalator.getFooter(), 0, 1);
+ insertColumns(0, 10);
}, menupath);
- addMenuCommand("Populate Escalator (columns, then rows)",
- new ScheduledCommand() {
- @Override
- public void execute() {
- resetColRow();
- insertColumns(0, 10);
- insertRows(escalator.getHeader(), 0, 1);
- insertRows(escalator.getBody(), 0, 100);
- insertRows(escalator.getFooter(), 0, 1);
- }
- }, menupath);
- addMenuCommand("Populate Escalator (rows, then columns)",
- new ScheduledCommand() {
- @Override
- public void execute() {
- resetColRow();
- insertRows(escalator.getHeader(), 0, 1);
- insertRows(escalator.getBody(), 0, 100);
- insertRows(escalator.getFooter(), 0, 1);
- insertColumns(0, 10);
- }
- }, menupath);
createSizeMenu();
}
private void addSizeMenuItem(final String size, final String direction,
String[] menupath) {
final String title = (size != null ? size : "undefined");
- addMenuCommand(title + " " + direction, new ScheduledCommand() {
- @Override
- public void execute() {
- if (direction.equals("height")) {
- escalator.setHeight(size);
- } else {
- escalator.setWidth(size);
- }
+ addMenuCommand(title + " " + direction, () -> {
+ if (direction.equals("height")) {
+ escalator.setHeight(size);
+ } else {
+ escalator.setWidth(size);
}
}, menupath);
}
private void createColumnMenu() {
String[] menupath = { COLUMNS_AND_ROWS_MENU, "Columns" };
- addMenuCommand("Add one column to beginning", new ScheduledCommand() {
- @Override
- public void execute() {
- insertColumns(0, 1);
- }
- }, menupath);
- addMenuCommand("Add one column to end", new ScheduledCommand() {
- @Override
- public void execute() {
- insertColumns(
- escalator.getColumnConfiguration().getColumnCount(), 1);
- }
- }, menupath);
- addMenuCommand("Add ten columns", new ScheduledCommand() {
- @Override
- public void execute() {
- insertColumns(0, 10);
- }
- }, menupath);
+ addMenuCommand("Add one column to beginning", () -> insertColumns(0, 1),
+ menupath);
+ addMenuCommand("Add one column to end",
+ () -> insertColumns(
+ escalator.getColumnConfiguration().getColumnCount(), 1),
+ menupath);
+ addMenuCommand("Add ten columns", () -> insertColumns(0, 10), menupath);
addMenuCommand("Remove one column from beginning",
- new ScheduledCommand() {
- @Override
- public void execute() {
- removeColumns(0, 1);
- }
- }, menupath);
- addMenuCommand("Remove one column from end", new ScheduledCommand() {
- @Override
- public void execute() {
- removeColumns(
+ () -> removeColumns(0, 1), menupath);
+ addMenuCommand("Remove one column from end",
+ () -> removeColumns(
escalator.getColumnConfiguration().getColumnCount() - 1,
- 1);
- }
- }, menupath);
+ 1),
+ menupath);
- addMenuCommand("Refresh first column", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getColumnConfiguration().refreshColumns(0, 1);
- }
- }, menupath);
+ addMenuCommand("Refresh first column",
+ () -> escalator.getColumnConfiguration().refreshColumns(0, 1),
+ menupath);
addMenuCommand("Resize first column to max width",
- new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getColumnConfiguration().setColumnWidth(0,
- -1);
- }
- }, menupath);
+ () -> escalator.getColumnConfiguration().setColumnWidth(0, -1),
+ menupath);
- addMenuCommand("Resize first column to 100 px", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getColumnConfiguration().setColumnWidth(0, 100);
- }
- }, menupath);
+ addMenuCommand("Resize first column to 100 px",
+ () -> escalator.getColumnConfiguration().setColumnWidth(0, 100),
+ menupath);
}
private void createHeaderRowsMenu() {
String[] menupath = { COLUMNS_AND_ROWS_MENU, "Body Rows" };
createRowsMenu(escalator.getBody(), menupath);
- addMenuCommand("Add 5 rows to top", new ScheduledCommand() {
- @Override
- public void execute() {
- insertRows(escalator.getBody(), 0, 5);
- }
- }, menupath);
- addMenuCommand("Add 22 rows to top", new ScheduledCommand() {
- @Override
- public void execute() {
- insertRows(escalator.getBody(), 0, 22);
- }
- }, menupath);
- addMenuCommand("Add 50 rows to top", new ScheduledCommand() {
- @Override
- public void execute() {
- insertRows(escalator.getBody(), 0, 50);
- }
- }, menupath);
- addMenuCommand("Remove 5 rows from bottom", new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getBody(),
- escalator.getBody().getRowCount() - 5, 5);
- }
- }, menupath);
- addMenuCommand("Remove 50 rows from bottom", new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getBody(),
- escalator.getBody().getRowCount() - 50, 50);
- }
- }, menupath);
- addMenuCommand("Remove 15 rows from middle", new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getBody(), 3, 15);
- }
- }, menupath);
+ addMenuCommand("Add 5 rows to top",
+ () -> insertRows(escalator.getBody(), 0, 5), menupath);
+ addMenuCommand("Add 22 rows to top",
+ () -> insertRows(escalator.getBody(), 0, 22), menupath);
+ addMenuCommand("Add 50 rows to top",
+ () -> insertRows(escalator.getBody(), 0, 50), menupath);
+ addMenuCommand("Remove 5 rows from bottom",
+ () -> removeRows(escalator.getBody(),
+ escalator.getBody().getRowCount() - 5, 5),
+ menupath);
+ addMenuCommand("Remove 50 rows from bottom",
+ () -> removeRows(escalator.getBody(),
+ escalator.getBody().getRowCount() - 50, 50),
+ menupath);
+ addMenuCommand("Remove 15 rows from middle",
+ () -> removeRows(escalator.getBody(), 3, 15), menupath);
addMenuCommand("Remove 50 rows from almost bottom",
- new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getBody(),
- escalator.getBody().getRowCount() - 60, 50);
- }
- }, menupath);
- addMenuCommand("Remove all, insert 30 and scroll 40px",
- new ScheduledCommand() {
- @Override
- public void execute() {
- removeRows(escalator.getBody(), 0,
- escalator.getBody().getRowCount());
- insertRows(escalator.getBody(), 0, 30);
- escalator.setScrollTop(40);
- }
- }, menupath);
+ () -> removeRows(escalator.getBody(),
+ escalator.getBody().getRowCount() - 60, 50),
+ menupath);
+ addMenuCommand("Remove all, insert 30 and scroll 40px", () -> {
+ removeRows(escalator.getBody(), 0,
+ escalator.getBody().getRowCount());
+ insertRows(escalator.getBody(), 0, 30);
+ escalator.setScrollTop(40);
+ }, menupath);
String[] scrollToRowMenuPath = new String[menupath.length + 1];
System.arraycopy(menupath, 0, scrollToRowMenuPath, 0, menupath.length);
scrollToRowMenuPath[scrollToRowMenuPath.length - 1] = "Scroll to...";
for (int i = 0; i < 100; i += 25) {
final int rowIndex = i;
- addMenuCommand("Row " + i, new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.scrollToRow(rowIndex, ScrollDestination.ANY, 0);
- }
- }, scrollToRowMenuPath);
+ addMenuCommand("Row " + i, () -> escalator.scrollToRow(rowIndex,
+ ScrollDestination.ANY, 0), scrollToRowMenuPath);
}
- addMenuCommand("Set 20px default height", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getBody().setDefaultRowHeight(20);
- }
- }, menupath);
+ addMenuCommand("Set 20px default height",
+ () -> escalator.getBody().setDefaultRowHeight(20), menupath);
}
private void createRowsMenu(final RowContainer container,
String[] menupath) {
- addMenuCommand("Add one row to beginning", new ScheduledCommand() {
- @Override
- public void execute() {
- int offset = 0;
- int number = 1;
- insertRows(container, offset, number);
- }
+ addMenuCommand("Add one row to beginning", () -> {
+ int offset = 0;
+ int number = 1;
+ insertRows(container, offset, number);
}, menupath);
- addMenuCommand("Add one row to end", new ScheduledCommand() {
- @Override
- public void execute() {
- int offset = container.getRowCount();
- int number = 1;
- insertRows(container, offset, number);
- }
+ addMenuCommand("Add one row to end", () -> {
+ int offset = container.getRowCount();
+ int number = 1;
+ insertRows(container, offset, number);
}, menupath);
- addMenuCommand("Remove one row from beginning", new ScheduledCommand() {
- @Override
- public void execute() {
- int offset = 0;
- int number = 1;
- removeRows(container, offset, number);
- }
+ addMenuCommand("Remove one row from beginning", () -> {
+ int offset = 0;
+ int number = 1;
+ removeRows(container, offset, number);
}, menupath);
- addMenuCommand("Remove one row from end", new ScheduledCommand() {
- @Override
- public void execute() {
- int offset = container.getRowCount() - 1;
- int number = 1;
- removeRows(container, offset, number);
- }
+ addMenuCommand("Remove one row from end", () -> {
+ int offset = container.getRowCount() - 1;
+ int number = 1;
+ removeRows(container, offset, number);
}, menupath);
- addMenuCommand("Remove all rows", new ScheduledCommand() {
- @Override
- public void execute() {
- if (container.getRowCount() > 0) {
- removeRows(container, 0, container.getRowCount());
- }
+ addMenuCommand("Remove all rows", () -> {
+ if (container.getRowCount() > 0) {
+ removeRows(container, 0, container.getRowCount());
}
}, menupath);
}
}
}, menupath);
- addMenuCommand("Focusable Updater", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getBody().setSpacerUpdater(new SpacerUpdater() {
+ addMenuCommand("Focusable Updater",
+ () -> escalator.getBody().setSpacerUpdater(new SpacerUpdater() {
@Override
public void init(Spacer spacer) {
spacer.getElement().appendChild(DOM.createInputText());
public void destroy(Spacer spacer) {
spacer.getElement().removeAllChildren();
}
- });
- }
- }, menupath);
+ }), menupath);
createSpacersMenuForRow(-1, menupath);
createSpacersMenuForRow(1, menupath);
private void createSpacersMenuForRow(final int rowIndex,
String[] menupath) {
menupath = new String[] { menupath[0], menupath[1], "Row " + rowIndex };
- addMenuCommand("Set 100px", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getBody().setSpacer(rowIndex, 100);
- }
- }, menupath);
- addMenuCommand("Set 50px", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getBody().setSpacer(rowIndex, 50);
- }
- }, menupath);
- addMenuCommand("Remove", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.getBody().setSpacer(rowIndex, -1);
- }
- }, menupath);
- addMenuCommand("Scroll here (ANY, 0)", new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.scrollToSpacer(rowIndex, ScrollDestination.ANY, 0);
- }
- }, menupath);
- addMenuCommand("Scroll here row+spacer below (ANY, 0)",
- new ScheduledCommand() {
- @Override
- public void execute() {
- escalator.scrollToRowAndSpacer(rowIndex,
- ScrollDestination.ANY, 0);
- }
- }, menupath);
+ addMenuCommand("Set 100px",
+ () -> escalator.getBody().setSpacer(rowIndex, 100), menupath);
+ addMenuCommand("Set 50px",
+ () -> escalator.getBody().setSpacer(rowIndex, 50), menupath);
+ addMenuCommand("Remove",
+ () -> escalator.getBody().setSpacer(rowIndex, -1), menupath);
+ addMenuCommand("Scroll here (ANY, 0)", () -> escalator
+ .scrollToSpacer(rowIndex, ScrollDestination.ANY, 0), menupath);
+ addMenuCommand("Scroll here row+spacer below (ANY, 0)", () -> escalator
+ .scrollToRowAndSpacer(rowIndex, ScrollDestination.ANY, 0),
+ menupath);
}
private void insertRows(final RowContainer container, int offset,