Search in sources :

Example 66 with ScheduledCommand

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

the class DesktopApplicationHeader method initialize.

@Inject
public void initialize(final Commands commands, EventBus events, final Session session, ApplicationServerOperations server, Provider<DesktopHooks> pDesktopHooks, Provider<CodeSearch> pCodeSearch, Provider<UIPrefs> pUIPrefs, ErrorManager errorManager, GlobalDisplay globalDisplay, ApplicationQuit appQuit) {
    session_ = session;
    eventBus_ = events;
    pUIPrefs_ = pUIPrefs;
    globalDisplay_ = globalDisplay;
    ignoredUpdates_ = IgnoredUpdates.create();
    server_ = server;
    appQuit_ = appQuit;
    binder_.bind(commands, this);
    commands.mainMenu(new DesktopMenuCallback());
    pDesktopHooks.get();
    commands.uploadFile().remove();
    commands.exportFiles().remove();
    commands.updateCredentials().remove();
    commands.checkForUpdates().setVisible(true);
    commands.showLogFiles().setVisible(true);
    commands.diagnosticsReport().setVisible(true);
    commands.showFolder().setVisible(true);
    events.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {

        public void onSessionInit(SessionInitEvent sie) {
            final SessionInfo sessionInfo = session.getSessionInfo();
            toolbar_.completeInitialization(sessionInfo);
            new JSObjectStateValue("updates", "ignoredUpdates", ClientState.PERSISTENT, session_.getSessionInfo().getClientState(), false) {

                @Override
                protected void onInit(JsObject value) {
                    if (value != null)
                        ignoredUpdates_ = value.cast();
                }

                @Override
                protected JsObject getValue() {
                    ignoredUpdatesDirty_ = false;
                    return ignoredUpdates_.cast();
                }

                @Override
                protected boolean hasChanged() {
                    return ignoredUpdatesDirty_;
                }
            };
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                public void execute() {
                    Desktop.getFrame().onWorkbenchInitialized(sessionInfo.getScratchDir());
                    if (sessionInfo.getDisableCheckForUpdates())
                        commands.checkForUpdates().remove();
                    if (!sessionInfo.getDisableCheckForUpdates() && pUIPrefs_.get().checkForUpdates().getValue()) {
                        checkForUpdates(false);
                    }
                }
            });
        }
    });
    events.addHandler(ShowFolderEvent.TYPE, new ShowFolderHandler() {

        public void onShowFolder(ShowFolderEvent event) {
            Desktop.getFrame().showFolder(event.getPath().getPath());
        }
    });
    toolbar_ = new GlobalToolbar(commands, events, pCodeSearch);
    ThemeStyles styles = ThemeResources.INSTANCE.themeStyles();
    toolbar_.addStyleName(styles.desktopGlobalToolbar());
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) SessionInitEvent(org.rstudio.studio.client.workbench.events.SessionInitEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) DesktopMenuCallback(org.rstudio.core.client.command.impl.DesktopMenuCallback) ShowFolderEvent(org.rstudio.studio.client.workbench.views.files.events.ShowFolderEvent) GlobalToolbar(org.rstudio.studio.client.application.ui.GlobalToolbar) ThemeStyles(org.rstudio.core.client.theme.res.ThemeStyles) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) SessionInitHandler(org.rstudio.studio.client.workbench.events.SessionInitHandler) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue) ShowFolderHandler(org.rstudio.studio.client.workbench.views.files.events.ShowFolderHandler) Inject(com.google.inject.Inject)

Example 67 with ScheduledCommand

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

the class ShellWidget method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    if (!initialized_) {
        initialized_ = true;
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            public void execute() {
                doOnLoad();
                scrollPanel_.scrollToBottom();
            }
        });
    }
    ElementIds.assignElementId(this.getElement(), ElementIds.SHELL_WIDGET);
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 68 with ScheduledCommand

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

the class RmdOutput method displayHTMLRenderResult.

private void displayHTMLRenderResult(RmdRenderResult result) {
    // find the last known position for this file
    int scrollPosition = 0;
    String anchor = "";
    if (scrollPositions_.containsKey(keyFromResult(result))) {
        scrollPosition = scrollPositions_.get(keyFromResult(result));
    }
    if (anchors_.containsKey(keyFromResult(result))) {
        anchor = anchors_.get(keyFromResult(result));
    }
    final RmdPreviewParams params = RmdPreviewParams.create(result, scrollPosition, anchor);
    // get the default viewer type from prefs
    int viewerType = prefs_.rmdViewerType().getValue();
    // apply override from result, if any
    if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_VIEWER)
        viewerType = RMD_VIEWER_TYPE_PANE;
    else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_WINDOW)
        viewerType = RMD_VIEWER_TYPE_WINDOW;
    else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_NONE)
        viewerType = RMD_VIEWER_TYPE_NONE;
    // slides well without help
    if (result.isHtmlPresentation() && viewerType == RMD_VIEWER_TYPE_PANE)
        viewerType = RMD_VIEWER_TYPE_WINDOW;
    final int newViewerType = viewerType;
    // we don't disturb the publish flow with a window popping up
    if (newViewerType == RMD_VIEWER_TYPE_WINDOW && RSConnectPublishButton.isAnyRmdRenderPending()) {
        return;
    }
    // get the window object if available
    WindowEx win = null;
    boolean needsReopen = false;
    if (outputFrame_ != null) {
        win = outputFrame_.getWindowObject();
        if (outputFrame_.getViewerType() != newViewerType)
            needsReopen = true;
    }
    // close it so that we can create a new one better suited to this doc type
    if (needsReopen || (win != null && result_ != null && !result_.getFormatName().equals(result.getFormatName()))) {
        outputFrame_.closeOutputFrame(false);
        outputFrame_ = null;
        win = null;
        // let window finish closing before continuing
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                displayRenderResult(null, newViewerType, params);
            }
        });
    } else {
        displayRenderResult(win, newViewerType, params);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) WindowEx(org.rstudio.core.client.dom.WindowEx) RmdPreviewParams(org.rstudio.studio.client.rmarkdown.model.RmdPreviewParams)

Example 69 with ScheduledCommand

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

the class MainSplitPanel method initialize.

public void initialize(Widget left, Widget right) {
    left_ = left;
    right_ = right;
    new JSObjectStateValue(GROUP_WORKBENCH, KEY_RIGHTPANESIZE, ClientState.PERSISTENT, session_.getSessionInfo().getClientState(), false) {

        @Override
        protected void onInit(JsObject value) {
            State state = value == null ? null : (State) value.cast();
            if (state != null && state.hasSplitterPos()) {
                if (state.hasPanelWidth() && state.hasWindowWidth() && state.getWindowWidth() != Window.getClientWidth()) {
                    int delta = state.getWindowWidth() - state.getPanelWidth();
                    int offsetWidth = Window.getClientWidth() - delta;
                    double pct = (double) state.getSplitterPos() / state.getPanelWidth();
                    addEast(right_, pct * offsetWidth);
                } else {
                    addEast(right_, state.getSplitterPos());
                }
            } else {
                addEast(right_, Window.getClientWidth() * 0.45);
            }
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {
                    enforceBoundaries();
                }
            });
        }

        @Override
        protected JsObject getValue() {
            State state = JavaScriptObject.createObject().cast();
            state.setPanelWidth(getOffsetWidth());
            state.setWindowWidth(Window.getClientWidth());
            state.setSplitterPos(right_.getOffsetWidth());
            return state.cast();
        }

        @Override
        protected boolean hasChanged() {
            JsObject newValue = getValue();
            if (!State.equals(lastKnownValue_, (State) newValue.cast())) {
                lastKnownValue_ = newValue.cast();
                return true;
            }
            return false;
        }

        private State lastKnownValue_;
    };
    add(left);
    setWidgetMinSize(right_, 0);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ClientState(org.rstudio.studio.client.workbench.model.ClientState) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)

Example 70 with ScheduledCommand

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

the class Shell method onConsoleClear.

@Handler
void onConsoleClear() {
    // clear output
    view_.clearOutput();
    // notify server
    server_.resetConsoleActions(new VoidServerRequestCallback());
    // if we don't bounce setFocus the menu retains focus
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            view_.getInputEditorDisplay().setFocus(true);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Handler(org.rstudio.core.client.command.Handler)

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