Search in sources :

Example 16 with Timer

use of com.google.gwt.user.client.Timer in project rstudio by rstudio.

the class Console method activateConsole.

private void activateConsole(boolean focusWindow) {
    // ensure we don't leave focus in the console
    final FocusContext focusContext = new FocusContext();
    if (!focusWindow)
        focusContext.record();
    if (focusWindow)
        WindowEx.get().focus();
    view_.bringToFront();
    view_.focus();
    view_.ensureCursorVisible();
    // if that's what the caller requested.
    if (!focusWindow) {
        new Timer() {

            @Override
            public void run() {
                focusContext.restore();
            }
        }.schedule(100);
    }
}
Also used : Timer(com.google.gwt.user.client.Timer) FocusContext(org.rstudio.core.client.widget.FocusContext)

Example 17 with Timer

use of com.google.gwt.user.client.Timer in project rstudio by rstudio.

the class MathJax method onMathJaxTypesetCompleted.

private void onMathJaxTypesetCompleted(final Object mathjaxElObject, final String text, final boolean error, final Object commandObject, final int attempt) {
    final Element mathjaxEl = (Element) mathjaxElObject;
    if (attempt < MAX_RENDER_ATTEMPTS) {
        // if mathjax displayed an error, try re-rendering once more
        Element[] errorEls = DomUtils.getElementsByClassName(mathjaxEl, "MathJax_Error");
        if (errorEls != null && errorEls.length > 0 && attempt < MAX_RENDER_ATTEMPTS) {
            // hide the error and retry in 25ms (experimentally this seems to
            // produce a better shot at rendering successfully than an immediate
            // or deferred retry)
            mathjaxEl.getStyle().setVisibility(Visibility.HIDDEN);
            new Timer() {

                @Override
                public void run() {
                    mathjaxTypeset(mathjaxEl, text, commandObject, attempt + 1);
                }
            }.schedule(25);
            return;
        }
    }
    // show whatever we've got (could be an error if we ran out of retries)
    mathjaxEl.getStyle().setVisibility(Visibility.VISIBLE);
    // execute callback
    if (commandObject != null && commandObject instanceof MathJaxTypesetCallback) {
        MathJaxTypesetCallback callback = (MathJaxTypesetCallback) commandObject;
        callback.onMathJaxTypesetComplete(error);
    }
    if (!error) {
        lastRenderedText_ = text;
    }
}
Also used : Timer(com.google.gwt.user.client.Timer) Element(com.google.gwt.dom.client.Element)

Example 18 with Timer

use of com.google.gwt.user.client.Timer in project rstudio by rstudio.

the class LocatorPanel method showFeedbackAt.

private void showFeedbackAt(Point p) {
    cancelFeedback();
    setWidgetTopHeight(feedbackImage_, p.getY() - FB_OFFSET_Y, Unit.PX, FB_HEIGHT, Unit.PX);
    setWidgetLeftWidth(feedbackImage_, p.getX() - FB_OFFSET_X, Unit.PX, FB_WIDTH, Unit.PX);
    forceLayout();
    feedbackImage_.setVisible(true);
    feedbackImage_.getElement().getStyle().setOpacity(1.0);
    feedbackTimer_ = new Timer() {

        @Override
        public void run() {
            feedbackTimer_ = null;
            ArrayList<Widget> widgets = new ArrayList<Widget>();
            widgets.add(feedbackImage_);
            feedbackAnimation_ = new FadeOutAnimation(widgets, new Command() {

                public void execute() {
                    feedbackAnimation_ = null;
                }
            });
            feedbackAnimation_.run(300);
        }
    };
    feedbackTimer_.schedule(700);
}
Also used : Timer(com.google.gwt.user.client.Timer) FadeOutAnimation(org.rstudio.core.client.layout.FadeOutAnimation) Command(com.google.gwt.user.client.Command) ArrayList(java.util.ArrayList)

Example 19 with Timer

use of com.google.gwt.user.client.Timer in project rstudio by rstudio.

the class EnvironmentObjects method setDeferredObjectDisplay.

private void setDeferredObjectDisplay() {
    if (deferredObjectDisplayType_ == null) {
        return;
    }
    final int type = deferredObjectDisplayType_;
    // if we already have an active display of this type, do nothing
    if (type == objectDisplayType_ && objectDisplay_ != null) {
        return;
    }
    // clean up previous object display, if we had one
    if (objectDisplay_ != null) {
        objectDataProvider_.removeDataDisplay(objectDisplay_);
        splitPanel.remove(objectDisplay_);
    }
    try {
        // create the new object display and wire it to the data source
        if (type == OBJECT_LIST_VIEW) {
            objectDisplay_ = new EnvironmentObjectList(this, observer_, environmentName_);
            objectSort_.setSortType(RObjectEntrySort.SORT_AUTO);
        } else if (type == OBJECT_GRID_VIEW) {
            objectDisplay_ = new EnvironmentObjectGrid(this, observer_, environmentName_);
            objectSort_.setSortType(RObjectEntrySort.SORT_COLUMN);
        }
    } catch (Throwable e) {
        if (SuperDevMode.isActive()) {
            if (gridRenderRetryCount_ >= 5) {
                Debug.log("WARNING: Failed to render environment pane data grid");
            }
            gridRenderRetryCount_++;
            Debug.log("WARNING: Retrying environment data grid render (" + gridRenderRetryCount_ + ")");
            Timer t = new Timer() {

                @Override
                public void run() {
                    setObjectDisplay(type);
                }
            };
            t.schedule(5);
        }
        return;
    }
    objectDisplayType_ = type;
    Collections.sort(objectDataProvider_.getList(), objectSort_);
    updateCategoryLeaders(false);
    objectDataProvider_.addDataDisplay(objectDisplay_);
    objectDisplay_.getScrollPanel().addScrollHandler(new ScrollHandler() {

        @Override
        public void onScroll(ScrollEvent event) {
            if (useStatePersistence()) {
                deferredScrollPosition_ = getScrollPosition();
                observer_.setPersistedScrollPosition(deferredScrollPosition_);
            }
        }
    });
    objectDisplay_.setEmptyTableWidget(buildEmptyGridMessage());
    objectDisplay_.addStyleName(style.objectGrid());
    objectDisplay_.addStyleName(style.environmentPanel());
    splitPanel.add(objectDisplay_);
    deferredObjectDisplayType_ = null;
}
Also used : ScrollHandler(com.google.gwt.event.dom.client.ScrollHandler) Timer(com.google.gwt.user.client.Timer) ScrollEvent(com.google.gwt.event.dom.client.ScrollEvent)

Example 20 with Timer

use of com.google.gwt.user.client.Timer in project rstudio by rstudio.

the class Application method reloadWindowWithDelay.

private void reloadWindowWithDelay(final boolean baseUrlOnly) {
    new Timer() {

        @Override
        public void run() {
            if (baseUrlOnly)
                Window.Location.replace(GWT.getHostPageBaseURL());
            else
                Window.Location.reload();
        }
    }.schedule(100);
}
Also used : Timer(com.google.gwt.user.client.Timer)

Aggregations

Timer (com.google.gwt.user.client.Timer)85 Command (com.google.gwt.user.client.Command)6 ServerError (org.rstudio.studio.client.server.ServerError)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 Element (com.google.gwt.dom.client.Element)3 SessionInfo (org.rstudio.studio.client.workbench.model.SessionInfo)3 Animation (com.google.gwt.animation.client.Animation)2 JsArray (com.google.gwt.core.client.JsArray)2 Style (com.google.gwt.dom.client.Style)2 Image (com.google.gwt.user.client.ui.Image)2 Label (com.google.gwt.user.client.ui.Label)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 Widget (com.google.gwt.user.client.ui.Widget)2 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)2 TimerTask (java.util.TimerTask)2 Operation (org.eclipse.che.api.promises.client.Operation)2 Operation (org.rstudio.core.client.widget.Operation)2 InvalidSessionInfo (org.rstudio.studio.client.application.model.InvalidSessionInfo)2 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)2 Optional (com.google.common.base.Optional)1