Search in sources :

Example 71 with ScheduledCommand

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

the class WorkbenchScreen method prefetch.

private void prefetch() {
    final SerializedCommandQueue prefetchQueue = new SerializedCommandQueue();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            onPaneSizesChanged();
        }
    });
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            for (final WorkbenchTab tab : paneManager_.getAllTabs()) prefetchQueue.addCommand(new SerializedCommand() {

                public void onExecute(Command continuation) {
                    tab.prefetch(continuation);
                }
            });
            prefetchQueue.addCommand(new SerializedCommand() {

                public void onExecute(Command continuation) {
                    ApplicationEndedPopupPanel.prefetch(continuation);
                }
            });
            prefetchQueue.addCommand(new SerializedCommand() {

                public void onExecute(Command continuation) {
                    edit_.forceLoad(true, continuation);
                }
            });
            prefetchQueue.addCommand(new SerializedCommand() {

                public void onExecute(Command continuation) {
                    optionsLoader_.forceLoad(true, continuation);
                }
            });
        }
    });
}
Also used : SerializedCommand(org.rstudio.core.client.SerializedCommand) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SerializedCommand(org.rstudio.core.client.SerializedCommand) Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) TimeBufferedCommand(org.rstudio.core.client.TimeBufferedCommand) SerializedCommandQueue(org.rstudio.core.client.SerializedCommandQueue)

Example 72 with ScheduledCommand

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

the class HelpPane method onLoad.

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

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

Example 73 with ScheduledCommand

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

the class HelpPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    toolbar.addLeftPopupMenu(title_ = new Label(), history_.getMenu());
    if (isFindSupported()) {
        final SmallButton btnNext = new SmallButton(">", true);
        btnNext.setTitle("Find next (Enter)");
        btnNext.setVisible(false);
        btnNext.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findNext();
            }
        });
        final SmallButton btnPrev = new SmallButton("<", true);
        btnPrev.setTitle("Find previous");
        btnPrev.setVisible(false);
        btnPrev.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findPrev();
            }
        });
        findTextBox_ = new FindTextBox("Find in Topic");
        findTextBox_.setOverrideWidth(90);
        toolbar.addLeftWidget(findTextBox_);
        findTextBox_.addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                // ignore modifier key release
                if (event.getNativeKeyCode() == KeyCodes.KEY_CTRL || event.getNativeKeyCode() == KeyCodes.KEY_ALT || event.getNativeKeyCode() == KeyCodes.KEY_SHIFT) {
                    return;
                }
                WindowEx contentWindow = getContentWindow();
                if (contentWindow != null) {
                    // into the main content window
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                        event.preventDefault();
                        event.stopPropagation();
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE)
                            clearTerm();
                        contentWindow.focus();
                    } else {
                        // minimizing or maximizing the help pane
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                        // check for term
                        String term = findTextBox_.getValue().trim();
                        int modifier = KeyboardShortcut.getModifierValue(event.getNativeEvent());
                        boolean isShift = modifier == KeyboardShortcut.SHIFT;
                        // if there is a term then search for it
                        if (term.length() > 0) {
                            // make buttons visible
                            setButtonVisibility(true);
                            // perform the find (check for incremental)
                            if (isIncrementalFindSupported()) {
                                boolean incremental = !event.isAnyModifierKeyDown() && (event.getNativeKeyCode() != KeyCodes.KEY_ENTER);
                                performFind(term, !isShift, incremental);
                            } else {
                                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                                    performFind(term, !isShift, false);
                            }
                        } else // no term means clear term and remove selection
                        {
                            if (isIncrementalFindSupported()) {
                                clearTerm();
                                contentWindow.removeSelection();
                            }
                        }
                    }
                }
            }

            private void clearTerm() {
                findTextBox_.setValue("");
                setButtonVisibility(false);
            }

            private void setButtonVisibility(final boolean visible) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        btnNext.setVisible(visible);
                        btnPrev.setVisible(visible);
                    }
                });
            }
        });
        findTextBox_.addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                // from handling them
                if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB || event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    event.preventDefault();
                    event.stopPropagation();
                }
            }
        });
        if (isIncrementalFindSupported()) {
            btnPrev.getElement().getStyle().setMarginRight(3, Unit.PX);
            toolbar.addLeftWidget(btnPrev);
            toolbar.addLeftWidget(btnNext);
        }
    }
    return toolbar;
}
Also used : KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) NativeKeyDownEvent(org.rstudio.core.client.events.NativeKeyDownEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SmallButton(org.rstudio.core.client.widget.SmallButton) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar) WindowEx(org.rstudio.core.client.dom.WindowEx) FindTextBox(org.rstudio.core.client.widget.FindTextBox)

Example 74 with ScheduledCommand

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

the class FilesList method redraw.

public void redraw() {
    onResize();
    // deferred to ensure that browser has responded to our
    // resize request
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

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

Example 75 with ScheduledCommand

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

the class HistoryPane method onSelected.

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

        @Override
        public void execute() {
            recentScrollPanel_.restoreScrollPosition();
        }
    });
}
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