Java Code Examples for org.eclipse.jface.viewers.TreeViewer#setComparator()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#setComparator() .
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: AbstractSelectTreeViewer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Constructor * * @param parent * Parent composite * @param checkboxTree * <code>TriStateFilteredTree</code> wrapping a * <code>CheckboxTreeViewer</code> * @param legendColumnIndex * index of the legend column (-1 if none) */ private AbstractSelectTreeViewer(Composite parent, TriStateFilteredCheckboxTree checkboxTree, int legendIndex, String id) { super(parent, checkboxTree.getViewer()); TreeViewer treeViewer = checkboxTree.getViewer(); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.setComparator(COMPARATOR); if (treeViewer instanceof CheckboxTreeViewer) { ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener()); } treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener()); checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext()); fCheckboxTree = checkboxTree; fLegendIndex = legendIndex; fId = id; fLogCategory = fId + LOG_CATEGORY_SUFFIX; setLabelProvider(new DataProviderTreeLabelProvider()); fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet(); }
Example 2
Source File: AbstractSelectTreeViewer2.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Constructor * * @param parent * Parent composite * @param checkboxTree * <code>TriStateFilteredTree</code> wrapping a * <code>CheckboxTreeViewer</code> * @param legendColumnIndex * index of the legend column (-1 if none) */ private AbstractSelectTreeViewer2(Composite parent, TriStateFilteredCheckboxTree checkboxTree, int legendIndex, String id) { super(parent, checkboxTree.getViewer()); TreeViewer treeViewer = checkboxTree.getViewer(); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.setComparator(COMPARATOR); if (treeViewer instanceof CheckboxTreeViewer) { ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener()); } treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener()); checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext()); fCheckboxTree = checkboxTree; fLegendIndex = legendIndex; fId = id; fLogCategory = fId + LOG_CATEGORY_SUFFIX; fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet(); setLabelProvider(new DataProviderTreeLabelProvider()); }
Example 3
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void configureDropDownViewer(TreeViewer viewer, Object input) { viewer.setContentProvider(createDropDownContentProvider()); viewer.setLabelProvider(createDropDownLabelProvider()); viewer.setComparator(new JavaElementComparator()); viewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer1, Object parentElement, Object element) { if (element instanceof IMember) { if (((IMember) element).getElementName().startsWith("<")) { //$NON-NLS-1$ // filter out <clinit> return false; } } return true; } }); if (SHOW_LIBRARIES_NODE) viewer.addFilter(new EmptyLibraryContainerFilter()); JavaUIHelp.setHelp(viewer, IJavaHelpContextIds.JAVA_EDITOR_BREADCRUMB); }
Example 4
Source File: AbapGitStagingView.java From ADT_Frontend with MIT License | 6 votes |
private TreeViewer createTreeViewer(Composite parent, Boolean unstaged) { TreeViewer viewer = this.createTree(parent); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); viewer.getTree().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); viewer.setLabelProvider(new AbapGitStagingLabelProvider()); viewer.setContentProvider(new AbapGitStagingContentProvider()); viewer.setComparator(new AbapGitStagingTreeComparator()); viewer.getTree().setSortDirection(SWT.UP); if (this.treeFilter == null) { this.treeFilter = new AbapGitStagingTreeFilter(); } viewer.setFilters(this.treeFilter); addDoubleClickListener(viewer); addKeyListener(viewer, unstaged); return viewer; }
Example 5
Source File: TreeNavigationView.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public TreeNavigationView(Composite parent, int style) { super(parent, style); setLayout(new FillLayout(SWT.VERTICAL)); sashForm = new SashForm(this, SWT.HORIZONTAL); contentTypes = new TreeViewer(sashForm); contentTypes.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { fireSelectionChangedEvent(event); Object contentPanelSelection = null; ISelection selection = contentTypes.getSelection(); if (selection != null && !selection.isEmpty()) { contentPanelSelection = ((ITreeSelection) selection).getFirstElement(); } contentPanel.setSelection(contentPanelSelection); } }); contentPanel = new ContentPanel(sashForm, SWT.NONE); contentTypes.setComparator(new ModelNodeViewerComparator()); sashForm.setWeights(new int[] {20, 80}); contentTypes.setLabelProvider(new ModelLabelProvider()); contentTypes.setContentProvider(new TreeContentProvider()); contentTypes.getTree().addKeyListener( new EnterKeyTreeToggleKeyAdapter(contentTypes)); }
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: 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 8
Source File: JavaWorkingSetPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void configureTree(TreeViewer tree) { tree.setContentProvider(new JavaWorkingSetPageContentProvider()); AppearanceAwareLabelProvider javaElementLabelProvider= new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS ); tree.setLabelProvider(new DecoratingJavaLabelProvider(javaElementLabelProvider)); tree.setComparator(new JavaElementComparator()); tree.addFilter(new EmptyInnerPackageFilter()); tree.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())); if (getSelection() == null) return; Object[] selection= getInitialTreeSelection(); if (selection.length > 0) { try { tree.getTree().setRedraw(false); for (int i= 0; i < selection.length; i++) { tree.expandToLevel(selection[i], 0); } tree.setSelection(new StructuredSelection(selection)); } finally { tree.getTree().setRedraw(true); } } }
Example 9
Source File: DialogPackageExplorer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Control createControl(Composite parent) { fPackageViewer= new TreeViewer(parent, SWT.MULTI); fPackageViewer.setComparer(WorkingSetModel.COMPARER); fPackageViewer.addFilter(new PackageFilter()); fPackageViewer.setComparator(new ExtendedJavaElementSorter()); fPackageViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object element= ((IStructuredSelection)event.getSelection()).getFirstElement(); if (fPackageViewer.isExpandable(element)) { fPackageViewer.setExpandedState(element, !fPackageViewer.getExpandedState(element)); } else { if (element instanceof CPListElementAttribute) { CPListElementAttribute attribute= (CPListElementAttribute)element; if (attribute.getKey().equals(CPListElement.OUTPUT)) { fActionGroup.getEditOutputFolderAction().run(); } } } } }); MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(this); fContextMenu= menuMgr.createContextMenu(fPackageViewer.getTree()); fPackageViewer.getTree().setMenu(fContextMenu); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { fContextMenu.dispose(); } }); return fPackageViewer.getControl(); }
Example 10
Source File: JavaOutlineInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeViewer createTreeViewer(Composite parent, int style) { Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI)); GridData gd= new GridData(GridData.FILL_BOTH); gd.heightHint= tree.getItemHeight() * 12; tree.setLayoutData(gd); final TreeViewer treeViewer= new OutlineTreeViewer(tree); // Hard-coded filters treeViewer.addFilter(new NamePatternFilter()); treeViewer.addFilter(new MemberFilter()); fInnerLabelProvider= new OutlineLabelProvider(); fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager(); if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$ fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null)); treeViewer.setLabelProvider(new ColoringLabelProvider(fInnerLabelProvider)); fLexicalSortingAction= new LexicalSortingAction(treeViewer); fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer); fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer); fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer, getId(), getInputForCategories()); fOutlineContentProvider= new OutlineContentProvider(false); treeViewer.setContentProvider(fOutlineContentProvider); fOutlineSorter= new OutlineSorter(); treeViewer.setComparator(fOutlineSorter); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }
Example 11
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void configureTreeViewer(TreeViewer viewer) { PostfixLabelProvider postfixLabelProvider= new PostfixLabelProvider(this); viewer.setUseHashlookup(true); viewer.setComparator(new DecoratorIgnoringViewerSorter(postfixLabelProvider)); viewer.setLabelProvider(new DecoratingJavaLabelProvider(postfixLabelProvider, false)); fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping); viewer.setContentProvider(fContentProvider); addDragAdapters(viewer); }
Example 12
Source File: ReorgUserInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private TreeViewer createViewer(Composite parent) { TreeViewer treeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); GridData gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(40); gd.heightHint= convertHeightInCharsToPixels(15); treeViewer.getTree().setLayoutData(gd); treeViewer.setLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS)); treeViewer.setContentProvider(new DestinationContentProvider(getDestinationValidator())); treeViewer.setComparator(new JavaElementComparator()); treeViewer.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())); return treeViewer; }
Example 13
Source File: ProjectResourceControl.java From depan with Apache License 2.0 | 5 votes |
protected DrillDownComposite setupContainerControl(Composite parent) { DrillDownComposite result = new DrillDownComposite(parent, SWT.BORDER); containerViewer = new TreeViewer(result, SWT.NONE); result.setChildTree(containerViewer); containerViewer.setContentProvider(new WorkbenchContentProvider()); containerViewer.setLabelProvider(new WorkbenchLabelProvider()); containerViewer.setComparator(new ViewerComparator()); containerViewer.setUseHashlookup(true); containerViewer.setInput(prepareInput()); return result; }
Example 14
Source File: GraphNodeViewer.java From depan with Apache License 2.0 | 5 votes |
/** * Can be overridden to provide a customized tree viewer. * For example, the derived type {@link CheckNodeTreeView} * uses a {@code CheckboxTreeViewer}. */ protected TreeViewer createTreeViewer(Composite parent) { int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL; TreeViewer result = new TreeViewer(parent, style); result.setLabelProvider(new WorkbenchLabelProvider()); result.setContentProvider(new BaseWorkbenchContentProvider()); result.setComparator(SORTER); setupHierarchyMenu(result); return result; }
Example 15
Source File: TsfTraceAnalysisView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * This is a callback that will allow us to create the viewer and initialize * it. */ @Override public void createPartControl(Composite parent) { final SashForm sashForm = new SashForm(parent, SWT.NONE); final SashForm sashForm2 = new SashForm(sashForm, SWT.NONE); tsfviewer = new TimeGraphViewer(sashForm2, SWT.NONE); tsfviewer.setTimeGraphProvider(new TsfImplProvider()); tsfviewer2 = new TimeGraphViewer(sashForm2, SWT.NONE); tsfviewer2.setTimeGraphProvider(new TsfImplProvider()); viewer = new TreeViewer(sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); drillDownAdapter = new DrillDownAdapter(viewer); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setComparator(new ViewerComparator()); viewer.setInput(getViewSite()); sashForm.setWeights(new int[] { 5, 1 }); sashForm2.setWeights(new int[] { 1, 1 }); fact = new TraceModelImplFactory(); ITimeGraphEntry[] traceArr = fact.createTraces(); tsfviewer.setInput(traceArr); tsfviewer.addSelectionListener(this); tsfviewer.addRangeListener(this); tsfviewer.setTimeFormat(TimeFormat.CALENDAR); tsfviewer2.setInput(traceArr); tsfviewer2.addSelectionListener(this); tsfviewer2.addRangeListener(this); // tsfviewer2.setTimeFormat(TimeGraphViewer.timeFormat.epoch); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
Example 16
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 17
Source File: NavigationTree.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private static TreeViewer createViewer(Composite parent, boolean multi) { int selectionFlag = multi ? SWT.MULTI : SWT.SINGLE; TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | selectionFlag); viewer.setContentProvider(new NavigationContentProvider()); viewer.setLabelProvider(new NavigationLabelProvider(false)); viewer.setComparator(new NavigationComparator()); ColumnViewerToolTipSupport.enableFor(viewer); return viewer; }
Example 18
Source File: SelectLanguageConfigurationWizardPage.java From tm4e with Eclipse Public License 1.0 | 5 votes |
private void createContentTypeTreeViewer(Composite composite) { TreeViewer contentTypesViewer = new TreeViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); contentTypesViewer.getControl().setFont(composite.getFont()); contentTypesViewer.setContentProvider(new ContentTypesContentProvider()); contentTypesViewer.setLabelProvider(new ContentTypesLabelProvider()); contentTypesViewer.setComparator(new ViewerComparator()); contentTypesViewer.setInput(Platform.getContentTypeManager()); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; contentTypesViewer.getControl().setLayoutData(data); contentTypesViewer.addSelectionChangedListener(event -> contentTypeText .setText(((IContentType) event.getStructuredSelection().getFirstElement()).toString())); }
Example 19
Source File: DiffTreeViewer.java From olca-app with Mozilla Public License 2.0 | 4 votes |
protected void configureViewer(TreeViewer viewer, boolean checkable) { viewer.setContentProvider(new ContentProvider()); viewer.setComparator(new Comparator()); viewer.addDoubleClickListener(this::onDoubleClick); }
Example 20
Source File: AbstractSearchResultTreePage.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
protected void configureTreeViewer(TreeViewer viewer) { viewer.setComparator(createViewerComparator()); viewer.setLabelProvider(createLabelProvider()); fContentProvider = new ContentProvider(); viewer.setContentProvider(fContentProvider); }