Java Code Examples for org.eclipse.jface.viewers.TreeViewer#getContentProvider()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#getContentProvider() .
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: ContactSelectionComposite.java From saros with GNU General Public License v2.0 | 6 votes |
/** * Gathers the checked states of the given widget and its descendants, following a pre-order * traversal of the {@link ITreeContentProvider}. * * @param treeViewer to be traversed * @return */ protected static List<RosterEntryElement> collectAllRosterEntryElement(TreeViewer treeViewer) { ITreeContentProvider treeContentProvider = (ITreeContentProvider) treeViewer.getContentProvider(); List<Object> collectedObjects = new ArrayList<Object>(); Object[] objects = treeContentProvider.getElements(treeViewer.getInput()); for (Object object : objects) { collectedObjects.add(object); collectAllRosterEntryElement(collectedObjects, treeViewer, object); } return ArrayUtils.getInstances(collectedObjects.toArray(), RosterEntryElement.class); }
Example 2
Source File: TypeScriptSearchResultPage.java From typescript.java with MIT License | 5 votes |
protected void configureTreeViewer(TreeViewer viewer) { viewer.setUseHashlookup(true); TypeScriptSearchLabelProvider innerLabelProvider= new TypeScriptSearchLabelProvider(this, TypeScriptSearchLabelProvider.SHOW_LABEL); viewer.setLabelProvider(new DecoratingTypeScriptSearchLabelProvider(innerLabelProvider)); viewer.setContentProvider(new TypeScriptSearchTreeContentProvider(this, viewer)); viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider)); fContentProvider= (ITypeScriptSearchContentProvider) viewer.getContentProvider(); addDragAdapters(viewer); }
Example 3
Source File: ReorgMoveWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void doNewButtonPressed() { Object newElement= fCreateTargetQuery.getCreatedTarget(fDestination); if (newElement != null) { TreeViewer viewer= getTreeViewer(); ITreeContentProvider contentProvider= (ITreeContentProvider) viewer.getContentProvider(); viewer.refresh(contentProvider.getParent(newElement)); viewer.setSelection(new StructuredSelection(newElement), true); viewer.getTree().setFocus(); } }
Example 4
Source File: HierarchyInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void toggleHierarchy() { TreeViewer treeViewer= getTreeViewer(); treeViewer.getTree().setRedraw(false); Object[] expandedElements= treeViewer.getExpandedElements(); TypeHierarchyContentProvider contentProvider= (TypeHierarchyContentProvider) treeViewer.getContentProvider(); treeViewer.setContentProvider(fOtherContentProvider); treeViewer.refresh(); if (fOtherExpandedElements != null) { treeViewer.setExpandedElements(fOtherExpandedElements); } else { treeViewer.expandAll(); } // reveal selection Object selectedElement= getSelectedElement(); if (selectedElement != null) getTreeViewer().reveal(selectedElement); else selectFirstMatch(); treeViewer.getTree().setRedraw(true); fOtherContentProvider= contentProvider; fOtherExpandedElements= expandedElements; updateStatusFieldText(); }
Example 5
Source File: AbstractSearchIndexResultPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected void configureTreeViewer(TreeViewer viewer) { viewer.setUseHashlookup(true); SearchIndexLabelProvider innerLabelProvider = createSearchIndexLabelProvider(); viewer.setLabelProvider(new DecoratingFileSearchLabelProvider(innerLabelProvider)); viewer.setContentProvider(createTreeContentProvider(viewer)); viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider)); fContentProvider = (ISearchIndexContentProvider) viewer.getContentProvider(); addDragAdapters(viewer); updateGroupWith(viewer); }
Example 6
Source File: FileSearchPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected void configureTreeViewer(TreeViewer viewer) { viewer.setUseHashlookup(true); FileLabelProvider innerLabelProvider = new FileLabelProvider(this, FileLabelProvider.SHOW_LABEL); viewer.setLabelProvider(innerLabelProvider); viewer.setContentProvider(new FileTreeContentProvider(this, viewer)); viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider)); fContentProvider = (IFileSearchContentProvider) viewer.getContentProvider(); addDragAdapters(viewer); }
Example 7
Source File: ContactSelectionComposite.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Gathers the checked states of the given widget and its descendants, following a pre-order * traversal of the {@link ITreeContentProvider}. * * @param collectedObjects a writable list of elements (element type: <code>Object</code> ) * @param treeViewer to be traversed * @param parentElement of which to determine the child nodes */ protected static void collectAllRosterEntryElement( List<Object> collectedObjects, TreeViewer treeViewer, Object parentElement) { ITreeContentProvider treeContentProvider = (ITreeContentProvider) treeViewer.getContentProvider(); Object[] objects = treeContentProvider.getChildren(parentElement); for (Object object : objects) { collectedObjects.add(object); collectAllRosterEntryElement(collectedObjects, treeViewer, object); } }
Example 8
Source File: AbstractWorkingSetWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void createTree(Composite parent) { Label label= new Label(parent, SWT.NONE); label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false)); label.setText(WorkingSetMessages.JavaWorkingSetPage_workspace_content); fTree= new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); fTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); fTree.addFilter(new AddedElementsFilter()); fTree.setUseHashlookup(true); configureTree(fTree); fTreeContentProvider= (ITreeContentProvider) fTree.getContentProvider(); }
Example 9
Source File: PyCodeCoverageTestWorkbench.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void testPyCodeCoverageView() throws Exception { final PyCodeCoverageView view = PyCodeCoverageView.getView(true); //At this point it should have no folder selected and the option to run things in coverage should be //set to false. assertTrue(!PyCoveragePreferences.getAllRunsDoCoverage()); assertTrue(PyCodeCoverageView.getChosenDir() == null); assertTrue(!view.allRunsGoThroughCoverage.getSelection()); assertTrue(!PyCoveragePreferences.getInternalAllRunsDoCoverage()); view.allRunsGoThroughCoverage.setSelection(true); view.allRunsGoThroughCoverage.notifyListeners(SWT.Selection, new Event()); assertTrue(PyCoveragePreferences.getInternalAllRunsDoCoverage()); assertTrue(!PyCoveragePreferences.getAllRunsDoCoverage()); view.setSelectedContainer(sourceFolder); TreeViewer treeViewer = view.getTreeViewer(); ITreeContentProvider cp = (ITreeContentProvider) treeViewer.getContentProvider(); Object[] elements = cp.getElements(treeViewer.getInput()); assertEquals(1, elements.length); ILabelProvider labelProvider = (ILabelProvider) treeViewer.getLabelProvider(); assertEquals("pack_cov", labelProvider.getText(elements[0])); TestCaseUtils.assertContentsEqual(getInitialCoverageText(), view.getCoverageText()); Object[] expandedElements = treeViewer.getExpandedElements(); assertEquals(0, expandedElements.length); treeViewer.expandAll(); expandedElements = treeViewer.getExpandedElements(); assertEquals(1, expandedElements.length); view.executeRefreshAction(new NullProgressMonitor()); expandedElements = treeViewer.getExpandedElements(); assertEquals(1, expandedElements.length); assertTrue(PyCoveragePreferences.getAllRunsDoCoverage()); final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench(); Display display = workBench.getDisplay(); // Make sure to run the UI thread. final PyEdit modCovEditor = (PyEdit) PyOpenEditor.doOpenEditor(modCov); try { display.syncExec(new Runnable() { @Override public void run() { LaunchShortcut launchShortcut = new LaunchShortcut(); launchShortcut.launch(modCovEditor, "run"); } }); final String modCovCoverageText = StringUtils.replaceNewLines(getModCovCoverageText(), "\n"); //Should be enough time for the refresh to happen! goToManual(10000, new ICallback<Boolean, Object>() { @Override public Boolean call(Object arg) { return modCovCoverageText.equals(StringUtils.replaceNewLines(view.getCoverageText(), "\n")); } }); TestCaseUtils.assertContentsEqual(modCovCoverageText, view.getCoverageText()); //goToManual(); } finally { try { modCovEditor.close(false); } catch (Exception e) { //ignore anything here } } }
Example 10
Source File: ClipboardHandlerTree.java From arx with Apache License 2.0 | 2 votes |
/** * Returns the number of items. * * @param tree * @return */ private int getItemCount(TreeViewer tree) { ITreeContentProvider provider = (ITreeContentProvider)tree.getContentProvider(); return provider.getElements(null).length; }