Search in sources :

Example 46 with ScheduledCommand

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

the class RequestLogVisualization method onLoad.

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

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

Example 47 with ScheduledCommand

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

the class MathJax method renderLatexLineWidget.

private void renderLatexLineWidget(LineWidget widget, final Range range, final String text, final MathJaxTypesetCallback callback) {
    final Element el = DomUtils.getFirstElementWithClassName(widget.getElement(), MATHJAX_ROOT_CLASSNAME);
    // call 'onLineWidgetChanged' to ensure the widget is attached
    docDisplay_.onLineWidgetChanged(widget);
    // defer typesetting just to ensure that the widget has actually been
    // attached to the DOM
    final LineWidget lineWidget = widget;
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            mathjaxTypeset(el, text, new MathJaxTypesetCallback() {

                @Override
                public void onMathJaxTypesetComplete(final boolean error) {
                    // force expansion
                    withExpandedLineWidget(lineWidget, new CommandWithArg<Boolean>() {

                        @Override
                        public void execute(Boolean stateChanged) {
                            // re-position the element
                            int height = el.getOffsetHeight() + 30;
                            Element ppElement = el.getParentElement().getParentElement();
                            ppElement.getStyle().setHeight(height, Unit.PX);
                            docDisplay_.onLineWidgetChanged(lineWidget);
                            // invoke supplied callback
                            if (callback != null)
                                callback.onMathJaxTypesetComplete(error);
                        }
                    });
                }
            });
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Element(com.google.gwt.dom.client.Element) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget) LineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget)

Example 48 with ScheduledCommand

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

the class EnvironmentObjects method setObjectDisplay.

// Sets the object display type. Waits for the event loop to finish because
// of an apparent timing bug triggered by superdevmode (see case 3745).
public void setObjectDisplay(int type) {
    deferredObjectDisplayType_ = new Integer(type);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

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

Example 49 with ScheduledCommand

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

the class Files method initSession.

private void initSession() {
    final SessionInfo sessionInfo = session_.getSessionInfo();
    ClientInitState state = sessionInfo.getClientState();
    // make the column sort order persistent
    new JSObjectStateValue(MODULE_FILES, KEY_SORT_ORDER, ClientState.PROJECT_PERSISTENT, state, false) {

        @Override
        protected void onInit(JsObject value) {
            if (value != null)
                columnSortOrder_ = value.cast();
            else
                columnSortOrder_ = null;
            lastKnownState_ = columnSortOrder_;
            view_.setColumnSortOrder(columnSortOrder_);
        }

        @Override
        protected JsObject getValue() {
            if (columnSortOrder_ != null)
                return columnSortOrder_.cast();
            else
                return null;
        }

        @Override
        protected boolean hasChanged() {
            if (lastKnownState_ != columnSortOrder_) {
                lastKnownState_ = columnSortOrder_;
                return true;
            } else {
                return false;
            }
        }

        private JsArray<ColumnSortInfo> lastKnownState_ = null;
    };
    // navigate to previous directory (works for resumed case)
    new StringStateValue(MODULE_FILES, KEY_PATH, ClientState.PROJECT_PERSISTENT, state) {

        @Override
        protected void onInit(final String value) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {
                    // we don't need to initialize from client state
                    if (hasNavigatedToDirectory_)
                        return;
                    // compute start dir
                    String path = transformPathStateValue(value);
                    FileSystemItem start = path != null ? FileSystemItem.createDir(path) : FileSystemItem.createDir(sessionInfo.getInitialWorkingDir());
                    navigateToDirectory(start);
                }
            });
        }

        @Override
        protected String getValue() {
            return currentPath_.getPath();
        }

        private String transformPathStateValue(String value) {
            // if the value is null then return null
            if (value == null)
                return null;
            // only respect the value for projects
            String projectFile = session_.getSessionInfo().getActiveProjectFile();
            if (projectFile == null)
                return null;
            // ensure that the value is within the project dir (it wouldn't 
            // be if the project directory has been moved or renamed)
            String projectDirPath = FileSystemItem.createFile(projectFile).getParentPathString();
            if (value.startsWith(projectDirPath))
                return value;
            else
                return null;
        }
    };
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArray(com.google.gwt.core.client.JsArray) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) StringStateValue(org.rstudio.studio.client.workbench.model.helper.StringStateValue) ClientInitState(org.rstudio.studio.client.workbench.model.ClientInitState) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)

Example 50 with ScheduledCommand

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

the class HistoryPane method setRecentCommands.

public void setRecentCommands(ArrayList<HistoryEntry> entries, boolean scrollToBottom) {
    commandList_.clear();
    commandList_.addItems(entries, true);
    if (scrollToBottom) {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

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

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