Search in sources :

Example 21 with EditingTarget

use of org.rstudio.studio.client.workbench.views.source.editors.EditingTarget in project rstudio by rstudio.

the class Source method withTarget.

private void withTarget(String id, CommandWithArg<TextEditingTarget> command, Command onFailure) {
    EditingTarget target = StringUtil.isNullOrEmpty(id) ? activeEditor_ : getEditingTargetForId(id);
    if (target == null) {
        if (onFailure != null)
            onFailure.execute();
        return;
    }
    if (!(target instanceof TextEditingTarget)) {
        if (onFailure != null)
            onFailure.execute();
        return;
    }
    command.execute((TextEditingTarget) target);
}
Also used : TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)

Example 22 with EditingTarget

use of org.rstudio.studio.client.workbench.views.source.editors.EditingTarget in project rstudio by rstudio.

the class Source method getNextDefaultName.

private String getNextDefaultName(String defaultNamePrefix) {
    if (StringUtil.isNullOrEmpty(defaultNamePrefix)) {
        defaultNamePrefix = "Untitled";
    }
    int max = 0;
    for (EditingTarget target : editors_) {
        String name = target.getName().getValue();
        max = Math.max(max, getUntitledNum(name, defaultNamePrefix));
    }
    return defaultNamePrefix + (max + 1);
}
Also used : TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget) JSONString(com.google.gwt.json.client.JSONString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)22 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)22 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)22 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)22 JsArrayString (com.google.gwt.core.client.JsArrayString)10 JSONString (com.google.gwt.json.client.JSONString)10 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)9 Command (com.google.gwt.user.client.Command)7 AppCommand (org.rstudio.core.client.command.AppCommand)7 ServerError (org.rstudio.studio.client.server.ServerError)7 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)4 SourceDocument (org.rstudio.studio.client.workbench.views.source.model.SourceDocument)4 ArrayList (java.util.ArrayList)3 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)3 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)2 SelectionHandler (com.google.gwt.event.logical.shared.SelectionHandler)2 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)2 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)2