use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class FileTypeRegistry method openFile.
public void openFile(final FileSystemItem file, final boolean canUseBrowser) {
FileType fileType = getTypeForFile(file);
if (fileType != null) {
fileType.openFile(file, eventBus_);
} else {
// build default command to use if we have an error or the
// file is not a text file
final Command defaultCommand = new Command() {
@Override
public void execute() {
if (canUseBrowser) {
if (session_.getSessionInfo().getAllowFileDownloads()) {
BROWSER.openFile(file, eventBus_);
} else {
globalDisplay_.showErrorMessage("File Download Error", "Unable to show file because file downloads are " + "restricted on this server.\n");
}
}
}
};
// check with the server to see if this is likely to be a text file
server_.isTextFile(file.getPath(), new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean isText) {
if (isText)
TEXT.openFile(file, eventBus_);
else
defaultCommand.execute();
}
@Override
public void onError(ServerError error) {
defaultCommand.execute();
}
});
}
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class LocatorPanel method showFeedbackAt.
private void showFeedbackAt(Point p) {
cancelFeedback();
setWidgetTopHeight(feedbackImage_, p.getY() - FB_OFFSET_Y, Unit.PX, FB_HEIGHT, Unit.PX);
setWidgetLeftWidth(feedbackImage_, p.getX() - FB_OFFSET_X, Unit.PX, FB_WIDTH, Unit.PX);
forceLayout();
feedbackImage_.setVisible(true);
feedbackImage_.getElement().getStyle().setOpacity(1.0);
feedbackTimer_ = new Timer() {
@Override
public void run() {
feedbackTimer_ = null;
ArrayList<Widget> widgets = new ArrayList<Widget>();
widgets.add(feedbackImage_);
feedbackAnimation_ = new FadeOutAnimation(widgets, new Command() {
public void execute() {
feedbackAnimation_ = null;
}
});
feedbackAnimation_.run(300);
}
};
feedbackTimer_.schedule(700);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class CompilePdfOutputPresenter method onSelected.
@Override
public void onSelected() {
super.onSelected();
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
view_.scrollToBottom();
}
});
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class DataImportPresenter method getImportDatasetCommandFromMode.
public Command getImportDatasetCommandFromMode(final DataImportModes dataImportMode, final String dialogTitle, final String path) {
return new Command() {
@Override
public void execute() {
DataImportDialog dataImportDialog = new DataImportDialog(dataImportMode, dialogTitle, path, new OperationWithInput<String>() {
@Override
public void execute(final String importCode) {
eventBus_.fireEvent(new SendToConsoleEvent(importCode, true, true));
}
});
dataImportDialog.showModal();
}
};
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class PlotsPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_PLOT, true, commands_.savePlotAsImage());
publishButton_.setPublishHtmlSource(new PublishHtmlSource() {
@Override
public String getTitle() {
return "Current Plot";
}
@Override
public void generatePublishHtml(final CommandWithArg<String> onComplete) {
dependencies_.withRMarkdown("Publishing plots", new Command() {
@Override
public void execute() {
final Size size = ZoomUtils.getZoomedSize(getPlotFrameSize(), new Size(400, 350), new Size(800, 700));
server_.plotsCreateRPubsHtml("Plot", "", size.width, size.height, new SimpleRequestCallback<String>() {
@Override
public void onResponseReceived(String rpubsHtmlFile) {
onComplete.execute(rpubsHtmlFile);
}
});
}
});
}
});
plotsToolbar_ = new PlotsToolbar(commands_, publishButton_);
return plotsToolbar_;
}
Aggregations