use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Synctex method doDesktopInverseSearch.
private void doDesktopInverseSearch(String file, int line, int column) {
// apply concordance
final ProgressIndicator indicator = getSyncProgress();
server_.applyInverseConcordance(SourceLocation.create(file, line, column, true), new ServerRequestCallback<SourceLocation>() {
@Override
public void onResponseReceived(SourceLocation sourceLocation) {
indicator.onCompleted();
if (sourceLocation != null)
goToSourceLocation(sourceLocation);
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Synctex method doForwardSearch.
private void doForwardSearch(String rootDocument, JavaScriptObject sourceLocationObject) {
SourceLocation sourceLocation = sourceLocationObject.cast();
final ProgressIndicator indicator = getSyncProgress();
server_.synctexForwardSearch(rootDocument, sourceLocation, new ServerRequestCallback<PdfLocation>() {
@Override
public void onResponseReceived(PdfLocation location) {
indicator.onCompleted();
if (location != null)
eventBus_.fireEvent(new SynctexViewPdfEvent(location));
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class FileExport method export.
public void export(String caption, String description, final FileSystemItem parentDir, final ArrayList<FileSystemItem> files) {
// validation: some files provided
if (files.size() == 0)
return;
// case: single file which is not a folder
if ((files.size()) == 1 && !files.get(0).isDirectory()) {
final FileSystemItem file = files.get(0);
showFileExport(caption, description, file.getStem(), file.getExtension(), new ProgressOperationWithInput<String>() {
public void execute(String name, ProgressIndicator progress) {
// progress complete
progress.onCompleted();
// execute the download (open in a new window)
globalDisplay_.openWindow(server_.getFileExportUrl(name, file));
}
});
} else // case: folder or multiple files
{
// determine the default zip file name based on the selection
String defaultArchiveName;
if (files.size() == 1)
defaultArchiveName = files.get(0).getStem();
else
defaultArchiveName = "rstudio-export";
// prompt user
final String ZIP = ".zip";
showFileExport(caption, description, defaultArchiveName, ZIP, new ProgressOperationWithInput<String>() {
public void execute(String archiveName, ProgressIndicator progress) {
// progress complete
progress.onCompleted();
// force zip extension in case the user deleted it
if (!archiveName.endsWith(ZIP))
archiveName += ZIP;
// build list of filenames
ArrayList<String> filenames = new ArrayList<String>();
for (FileSystemItem file : files) filenames.add(file.getName());
// execute the download (open in a new window)
globalDisplay_.openWindow(server_.getFileExportUrl(archiveName, parentDir, filenames));
}
});
}
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Plots method onClearPlots.
void onClearPlots() {
// clear plots gesture indicates we are done with locator
safeClearLocator();
// confirm
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Clear Plots", "Are you sure you want to clear all of the plots in the history?", new ProgressOperation() {
public void execute(final ProgressIndicator indicator) {
indicator.onProgress("Clearing plots...");
server_.clearPlots(new VoidServerRequestCallback(indicator));
}
}, true);
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class SavePlotAsPdfDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
ExportPlotResources.Styles styles = ExportPlotResources.INSTANCE.styles();
Grid grid = new Grid(7, 2);
grid.setStylePrimaryName(styles.savePdfMainWidget());
// paper size
grid.setWidget(0, 0, new Label("PDF Size:"));
// paper size label
paperSizeEditor_ = new PaperSizeEditor();
grid.setWidget(0, 1, paperSizeEditor_);
// orientation
grid.setWidget(1, 0, new Label("Orientation:"));
HorizontalPanel orientationPanel = new HorizontalPanel();
orientationPanel.setSpacing(kComponentSpacing);
VerticalPanel orientationGroupPanel = new VerticalPanel();
final String kOrientationGroup = new String("Orientation");
portraitRadioButton_ = new RadioButton(kOrientationGroup, "Portrait");
orientationGroupPanel.add(portraitRadioButton_);
landscapeRadioButton_ = new RadioButton(kOrientationGroup, "Landscape");
orientationGroupPanel.add(landscapeRadioButton_);
orientationPanel.add(orientationGroupPanel);
grid.setWidget(1, 1, orientationPanel);
boolean haveCairoPdf = sessionInfo_.isCairoPdfAvailable();
if (haveCairoPdf)
grid.setWidget(2, 0, new Label("Options:"));
HorizontalPanel cairoPdfPanel = new HorizontalPanel();
String label = "Use cairo_pdf device";
if (BrowseCap.isMacintoshDesktop())
label = label + " (requires X11)";
chkCairoPdf_ = new CheckBox(label);
chkCairoPdf_.getElement().getStyle().setMarginLeft(kComponentSpacing, Unit.PX);
cairoPdfPanel.add(chkCairoPdf_);
chkCairoPdf_.setValue(haveCairoPdf && options_.getCairoPdf());
if (haveCairoPdf)
grid.setWidget(2, 1, cairoPdfPanel);
grid.setWidget(3, 0, new HTML(" "));
ThemedButton directoryButton = new ThemedButton("Directory...");
directoryButton.setStylePrimaryName(styles.directoryButton());
directoryButton.getElement().getStyle().setMarginLeft(-2, Unit.PX);
grid.setWidget(4, 0, directoryButton);
directoryButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
fileDialogs_.chooseFolder("Choose Directory", fileSystemContext_, FileSystemItem.createDir(directoryLabel_.getTitle().trim()), new ProgressOperationWithInput<FileSystemItem>() {
public void execute(FileSystemItem input, ProgressIndicator indicator) {
if (input == null)
return;
indicator.onCompleted();
// update default
ExportPlotUtils.setDefaultSaveDirectory(input);
// set display
setDirectory(input);
}
});
}
});
directoryLabel_ = new Label();
setDirectory(defaultDirectory_);
directoryLabel_.setStylePrimaryName(styles.savePdfDirectoryLabel());
grid.setWidget(4, 1, directoryLabel_);
Label fileNameLabel = new Label("File name:");
fileNameLabel.setStylePrimaryName(styles.savePdfFileNameLabel());
grid.setWidget(5, 0, fileNameLabel);
fileNameTextBox_ = new TextBox();
fileNameTextBox_.setText(defaultPlotName_);
fileNameTextBox_.setStylePrimaryName(styles.savePdfFileNameTextBox());
grid.setWidget(5, 1, fileNameTextBox_);
// view after size
viewAfterSaveCheckBox_ = new CheckBox("View plot after saving");
viewAfterSaveCheckBox_.setStylePrimaryName(styles.savePdfViewAfterCheckbox());
viewAfterSaveCheckBox_.setValue(options_.getViewAfterSave());
grid.setWidget(6, 1, viewAfterSaveCheckBox_);
// set default value
if (options_.getPortrait())
portraitRadioButton_.setValue(true);
else
landscapeRadioButton_.setValue(true);
// return the widget
return grid;
}
Aggregations