List of usage examples for org.eclipse.jface.viewers AbstractTreeViewer reveal
@Override public void reveal(Object elementOrTreePath)
From source file:org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP.java
License:Open Source License
/** * Tries to select the given node in the given TreeViewer. * //from w w w . ja v a 2 s . c o m * @param o * The Object to select * @param tv * the TreeViewer * @return the object which should be selected if found in tree viewer, null * otherwise */ public static Object selectNodeInTree(Object o, AbstractTreeViewer tv) { ISelection oldSelection = tv.getSelection(); if (o != null) { tv.refresh(); tv.expandToLevel(o, 0); tv.reveal(o); StructuredSelection newSelection = new StructuredSelection(o); tv.setSelection(newSelection); InteractionEventDispatcher.getDefault().fireProgammableSelectionEvent(newSelection); ISelection currSelection = tv.getSelection(); if (currSelection instanceof StructuredSelection) { Object currObj = ((StructuredSelection) currSelection).getFirstElement(); IElementComparer comparer = tv.getComparer(); if (comparer != null) { if (comparer.equals(o, currObj)) { return o; } } else { if (o.equals(currObj)) { return o; } } } } tv.setSelection(oldSelection); return null; }
From source file:org.eclipse.search.tests.filesearch.SearchResultPageTest.java
License:Open Source License
public void atestRemoveTreeMatches() 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();//from ww w. j a va 2 s .co m 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); }