org.eclipse.jface.viewers.ITreeContentProvider Java Examples
The following examples show how to use
org.eclipse.jface.viewers.ITreeContentProvider.
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: CommonListeningLabelProvider.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public void init ( final ICommonContentExtensionSite config ) { final ITreeContentProvider contentProvider = config.getService ().getContentExtensionById ( this.contentExtensionId ).getContentProvider (); if ( contentProvider instanceof ObservableSetTreeContentProvider ) { addSource ( ( (ObservableSetTreeContentProvider)contentProvider ).getKnownElements () ); } else if ( contentProvider instanceof ObservableSetContentProvider ) { addSource ( ( (ObservableSetContentProvider)contentProvider ).getKnownElements () ); } else if ( contentProvider instanceof ObservableListContentProvider ) { addSource ( ( (ObservableListContentProvider)contentProvider ).getKnownElements () ); } else if ( contentProvider instanceof ObservableListTreeContentProvider ) { addSource ( ( (ObservableListTreeContentProvider)contentProvider ).getKnownElements () ); } }
Example #2
Source File: FilteredElementTreeSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean isElementVisible(Viewer viewer, Object element) { boolean hasChildren= ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()).hasChildren(element); if (fIsDeepFiltering) { if (!super.isElementVisible(viewer, element)) return false; // Also apply deep filtering to the other registered filters ViewerFilter[] filters= ((TreeViewer)viewer).getFilters(); for (int i= 0; i < filters.length; i++) { if (filters[i] == this) continue; if (!filters[i].select(viewer, element, element)) return false; } return true; } return hasChildren || isLeafMatch(viewer, element); }
Example #3
Source File: PyCodeCoverageView.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public void setSelectedContainer(IContainer container) { lastSelectedFile = null; PyCoveragePreferences.setLastChosenDir(container); updateErrorMessages(); File input = container.getLocation().toFile(); viewer.setInput(input); ITreeContentProvider contentProvider = (ITreeContentProvider) viewer.getContentProvider(); Object[] children = contentProvider.getChildren(input); if (children.length > 0) { viewer.setSelection(new StructuredSelection(children[0])); } else { viewer.setSelection(new StructuredSelection()); } ProgressOperation.startAction(getSite().getShell(), refreshAction, true); }
Example #4
Source File: IndexViewContentProvider.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public boolean hasChildren(Object element) { List<ITreeContentProvider> providers = this.getProcessors(); boolean result = false; for (ITreeContentProvider provider : providers) { if (provider.hasChildren(element)) { result = true; break; } } return result; }
Example #5
Source File: RepositoryTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * */ protected void initialize() { setLabelProvider(new FileStoreLabelProvider()); setContentProvider(new RepositoryTreeContentProvider()); addFilter(new ViewerFilter() { @Override public boolean select(Viewer arg0, Object parentElement, Object element) { if(element instanceof IRepositoryStore){ ITreeContentProvider provider = (ITreeContentProvider) getContentProvider() ; return provider.hasChildren(element) ; } return true; } }) ; }
Example #6
Source File: ExportBarWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected boolean queryElementAndChildren(final String searchQuery, final Object element) { final String processName = ((AbstractProcess) element).getName(); final String processVersion = ((AbstractProcess) element).getVersion(); if (processName != null && processName.toLowerCase().contains(searchQuery.toLowerCase()) || processVersion != null && processVersion.toLowerCase().contains(searchQuery.toLowerCase())) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { viewer.expandAll(); } }); return true; } final ITreeContentProvider contentProvider = (ITreeContentProvider) viewer.getContentProvider(); if (contentProvider.hasChildren(element)) { for (final Object child : contentProvider.getChildren(element)) { if (queryElementAndChildren(searchQuery, child)) { return true; } } } return false; }
Example #7
Source File: ProblemsTreeEditor.java From cppcheclipse with Apache License 2.0 | 6 votes |
public void checkStateChanged(CheckStateChangedEvent event) { Object element = event.getElement(); // in case of changed category, go to all problems if (element instanceof String) { ITreeContentProvider contentProvider = (ITreeContentProvider)getTreeViewer().getContentProvider(); Object[] problems = contentProvider.getChildren(element); for (Object problem : problems) { if (problem instanceof Problem) { ((Problem)problem).setEnabled(event.getChecked()); } } } if (element instanceof Problem) { ((Problem) element).setEnabled(event.getChecked()); } }
Example #8
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 #9
Source File: GroupsWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void removeButtonSelected() { for (final Object sel : ((IStructuredSelection) getViewer().getSelection()).toList()) { if (sel instanceof org.bonitasoft.studio.actors.model.organization.Group) { final ITreeContentProvider contentProvider = (ITreeContentProvider) getViewer().getContentProvider(); if (contentProvider.hasChildren(sel)) { if (groupList.contains(sel)) { if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.deleteGroupTitle, Messages.deleteGroupMsg)) { removeChildren(contentProvider, sel); } else { return; } } } groupList.remove(sel); } } getViewer().setInput(groupList); selectionChanged(new SelectionChangedEvent(getViewer(), new StructuredSelection())); ((TreeViewer) getViewer()).expandAll(); }
Example #10
Source File: ConnectorImplementationWizard.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IWizardPage getDefinitionSelectionWizardPage( List<ConnectorImplementation> existingImplementation) { return new AbstractDefinitionSelectionImpementationWizardPage(implWorkingCopy,existingImplementation,((IDefinitionRepositoryStore) defStore).getDefinitions(),getSelectionPageTitle(),getSelectionPageDescription(),messageProvider){ @Override protected ITreeContentProvider getContentProvider() { return new UniqueConnectorDefinitionContentProvider(); } @Override protected ITreeContentProvider getCustomContentProvider() { return new UniqueConnectorDefinitionContentProvider(true); } @Override protected void bindValue() { final IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(explorer.getRightTableViewer()); context.bindValue(observeSingleSelection, EMFObservables.observeValue(implementation, ConnectorImplementationPackage.Literals.CONNECTOR_IMPLEMENTATION__DEFINITION_ID),defIdStrategy,defModelStrategy) ; context.bindValue(ViewersObservables.observeSingleSelection(versionCombo), EMFObservables.observeValue(implementation, ConnectorImplementationPackage.Literals.CONNECTOR_IMPLEMENTATION__DEFINITION_VERSION)); } }; }
Example #11
Source File: CheckboxTreeAndListGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates an instance of this class. Use this constructor if you wish to specify * the width and/or height of the combined widget (to only hardcode one of the * sizing dimensions, specify the other dimension's value as -1) * @param parent parent composite * @param rootObject * @param treeContentProvider * @param treeLabelProvider * @param listContentProvider * @param listLabelProvider * @param style * @param width the width * @param height the height */ public CheckboxTreeAndListGroup( Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height) { fRoot= rootObject; fTreeContentProvider= treeContentProvider; fListContentProvider= listContentProvider; fTreeLabelProvider= treeLabelProvider; fListLabelProvider= listLabelProvider; createContents(parent, width, height, style); }
Example #12
Source File: DataSetBasePage.java From birt with Eclipse Public License 1.0 | 6 votes |
public boolean isElementVisible( Viewer viewer, Object element ) { if ( isLeafMatch( viewer, element ) ) { return true; } if ( element instanceof DataSourceType ) { ITreeContentProvider contentProvider = (ITreeContentProvider) ( (TreeViewer) viewer ).getContentProvider( ); DataSourceType node = (DataSourceType) element; Object[] children = contentProvider.getChildren( node ); // Will return true if any subnode of the element matches the search if ( filter( viewer, element, children ).length > 0 ) { return true; } } return false; }
Example #13
Source File: AbstractInformationControl.java From typescript.java with MIT License | 6 votes |
/** * @param viewer * @param element * @return if the element has children that pass the filter */ private boolean hasUnfilteredChild(TreeViewer viewer, Object element) { // No point calling hasChildren() because the operation is the same // cost // as getting the children // If the element has a child that passes the filter, then we want // to // keep the parent around - even if it does not pass the filter // itself Object[] children = ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element); if (children != null) { for (int i = 0; i < children.length; i++) { if (select(viewer, element, children[i])) { return true; } } } // Element does not pass the filter return false; }
Example #14
Source File: TriStateFilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override protected void checkSubtree(Object element, boolean state) { CheckboxTreeViewer checkboxTreeViewer = getCheckboxTreeViewer(); if (checkboxTreeViewer.testFindItem(element) != null) { if (state) { fCheckedObjects.add(element); } else { fCheckedObjects.remove(element); } } boolean expanded = checkboxTreeViewer.getExpandedState(element); /* make sure element is expanded so that testFindItem will find the children */ checkboxTreeViewer.setExpandedState(element, true); for (Object o : ((ITreeContentProvider) checkboxTreeViewer.getContentProvider()).getChildren(element)) { checkSubtree(o, state); } checkboxTreeViewer.setExpandedState(element, expanded); maintainAllCheckIntegrity(); }
Example #15
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 #16
Source File: JavaSynchronizationContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected ITreeContentProvider getDelegateContentProvider() { if (fContentProvider == null) fContentProvider= new JavaModelContentProvider(); return fContentProvider; }
Example #17
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int getMatchCount(ITreeContentProvider cp, Object[] elements) { int count= 0; for (int j = 0; j < elements.length; j++) { count+= getDisplayedMatchCount(elements[j]); Object[] children = cp.getChildren(elements[j]); count+= getMatchCount(cp, children); } return count; }
Example #18
Source File: ResourceTree.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public ResourceTree(Composite parent, ITreeContentProvider contentProvider, ILabelProvider labelProvider) { super(parent); this.contentProvider = contentProvider; this.labelProvider = labelProvider; tree = this.getTree(); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); this.setLabelProvider(this.labelProvider); this.setContentProvider(this.contentProvider); this.addCheckStateListener(this); this.addDoubleClickListener(this); }
Example #19
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int getFilteredMatchCount() { StructuredViewer viewer= getViewer(); if (viewer instanceof TreeViewer) { ITreeContentProvider tp= (ITreeContentProvider) viewer.getContentProvider(); return getMatchCount(tp, getRootElements((TreeViewer) getViewer())); } else { return getMatchCount((TableViewer) viewer); } }
Example #20
Source File: JavadocTreeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void createInputGroup(Composite composite) { createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocTreeWizardPage_checkboxtreeandlistgroup_label, createGridData(6)); Composite c= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 1; layout.makeColumnsEqualWidth= true; layout.marginWidth= 0; layout.marginHeight= 0; c.setLayout(layout); c.setLayoutData(createGridData(GridData.FILL_BOTH, 6, 0)); ITreeContentProvider treeContentProvider= new JavadocProjectContentProvider(); ITreeContentProvider listContentProvider= new JavadocMemberContentProvider(); fInputGroup= new CheckboxTreeAndListGroup(c, this, treeContentProvider, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), listContentProvider, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), SWT.NONE, convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(7)); fInputGroup.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent e) { doValidation(TREESTATUS); } }); fInputGroup.setTreeComparator(new JavaElementComparator()); SWTUtil.setAccessibilityText(fInputGroup.getTree(), JavadocExportMessages.JavadocTreeWizardPage_tree_accessibility_message); SWTUtil.setAccessibilityText(fInputGroup.getTable(), JavadocExportMessages.JavadocTreeWizardPage_table_accessibility_message); IJavaElement[] elements= fStore.getInitialElements(); setTreeChecked(elements); if (elements.length > 0) { fInputGroup.setTreeSelection(new StructuredSelection(elements[0].getJavaProject())); } fInputGroup.aboutToOpen(); }
Example #21
Source File: CheckboxTreeAndListGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Sets the tree viewer's providers to those passed * * @param contentProvider ITreeContentProvider * @param labelProvider ILabelProvider */ public void setTreeProviders( ITreeContentProvider contentProvider, ILabelProvider labelProvider) { fTreeViewer.setContentProvider(contentProvider); fTreeViewer.setLabelProvider(labelProvider); }
Example #22
Source File: DocumentsView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element){ if (searchTitle != null && !searchTitle.isEmpty()) { String searchText = searchTitle.toLowerCase(); if (element instanceof ICategory) { StructuredViewer sviewer = (StructuredViewer) viewer; ITreeContentProvider provider = (ITreeContentProvider) sviewer.getContentProvider(); for (Object child : provider.getChildren(element)) { if (select(viewer, element, child)) return true; } return false; } if (element instanceof IDocument) { IDocument iDocument = (IDocument) element; if (iDocument.getCategory().getName().toLowerCase().startsWith(searchText)) { return true; } if (iDocument.getTitle().toLowerCase().contains(searchText)) { return true; } if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase() .contains(searchText.toLowerCase())) { return true; } } return false; } return true; }
Example #23
Source File: ConnectorImplementationWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IWizardPage getImplementationPage( List<ConnectorImplementation> existingImplementation) { return new AbstractImplementationWizardPage(implWorkingCopy,existingImplementation,((IDefinitionRepositoryStore) defStore).getDefinitions(),sourceStore,getPageTitle(),getPageDescription(),messageProvider){ @Override protected ITreeContentProvider getContentProvider() { return new ConnectorDefinitionContentProvider(); } }; }
Example #24
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 #25
Source File: NonEssentialElementsFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Object[] getRawChildren(StructuredViewer viewer, IPackageFragment fragment) { IStructuredContentProvider provider = (IStructuredContentProvider) viewer.getContentProvider(); if (provider instanceof ITreeContentProvider) { return ((ITreeContentProvider)provider).getChildren(fragment); } return provider.getElements(fragment); }
Example #26
Source File: WizardExportResourcesPage2.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Returns a content provider for <code>IResource</code>s that returns only children of the given resource type. */ private ITreeContentProvider getResourceProvider(final int resourceType) { return new WorkbenchContentProvider() { public Object[] getChildren(Object o) { if (o instanceof IContainer) { IResource[] members = null; try { members = ((IContainer) o).members(); } catch (CoreException e) { // just return an empty set of children return new Object[0]; } // filter out the desired resource types ArrayList results = new ArrayList(); for (int i = 0; i < members.length; i++) { if (members[i].getName().equals(".config") || members[i].getName().equals(".project") ||members[i].getName().equalsIgnoreCase(".temp") ) { defaultExportItems.add(members[i]); continue; } // And the test bits with the resource types to see if they are what we want if ((members[i].getType() & resourceType) > 0) { results.add(members[i]); } } return results.toArray(); } // input element case if (o instanceof ArrayList) { return ((ArrayList) o).toArray(); } return new Object[0]; } }; }
Example #27
Source File: TreePatternFilter.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Check if at least one of the parents of this element is a match with the * filter text. * * @param viewer * the viewer that contains the element * @param element * the tree element to check * @return true if the given element has a parent that matches the filter * text */ private boolean isChildMatch(Viewer viewer, Object element) { Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()) .getParent(element); while (parent != null) { if (isLeafMatch(viewer, parent)) { return true; } parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()) .getParent(parent); } return false; }
Example #28
Source File: DiagnoseSelektor.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void addDiagnoses(ITreeContentProvider tcp, Object[] roots){ for (Object object : roots) { if (tcp.hasChildren(object)) { addDiagnoses(tcp, tcp.getChildren(object)); } else { diagnoses.add((IDiagnosis) object); } } }
Example #29
Source File: AbstractSearchResultsViewerFilter.java From Pydev with Eclipse Public License 1.0 | 5 votes |
protected boolean isParentMatch(Viewer viewer, Object element) { Object[] children = ((ITreeContentProvider) ((AbstractTreeViewer) viewer) .getContentProvider()).getChildren(element); if ((children != null) && (children.length > 0)) { return isAnyVisible(viewer, element, children); } return false; }
Example #30
Source File: SelectConnectorConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(10, 10, 10, 0).create()); filterTree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER, new PatternFilter(), true); filterTree.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ; filterTree.getViewer().setLabelProvider(new ConnectorConfigurationLabelProvider()); filterTree.getViewer().setContentProvider(new ConnectorConfigurationContentProvider()); filterTree.getViewer().addSelectionChangedListener(this) ; filterTree.getViewer().addDoubleClickListener(this) ; filterTree.getViewer().setInput(new Object()); filterTree.getViewer().addFilter(new ViewerFilter() { @Override public boolean select(Viewer arg0, Object arg1, Object element) { ITreeContentProvider contentProvider = (ITreeContentProvider)filterTree.getViewer().getContentProvider(); if (element instanceof Category){ if(!contentProvider.hasChildren(element)){ return false; } boolean hasElements=false; for(Object c : contentProvider.getChildren(element)){ hasElements=hasElements || select(arg0,element,c); } return hasElements; }else if(element instanceof ConnectorDefinition){ return contentProvider.getChildren(element).length > 0; } return element instanceof ConnectorConfiguration; } }) ; filterTree.getViewer().expandAll(); filterTree.setFocus(); setControl(composite); }