Search in sources :

Example 6 with Operation

use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.

the class WebWindowOpener method openWindowInternal.

private void openWindowInternal(GlobalDisplay globalDisplay, final String url, NewWindowOptions options, final String features, final int width, final int height) {
    String name = options.getName();
    final boolean focus = options.isFocus();
    final OperationWithInput<WindowEx> openOperation = options.getCallback();
    if (name == null)
        name = "_blank";
    if (!name.equals("_blank") && !name.equals("_top") && !name.equals("_parent") && !name.equals("_self")) {
        name += "_" + clientId;
    }
    // Need to make the URL absolute because IE resolves relative URLs
    // against the JavaScript file location, not the window.location like
    // the other browsers do
    final String absUrl = Pattern.create("^/|([a-zA-Z]+:)").match(url, 0) == null ? GWT.getHostPageBaseURL() + url : url;
    final String finalName = name;
    WindowEx window = doOpenWindow(absUrl, finalName, features, focus);
    if (window == null) {
        if (showPopupBlockedMessage()) {
            globalDisplay.showPopupBlockedMessage(new Operation() {

                public void execute() {
                    WindowEx window = doOpenWindow(absUrl, finalName, features, focus);
                    if (window != null) {
                        if (openOperation != null)
                            openOperation.execute(window);
                    }
                }
            });
        }
    } else {
        if (openOperation != null)
            openOperation.execute(window);
    }
}
Also used : Operation(org.rstudio.core.client.widget.Operation) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 7 with Operation

use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.

the class Packages method doUpdatePackages.

private void doUpdatePackages(final PackageInstallContext installContext) {
    new CheckForUpdatesDialog(globalDisplay_, new ServerDataSource<JsArray<PackageUpdate>>() {

        public void requestData(ServerRequestCallback<JsArray<PackageUpdate>> requestCallback) {
            server_.checkForPackageUpdates(requestCallback);
        }
    }, new OperationWithInput<ArrayList<PackageUpdate>>() {

        @Override
        public void execute(ArrayList<PackageUpdate> updates) {
            InstallCommand cmd = buildUpdatePackagesCommand(updates, installContext);
            executeWithLoadedPackageCheck(cmd);
        }
    }, new Operation() {

        @Override
        public void execute() {
            // cancel emits an empty console input line to clear
            // the busy indicator
            events_.fireEvent(new SendToConsoleEvent("", true));
        }
    }).showModal();
}
Also used : ServerDataSource(org.rstudio.studio.client.server.ServerDataSource) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) OperationWithInput(org.rstudio.core.client.widget.OperationWithInput) ArrayList(java.util.ArrayList) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) PackageUpdate(org.rstudio.studio.client.workbench.views.packages.model.PackageUpdate) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) CheckForUpdatesDialog(org.rstudio.studio.client.workbench.views.packages.ui.CheckForUpdatesDialog) Operation(org.rstudio.core.client.widget.Operation)

Example 8 with Operation

use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.

the class Packages method restartForInstallWithConfirmation.

private void restartForInstallWithConfirmation(final String installCmd) {
    String msg = "One or more of the packages that will be updated by this " + "installation are currently loaded. Restarting R prior " + "to updating these packages is strongly recommended.\n\n" + "RStudio can restart R and then automatically continue " + "the installation after restarting (all work and " + "data will be preserved during the restart).\n\n" + "Do you want to restart R prior to installing?";
    final boolean haveInstallCmd = installCmd.startsWith("install.packages");
    globalDisplay_.showYesNoMessage(MessageDialog.WARNING, "Updating Loaded Packages", msg, true, new Operation() {

        public void execute() {
            events_.fireEvent(new SuspendAndRestartEvent(SuspendOptions.createSaveAll(true), installCmd));
        }
    }, new Operation() {

        public void execute() {
            server_.ignoreNextLoadedPackageCheck(new VoidServerRequestCallback() {

                @Override
                public void onSuccess() {
                    if (haveInstallCmd)
                        executePkgCommand(installCmd);
                }
            });
        }
    }, true);
}
Also used : VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Operation(org.rstudio.core.client.widget.Operation) SuspendAndRestartEvent(org.rstudio.studio.client.application.events.SuspendAndRestartEvent)

Example 9 with Operation

use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.

the class FilesUpload method completeFileUploadOperation.

private Operation completeFileUploadOperation(final FileUploadToken token, final boolean commit) {
    return new Operation() {

        public void execute() {
            String msg = (commit ? "Completing" : "Cancelling") + " file upload...";
            final Command dismissProgress = globalDisplay_.showProgress(msg);
            server_.completeUpload(token, commit, new ServerRequestCallback<Void>() {

                @Override
                public void onResponseReceived(Void response) {
                    dismissProgress.execute();
                }

                @Override
                public void onError(ServerError error) {
                    dismissProgress.execute();
                    globalDisplay_.showErrorMessage("File Upload Error", error.getUserMessage());
                }
            });
        }
    };
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError) Operation(org.rstudio.core.client.widget.Operation) Void(org.rstudio.studio.client.server.Void)

Example 10 with Operation

use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.

the class Application method go.

public void go(final RootLayoutPanel rootPanel, final Command dismissLoadingProgress) {
    Widget w = view_.getWidget();
    rootPanel.add(w);
    rootPanel.setWidgetTopBottom(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
    rootPanel.setWidgetLeftRight(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
    // attempt init
    pClientInit_.get().execute(new ServerRequestCallback<SessionInfo>() {

        public void onResponseReceived(final SessionInfo sessionInfo) {
            // initialize workbench after verifying agreement
            verifyAgreement(sessionInfo, new Operation() {

                public void execute() {
                    // directly to the user
                    if (ApplicationAction.isSwitchProject()) {
                        new Timer() {

                            @Override
                            public void run() {
                                dismissLoadingProgress.execute();
                            }
                        }.schedule(10000);
                    } else {
                        dismissLoadingProgress.execute();
                    }
                    session_.setSessionInfo(sessionInfo);
                    // initialize workbench
                    initializeWorkbench();
                }
            });
        }

        public void onError(ServerError error) {
            Debug.logError(error);
            dismissLoadingProgress.execute();
            globalDisplay_.showErrorMessage("RStudio Initialization Error", error.getUserMessage());
        }
    });
}
Also used : Timer(com.google.gwt.user.client.Timer) Widget(com.google.gwt.user.client.ui.Widget) InvalidSessionInfo(org.rstudio.studio.client.application.model.InvalidSessionInfo) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) Operation(org.rstudio.core.client.widget.Operation)

Aggregations

Operation (org.rstudio.core.client.widget.Operation)47 ServerError (org.rstudio.studio.client.server.ServerError)8 Command (com.google.gwt.user.client.Command)7 ArrayList (java.util.ArrayList)6 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)5 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)5 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)4 SimpleRequestCallback (org.rstudio.studio.client.common.SimpleRequestCallback)4 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 Timer (com.google.gwt.user.client.Timer)2 HTML (com.google.gwt.user.client.ui.HTML)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 WindowEx (org.rstudio.core.client.dom.WindowEx)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2