Search in sources :

Example 11 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Presentation method onTutorialFeedback.

@Handler
void onTutorialFeedback() {
    EditDialog editDialog = new EditDialog("Provide Feedback", "Submit", "", false, true, new Size(450, 300), new ProgressOperationWithInput<String>() {

        @Override
        public void execute(String input, ProgressIndicator indicator) {
            if (input == null) {
                indicator.onCompleted();
                return;
            }
            indicator.onProgress("Saving feedback...");
            server_.tutorialFeedback(input, new VoidServerRequestCallback(indicator));
        }
    });
    editDialog.showModal();
}
Also used : EditDialog(org.rstudio.studio.client.workbench.views.edit.ui.EditDialog) Size(org.rstudio.core.client.Size) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JSONString(com.google.gwt.json.client.JSONString) Handler(org.rstudio.core.client.command.Handler)

Example 12 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Presentation method onPresentationSaveAsStandalone.

@Handler
void onPresentationSaveAsStandalone() {
    // determine the default file name
    if (saveAsStandaloneDefaultPath_ == null) {
        FileSystemItem presFilePath = FileSystemItem.createFile(currentState_.getFilePath());
        saveAsStandaloneDefaultPath_ = FileSystemItem.createFile(presFilePath.getParentPath().completePath(presFilePath.getStem() + ".html"));
    }
    fileDialogs_.saveFile("Save Presentation As", fileSystemContext_, saveAsStandaloneDefaultPath_, ".html", false, new ProgressOperationWithInput<FileSystemItem>() {

        @Override
        public void execute(final FileSystemItem targetFile, ProgressIndicator indicator) {
            if (targetFile == null) {
                indicator.onCompleted();
                return;
            }
            indicator.onProgress("Saving Presentation...");
            server_.createStandalonePresentation(targetFile.getPath(), new VoidServerRequestCallback(indicator) {

                @Override
                public void onSuccess() {
                    saveAsStandaloneDefaultPath_ = targetFile;
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Handler(org.rstudio.core.client.command.Handler)

Example 13 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Source method onNewRPresentationDoc.

@Handler
public void onNewRPresentationDoc() {
    dependencyManager_.withRMarkdown("Authoring R Presentations", new Command() {

        @Override
        public void execute() {
            fileDialogs_.saveFile("New R Presentation", fileContext_, workbenchContext_.getDefaultFileDialogDir(), ".Rpres", true, new ProgressOperationWithInput<FileSystemItem>() {

                @Override
                public void execute(final FileSystemItem input, final ProgressIndicator indicator) {
                    if (input == null) {
                        indicator.onCompleted();
                        return;
                    }
                    indicator.onProgress("Creating Presentation...");
                    server_.createNewPresentation(input.getPath(), new VoidServerRequestCallback(indicator) {

                        @Override
                        public void onSuccess() {
                            openFile(input, FileTypeRegistry.RPRESENTATION, new CommandWithArg<EditingTarget>() {

                                @Override
                                public void execute(EditingTarget arg) {
                                    server_.showPresentationPane(input.getPath(), new VoidServerRequestCallback());
                                }
                            });
                        }
                    });
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) 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) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) FileTypeChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.FileTypeChangedHandler) Handler(org.rstudio.core.client.command.Handler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) SelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) CloseHandler(com.google.gwt.event.logical.shared.CloseHandler) ViewDataHandler(org.rstudio.studio.client.workbench.views.data.events.ViewDataHandler) SourceOnSaveChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.SourceOnSaveChangedHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) OpenSourceFileHandler(org.rstudio.studio.client.common.filetypes.events.OpenSourceFileHandler)

Example 14 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Source method onTabReorder.

@Override
public void onTabReorder(TabReorderEvent event) {
    syncTabOrder();
    // valid location
    if (event.getOldPos() < 0 || event.getOldPos() >= tabOrder_.size() || event.getNewPos() < 0 || event.getNewPos() >= tabOrder_.size()) {
        return;
    }
    // remove the tab from its old position
    int idx = tabOrder_.get(event.getOldPos());
    // force type box 
    tabOrder_.remove(new Integer(idx));
    // add it to its new position 
    tabOrder_.add(event.getNewPos(), idx);
    // sort the document IDs and send to the server
    ArrayList<String> ids = new ArrayList<String>();
    for (int i = 0; i < tabOrder_.size(); i++) {
        ids.add(editors_.get(tabOrder_.get(i)).getId());
    }
    server_.setDocOrder(ids, new VoidServerRequestCallback());
    // activate the tab 
    setPhysicalTabIndex(event.getNewPos());
    fireDocTabsChanged();
}
Also used : ArrayList(java.util.ArrayList) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JSONString(com.google.gwt.json.client.JSONString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 15 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Source method closeTabIndex.

private void closeTabIndex(int idx, boolean closeDocument) {
    EditingTarget target = editors_.remove(idx);
    tabOrder_.remove(new Integer(idx));
    for (int i = 0; i < tabOrder_.size(); i++) {
        if (tabOrder_.get(i) > idx) {
            tabOrder_.set(i, tabOrder_.get(i) - 1);
        }
    }
    target.onDismiss(closeDocument ? EditingTarget.DISMISS_TYPE_CLOSE : EditingTarget.DISMISS_TYPE_MOVE);
    if (activeEditor_ == target) {
        activeEditor_.onDeactivate();
        activeEditor_ = null;
    }
    if (closeDocument) {
        events_.fireEvent(new DocTabClosedEvent(target.getId()));
        server_.closeDocument(target.getId(), new VoidServerRequestCallback());
    }
    manageCommands();
    fireDocTabsChanged();
    if (view_.getTabCount() == 0) {
        sourceNavigationHistory_.clear();
        events_.fireEvent(new LastSourceDocClosedEvent());
    }
}
Also used : 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) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Aggregations

VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)44 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)14 Handler (org.rstudio.core.client.command.Handler)8 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)7 ServerError (org.rstudio.studio.client.server.ServerError)7 Command (com.google.gwt.user.client.Command)6 Operation (org.rstudio.core.client.widget.Operation)4 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)4 Void (org.rstudio.studio.client.server.Void)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)3 ArrayList (java.util.ArrayList)3 AppCommand (org.rstudio.core.client.command.AppCommand)3 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)3 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)3 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)3 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)3 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)2