org.eclipse.jface.viewers.Viewer Java Examples
The following examples show how to use
org.eclipse.jface.viewers.Viewer.
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: DataSetBasePage.java From birt with Eclipse Public License 1.0 | 6 votes |
protected boolean isLeafMatch( Viewer viewer, Object element ) { String text; if ( element instanceof DataSourceType ) { return false; } else if ( element instanceof DataSourceHandle ) { DataSourceHandle node = (DataSourceHandle) element; text = node.getName( ); if ( wordMatches( text ) ) { return true; } } return false; }
Example #2
Source File: ContainedLibraryFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root= (IPackageFragmentRoot)element; if (root.isArchive()) { // don't filter out JARs contained in the project itself IResource resource= root.getResource(); if (resource != null) { IProject jarProject= resource.getProject(); IProject container= root.getJavaProject().getProject(); return !container.equals(jarProject); } } } return true; }
Example #3
Source File: DefinesViewer.java From cmake4eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2) { CmakeDefine v1 = (CmakeDefine) e1; CmakeDefine v2 = (CmakeDefine) e2; int rc = 0; switch (sortColumn) { case 0: rc = v1.getName().compareTo(v2.getName()); break; case 1: rc = v1.getType().name().compareTo(v2.getType().name()); break; case 2: rc = v1.getValue().compareTo(v2.getValue()); break; default: rc = 0; } // If descending order, flip the direction if (!ascending) { rc = -rc; } return rc; }
Example #4
Source File: PyExceptionListProvider.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (newInput == this.newInput) { return; } // let go of the old info before getting the new info dispose(); this.newInput = newInput; if (newInput == null) { return; } PyExceptionBreakPointManager instance = PyExceptionBreakPointManager.getInstance(); List<String> list = instance.getBuiltinExceptions(); list.addAll(instance.getUserConfiguredExceptions()); elementsForCurrentInput = list.toArray(new String[0]); }
Example #5
Source File: JavaElementComparator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private String getNonJavaElementLabel(Viewer viewer, Object element) { // try to use the workbench adapter for non - java resources or if not available, use the viewers label provider if (element instanceof IResource) { return ((IResource) element).getName(); } if (element instanceof IStorage) { return ((IStorage) element).getName(); } if (element instanceof IAdaptable) { IWorkbenchAdapter adapter= (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class); if (adapter != null) { return adapter.getLabel(element); } } if (viewer instanceof ContentViewer) { IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider(); if (prov instanceof ILabelProvider) { return ((ILabelProvider) prov).getText(element); } } return null; }
Example #6
Source File: CategoryFilterActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IMember) { IMember member= (IMember)element; try { String[] categories= member.getCategories(); if (categories.length == 0) return !fFilterUncategorizedMembers; for (int i= 0; i < categories.length; i++) { if (!fFilteredCategories.contains(categories[i])) return true; } return false; } catch (JavaModelException e) { JavaPlugin.log(e); } } return true; }
Example #7
Source File: ComplexFileSetsEditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2) { int result = 0; if ((e1 instanceof FileSet) && (e2 instanceof FileSet)) { FileSet fileSet1 = (FileSet) e1; FileSet fileSet2 = (FileSet) e2; String name1 = fileSet1.getName(); String name2 = fileSet2.getName(); result = name1.compareTo(name2); } return result; }
Example #8
Source File: KontaktAnzeigeTypViewerFilter.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public KontaktAnzeigeTypViewerFilter(Viewer viewer){ KontaktAnzeigeTypViewerFilter.viewer = viewer; PlatformUI.getPreferenceStore().setDefault( KontaktAnzeigeTypViewerFilter.class.getName() + ".showPatient", true); showPerson = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showPerson"); showPatient = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showPatient"); showOrganisation = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showOrganisation"); showMandant = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showMandant"); showAnwender = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showAnwender"); showDeleted = PlatformUI.getPreferenceStore().getBoolean( KontaktAnzeigeTypViewerFilter.class.getName() + ".showDeleted"); }
Example #9
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public Viewer createDiffViewer(final Composite parent) { viewer = new DiffTreeViewer(parent, getCompareConfiguration()); viewer.addOpenListener(new IOpenListener() { @Override public void open(final OpenEvent event) { final IStructuredSelection sel = (IStructuredSelection) event.getSelection(); final DiffNode obj = (DiffNode) sel.getFirstElement(); obj.setDontExpand(false); } }); viewer.setFilters(getFilters()); viewer.setLabelProvider(new DiffTreeLabelProvider()); viewer.setContentProvider(new BonitaScriptRefactoringContentProvider()); viewer.setInput(root); viewer.expandAll(); return viewer; }
Example #10
Source File: ContactSelectorViewerComparator.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2){ IContact c1 = (IContact) e1; IContact c2 = (IContact) e2; switch (selectedSorter) { case SORT_BY_FIRSTNAME: if (c1.getDescription1() == null || c2.getDescription1() == null) return 0; return c1.getDescription1().compareToIgnoreCase(c2.getDescription1()); case SORT_BY_FAMILYNAME: if (c1.getDescription2() == null || c2.getDescription2() == null) return 0; return c1.getDescription2().compareToIgnoreCase(c2.getDescription2()); default: if (c1.getDescription2() == null || c2.getDescription2() == null) return 0; return c1.getDescription2().compareToIgnoreCase(c2.getDescription2()); } }
Example #11
Source File: WorkingSetAwareJavaElementSorter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof IWorkingSet || e2 instanceof IWorkingSet) return 0; return super.compare(viewer, e1, e2); }
Example #12
Source File: CategoryPatternFilter.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * * @see org.eclipse.ui.dialogs.PatternFilter#isLeafMatch(org.eclipse.jface.viewers.Viewer, * java.lang.Object) */ protected boolean isLeafMatch(Viewer viewer, Object element) { if (filterCategories) { final ParameterizedCommand cmd = getCommand(element); try { if (cmd != null && cmd.getCommand().getCategory() == uncategorized) { return false; } } catch (NotDefinedException e) { return false; } } return super.isLeafMatch(viewer, element); }
Example #13
Source File: SpecialFoldersFilter.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IFolder) { if (((IFolder)element).getName().startsWith(".")) { //$NON-NLS-1$ return false; // exclude ".externals", ".settings" and other special folders started with '.' } } else if (element instanceof IFile) { if (hideFiles) { return false; } } return true; }
Example #14
Source File: InvasiveThemeHijacker.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void hijackCallHierarchy(final IViewPart view, final boolean revertToDefaults) { try { Field f = view.getClass().getDeclaredField("fPagebook"); //$NON-NLS-1$ f.setAccessible(true); PageBook pageBook = (PageBook) f.get(view); f = pageBook.getClass().getDeclaredField("currentPage"); //$NON-NLS-1$ f.setAccessible(true); Control control = (Control) f.get(pageBook); if (control instanceof Label) { hookTheme(control, revertToDefaults); return; } Method m = view.getClass().getMethod("getViewer"); //$NON-NLS-1$ TreeViewer treeViewer = (TreeViewer) m.invoke(view); hookTheme(treeViewer, revertToDefaults); m = view.getClass().getDeclaredMethod("getLocationViewer"); //$NON-NLS-1$ if (m != null) { m.setAccessible(true); Viewer viewer = (Viewer) m.invoke(view); hookTheme(viewer, revertToDefaults); } } catch (Exception e) { // ignore } }
Example #15
Source File: PythonNodeFilter.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof PythonNode) { return false; } return true; }
Example #16
Source File: LazyDiffEntryTreeProvider.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged ( final Viewer viewer, final Object oldInput, final Object newInput ) { this.input = newInput; if ( viewer instanceof TreeViewer ) { this.viewer = (TreeViewer)viewer; } else { this.viewer = null; } }
Example #17
Source File: JavaElementContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); fViewer= (TreeViewer)viewer; if (oldInput == null && newInput != null) { JavaCore.addElementChangedListener(this); } else if (oldInput != null && newInput == null) { JavaCore.removeElementChangedListener(this); } fInput= newInput; }
Example #18
Source File: BillingProposalView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput){ if (newInput instanceof List<?>) { currentContent = ((List<Konsultation>) newInput).parallelStream() .map(k -> new BillingInformation(this.viewer, k.getFall(), k)) .collect(Collectors.toList()); } }
Example #19
Source File: NavigationComparator.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 == null || e2 == null) return 0; if (!Objects.equals(e1.getClass(), e2.getClass())) return compareByType(e1, e2); if (e1 instanceof GroupElement && e2 instanceof GroupElement) return 0; if (e1 instanceof ModelTypeElement && e2 instanceof ModelTypeElement) return compare((ModelTypeElement) e1, (ModelTypeElement) e2); // the scripting folder should be always the last element in the tree if (!(e1 instanceof ScriptElement) && e2 instanceof ScriptElement) return -1; if (e1 instanceof ScriptElement && !(e2 instanceof ScriptElement)) return 1; if (e1 instanceof ScriptElement) { var f1 = ((ScriptElement) e1).getContent(); var f2 = ((ScriptElement) e2).getContent(); if (f1.isDirectory() && !f2.isDirectory()) return -1; if (!f1.isDirectory() && f2.isDirectory()) return 1; return Strings.compare(f1.getName(), f2.getName()); } String name1 = getLabel(viewer, e1); String name2 = getLabel(viewer, e2); // TODO: document why this here makes sense: (?) // probably the status suffix when the database is // connected to a repository? if (e1 instanceof DatabaseElement && name1.contains(" ")) name1 = name1.substring(0, name1.indexOf(" ")); if (e2 instanceof DatabaseElement && name2.contains(" ")) name2 = name2.substring(0, name2.indexOf(" ")); return getComparator().compare(name1, name2); }
Example #20
Source File: JavaBrowsingContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); if (newInput instanceof Collection) { // Get a template object from the collection Collection<?> col= (Collection<?>)newInput; if (!col.isEmpty()) newInput= col.iterator().next(); else newInput= null; } fInput= newInput; }
Example #21
Source File: NavigatorContentProvider.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void inputChanged(final Viewer v, final Object oldInput, final Object newInput) { final CommonViewer viewer = (CommonViewer) v; final ResourceManager mapper = new ResourceManager(this, viewer); getInstance().resetVirtualFolders(mapper); getWorkspace().addResourceChangeListener(mapper, POST_CHANGE | PRE_DELETE); super.inputChanged(viewer, oldInput, newInput); }
Example #22
Source File: EmptyCategoryFilter.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private boolean passesFilters(Viewer viewer, ViewerFilter[] filters, ModelElement element) { for (ViewerFilter filter : filters) if (!filter.select(viewer, element.getParent(), element)) return false; return true; }
Example #23
Source File: ArchiveFileFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { if (fExcludes != null && fExcludes.contains(element)) { return false; } return isArchivePath(((IFile)element).getFullPath(), fAllowAllArchives); } else if (element instanceof IContainer) { // IProject, IFolder if (!fRecursive) { return true; } // ignore closed projects if (element instanceof IProject && !((IProject)element).isOpen()) return false; try { IResource[] resources= ((IContainer)element).members(); for (int i= 0; i < resources.length; i++) { // recursive! Only show containers that contain an archive if (select(viewer, parent, resources[i])) { return true; } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return false; }
Example #24
Source File: ColumnViewerComparator.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (viewer instanceof TableViewer) { IBaseLabelProvider baseLabel = ((TableViewer) viewer).getLabelProvider(); String left = ((ITableLabelProvider) baseLabel).getColumnText(e1, fSortColumn); String right = ((ITableLabelProvider) baseLabel).getColumnText(e2, fSortColumn); int sortResult = getComparator().compare(left != null ? left : "", right != null ? right : ""); return sortResult * fSortOrder; } return super.compare(viewer, e1, e2); }
Example #25
Source File: KontaktAnzeigeTextFieldViewerFilter.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element){ if (searchString == null) return true; IContact k = (IContact) element; if (searchString.startsWith("$")) { // Nothing to do here, we have a formula evaluation return true; } else if (searchString.startsWith("#")) { // direct patient number lookup if (k.isPatient()) { String patNr = k.getCode(); if (patNr.toLowerCase().equalsIgnoreCase(searchString.substring(1).trim())) return true; } } else { String desc1 = (k.getDescription1() != null) ? k.getDescription1().toLowerCase() : ""; String desc2 = (k.getDescription2() != null) ? k.getDescription2().toLowerCase() : ""; String[] searchListComma = searchString.split(","); for (String string : searchListComma) { if (string.contains(" ")) { String searchA = desc1 + " " + desc2; String searchB = desc2 + " " + desc1; if (searchA.matches(".*" + string + ".*") || searchB.matches(".*" + string + ".*")) return true; } else if (desc1.matches(".*" + string + ".*") || desc2.matches(".*" + string + ".*")) { return true; } } } return false; }
Example #26
Source File: Comparator.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override public int compare(Viewer viewer, Object o1, Object o2) { LibraryRestriction l1 = (LibraryRestriction) o1; LibraryRestriction l2 = (LibraryRestriction) o2; if (l1.type == RestrictionType.FORBIDDEN && l2.type == RestrictionType.WARNING) return -1; if (l1.type == RestrictionType.WARNING && l2.type == RestrictionType.FORBIDDEN) return 1; return compare(viewer, l1.dataset, l2.dataset); }
Example #27
Source File: PShelfViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.StructuredViewer#doUpdateItem(org.eclipse.swt.widgets.Widget, java.lang.Object, boolean) */ protected void doUpdateItem(Widget item, Object element, boolean fullMap) { Viewer viewer = getViewerForItem(pshelf.getSelection()); if (viewer instanceof StructuredViewer) { ReflectionUtils.callMethod(viewer, "doUpdateItem", item, element, fullMap); } }
Example #28
Source File: PShelfViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.ContentViewer#labelProviderChanged() */ protected void labelProviderChanged() { Assert.isNotNull(getLabelProvider()); if (!(getLabelProvider() instanceof ILabelProvider)) throw new IllegalArgumentException("Label provider must implement ILabelProvider" + ", got " + getLabelProvider() == null ? "null" : getLabelProvider().getClass().toString()); if (pshelf != null) { PShelfItem[] shelfItems = pshelf.getItems(); for (int i = 0; i < shelfItems.length; i++) { PShelfItem item = shelfItems[i]; // re-query texts and images for pshelf items ILabelProvider lp = (ILabelProvider) getLabelProvider(); item.setText(lp.getText(item.getData())); item.setImage(lp.getImage(item.getData())); // change provider for sub-viewers Viewer viewer = getViewerForItem(item); ContentViewer contentViewer = (ContentViewer) viewer; if (contentViewer != null) contentViewer.setLabelProvider(lp); } } // refresh in super impl super.labelProviderChanged(); }
Example #29
Source File: RnContentProvider.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void reorder(final String field){ cv.getViewerWidget().setSorter(new ViewerSorter() { @Override public int compare(final Viewer viewer, final Object e1, final Object e2){ TimeTool t1 = getLatest((Tree) e1); TimeTool t2 = getLatest((Tree) e2); return t1.compareTo(t2); } }); }
Example #30
Source File: TextTemplateFilter.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element){ if (searchTerm == null || searchTerm.length() == 0) { return true; } TextTemplate tt = (TextTemplate) element; String name = tt.getName().toLowerCase(); if (name.matches(searchTerm)) { return true; } String desc = tt.getDescription().toLowerCase(); if (desc.matches(searchTerm)) { return true; } String mime = tt.getMimeTypePrintname().toLowerCase(); if (mime.matches(searchTerm)) { return true; } String mandant = tt.getMandantLabel().toLowerCase(); if (mandant.matches(searchTerm)) { return true; } return false; }