Search in sources :

Example 26 with Timer

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

the class DesktopHooks method evaluateRCmd.

void evaluateRCmd(final String cmd) {
    // inject a 100ms delay between execution of commands to prevent
    // issues with commands being delivered out of order by cocoa
    // networking to the server (it appears as if when you put e.g. 10
    // requests in flight simultaneously it's not guarnateed that they
    // will be received in the order they were sent).
    commandQueue_.addCommand(new SerializedCommand() {

        @Override
        public void onExecute(final Command continuation) {
            // execute the code
            events_.fireEvent(new SendToConsoleEvent(cmd, true));
            // wait 100ms to execute the next command in the queue
            new Timer() {

                @Override
                public void run() {
                    continuation.execute();
                }
            }.schedule(100);
            ;
        }
    });
    // make sure the queue is running
    commandQueue_.run();
}
Also used : SerializedCommand(org.rstudio.core.client.SerializedCommand) Timer(com.google.gwt.user.client.Timer) SerializedCommand(org.rstudio.core.client.SerializedCommand) AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)

Example 27 with Timer

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

the class ApplicationWindow method showSerializationProgress.

public void showSerializationProgress(String msg, boolean modal, int delayMs, int timeoutMs) {
    // hide any existing progress
    hideSerializationProgress();
    // create and show progress
    activeSerializationProgress_ = new ApplicationSerializationProgress(msg, modal, delayMs);
    // want to hide it)
    if (timeoutMs > 0) {
        final ApplicationSerializationProgress timeoutSerializationProgress = activeSerializationProgress_;
        new Timer() {

            @Override
            public void run() {
                if (timeoutSerializationProgress == activeSerializationProgress_)
                    hideSerializationProgress();
            }
        }.schedule(timeoutMs);
    }
}
Also used : Timer(com.google.gwt.user.client.Timer) ApplicationSerializationProgress(org.rstudio.studio.client.application.ui.serializationprogress.ApplicationSerializationProgress)

Example 28 with Timer

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

the class ChunkOutputWidget method toggleExpansionState.

private void toggleExpansionState(final boolean ensureVisible, final CommandWithArg<Boolean> onTransitionCompleted) {
    // (no simple way to gracefully reverse direction) 
    if (collapseTimer_ != null && collapseTimer_.isRunning())
        return;
    if (expansionState_.getValue() == EXPANDED) {
        // remove scrollbars
        frame_.getElement().getStyle().setProperty("transition", "height " + ANIMATION_DUR + "ms ease");
        setCollapsedStyles();
        collapseTimer_ = new Timer() {

            @Override
            public void run() {
                renderedHeight_ = ChunkOutputUi.CHUNK_COLLAPSED_HEIGHT;
                host_.onOutputHeightChanged(ChunkOutputWidget.this, renderedHeight_, ensureVisible);
                if (onTransitionCompleted != null)
                    onTransitionCompleted.execute(true);
            }
        };
        expansionState_.setValue(COLLAPSED, true);
    } else {
        clearCollapsedStyles();
        expansionState_.setValue(EXPANDED, true);
        syncHeight(true, ensureVisible);
        collapseTimer_ = new Timer() {

            @Override
            public void run() {
                syncHeight(true, ensureVisible);
                frame_.getElement().getStyle().clearProperty("transition");
                if (onTransitionCompleted != null)
                    onTransitionCompleted.execute(true);
            }
        };
    }
    collapseTimer_.schedule(ANIMATION_DUR);
}
Also used : Timer(com.google.gwt.user.client.Timer)

Example 29 with Timer

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

the class ChunkRowExecState method setState.

public void setState(int state) {
    // ignore if already at this state
    if (state_ == state)
        return;
    // if the moving to the error state, clean other states
    if (state == LINE_ERROR)
        removeClazz();
    // if this is the error state, there's no transition to the resting state
    if (state_ == LINE_ERROR && state == LINE_RESTING)
        return;
    state_ = state;
    if (state_ == LINE_RESTING) {
        timer_ = new Timer() {

            @Override
            public void run() {
                addClazz(state_);
                scheduleDismiss();
            }
        };
        timer_.schedule(LINGER_MS);
    } else {
        addClazz(state_);
    }
}
Also used : Timer(com.google.gwt.user.client.Timer)

Example 30 with Timer

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

the class ChunkRowExecState method scheduleDismiss.

private void scheduleDismiss() {
    resetTimer();
    timer_ = new Timer() {

        @Override
        public void run() {
            detach();
        }
    };
    timer_.schedule(FADE_MS);
}
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