Java Code Examples for org.eclipse.jface.viewers.ITreeContentProvider#getParent()
The following examples show how to use
org.eclipse.jface.viewers.ITreeContentProvider#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTreePatternFilter.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override protected boolean isLeafMatch(Viewer viewer, Object element) { Object node = element; StructuredViewer structuredViewer = (StructuredViewer) viewer; ITableLabelProvider labelProvider = (ITableLabelProvider) structuredViewer.getLabelProvider(); ITreeContentProvider treeContentProvider = (ITreeContentProvider) structuredViewer.getContentProvider(); // Ensure the tree element and its parent(s) match the filter text for (Predicate<String> p : fPredicates) { // Retrieve tree element text and make verification. Text is at column 0 String labelText = labelProvider.getColumnText(node, 0); if (labelText == null || !p.test(labelText)) { return false; } // Retrieve parent element node = treeContentProvider.getParent(node); } return true; }
Example 2
Source File: PostfixLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private String getQualification(Object element) { StringBuffer res= new StringBuffer(); ITreeContentProvider provider= (ITreeContentProvider) fPage.getViewer().getContentProvider(); Object visibleParent= provider.getParent(element); Object realParent= fContentProvider.getParent(element); Object lastElement= element; while (realParent != null && !(realParent instanceof IJavaModel) && !realParent.equals(visibleParent)) { if (!isSameInformation(realParent, lastElement)) { res.append(JavaElementLabels.CONCAT_STRING).append(internalGetText(realParent)); } lastElement= realParent; realParent= fContentProvider.getParent(realParent); } return res.toString(); }
Example 3
Source File: TriStateFilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Ensure that the state of the checkbox and its parents are correct. * * TODO: Create utils method for use in other checkboxes. * * @param element * Tree element from which the verification needs to be made */ private void maintainCheckIntegrity(final Object element) { CheckboxTreeViewer checkboxTreeViewer = getCheckboxTreeViewer(); ITreeContentProvider contentProvider = (ITreeContentProvider) checkboxTreeViewer.getContentProvider(); boolean allChecked = true; boolean oneChecked = false; boolean oneGrayed = false; for (Object child : contentProvider.getChildren(element)) { if (checkboxTreeViewer.testFindItem(child) == null) { continue; } boolean checked = getChecked(child); oneChecked |= checked; allChecked &= checked; oneGrayed |= (checked && getGrayed(child)); if (oneGrayed || (oneChecked && !allChecked)) { setGrayed(element, true); setChecked(element, true); } else { setGrayed(element, false); setChecked(element, allChecked); } } Object parentElement = contentProvider.getParent(element); if (parentElement != null) { maintainCheckIntegrity(parentElement); } }
Example 4
Source File: BreadcrumbViewer.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Generates the parent chain of the given element. * * @param element element to build the parent chain for * @return the first index of an item in fBreadcrumbItems which is not part of * the chain */ private int buildItemChain(Object element) { if (element == null) return 0; ITreeContentProvider contentProvider = (ITreeContentProvider) getContentProvider(); Object parent = contentProvider.getParent(element); int index = buildItemChain(parent); BreadcrumbItem item; if (index < fBreadcrumbItems.size()) { item = (BreadcrumbItem) fBreadcrumbItems.get(index); if (item.getData() != null) unmapElement(item.getData()); } else { item = createItem(); fBreadcrumbItems.add(item); } if (equals(element, item.getData())) { update(element, null); } else { item.setData(element); item.refresh(); } if (parent == null) { // don't show the models root item.setDetailsVisible(false); } mapElement(element, item); return index + 1; }
Example 5
Source File: CustomFiltersActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isSelected(Object parent, Object element, IContentProvider contentProvider, ViewerFilter filter) { if (filter instanceof EmptyLibraryContainerFilter) // workaround for https://bugs.eclipse.org/341109 return true; if (contentProvider instanceof ITreeContentProvider) { // the element and all its parents have to be selected ITreeContentProvider provider = (ITreeContentProvider) contentProvider; while (element != null && !(element instanceof IJavaModel)) { if (!filter.select(fViewer, parent, element)) return false; element= provider.getParent( element); } return true; } return filter.select(fViewer, parent, element); }
Example 6
Source File: BreadcrumbViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Generates the parent chain of the given element. * * @param element element to build the parent chain for * @return the first index of an item in fBreadcrumbItems which is not part of the chain */ private int buildItemChain(Object element) { if (element == null) return 0; ITreeContentProvider contentProvider= (ITreeContentProvider) getContentProvider(); Object parent= contentProvider.getParent(element); int index= buildItemChain(parent); BreadcrumbItem item; if (index < fBreadcrumbItems.size()) { item= fBreadcrumbItems.get(index); if (item.getData() != null) unmapElement(item.getData()); } else { item= createItem(); fBreadcrumbItems.add(item); } if (equals(element, item.getData())) { update(element, null); } else { item.setData(element); item.refresh(); } if (parent == null) { //don't show the models root item.setDetailsVisible(false); } mapElement(element, item); return index + 1; }
Example 7
Source File: BreadcrumbViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Generates the parent chain of the given element. * * @param element * element to build the parent chain for * @return the first index of an item in fBreadcrumbItems which is not part * of the chain */ protected int buildItemChain( Object element ) { if ( element == null ) return 0; ITreeContentProvider contentProvider = (ITreeContentProvider) getContentProvider( ); Object parent = contentProvider.getParent( element ); if ( parent == element ) return 0; int index = buildItemChain( parent ); BreadcrumbItem item; if ( index < fBreadcrumbItems.size( ) ) { item = (BreadcrumbItem) fBreadcrumbItems.get( index ); if ( item.getData( ) != null ) unmapElement( item.getData( ) ); } else { item = createItem( ); fBreadcrumbItems.add( item ); } if ( element != null && equals( element, item.getData( ) ) ) { update( element, null ); } else { item.setData( element ); item.refresh( ); } if ( parent == null ) { // don't show the models root item.setDetailsVisible( true ); item.setShowText( false ); rootItem = item; } mapElement( element, item ); return index + 1; }