Search in sources :

Example 1 with CodeBrowserEditingTarget

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

the class Source method attemptSourceNavigation.

private void attemptSourceNavigation(final SourceNavigation navigation, final AppCommand retryCommand) {
    // see if we can navigate by id
    String docId = navigation.getDocumentId();
    final EditingTarget target = getEditingTargetForId(docId);
    if (target != null) {
        // case execute the retry command
        if ((target == activeEditor_) && target.isAtSourceRow(navigation.getPosition())) {
            if (retryCommand.isEnabled())
                retryCommand.execute();
        } else {
            suspendSourceNavigationAdding_ = true;
            try {
                view_.selectTab(target.asWidget());
                target.restorePosition(navigation.getPosition());
            } finally {
                suspendSourceNavigationAdding_ = false;
            }
        }
    } else // check for code browser navigation
    if ((navigation.getPath() != null) && navigation.getPath().startsWith(CodeBrowserEditingTarget.PATH)) {
        activateCodeBrowser(navigation.getPath(), false, new SourceNavigationResultCallback<CodeBrowserEditingTarget>(navigation.getPosition(), retryCommand));
    } else // check for file path navigation
    if ((navigation.getPath() != null) && !navigation.getPath().startsWith(DataItem.URI_PREFIX)) {
        FileSystemItem file = FileSystemItem.createFile(navigation.getPath());
        TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
        // open the file and restore the position
        openFile(file, fileType, new SourceNavigationResultCallback<EditingTarget>(navigation.getPosition(), retryCommand));
    } else {
        // couldn't navigate to this item, retry
        if (retryCommand.isEnabled())
            retryCommand.execute();
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) TextFileType(org.rstudio.studio.client.common.filetypes.TextFileType) 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

JsArrayString (com.google.gwt.core.client.JsArrayString)1 JSONString (com.google.gwt.json.client.JSONString)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 TextFileType (org.rstudio.studio.client.common.filetypes.TextFileType)1 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)1 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)1 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)1 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)1