use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class ShinyApplication method launchShinyApplication.
// Public methods ----------------------------------------------------------
// Private methods ---------------------------------------------------------
private void launchShinyApplication(final String filePath, final String extendedType) {
String fileDir = filePath.substring(0, filePath.lastIndexOf("/"));
if (fileDir.equals(currentAppPath())) {
// reload the app.
if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_WINDOW) {
satelliteManager_.dispatchCommand(commands_.reloadShinyApp(), ShinyApplicationSatellite.NAME);
activateWindow();
} else if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_PANE && commands_.viewerRefresh().isEnabled()) {
commands_.viewerRefresh().execute();
} else if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_BROWSER) {
eventBus_.fireEvent(new ShinyApplicationStatusEvent(params_));
}
return;
} else if (params_ != null && isBusy_) {
// There's another app running. Interrupt it and then start this one.
interrupt_.interruptR(new InterruptHandler() {
@Override
public void onInterruptFinished() {
launchShinyFile(filePath, extendedType);
}
});
} else {
// Nothing else running, start this app.
dependencyManager_.withShiny("Running Shiny applications", new Command() {
@Override
public void execute() {
launchShinyFile(filePath, extendedType);
}
});
}
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class CopyPlotToClipboardDesktopDialog method copyAsBitmap.
protected void copyAsBitmap(final Operation onCompleted) {
final ExportPlotSizeEditor sizeEditor = getSizeEditor();
sizeEditor.prepareForExport(new Command() {
@Override
public void execute() {
if (BrowseCap.isCocoaDesktop()) {
clipboard_.copyPlotToCocoaPasteboard(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {
@Override
public void execute() {
onCompleted.execute();
}
});
} else {
WindowEx win = sizeEditor.getPreviewIFrame().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
DesktopFrame frame = Desktop.getFrame();
frame.copyImageToClipboard(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
}
onCompleted.execute();
}
}
});
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class CopyPlotToClipboardDesktopMetafileDialog method copyAsMetafile.
private void copyAsMetafile(final Operation onCompleted) {
ExportPlotSizeEditor sizeEditor = getSizeEditor();
clipboard_.copyPlotToClipboardMetafile(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {
@Override
public void execute() {
onCompleted.execute();
}
});
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class CppCompletionManager method performCompletionRequest.
private void performCompletionRequest(final CompletionPosition completionPosition, final boolean explicit) {
terminateCompletionRequest();
final Invalidation.Token invalidationToken = completionRequestInvalidation_.getInvalidationToken();
completionContext_.withUpdatedDoc(new CommandWith2Args<String, String>() {
@Override
public void execute(String docPath, String docId) {
if (invalidationToken.isInvalid())
return;
request_ = new CppCompletionRequest(docPath, docId, completionPosition, docDisplay_, invalidationToken, explicit, CppCompletionManager.this, new Command() {
@Override
public void execute() {
suggestionTimer_.cancel();
}
});
}
});
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class ViewerPresenter method onViewerSaveAsWebPage.
@Handler
public void onViewerSaveAsWebPage() {
display_.bringToFront();
if (saveAsWebPageDefaultPath_ == null)
saveAsWebPageDefaultPath_ = workbenchContext_.getCurrentWorkingDir();
dependencyManager_.withRMarkdown("Saving standalone web pages", new Command() {
@Override
public void execute() {
fileDialogs_.saveFile("Save As Web Page", fileSystemContext_, saveAsWebPageDefaultPath_, ".html", false, new ProgressOperationWithInput<FileSystemItem>() {
@Override
public void execute(final FileSystemItem targetFile, ProgressIndicator indicator) {
if (targetFile == null) {
indicator.onCompleted();
return;
}
indicator.onProgress("Saving as web page...");
server_.viewerSaveAsWebPage(targetFile.getPath(), new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
saveAsWebPageDefaultPath_ = targetFile.getParentPath();
}
});
}
});
}
});
}
Aggregations