Search in sources :

Example 41 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 42 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 43 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 44 with Command

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

the class SVNCommandHandler method onVcsRevert.

@Handler
void onVcsRevert() {
    final ArrayList<String> paths = getPathArray();
    if (paths.size() == 0)
        return;
    doRevert(paths, new Command() {

        @Override
        public void execute() {
            display_.getChangelistTable().selectNextUnselectedItem();
            display_.getChangelistTable().focus();
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) Handler(org.rstudio.core.client.command.Handler)

Example 45 with Command

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

the class ConnectionsPane method transitionMainPanel.

private void transitionMainPanel(final Widget from, final Widget to, boolean rightToLeft, boolean animate, final Command onComplete) {
    assert from != to;
    int width = getOffsetWidth();
    mainPanel_.setWidgetLeftWidth(from, 0, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, rightToLeft ? width : -width, Unit.PX, width, Unit.PX);
    mainPanel_.forceLayout();
    mainPanel_.setWidgetLeftWidth(from, rightToLeft ? -width : width, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, 0, Unit.PX, width, Unit.PX);
    to.setVisible(true);
    from.setVisible(true);
    final Command completeLayout = new Command() {

        @Override
        public void execute() {
            mainPanel_.setWidgetLeftRight(to, 0, Unit.PX, 0, Unit.PX);
            from.setVisible(false);
            mainPanel_.forceLayout();
            onComplete.execute();
        }
    };
    if (animate) {
        mainPanel_.animate(300, new AnimationCallback() {

            public void onAnimationComplete() {
                completeLayout.execute();
            }

            public void onLayout(Layer layer, double progress) {
            }
        });
    } else {
        completeLayout.execute();
    }
}
Also used : Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) Layer(com.google.gwt.layout.client.Layout.Layer)

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