Search in sources :

Example 6 with SimpleRequestCallback

use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.

the class RmdOutput method onRenderRmdSource.

@Override
public void onRenderRmdSource(final RenderRmdSourceEvent event) {
    quitInitiatedAfterLastRender_ = false;
    performRenderOperation(new Operation() {

        @Override
        public void execute() {
            server_.renderRmdSource(event.getSource(), new SimpleRequestCallback<Boolean>());
        }
    });
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) Operation(org.rstudio.core.client.widget.Operation) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 7 with SimpleRequestCallback

use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.

the class BuildPresenter method executeBuild.

private void executeBuild(final String type, final String subType) {
    // attempt to start a build (this will be a silent no-op if there
    // is already a build running)
    workbenchContext_.setBuildInProgress(true);
    sourceBuildHelper_.withSaveFilesBeforeCommand(new Command() {

        @Override
        public void execute() {
            server_.startBuild(type, subType, new SimpleRequestCallback<Boolean>() {

                @Override
                public void onResponseReceived(Boolean response) {
                }

                @Override
                public void onError(ServerError error) {
                    super.onError(error);
                    workbenchContext_.setBuildInProgress(false);
                }
            });
        }
    }, "Build");
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 8 with SimpleRequestCallback

use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.

the class TextEditingTargetPresentationHelper method buildSlideMenu.

public void buildSlideMenu(final String path, boolean isDirty, final EditingTarget editor, final CommandWithArg<StatusBarPopupRequest> onCompleted) {
    // rpc response handler
    SimpleRequestCallback<SlideNavigation> requestCallback = new SimpleRequestCallback<SlideNavigation>() {

        @Override
        public void onResponseReceived(SlideNavigation slideNavigation) {
            // create the menu and make sure we have some slides to return
            StatusBarPopupMenu menu = new StatusBarPopupMenu();
            if (slideNavigation.getTotalSlides() == 0) {
                onCompleted.execute(new StatusBarPopupRequest(menu, null));
                return;
            }
            MenuItem defaultMenuItem = null;
            int length = slideNavigation.getItems().length();
            for (int i = 0; i < length; i++) {
                SlideNavigationItem item = slideNavigation.getItems().get(i);
                String title = item.getTitle();
                if (StringUtil.isNullOrEmpty(title))
                    title = "(Untitled Slide)";
                StringBuilder indentBuilder = new StringBuilder();
                for (int level = 0; level < item.getIndent(); level++) indentBuilder.append("&nbsp;&nbsp;");
                SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder();
                labelBuilder.appendHtmlConstant(indentBuilder.toString());
                labelBuilder.appendEscaped(title);
                final int targetSlide = i;
                final MenuItem menuItem = new MenuItem(labelBuilder.toSafeHtml(), new Command() {

                    public void execute() {
                        navigateToSlide(editor, targetSlide);
                    }
                });
                menu.addItem(menuItem);
                // see if this is the default menu item
                if (defaultMenuItem == null && item.getLine() >= (docDisplay_.getSelectionStart().getRow())) {
                    defaultMenuItem = menuItem;
                }
            }
            StatusBarPopupRequest request = new StatusBarPopupRequest(menu, defaultMenuItem);
            onCompleted.execute(request);
        }
    };
    // send code over the wire if we are dirty
    if (isDirty) {
        server_.getSlideNavigationForCode(docDisplay_.getCode(), FileSystemItem.createFile(path).getParentPathString(), requestCallback);
    } else {
        server_.getSlideNavigationForFile(path, requestCallback);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) StatusBarPopupMenu(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu) StatusBarPopupRequest(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest) MenuItem(com.google.gwt.user.client.ui.MenuItem) SlideNavigation(org.rstudio.studio.client.common.presentation.model.SlideNavigation) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SlideNavigationItem(org.rstudio.studio.client.common.presentation.model.SlideNavigationItem) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 9 with SimpleRequestCallback

use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.

the class GitPresenter method doRevert.

private void doRevert(final ArrayList<String> revertList, final Command onRevertConfirmed) {
    String noun = revertList.size() == 1 ? "file" : "files";
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "Revert Changes", "Changes to the selected " + noun + " will be lost, including " + "staged changes.\n\nAre you sure you want to continue?", new Operation() {

        @Override
        public void execute() {
            if (onRevertConfirmed != null)
                onRevertConfirmed.execute();
            server_.gitRevert(revertList, new SimpleRequestCallback<Void>("Revert Changes"));
        }
    }, false);
}
Also used : Operation(org.rstudio.core.client.widget.Operation) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Aggregations

SimpleRequestCallback (org.rstudio.studio.client.common.SimpleRequestCallback)9 Operation (org.rstudio.core.client.widget.Operation)4 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Command (com.google.gwt.user.client.Command)2 ServerError (org.rstudio.studio.client.server.ServerError)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 HTML (com.google.gwt.user.client.ui.HTML)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 HyperlinkLabel (org.rstudio.core.client.widget.HyperlinkLabel)1 MessageDialog (org.rstudio.core.client.widget.MessageDialog)1 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)1 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)1 Toolbar (org.rstudio.core.client.widget.Toolbar)1 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)1