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());
}
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());
}
}
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;
}
}
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;
}
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);
}
Aggregations