Search in sources :

Example 1 with ISearchResultViewPart

use of org.eclipse.search.ui.ISearchResultViewPart in project eclipse.platform.text by eclipse.

the class SearchResultPageTest method testTableNavigation.

@Test
public void testTableNavigation() {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    ISearchResultViewPart view = NewSearchUI.getSearchResultView();
    FileSearchPage page = (FileSearchPage) view.getActivePage();
    page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
    Table table = ((TableViewer) page.getViewer()).getTable();
    consumeEvents();
    // select the first element.
    table.setSelection(0);
    table.showSelection();
    consumeEvents();
    // back from first match, goto last
    page.gotoPreviousMatch();
    consumeEvents();
    assertEquals(1, table.getSelectionCount());
    assertEquals(table.getItemCount() - 1, table.getSelectionIndex());
    // and forward again, to the first match.
    page.gotoNextMatch();
    consumeEvents();
    assertEquals(1, table.getSelectionCount());
    assertEquals(0, table.getSelectionIndex());
}
Also used : Table(org.eclipse.swt.widgets.Table) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) FileSearchPage(org.eclipse.search.internal.ui.text.FileSearchPage) TableViewer(org.eclipse.jface.viewers.TableViewer) Test(org.junit.Test)

Example 2 with ISearchResultViewPart

use of org.eclipse.search.ui.ISearchResultViewPart in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method findCallers.

public void findCallers(WorkflowElement element) {
    WorkflowProcess processVersion = (WorkflowProcess) element;
    List<WorkflowProject> projects = new ArrayList<WorkflowProject>();
    projects.add(processVersion.getProject());
    Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
    ProcessSearchQuery searchQuery = new ProcessSearchQuery(projects, SearchQuery.SearchType.INVOKING_ENTITY, "*", true, shell);
    searchQuery.setInvokedEntityId(processVersion.getId());
    try {
        ProgressMonitorDialog context = new MdwProgressMonitorDialog(shell);
        NewSearchUI.runQueryInForeground(context, searchQuery);
        // this shouldn't be necessary according to the Eclipse API docs
        NewSearchUI.activateSearchResultView();
        ISearchResultViewPart part = NewSearchUI.getSearchResultView();
        part.updateLabel();
        SearchResultsPage page = (SearchResultsPage) part.getActivePage();
        page.setSearchQuery(searchQuery);
        page.setInput(searchQuery.getSearchResult(), null);
    } catch (OperationCanceledException ex) {
        MessageDialog.openInformation(shell, "Search Cancelled", "Search for callers cancelled.");
    } catch (Exception ex) {
        PluginMessages.uiError(shell, ex, "Search for Callers", processVersion.getProject());
    }
}
Also used : SearchResultsPage(com.centurylink.mdw.plugin.search.SearchResultsPage) Shell(org.eclipse.swt.widgets.Shell) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessSearchQuery(com.centurylink.mdw.plugin.search.ProcessSearchQuery) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException)

Example 3 with ISearchResultViewPart

use of org.eclipse.search.ui.ISearchResultViewPart in project eclipse.platform.text by eclipse.

the class TextSearchPage method performReplace.

@Override
public boolean performReplace() {
    try {
        IStatus status = NewSearchUI.runQueryInForeground(getContainer().getRunnableContext(), newQuery());
        if (status.matches(IStatus.CANCEL)) {
            return false;
        }
        if (!status.isOK()) {
            ErrorDialog.openError(getShell(), SearchMessages.TextSearchPage_replace_searchproblems_title, SearchMessages.TextSearchPage_replace_runproblem_message, status);
        }
        Display.getCurrent().asyncExec(() -> {
            ISearchResultViewPart view = NewSearchUI.activateSearchResultView();
            if (view != null) {
                ISearchResultPage page = view.getActivePage();
                if (page instanceof FileSearchPage) {
                    FileSearchPage filePage = (FileSearchPage) page;
                    new ReplaceAction(filePage.getSite().getShell(), (FileSearchResult) filePage.getInput(), null).run();
                }
            }
        });
        return true;
    } catch (CoreException e) {
        ErrorDialog.openError(getShell(), SearchMessages.TextSearchPage_replace_searchproblems_title, SearchMessages.TextSearchPage_replace_querycreationproblem_message, e.getStatus());
        return false;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) ISearchResultPage(org.eclipse.search.ui.ISearchResultPage)

Example 4 with ISearchResultViewPart

use of org.eclipse.search.ui.ISearchResultViewPart in project eclipse.platform.text by eclipse.

the class SearchViewManager method activateSearchView.

public ISearchResultViewPart activateSearchView(boolean avoidPinnedViews, boolean openInNew) {
    IWorkbenchPage activePage = SearchPlugin.getActivePage();
    String defaultPerspectiveId = NewSearchUI.getDefaultPerspectiveId();
    if (defaultPerspectiveId != null) {
        IWorkbenchWindow window = activePage.getWorkbenchWindow();
        if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
            try {
                activePage = PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window);
            } catch (WorkbenchException ex) {
            // show view in current perspective
            }
        }
    }
    if (activePage != null) {
        try {
            ISearchResultViewPart viewPart = null;
            if (!openInNew) {
                viewPart = findLRUSearchResultView(activePage, avoidPinnedViews);
            }
            String secondaryId = null;
            if (viewPart == null) {
                if (activePage.findViewReference(NewSearchUI.SEARCH_VIEW_ID) != null)
                    // avoid a secondary ID because of bug 125315
                    secondaryId = String.valueOf(++fViewCount);
            } else if (!SearchPreferencePage.isViewBroughtToFront())
                return viewPart;
            else
                secondaryId = viewPart.getViewSite().getSecondaryId();
            return (ISearchResultViewPart) activePage.showView(NewSearchUI.SEARCH_VIEW_ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
        } catch (PartInitException ex) {
            ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message);
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 5 with ISearchResultViewPart

use of org.eclipse.search.ui.ISearchResultViewPart in project eclipse.platform.text by eclipse.

the class SearchResultPageTest method testRemoveTreeMatches.

@Test
// checkElementDisplay(..) misses cases where one line contains multiple matches
@Ignore
public void testRemoveTreeMatches() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    ISearchResultViewPart view = NewSearchUI.getSearchResultView();
    FileSearchPage page = (FileSearchPage) view.getActivePage();
    page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_TREE);
    AbstractTreeViewer viewer = (AbstractTreeViewer) page.getViewer();
    AbstractTextSearchResult result = (AbstractTextSearchResult) fQuery1.getSearchResult();
    // make sure all elements have items.
    viewer.expandAll();
    Object[] elements = result.getElements();
    // page.setUpdateTracing(true);
    for (int i = 0; i < elements.length; i++) {
        Match[] matches = result.getMatches(elements[i]);
        viewer.reveal(elements[i]);
        for (int j = 0; j < matches.length; j++) {
            checkElementDisplay(viewer, result, elements[i]);
            result.removeMatch(matches[j]);
            consumeEvents(page);
        }
    }
// page.setUpdateTracing(false);
}
Also used : ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) FileSearchPage(org.eclipse.search.internal.ui.text.FileSearchPage) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Match(org.eclipse.search.ui.text.Match) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ISearchResultViewPart (org.eclipse.search.ui.ISearchResultViewPart)8 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)3 FileSearchPage (org.eclipse.search.internal.ui.text.FileSearchPage)3 Test (org.junit.Test)3 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 ProcessSearchQuery (com.centurylink.mdw.plugin.search.ProcessSearchQuery)2 SearchResultsPage (com.centurylink.mdw.plugin.search.SearchResultsPage)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 Shell (org.eclipse.swt.widgets.Shell)2 PartInitException (org.eclipse.ui.PartInitException)2 Ignore (org.junit.Ignore)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 ConnectException (java.net.ConnectException)1 IStatus (org.eclipse.core.runtime.IStatus)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1