Search in sources :

Example 21 with Command

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

the class Source method revertUnsavedTargets.

private void revertUnsavedTargets(Command onCompleted) {
    // collect up unsaved targets
    ArrayList<EditingTarget> unsavedTargets = new ArrayList<EditingTarget>();
    for (EditingTarget target : editors_) if (isUnsavedTarget(target, TYPE_FILE_BACKED))
        unsavedTargets.add(target);
    // revert all of them
    cpsExecuteForEachEditor(// targets the user chose not to save
    unsavedTargets, // save each editor
    new CPSEditingTargetCommand() {

        @Override
        public void execute(EditingTarget saveTarget, Command continuation) {
            if (saveTarget.getPath() != null) {
                // file backed document -- revert it
                saveTarget.revertChanges(continuation);
            } else {
                // untitled document -- just close the tab non-interactively
                view_.closeTab(saveTarget.asWidget(), false, continuation);
            }
        }
    }, // onCompleted at the end
    onCompleted);
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ArrayList(java.util.ArrayList) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)

Example 22 with Command

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

the class SourceWindowManager method handleUnsavedChangesBeforeExit.

public void handleUnsavedChangesBeforeExit(ArrayList<UnsavedChangesTarget> targets, Command onCompleted) {
    // accumulate the unsaved change targets that represent satellite windows
    final JsArray<UnsavedChangesItem> items = JsArray.createArray().cast();
    for (UnsavedChangesTarget target : targets) {
        if (target instanceof UnsavedChangesItem) {
            items.push((UnsavedChangesItem) target);
        }
    }
    // let each window have a crack at saving the targets (the windows will
    // discard any targets they don't own)
    doForAllSourceWindows(new SourceWindowCommand() {

        @Override
        public void execute(String windowId, WindowEx window, Command continuation) {
            handleUnsavedChangesBeforeExit(window, items, continuation);
        }
    }, onCompleted);
}
Also used : UnsavedChangesItem(org.rstudio.studio.client.workbench.model.UnsavedChangesItem) UnsavedChangesTarget(org.rstudio.studio.client.workbench.model.UnsavedChangesTarget) Command(com.google.gwt.user.client.Command) JsArrayString(com.google.gwt.core.client.JsArrayString) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 23 with Command

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

the class RStudio method onModuleLoad.

public void onModuleLoad() {
    Debug.injectDebug();
    Document.get().getBody().getStyle().setBackgroundColor("#e1e2e5");
    Command dismissProgressAnimation = showProgress();
    delayLoadApplication(dismissProgressAnimation);
}
Also used : Command(com.google.gwt.user.client.Command)

Example 24 with Command

use of com.google.gwt.user.client.Command 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 25 with Command

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

the class SlideLabel method show.

public static void show(String label, boolean asHtml, boolean showProgressSpinner, int autoHideMillis, final LayoutPanel panel) {
    final SlideLabel slideLabel = showInternal(label, asHtml, showProgressSpinner, panel);
    slideLabel.show(autoHideMillis, new Command() {

        public void execute() {
            panel.remove(slideLabel);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command)

Aggregations

Command (com.google.gwt.user.client.Command)208 AppCommand (org.rstudio.core.client.command.AppCommand)39 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)38 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)21 JsArrayString (com.google.gwt.core.client.JsArrayString)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)16 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)16 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)12 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)11 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)11 ServerError (org.rstudio.studio.client.server.ServerError)11 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)9 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)9 MenuItem (com.google.gwt.user.client.ui.MenuItem)8 Handler (org.rstudio.core.client.command.Handler)8 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)8 Timer (com.google.gwt.user.client.Timer)7 Widget (com.google.gwt.user.client.ui.Widget)7 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)7