use of org.rstudio.core.client.widget.ProgressOperationWithInput in project rstudio by rstudio.
the class ConnectionsPresenter method onNewConnection.
public void onNewConnection() {
// if r session bussy, fail
if (commands_.interruptR().isEnabled()) {
showError("The R session is currently busy. Wait for completion or " + "interrupt the current session and retry.");
return;
}
// get the context
server_.getNewConnectionContext(new DelayedProgressRequestCallback<NewConnectionContext>("New Connection...") {
@Override
protected void onSuccess(final NewConnectionContext context) {
// show dialog
NewConnectionWizard newConnectionWizard = new NewConnectionWizard(context, new ProgressOperationWithInput<ConnectionOptions>() {
@Override
public void execute(ConnectionOptions result, ProgressIndicator indicator) {
indicator.onCompleted();
eventBus_.fireEvent(new PerformConnectionEvent(result.getConnectVia(), result.getConnectCode()));
}
});
newConnectionWizard.showModal();
}
});
}
use of org.rstudio.core.client.widget.ProgressOperationWithInput in project rstudio by rstudio.
the class EnvironmentPresenter method onClearWorkspace.
void onClearWorkspace() {
view_.bringToFront();
final List<String> objectNames = view_.getSelectedObjects();
new ClearAllDialog(objectNames.size(), new ProgressOperationWithInput<Boolean>() {
@Override
public void execute(Boolean includeHidden, ProgressIndicator indicator) {
indicator.onProgress("Removing objects...");
if (objectNames.size() == 0) {
server_.removeAllObjects(includeHidden, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
view_.clearSelection();
view_.clearObjects();
}
});
} else {
server_.removeObjects(objectNames, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
view_.clearSelection();
for (String obj : objectNames) {
view_.removeObject(obj);
}
}
});
}
}
}).showModal();
}
use of org.rstudio.core.client.widget.ProgressOperationWithInput 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;
}
use of org.rstudio.core.client.widget.ProgressOperationWithInput 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());
}
});
}
});
}
});
}
});
}
use of org.rstudio.core.client.widget.ProgressOperationWithInput 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