Search in sources :

Example 61 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class DynamicIFrame method pollForLoad.

protected void pollForLoad() {
    // wait for the window object to become available
    final Scheduler.RepeatingCommand loadFrame = new Scheduler.RepeatingCommand() {

        @Override
        public boolean execute() {
            if (getIFrame() == null || getWindow() == null || getDocument() == null)
                return true;
            // URL refers to is fully loaded
            if (url_ != null && getDocument().getURL() == "about:blank" || getDocument().getBody() == null || getDocument().getReadyState() != DocumentEx.STATE_COMPLETE)
                return true;
            onFrameLoaded();
            return false;
        }
    };
    // defer an attempt to pull the window object; if it isn't successful, try
    // every 50ms
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            if (loadFrame.execute()) {
                Scheduler.get().scheduleFixedDelay(loadFrame, 50);
            }
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Scheduler(com.google.gwt.core.client.Scheduler)

Example 62 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class FileSystemDialog method showModal.

@Override
public void showModal() {
    super.showModal();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            center();
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 63 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class BinarySplitLayoutPanel method onAttach.

@Override
protected void onAttach() {
    super.onAttach();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            offsetHeight_ = getOffsetHeight();
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 64 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class SlideLabel method show.

public void show(final int autoHideMillis, final Command executeOnComplete) {
    assert autoHideMillis >= 0 || executeOnComplete == null : "Possible error: executeOnComplete will never be called with " + "negative value for autoHideMillis";
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            stopCurrentAnimation();
            currentAnimation_ = new Animation() {

                @Override
                protected void onStart() {
                    setVisible(true);
                    curtain_.setHeight("0px");
                    height = content_.getOffsetHeight() + 14 + 14;
                    super.onStart();
                }

                @Override
                protected void onUpdate(double progress) {
                    setHeight(height * progress);
                }

                @Override
                protected void onComplete() {
                    currentAnimation_ = null;
                    if (autoHideMillis >= 0) {
                        currentAutoHideTimer_ = new Timer() {

                            @Override
                            public void run() {
                                currentAutoHideTimer_ = null;
                                hide(executeOnComplete);
                            }
                        };
                        currentAutoHideTimer_.schedule(autoHideMillis);
                    }
                }

                private int height;
            };
            currentAnimation_.run(ANIM_MILLIS);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Timer(com.google.gwt.user.client.Timer) Animation(com.google.gwt.animation.client.Animation)

Example 65 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.

the class ToolbarButton method addMenuHandlers.

private void addMenuHandlers(final ToolbarPopupMenu popupMenu, final boolean rightAlign) {
    menu_ = popupMenu;
    /*
       * We want clicks on this button to toggle the visibility of the menu,
       * as well as having the menu auto-hide itself as it normally does.
       * It's necessary to manually track the visibility (menuShowing) because
       * in the case where the menu is showing, clicking on this button first
       * causes the menu to auto-hide and then our mouseDown handler is called
       * (so we can't rely on menu.isShowing(), it'll always be false by the
       * time you get into the mousedown handler).
       */
    final boolean[] menuShowing = new boolean[1];
    addMouseDownHandler(new MouseDownHandler() {

        public void onMouseDown(MouseDownEvent event) {
            event.preventDefault();
            event.stopPropagation();
            addStyleName(styles_.toolbarButtonPushed());
            // Some menus are rebuilt on every invocation. Ask the menu for 
            // the most up-to-date version before proceeding.
            popupMenu.getDynamicPopupMenu(new ToolbarPopupMenu.DynamicPopupMenuCallback() {

                @Override
                public void onPopupMenu(final ToolbarPopupMenu menu) {
                    if (menuShowing[0]) {
                        removeStyleName(styles_.toolbarButtonPushed());
                        menu.hide();
                    } else {
                        if (rightAlign) {
                            menu.setPopupPositionAndShow(new PositionCallback() {

                                @Override
                                public void setPosition(int offsetWidth, int offsetHeight) {
                                    menu.setPopupPosition((rightImageWidget_ != null ? rightImageWidget_.getAbsoluteLeft() : leftImageWidget_.getAbsoluteLeft()) + 20 - offsetWidth, ToolbarButton.this.getAbsoluteTop() + ToolbarButton.this.getOffsetHeight());
                                }
                            });
                        } else {
                            menu.showRelativeTo(ToolbarButton.this);
                        }
                        menuShowing[0] = true;
                    }
                }
            });
        }
    });
    popupMenu.addCloseHandler(new CloseHandler<PopupPanel>() {

        public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
            removeStyleName(styles_.toolbarButtonPushed());
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {
                    menuShowing[0] = false;
                }
            });
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)105 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)7 Element (com.google.gwt.dom.client.Element)6 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)6 JsArray (com.google.gwt.core.client.JsArray)5 Command (com.google.gwt.user.client.Command)5 ServerError (org.rstudio.studio.client.server.ServerError)5 JsArrayString (com.google.gwt.core.client.JsArrayString)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 Event (com.google.gwt.user.client.Event)3 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)3 Timer (com.google.gwt.user.client.Timer)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)3 ErrorDialog (com.google.gerrit.client.ErrorDialog)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2