Search in sources :

Example 51 with Handler

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);
    }
}
Also used : Range(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 52 with Handler

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());
        }
    });
}
Also used : SavePlotAsImageContext(org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) SaveViewerPlotAsImageDesktopDialog(org.rstudio.studio.client.workbench.views.viewer.export.SaveViewerPlotAsImageDesktopDialog) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Example 53 with Handler

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);
}
Also used : NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions) Size(org.rstudio.core.client.Size) WindowEx(org.rstudio.core.client.dom.WindowEx) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Example 54 with Handler

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();
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) VcsRefreshHandler(org.rstudio.studio.client.workbench.views.vcs.common.events.VcsRefreshHandler) Handler(org.rstudio.core.client.command.Handler)

Example 55 with Handler

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);
    }
}
Also used : ProcessCallback(org.rstudio.studio.client.workbench.views.vcs.common.ProcessCallback) StatusAndPath(org.rstudio.studio.client.common.vcs.StatusAndPath) ArrayList(java.util.ArrayList) OperationWithInput(org.rstudio.core.client.widget.OperationWithInput) Operation(org.rstudio.core.client.widget.Operation) Handler(org.rstudio.core.client.command.Handler)

Aggregations

Handler (org.rstudio.core.client.command.Handler)55 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)20 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)19 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)19 FileChangeHandler (org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)18 HideMessageHandler (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler)18 RecordNavigationPositionHandler (org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler)18 JsArrayString (com.google.gwt.core.client.JsArrayString)12 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)12 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)11 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)10 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)9 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)8 SelectionHandler (com.google.gwt.event.logical.shared.SelectionHandler)8 Command (com.google.gwt.user.client.Command)8 ServerError (org.rstudio.studio.client.server.ServerError)7 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)7 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)6 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)6 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)6