Search in sources :

Example 61 with Command

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

the class PackagesPane method setActions.

@Override
public void setActions(ArrayList<Packages.Action> actions) {
    // command that manages the layout of the packages list and action center
    Command manageActionCenterLayout = new Command() {

        @Override
        public void execute() {
            resizeActionCenter();
        }
    };
    if (actions == null || actions.size() == 0) {
        if (actionCenter_ != null) {
            packagesTableContainer_.remove(actionCenter_);
            actionCenter_ = null;
            layoutPackagesTable();
            packagesTableContainer_.animate(ACTION_CENTER_ANIMATION_MS);
        }
    } else {
        // in a non-collapsed center, raise the packages pane
        if (actionCenter_ == null || ((!actionCenter_.collapsed()) && (actionCenter_.getActionCount() != actions.size()))) {
            events_.fireEvent(new RaisePackagePaneEvent());
        }
        // create the action center if it doesn't already exist
        if (actionCenter_ == null) {
            actionCenter_ = new ActionCenter(manageActionCenterLayout);
            packagesTableContainer_.add(actionCenter_);
        }
        actionCenter_.setActions(actions);
        resizeActionCenter();
    }
}
Also used : Command(com.google.gwt.user.client.Command) RaisePackagePaneEvent(org.rstudio.studio.client.workbench.views.packages.events.RaisePackagePaneEvent) ActionCenter(org.rstudio.studio.client.workbench.views.packages.ui.actions.ActionCenter)

Example 62 with Command

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

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

the class RSConnectPublishButton method renderThenPublish.

// for static content only: perform a just-in-time render if necessary and
// then publish the content
private void renderThenPublish(final String target, final RSConnectDeploymentRecord previous) {
    // prevent re-entrancy
    if (rmdInfoPending_)
        return;
    final Command renderCommand = new Command() {

        @Override
        public void execute() {
            publishAfterRmdRender_ = previous;
            rmdRenderPending_ = true;
            anyRmdRenderPending_ = true;
            if (commands_.knitDocument().isEnabled())
                commands_.knitDocument().execute();
            else if (commands_.previewHTML().isEnabled())
                commands_.previewHTML().execute();
            else
                display_.showErrorMessage("Can't Render Document", "RStudio cannot render " + target + " for publishing.");
        }
    };
    rmdInfoPending_ = true;
    rmdServer_.getRmdOutputInfo(target, new ServerRequestCallback<RmdOutputInfo>() {

        @Override
        public void onResponseReceived(RmdOutputInfo response) {
            if (response.isCurrent()) {
                RenderedDocPreview preview = new RenderedDocPreview(target, response.getOutputFile(), true);
                events_.fireEvent(RSConnectActionEvent.DeployDocEvent(preview, RSConnect.CONTENT_TYPE_DOCUMENT, previous));
            } else {
                renderCommand.execute();
            }
            rmdInfoPending_ = false;
        }

        @Override
        public void onError(ServerError error) {
            // if we failed to figure out whether we need to do a re-render, 
            // assume one is necessary
            Debug.logError(error);
            renderCommand.execute();
            rmdInfoPending_ = false;
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ServerError(org.rstudio.studio.client.server.ServerError) RmdOutputInfo(org.rstudio.studio.client.rmarkdown.model.RmdOutputInfo) RenderedDocPreview(org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)

Example 64 with Command

use of com.google.gwt.user.client.Command in project drools-wb by kiegroup.

the class ScoreCardXLSEditorViewImpl method submit.

private void submit(final Path path) {
    uploadWidget.submit(path, getServletUrl(), new Command() {

        @Override
        public void execute() {
            BusyPopup.close();
            notifySuccess();
        }
    }, new Command() {

        @Override
        public void execute() {
            BusyPopup.close();
        }
    });
    concurrentUpdateSessionInfo = null;
}
Also used : Command(com.google.gwt.user.client.Command)

Example 65 with Command

use of com.google.gwt.user.client.Command in project drools-wb by kiegroup.

the class NewScoreCardXLSHandler method create.

@Override
public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(ScoreCardXLSEditorConstants.INSTANCE.Uploading());
    final Path path = pkg.getPackageMainResourcesPath();
    final String fileName = buildFileName(baseFileName, resourceType);
    // Package Path is already encoded, fileName needs to be encoded
    final Path newPath = PathFactory.newPathBasedOn(fileName, path.toURI() + "/" + encode(fileName), path);
    uploadWidget.submit(path, fileName, getServletUrl(), new Command() {

        @Override
        public void execute() {
            busyIndicatorView.hideBusyIndicator();
            presenter.complete();
            notifySuccess();
            newResourceSuccessEvent.fire(new NewResourceSuccessEvent(path));
            placeManager.goTo(newPath);
        }
    }, new Command() {

        @Override
        public void execute() {
            busyIndicatorView.hideBusyIndicator();
        }
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) Command(com.google.gwt.user.client.Command) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent)

Aggregations

Command (com.google.gwt.user.client.Command)189 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 Test (org.junit.Test)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 ArrayList (java.util.ArrayList)11 ServerError (org.rstudio.studio.client.server.ServerError)11 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)10 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)9 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 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 Widget (com.google.gwt.user.client.ui.Widget)7 Operation (org.rstudio.core.client.widget.Operation)7 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)7