* Scheduler.ScheduledCommand and RepeatingCommand to be lambda * Restore <table> in javadoc * Fix docstags/8.2.0.alpha3
@@ -31,7 +31,6 @@ import com.google.gwt.core.client.JavaScriptObject; | |||
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; | |||
@@ -465,21 +464,15 @@ public class ApplicationConfiguration implements EntryPoint { | |||
* 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(); | |||
}); | |||
} | |||
@@ -29,17 +29,10 @@ public class VSchedulerImpl extends SchedulerImpl { | |||
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; | |||
} | |||
} |
@@ -20,7 +20,6 @@ import java.util.Set; | |||
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; | |||
@@ -319,12 +318,8 @@ public class VUIDLBrowser extends SimpleTree { | |||
} | |||
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()); | |||
} | |||
} | |||
} |
@@ -23,7 +23,6 @@ import java.util.logging.Logger; | |||
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; | |||
@@ -791,7 +790,7 @@ public class WidgetUtil { | |||
com.google.gwt.dom.client.Element el, String p) | |||
/*-{ | |||
try { | |||
if (el.currentStyle) { | |||
// IE | |||
return el.currentStyle[p]; | |||
@@ -806,7 +805,7 @@ public class WidgetUtil { | |||
} catch (e) { | |||
return ""; | |||
} | |||
}-*/; | |||
/** | |||
@@ -820,7 +819,7 @@ public class WidgetUtil { | |||
try { | |||
el.focus(); | |||
} catch (e) { | |||
} | |||
}-*/; | |||
@@ -1151,19 +1150,14 @@ public class WidgetUtil { | |||
((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) { | |||
} | |||
}); | |||
} | |||
/** | |||
@@ -1176,7 +1170,7 @@ public class WidgetUtil { | |||
if ($wnd.document.activeElement) { | |||
return $wnd.document.activeElement; | |||
} | |||
return null; | |||
}-*/; | |||
@@ -1247,11 +1241,11 @@ public class WidgetUtil { | |||
/*-{ | |||
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) { | |||
@@ -1260,12 +1254,12 @@ public class WidgetUtil { | |||
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; | |||
} | |||
@@ -1714,7 +1708,7 @@ public class WidgetUtil { | |||
} | |||
var heightWithoutBorder = cloneElement.offsetHeight; | |||
parentElement.removeChild(cloneElement); | |||
return heightWithBorder - heightWithoutBorder; | |||
} | |||
}-*/; |
@@ -16,7 +16,6 @@ | |||
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; | |||
@@ -113,15 +112,10 @@ public class DefaultReconnectDialog extends VOverlay | |||
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(); | |||
}); | |||
} | |||
} |
@@ -31,7 +31,6 @@ import com.google.gwt.core.client.JavaScriptObject; | |||
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; | |||
@@ -574,12 +573,9 @@ public class MessageHandler { | |||
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(); | |||
}); | |||
} | |||
} |
@@ -191,16 +191,13 @@ public class ServerRpcQueue { | |||
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(); | |||
}; | |||
/** |
@@ -137,22 +137,17 @@ public class DetailsManagerConnector extends AbstractExtensionConnector { | |||
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); | |||
} | |||
}; | |||
} |
@@ -206,12 +206,9 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> { | |||
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<>(); |
@@ -21,7 +21,6 @@ import java.util.List; | |||
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; | |||
@@ -706,29 +705,26 @@ public final class VDebugWindow extends VOverlay { | |||
* 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); | |||
} | |||
}); | |||
}); | |||
} | |||
@@ -18,7 +18,6 @@ package com.vaadin.client.ui; | |||
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; | |||
@@ -185,22 +184,18 @@ public class FocusableScrollPanel extends SimpleFocusablePanel | |||
@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(); | |||
} | |||
} |
@@ -17,7 +17,6 @@ | |||
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; | |||
@@ -50,12 +49,8 @@ public class ImageIcon extends Icon { | |||
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); |
@@ -26,7 +26,6 @@ import java.util.Set; | |||
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; | |||
@@ -258,12 +257,12 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
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); | |||
}); | |||
}-*/; | |||
@@ -1027,20 +1026,15 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
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); | |||
} | |||
}); | |||
@@ -17,7 +17,6 @@ | |||
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; | |||
@@ -66,12 +65,7 @@ public class VContextMenu extends VOverlay implements SubPartAware { | |||
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 |
@@ -21,7 +21,6 @@ import java.util.List; | |||
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; | |||
@@ -107,13 +106,7 @@ public class VMenuBar extends SimpleFocusablePanel | |||
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; |
@@ -21,7 +21,6 @@ import java.util.Iterator; | |||
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; | |||
@@ -326,16 +325,13 @@ public class VPopupView extends HTML | |||
* 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; | |||
} | |||
}); | |||
} |
@@ -16,7 +16,6 @@ | |||
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; | |||
@@ -90,15 +89,10 @@ public class VSlider extends SimpleFocusablePanel | |||
/* 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(); |
@@ -563,13 +563,8 @@ public class VTabsheet extends VTabsheetBase | |||
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) { |
@@ -18,7 +18,6 @@ package com.vaadin.client.ui; | |||
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; | |||
@@ -97,14 +96,7 @@ public class VUI extends SimplePanel implements ResizeHandler, | |||
private TouchScrollHandler touchScrollHandler; | |||
private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200, | |||
new ScheduledCommand() { | |||
@Override | |||
public void execute() { | |||
performSizeCheck(); | |||
} | |||
}); | |||
() -> performSizeCheck()); | |||
private Element storedFocus; | |||
@@ -270,8 +270,10 @@ public class VUpload extends SimplePanel { | |||
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(); | |||
} | |||
} | |||
@@ -290,40 +292,34 @@ public class VUpload extends SimplePanel { | |||
}); | |||
} | |||
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. */ |
@@ -28,7 +28,6 @@ import com.google.gwt.aria.client.Id; | |||
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; | |||
@@ -203,13 +202,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
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 |
@@ -17,7 +17,6 @@ package com.vaadin.client.ui.dd; | |||
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; | |||
@@ -372,8 +371,8 @@ public class VDragAndDropManager { | |||
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(); | |||
@@ -493,18 +492,13 @@ public class VDragAndDropManager { | |||
.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); | |||
@@ -516,9 +510,9 @@ public class VDragAndDropManager { | |||
} | |||
/* | |||
* 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( |
@@ -18,7 +18,6 @@ package com.vaadin.client.ui.orderedlayout; | |||
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; | |||
@@ -520,12 +519,8 @@ public abstract class AbstractOrderedLayoutConnector | |||
// 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(); | |||
} |
@@ -26,7 +26,6 @@ import java.util.Map; | |||
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; | |||
@@ -186,20 +185,17 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
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); | |||
} | |||
}); | |||
} | |||
@@ -445,12 +441,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector | |||
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()); | |||
} | |||
} | |||
@@ -18,7 +18,6 @@ package com.vaadin.client.ui.window; | |||
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; | |||
@@ -403,13 +402,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector | |||
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); | |||
} |
@@ -54,39 +54,34 @@ public abstract class ScrollbarBundle implements DeferredWorker { | |||
.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; |
@@ -1125,13 +1125,13 @@ public class Escalator extends Widget | |||
} | |||
/** | |||
* 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 | |||
@@ -1139,8 +1139,8 @@ public class Escalator extends Widget | |||
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 | |||
*/ | |||
@@ -1150,8 +1150,8 @@ public class Escalator extends Widget | |||
* 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 | |||
*/ | |||
@@ -1164,8 +1164,8 @@ public class Escalator extends Widget | |||
* 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 | |||
*/ | |||
@@ -1175,9 +1175,9 @@ public class Escalator extends Widget | |||
} | |||
/** | |||
* 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 | |||
*/ | |||
@@ -1217,7 +1217,8 @@ public class Escalator extends Widget | |||
private boolean initialColumnSizesCalculated = false; | |||
public AbstractRowContainer(final TableSectionElement rowContainerElement) { | |||
public AbstractRowContainer( | |||
final TableSectionElement rowContainerElement) { | |||
root = rowContainerElement; | |||
} | |||
@@ -2027,13 +2028,10 @@ public class Escalator extends Widget | |||
} | |||
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; | |||
} | |||
}); | |||
} | |||
@@ -2041,12 +2039,9 @@ public class Escalator extends Widget | |||
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; | |||
}); | |||
} | |||
} | |||
@@ -2236,7 +2231,8 @@ public class Escalator extends Widget | |||
/** 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); | |||
} | |||
@@ -5664,7 +5660,8 @@ public class Escalator extends Widget | |||
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); | |||
/** | |||
@@ -5703,12 +5700,9 @@ public class Escalator extends Widget | |||
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(); | |||
@@ -5835,13 +5829,9 @@ public class Escalator extends Widget | |||
* 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; | |||
}); | |||
} | |||
}); | |||
@@ -6235,13 +6225,10 @@ public class Escalator extends Widget | |||
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); | |||
}); | |||
} | |||
@@ -6306,59 +6293,53 @@ public class Escalator extends Widget | |||
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); | |||
}); | |||
} | |||
@@ -948,14 +948,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
* (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(); | |||
} | |||
}); | |||
} | |||
@@ -1036,14 +1032,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
* (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(); | |||
} | |||
} | |||
}); | |||
} | |||
@@ -1677,10 +1669,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
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); | |||
} | |||
} | |||
@@ -3866,20 +3859,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
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() { | |||
@@ -4013,13 +4001,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
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 | |||
@@ -4068,14 +4051,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
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); | |||
@@ -6439,7 +6418,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
/** | |||
* Request delayed refresh of all body rows. | |||
* | |||
* | |||
* @since 8.1 | |||
*/ | |||
public void requestRefreshBody() { | |||
@@ -8209,13 +8188,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
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); | |||
@@ -8910,10 +8886,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
/* | |||
* 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(); | |||
@@ -8929,7 +8902,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, | |||
// off-by-one error which occurs when the user scrolls all the | |||
// way to the bottom. | |||
refreshBody(); | |||
} | |||
}); | |||
} | |||
@@ -317,118 +317,73 @@ public class EscalatorBasicClientFeaturesWidget | |||
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(); | |||
} | |||
@@ -447,77 +402,43 @@ public class EscalatorBasicClientFeaturesWidget | |||
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() { | |||
@@ -534,124 +455,71 @@ public class EscalatorBasicClientFeaturesWidget | |||
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); | |||
} | |||
@@ -685,10 +553,8 @@ public class EscalatorBasicClientFeaturesWidget | |||
} | |||
}, 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()); | |||
@@ -698,9 +564,7 @@ public class EscalatorBasicClientFeaturesWidget | |||
public void destroy(Spacer spacer) { | |||
spacer.getElement().removeAllChildren(); | |||
} | |||
}); | |||
} | |||
}, menupath); | |||
}), menupath); | |||
createSpacersMenuForRow(-1, menupath); | |||
createSpacersMenuForRow(1, menupath); | |||
@@ -711,38 +575,17 @@ public class EscalatorBasicClientFeaturesWidget | |||
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, |