use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onFold.
@Handler
void onFold() {
if (useScopeTreeFolding()) {
Range range = Range.fromPoints(docDisplay_.getSelectionStart(), docDisplay_.getSelectionEnd());
if (range.isEmpty()) {
// If no selection, fold the innermost non-anonymous scope
Scope scope = docDisplay_.getCurrentScope();
while (scope != null && scope.isAnon()) scope = scope.getParentScope();
if (scope == null || scope.isTopLevel())
return;
docDisplay_.addFoldFromRow(scope.getFoldStart().getRow());
} else {
// If selection, fold the selection
docDisplay_.addFold(range);
}
} else {
int row = docDisplay_.getSelectionStart().getRow();
docDisplay_.addFoldFromRow(row);
}
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class ViewerPresenter method onViewerSaveAsImage.
@Handler
public void onViewerSaveAsImage() {
display_.bringToFront();
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Preparing to export plot...");
// get the default directory
FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
// get context
server_.getViewerExportContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {
@Override
public void onResponseReceived(SavePlotAsImageContext context) {
indicator.onCompleted();
new SaveViewerPlotAsImageDesktopDialog(globalDisplay_, display_.getUrl(), context, ExportPlotOptions.adaptToSize(pUIPrefs_.get().exportViewerOptions().getValue(), display_.getViewerFrameSize()), saveExportOptionsOperation_).showModal();
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class ViewerPresenter method onViewerZoom.
@Handler
public void onViewerZoom() {
Size windowSize = ZoomUtils.getZoomWindowSize(display_.getViewerFrameSize(), zoomWindowDefaultSize_);
// open and activate window
NewWindowOptions options = new NewWindowOptions();
options.setName("_rstudio_viewer_zoom");
options.setFocus(true);
options.setCallback(new OperationWithInput<WindowEx>() {
@Override
public void execute(WindowEx input) {
zoomWindow_ = input;
}
});
globalDisplay_.openMinimalWindow(display_.getUrl(), false, windowSize.width, windowSize.height, options);
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class GitPresenter method onVcsRevert.
@Handler
void onVcsRevert() {
final ArrayList<String> paths = view_.getSelectedPaths();
if (paths.size() == 0)
return;
doRevert(paths, new Command() {
@Override
public void execute() {
view_.getChangelistTable().selectNextUnselectedItem();
view_.getChangelistTable().focus();
}
});
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class SVNCommandHandler method onVcsResolve.
@Handler
void onVcsResolve() {
ArrayList<StatusAndPath> items = display_.getSelectedItems();
if (items.size() == 0)
return;
final ArrayList<String> paths = new ArrayList<String>();
boolean conflict = false;
for (StatusAndPath item : items) {
paths.add(item.getPath());
if ("C".equals(item.getStatus()))
conflict = true;
else if (item.isDirectory())
conflict = true;
}
Operation resolveOperation = new Operation() {
@Override
public void execute() {
new SVNResolveDialog(paths.size(), "Resolve", new OperationWithInput<String>() {
@Override
public void execute(String input) {
server_.svnResolve(input, paths, new ProcessCallback("SVN Resolve"));
}
}).showModal();
}
};
if (conflict) {
resolveOperation.execute();
} else {
String message = (paths.size() > 1 ? "None of the selected paths appear to have conflicts." : "The selected path does not appear to have conflicts.") + "\n\nDo you want to resolve anyway?";
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "No Conflicts Detected", message, resolveOperation, true);
}
}
Aggregations