use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.
the class Projects method handleNewProject.
private void handleNewProject(boolean forceSaveAll, final boolean allowOpenInNewWindow) {
// first resolve the quit context (potentially saving edited documents
// and determining whether to save the R environment on exit)
applicationQuit_.prepareForQuit("Save Current Workspace", forceSaveAll, new ApplicationQuit.QuitContext() {
@Override
public void onReadyToQuit(final boolean saveChanges) {
projServer_.getNewProjectContext(new SimpleRequestCallback<NewProjectContext>() {
@Override
public void onResponseReceived(NewProjectContext context) {
NewProjectWizard wiz = new NewProjectWizard(session_.getSessionInfo(), pUIPrefs_.get(), pWorkbenchContext_.get(), new NewProjectInput(FileSystemItem.createDir(pUIPrefs_.get().defaultProjectLocation().getValue()), context), allowOpenInNewWindow, new ProgressOperationWithInput<NewProjectResult>() {
@Override
public void execute(NewProjectResult newProject, ProgressIndicator indicator) {
indicator.onCompleted();
createNewProject(newProject, saveChanges);
}
});
wiz.showModal();
}
});
}
});
}
use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.
the class RmdOutput method onWebsiteFileSaved.
@Override
public void onWebsiteFileSaved(WebsiteFileSavedEvent event) {
// skip if there is a build in progress
if (workbenchContext_.isBuildInProgress())
return;
// skip if there is a render in progress
if (renderInProgress_)
return;
// skip if there was a quit initiated since the last render
if (quitInitiatedAfterLastRender_)
return;
// is there an output frame?
if (outputFrame_ == null || outputFrame_.getWindowObject() == null)
return;
// is it showing a page from the current site?
String websiteDir = session_.getSessionInfo().getBuildTargetDir();
final RmdPreviewParams params = outputFrame_.getPreviewParams();
if (!params.getTargetFile().startsWith(websiteDir))
return;
// is the changed file one that should always produce a rebuild?
FileSystemItem file = event.getFileSystemItem();
TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
String typeId = fileType.getTypeId();
if (fileType.isR() || typeId.equals(FileTypeRegistry.HTML.getTypeId()) || typeId.equals(FileTypeRegistry.YAML.getTypeId()) || typeId.equals(FileTypeRegistry.JSON.getTypeId())) {
reRenderPreview();
} else // is the changed file a markdown document
if (fileType.isMarkdown()) {
// included Rmd files always produce a rebuild of the current file
if (file.getStem().startsWith("_"))
reRenderPreview();
// files in subdirectories are also includes so re-render them also
if (!file.getParentPathString().equals(websiteDir))
reRenderPreview();
// ...otherwise leave it alone (requires a knit)
} else // see if this should result in a copy + refresh
{
server_.maybeCopyWebsiteAsset(file.getPath(), new SimpleRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean copied) {
if (copied)
outputFrame_.showRmdPreview(params, true);
}
});
}
}
use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.
the class PresentationPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
boolean isTutorial = session_.getSessionInfo().getPresentationState().isTutorial();
Toolbar toolbar = new Toolbar();
slideNavigationMenu_ = new SlideNavigationToolbarMenu(toolbar);
slideNavigationMenu_.setEditButtonVisible(!isTutorial);
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands_.presentationFullscreen().createToolbarButton());
// More
if (!isTutorial) {
ToolbarPopupMenu moreMenu = new ToolbarPopupMenu();
moreMenu.addItem(commands_.clearPresentationCache().createMenuItem(false));
moreMenu.addSeparator();
moreMenu.addItem(commands_.presentationViewInBrowser().createMenuItem(false));
moreMenu.addItem(commands_.presentationSaveAsStandalone().createMenuItem(false));
ToolbarButton moreButton = new ToolbarButton("More", new ImageResource2x(StandardIcons.INSTANCE.more_actions2x()), moreMenu);
toolbar.addRightWidget(moreButton);
// Create the publish button and wire it to our HTML generator
publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_PRES, false, null);
publishButton_.setPublishHtmlSource(new PublishHtmlSource() {
@Override
public void generatePublishHtml(final CommandWithArg<String> onCompleted) {
server_.createPresentationRPubsSource(new SimpleRequestCallback<PresentationRPubsSource>() {
@Override
public void onResponseReceived(PresentationRPubsSource source) {
onCompleted.execute(source.getSourceFilePath());
}
@Override
public void onError(ServerError error) {
display_.showErrorMessage("Error Saving Presentation", Presentation.getErrorMessage(error));
}
});
}
@Override
public String getTitle() {
return "Presentation:\n" + getPresentationTitle();
}
});
toolbar.addRightSeparator();
toolbar.addRightWidget(publishButton_);
} else {
toolbar.addRightWidget(commands_.tutorialFeedback().createToolbarButton());
}
toolbar.addRightSeparator();
toolbar.addRightWidget(refreshButton_ = commands_.refreshPresentation().createToolbarButton());
progressButton_ = new ToolbarButton(CoreResources.INSTANCE.progress_gray(), new ClickHandler() {
@Override
public void onClick(ClickEvent e) {
}
});
toolbar.addRightWidget(progressButton_);
progressButton_.setVisible(false);
return toolbar;
}
use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.
the class RStudioAPI method showDialog.
private void showDialog(String caption, String message, final String url) {
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.addStyleName(RES.styles().textInfoWidget());
SafeHtml safeMsg = DialogHtmlSanitizer.sanitizeHtml(message);
HTML msg = new HTML(safeMsg.asString());
msg.setWidth("100%");
verticalPanel.add(msg);
if (!StringUtil.isNullOrEmpty(url)) {
HyperlinkLabel link = new HyperlinkLabel(url, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
RStudioGinjector.INSTANCE.getGlobalDisplay().openWindow(url);
}
});
link.addStyleName(RES.styles().installLink());
verticalPanel.add(link);
}
MessageDialog dlg = new MessageDialog(MessageDialog.INFO, caption, verticalPanel);
dlg.addButton("OK", new Operation() {
@Override
public void execute() {
server_.showDialogCompleted(null, false, new SimpleRequestCallback<Void>());
}
}, true, false);
dlg.showModal();
}
use of org.rstudio.studio.client.common.SimpleRequestCallback in project rstudio by rstudio.
the class Application method verifyAgreement.
private void verifyAgreement(SessionInfo sessionInfo, final Operation verifiedOperation) {
// get the agreement (if any)
final Agreement agreement = sessionInfo.pendingAgreement();
// execute the verifiedOperation immediately)
if (agreement != null) {
// append updated to the title if necessary
String title = agreement.getTitle();
if (agreement.getUpdated())
title += " (Updated)";
view_.showApplicationAgreement(// title and contents
title, agreement.getContents(), // bail to sign in page if the user doesn't confirm
new Operation() {
public void execute() {
if (Desktop.isDesktop()) {
Desktop.getFrame().setPendingQuit(DesktopFrame.PENDING_QUIT_AND_EXIT);
server_.quitSession(false, null, null, GWT.getHostPageBaseURL(), new SimpleRequestCallback<Boolean>());
} else
navigateToSignIn();
}
}, // user confirmed
new Operation() {
public void execute() {
// call verified operation
verifiedOperation.execute();
// record agreement on server
server_.acceptAgreement(agreement, new VoidServerRequestCallback());
}
});
} else {
// no agreement pending
verifiedOperation.execute();
}
}
Aggregations