Search in sources :

Example 36 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class Files method onRenameFile.

@Handler
void onRenameFile() {
    // get currently selected files
    ArrayList<FileSystemItem> selectedFiles = view_.getSelectedFiles();
    // validation: some selection exists
    if (selectedFiles.size() == 0)
        return;
    // validation: no more than one file selected
    if (selectedFiles.size() > 1) {
        globalDisplay_.showErrorMessage("Invalid Selection", "Please select only one file to rename");
        return;
    }
    // validation -- not prohibited move of public folder
    if (!validateNotRestrictedFolder(selectedFiles, "renamed"))
        return;
    // prompt for new file name then execute the rename
    final FileSystemItem file = selectedFiles.get(0);
    globalDisplay_.promptForText("Rename File", "Please enter the new file name:", file.getName(), 0, file.getStem().length(), null, new ProgressOperationWithInput<String>() {

        public void execute(String input, final ProgressIndicator progress) {
            progress.onProgress("Renaming file...");
            String path = file.getParentPath().completePath(input);
            final FileSystemItem target = file.isDirectory() ? FileSystemItem.createDir(path) : FileSystemItem.createFile(path);
            // clear selection
            view_.selectNone();
            // premptively rename in the UI then fallback to refreshing
            // the view if there is an error
            view_.renameFile(file, target);
            // execute on the server
            server_.renameFile(file, target, new VoidServerRequestCallback(progress) {

                @Override
                protected void onSuccess() {
                    // if we were successful, let editor know
                    if (!file.isDirectory()) {
                        eventBus_.fireEvent(new SourcePathChangedEvent(file.getPath(), target.getPath()));
                    }
                }

                @Override
                protected void onFailure() {
                    onRefreshFiles();
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) SourcePathChangedEvent(org.rstudio.studio.client.workbench.views.source.events.SourcePathChangedEvent) OpenFileInBrowserHandler(org.rstudio.studio.client.common.filetypes.events.OpenFileInBrowserHandler) Handler(org.rstudio.core.client.command.Handler)

Example 37 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class History method onHistorySendToConsole.

@Handler
void onHistorySendToConsole() {
    String commandString = getSelectedCommands();
    commandString = StringUtil.chomp(commandString);
    if (commandString.length() > 0)
        events_.fireEvent(new SendToConsoleEvent(commandString, false));
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 38 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class History method onClearHistory.

@Handler
void onClearHistory() {
    view_.bringToFront();
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "Confirm Clear History", "Are you sure you want to clear all history entries?", new ProgressOperation() {

        public void execute(final ProgressIndicator indicator) {
            indicator.onProgress("Clearing history...");
            server_.clearHistory(new VoidServerRequestCallback(indicator));
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 39 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class ProfilerPresenter method onStartProfiler.

@Handler
public void onStartProfiler() {
    dependencyManager_.withProfvis(profilerDependecyUserAction_, new Command() {

        @Override
        public void execute() {
            ProfileOperationRequest request = ProfileOperationRequest.create("");
            server_.startProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {

                @Override
                public void onResponseReceived(ProfileOperationResponse response) {
                    if (response.getErrorMessage() != null) {
                        globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
                        return;
                    }
                    pSourceWindowManager_.get().ensureVisibleSourcePaneIfNecessary();
                    response_ = response;
                    sourceServer_.newDocument(FileTypeRegistry.PROFILER.getTypeId(), null, (JsObject) ProfilerContents.create(response.getFileName(), null, null, true).cast(), new SimpleRequestCallback<SourceDocument>("Show Profiler") {

                        @Override
                        public void onResponseReceived(SourceDocument response) {
                            currentDocId_ = response.getId();
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                        }
                    });
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                    globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
                }
            });
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) SourceDocument(org.rstudio.studio.client.workbench.views.source.model.SourceDocument) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest) Handler(org.rstudio.core.client.command.Handler)

Example 40 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class ProfilerPresenter method onStopProfiler.

@Handler
public void onStopProfiler() {
    ProfileOperationRequest request = ProfileOperationRequest.create(response_ != null ? response_.getFileName() : null);
    response_ = null;
    server_.stopProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {

        @Override
        public void onResponseReceived(ProfileOperationResponse response) {
            if (response.getErrorMessage() != null) {
                globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
                return;
            }
        }

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
            globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest) 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