Search in sources :

Example 1 with CodeNavigationTarget

use of org.rstudio.core.client.CodeNavigationTarget in project rstudio by rstudio.

the class CodeSearchOracle method navigationTarget.

public CodeNavigationTarget navigationTarget(String query, Suggestion suggestion) {
    CodeSearchSuggestion codeSearchSuggestion = (CodeSearchSuggestion) suggestion;
    // Allow queries of the form e.g. 'foo:15' to go to line '15' of a file.
    // We parse the integer following the ':' if possible.
    FilePosition filePos = codeSearchSuggestion.getNavigationTarget().getPosition();
    if (codeSearchSuggestion.isFileTarget()) {
        int colonIndex = query.indexOf(":");
        if (colonIndex > 0) {
            String[] splat = query.split(":");
            if (splat.length > 1) {
                int rowToNavigateTo = 0;
                try {
                    rowToNavigateTo = Integer.parseInt(splat[1]);
                } catch (Exception e) {
                }
                int colToNavigateTo = 0;
                if (splat.length > 2) {
                    try {
                        colToNavigateTo = Integer.parseInt(splat[2]);
                    } catch (Exception e) {
                    }
                }
                filePos = FilePosition.create(rowToNavigateTo, colToNavigateTo);
            }
        }
    }
    String fileName = codeSearchSuggestion.getNavigationTarget().getFile();
    CodeNavigationTarget target = new CodeNavigationTarget(fileName, filePos);
    return target;
}
Also used : CodeNavigationTarget(org.rstudio.core.client.CodeNavigationTarget) FilePosition(org.rstudio.core.client.FilePosition)

Example 2 with CodeNavigationTarget

use of org.rstudio.core.client.CodeNavigationTarget in project rstudio by rstudio.

the class FindOutputPane method createMainWidget.

@Override
protected Widget createMainWidget() {
    context_ = new FindResultContext();
    FindOutputResources resources = GWT.create(FindOutputResources.class);
    resources.styles().ensureInjected();
    table_ = new FastSelectTable<FindResult, CodeNavigationTarget, Object>(new FindOutputCodec(resources), resources.styles().selectedRow(), true, false);
    FontSizer.applyNormalFontSize(table_);
    table_.addStyleName(resources.styles().findOutput());
    table_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (event.getNativeButton() != NativeEvent.BUTTON_LEFT)
                return;
            if (dblClick_.checkForDoubleClick(event.getNativeEvent()))
                fireSelectionCommitted();
        }

        private final DoubleClickState dblClick_ = new DoubleClickState();
    });
    table_.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                fireSelectionCommitted();
            event.stopPropagation();
            event.preventDefault();
        }
    });
    container_ = new SimplePanel();
    container_.setSize("100%", "100%");
    statusPanel_ = new StatusPanel();
    statusPanel_.setSize("100%", "100%");
    scrollPanel_ = new ScrollPanel(table_);
    scrollPanel_.setSize("100%", "100%");
    container_.setWidget(scrollPanel_);
    return container_;
}
Also used : CodeNavigationTarget(org.rstudio.core.client.CodeNavigationTarget) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) FindResult(org.rstudio.studio.client.workbench.views.output.find.model.FindResult)

Aggregations

CodeNavigationTarget (org.rstudio.core.client.CodeNavigationTarget)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)1 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)1 FilePosition (org.rstudio.core.client.FilePosition)1 FindResult (org.rstudio.studio.client.workbench.views.output.find.model.FindResult)1