]> source.dussan.org Git - vaadin-framework.git/commitdiff
Scheduler.ScheduledCommand and RepeatingCommand to be lambda (#10203)
authorAhmed Ashour <asashour@yahoo.com>
Fri, 20 Oct 2017 07:01:39 +0000 (09:01 +0200)
committerPéter Török <31210544+torok-peter@users.noreply.github.com>
Fri, 20 Oct 2017 07:01:39 +0000 (10:01 +0300)
* Scheduler.ScheduledCommand and RepeatingCommand to be lambda

* Restore <table> in javadoc

* Fix docs

29 files changed:
client/src/main/java/com/vaadin/client/ApplicationConfiguration.java
client/src/main/java/com/vaadin/client/VSchedulerImpl.java
client/src/main/java/com/vaadin/client/VUIDLBrowser.java
client/src/main/java/com/vaadin/client/WidgetUtil.java
client/src/main/java/com/vaadin/client/communication/DefaultReconnectDialog.java
client/src/main/java/com/vaadin/client/communication/MessageHandler.java
client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java
client/src/main/java/com/vaadin/client/connectors/grid/DetailsManagerConnector.java
client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java
client/src/main/java/com/vaadin/client/debug/internal/VDebugWindow.java
client/src/main/java/com/vaadin/client/ui/FocusableScrollPanel.java
client/src/main/java/com/vaadin/client/ui/ImageIcon.java
client/src/main/java/com/vaadin/client/ui/VComboBox.java
client/src/main/java/com/vaadin/client/ui/VContextMenu.java
client/src/main/java/com/vaadin/client/ui/VMenuBar.java
client/src/main/java/com/vaadin/client/ui/VPopupView.java
client/src/main/java/com/vaadin/client/ui/VSlider.java
client/src/main/java/com/vaadin/client/ui/VTabsheet.java
client/src/main/java/com/vaadin/client/ui/VUI.java
client/src/main/java/com/vaadin/client/ui/VUpload.java
client/src/main/java/com/vaadin/client/ui/VWindow.java
client/src/main/java/com/vaadin/client/ui/dd/VDragAndDropManager.java
client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/ui/UIConnector.java
client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java
client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java
client/src/main/java/com/vaadin/client/widgets/Escalator.java
client/src/main/java/com/vaadin/client/widgets/Grid.java
uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java

index 9c3bc4d2ffbf42330a57d125a6d8e910afe8ecbd..f36a181dd21ce84323f42293c784db7efab7a50b 100644 (file)
@@ -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();
         });
     }
 
index 155487d7216143c85ecd3065baf2c02573fdf101..21425147354bdc23961121b49e8a15769de84a85 100644 (file)
@@ -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;
     }
 }
index 7068f7c7901fc8c8043a4df02f9711a3da011ee5..eaf0503fa0f205715258e0971a42e85b2bb4ce59 100644 (file)
@@ -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());
             }
         }
     }
index 56f8a1273b993755d9947303a47ad79140bdbacb..7d54ac7650bdc40ac553c3d21425b425c86167e3 100644 (file)
@@ -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;
         }
     }-*/;
index 0f8c1a1dc123565c75824bf37a16445169cf0609..4026796e0d0cdeb5b1a6854efecb333c62532b82 100644 (file)
@@ -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();
         });
     }
 }
index f1354f4a92d68d055aa05f057b32e6107d51f663..6fea01af69fae0eb2f5ac1e8d527119742f92294 100644 (file)
@@ -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();
                     });
                 }
             }
index 1460b978aca681f43086b6e994ac1683c75f81e3..fc66d8a502eae25243ca57a9cd5495f189a48462 100644 (file)
@@ -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();
     };
 
     /**
index b8889591dade6af0720573d4fc34fe260bb3542c..973a3df09a7149a80fe91316d6d9fddf012fbe35 100644 (file)
@@ -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);
                 }
             };
         }
index 20de99cef0e4834d3122ea0536e46e562e3ec9ef..dfe9036d1a5a7e0edc8fa7a1ccfbc5928366ab33 100644 (file)
@@ -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<>();
index aff8e5d2684cdad92cb189c783043388c0072742..7ac67d349a4c1fc7df5d31a293b710460a3853e8 100644 (file)
@@ -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);
+                        }
+                    });
         });
     }
 
index 9ec6c0ee2feb46b989f603d3b1c2d1c834c011ef..3b02145b0fae542f3cb815c273cb00e216eca3a3 100644 (file)
@@ -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();
     }
 
 }
index 7248ff754ecd113fb607d606f3529e283c7e9d23..cca477a131eef4f4ebe516012ece32662f13a8b5 100644 (file)
@@ -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);
index b28c5cb5181c8d3e8a32c3f2d30953d1333e806e..683f04a942037a58c086d90f58829fbbd46e5a90 100644 (file)
@@ -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);
                     }
                 });
 
index d9feb6193f8bb18557244492eaa831f6df9e2440..7d2f718566f16c78874df94d759ff66692feefc4 100644 (file)
@@ -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
index 0b8713947856fa57c0fbc44bc0c42a6068fe4141..607128c43c6639c2510c41659e4a336de6a538b1 100644 (file)
@@ -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;
index 7686703925cde788910258e8481233cf58ccf84b..8185bb06cda22e5893503eade816b5693a9ea90b 100644 (file)
@@ -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;
                 }
             });
         }
index e0676139236e9695713ed39e844050219e916a5c..22c681d5c2eab41adf8dd3ad6dd0f5b352a3edd2 100644 (file)
@@ -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();
index f5e137f6e46eded187d27e26f2f453aa6c4f5eee..c2cbd626e8d10f96db084cfd861438833c2c89ff 100644 (file)
@@ -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) {
index cf5de33866788a09b634e9c18fae2c65d92141dc..8fa0308df4bd240972e77c229ec963ec91a6aa29 100644 (file)
@@ -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;
 
index dd4c2954927f5ad2bfad9929f5a3a39fd7e9c021..5d78a68011f49261e1df82c872ae24fd36ca6fff 100644 (file)
@@ -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. */
index df2c4b17f37c9152f7fd237c6252552fcf0e10f4..8ac90386c756278dba296fc0901e3df4e1e6179f 100644 (file)
@@ -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
index e3b0f11a0d845431ebdc5c24cd6fb10de77e2d74..f1b2e3736ac1bdb74bbbdfd06e90e2119791c81d 100644 (file)
@@ -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(
index e111d4993e74512eadb002942099774efb31e495..3e8fc0eb8f8ae39762252f67b502c2350916e126 100644 (file)
@@ -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();
         }
index 597dca83c228aa197caa4477bb679528528d78ad..b502b89135a4e6f8da518ab35ae6b321a5a6dd68 100644 (file)
@@ -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());
         }
     }
 
index dc8d30e5175b4a70209620545d3c8a60643c2813..4159ef107855792f84a3df83cc48e11db95bdb2e 100644 (file)
@@ -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);
     }
index db80553b872f7c37fe1c56bd241b064f19a13c8b..bb1686ae8389abd220b12899c3c48f9f8a9554d9 100644 (file)
@@ -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;
index de4afcf2e1545065160c9f505e46b954c7b60be2..a85a16ab636e56a9690ccd6ac1bfe946b1414a0b 100644 (file)
@@ -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);
         });
     }
 
index e51d8d57fc9f88388c2097c938d7b691d27c0dd1..3d3a8b805b7625cf51a1f2bc7f2fcb6d8398de96 100755 (executable)
@@ -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();
-            }
         });
     }
 
index 77f9a18dd48dc8e6c38d0693f29485e4da13e833..2d7dd5cc370ddecf17f9c88637bfdf271027c667 100644 (file)
@@ -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,