use of org.eclipse.jface.viewers.AbstractTreeViewer in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method expandToNode.
private void expandToNode(DTDNode node) {
DTDFile dtdFile = node.getDTDFile();
// first expand the root
AbstractTreeViewer viewer = (AbstractTreeViewer) fViewer;
viewer.expandToLevel(dtdFile, 1);
NodeList listToExpand = null;
if (node instanceof Element || node instanceof ParameterEntityReference) {
listToExpand = dtdFile.getElementsAndParameterEntityReferences();
} else if (node instanceof Notation) {
listToExpand = dtdFile.getNotations();
} else if (node instanceof Entity) {
listToExpand = dtdFile.getEntities();
} else if (node instanceof Comment) {
listToExpand = dtdFile.getComments();
}
if (listToExpand != null) {
viewer.expandToLevel(listToExpand, 1);
}
viewer.expandToLevel(node, 0);
}
use of org.eclipse.jface.viewers.AbstractTreeViewer in project hale by halestudio.
the class TreePathPatternFilter method isParentMatch.
/**
* @see PatternFilter#isParentMatch(Viewer, Object)
*/
@Override
protected boolean isParentMatch(Viewer viewer, Object element) {
TreePath elementPath = (TreePath) element;
boolean proceed = allowDescend(elementPath);
if (!proceed) {
return false;
}
Object[] children;
ITreePathContentProvider cp = ((ITreePathContentProvider) ((AbstractTreeViewer) viewer).getContentProvider());
children = cp.getChildren(elementPath);
if ((children != null) && (children.length > 0)) {
// convert children to tree paths
List<TreePath> pathChildren = TreePathFilteredTree.getPathsForElements(elementPath, children);
return isAnyVisible(viewer, element, pathChildren.toArray());
}
return false;
}
use of org.eclipse.jface.viewers.AbstractTreeViewer 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);
}
use of org.eclipse.jface.viewers.AbstractTreeViewer in project webtools.sourceediting by eclipse.
the class XMLMultiPageEditorPart method addEditorActions.
private void addEditorActions(IDesignViewer viewer) {
if (viewer instanceof AbstractTreeViewer) {
final Tree tree = (Tree) ((AbstractTreeViewer) viewer).getControl();
fMenuManager = new MenuManager();
fMenuManager.add(new Action(XMLEditorMessages.ConfigureColumns_label) {
public void run() {
ConfigureColumns.forTree(tree, new SameShellProvider(tree));
}
});
// $NON-NLS-1$
getSite().registerContextMenu("org.eclipse.wst.xml.ui.editor", fMenuManager, getSite().getSelectionProvider());
fMenuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
fEditorManager.add(new EditorActions(fEditorManager.getControl()));
fEditorManager.update(true);
}
}
use of org.eclipse.jface.viewers.AbstractTreeViewer in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method nodesAdded.
public void nodesAdded(NodesEvent event) {
if (fViewer instanceof AbstractTreeViewer) {
StructuredViewer viewer = (StructuredViewer) fViewer;
ISelection selection = viewer.getSelection();
Object firstObj = (!selection.isEmpty() && selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
DTDNode oldSelectedNode = null;
if (firstObj instanceof DTDNode) {
oldSelectedNode = (DTDNode) firstObj;
}
// update the tree
refreshTree(event);
final List nodes = event.getNodes();
if (!nodes.isEmpty()) {
final DTDNode node = (DTDNode) nodes.get(0);
if (oldSelectedNode == null || node.getStructuredDTDDocumentRegion() != oldSelectedNode.getStructuredDTDDocumentRegion() || node.getStartOffset() != oldSelectedNode.getStartOffset() || node.getEndOffset() != oldSelectedNode.getEndOffset()) {
expandToNode(node);
viewer.setSelection(new StructuredSelection(node));
}
}
}
}
Aggregations