Java Code Examples for org.eclipse.jface.viewers.TreeViewer#setSorter()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#setSorter() .
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: SVNWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
protected TreeViewer createResourceSelectionTree(Composite composite, int types, int span) { TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); tree.setUseHashlookup(true); tree.setContentProvider(getResourceProvider(types)); tree.setLabelProvider( new DecoratingLabelProvider( new WorkbenchLabelProvider(), SVNUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator())); tree.setSorter(new ResourceSorter(ResourceSorter.NAME)); GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); data.heightHint = LIST_HEIGHT_HINT; data.horizontalSpan = span; tree.getControl().setLayoutData(data); return tree; }
Example 2
Source File: ReadOnceTreeLoader.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public void init(){ if (slp == null) { slp = (SelectorPanelProvider) cv.getConfigurer().getControlFieldProvider(); } if (filter == null) { filter = new TreeFilter(slp.getPanel()); } tv = (TreeViewer) cv.getViewerWidget(); if (orderBy != null) { tv.setSorter(new ViewerSorter() { @Override public int compare(Viewer viewer, Object e1, Object e2){ String c1 = ((PersistentObject) e1).get(orderBy); String c2 = ((PersistentObject) e2).get(orderBy); return c1.compareTo(c2); } }); } tv.setFilters(new ViewerFilter[] { filter }); }
Example 3
Source File: TreeDialogBar.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
private void buildTree(TreeViewer treeViewer) { Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy(); TreeContentProvider contentProvider = new TreeContentProvider(treeViewer); treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(new DefaultEObjectLabelProvider()); treeViewer.setSorter(null); if(m.isPresent()) { treeViewer.setInput(m.get()); } }
Example 4
Source File: TreeDialogBubble.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
private void buildTree(TreeViewer treeViewer) { Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy(); TreeContentProvider contentProvider = new TreeContentProvider(treeViewer); treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(new DefaultEObjectLabelProvider()); treeViewer.setSorter(null); if(m.isPresent()) treeViewer.setInput(m.get()); }
Example 5
Source File: LibraryExplorerTreeViewPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Creates the tree view * * @param parent * the parent */ protected TreeViewer createTreeViewer( Composite parent ) { TreeViewer treeViewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ); treeViewer.setSorter( new ItemSorter( ) { @Override public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof ReportElementEntry || e2 instanceof ReportElementEntry ) { if ( e1 instanceof ReportElementEntry ) e1 = ( (ReportElementEntry) e1 ).getReportElement( ); if ( e2 instanceof ReportElementEntry ) e2 = ( (ReportElementEntry) e2 ).getReportElement( ); } else if ( e1 instanceof ResourceEntry && e2 instanceof ResourceEntry ) { ResourceEntry entry1 = (ResourceEntry) e1; ResourceEntry entry2 = (ResourceEntry) e2; if ( entry1 == null || entry2 == null ) { return entry1 == null ? -1 : 1; } boolean isEntry1File = entry1.isFile( ); boolean isEntry2File = entry2.isFile( ); if ( isEntry1File == isEntry2File ) { String name1 = entry1.getName( ); String name2 = entry2.getName( ); if ( name1 != null && name2 != null ) { return name1.toLowerCase( ) .compareTo( name2.toLowerCase( ) ); } else { return name1 == null ? -1 : 1; } } return isEntry1File ? 1 : -1; } return super.compare( viewer, e1, e2 ); } } ); configTreeViewer( treeViewer ); return treeViewer; }