org.eclipse.jface.viewers.IContentProvider Java Examples

The following examples show how to use org.eclipse.jface.viewers.IContentProvider. 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: TmfSimpleTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e) {
    Table table = fTableViewer.getTable();
    TableColumn prevSortcolumn = table.getSortColumn();
    if (prevSortcolumn == fColumn) {
        flipSortDirection();
    }
    table.setSortDirection(fDirection);
    table.setSortColumn(fColumn);
    Comparator<T> comparator;
    if (fDirection == SWT.DOWN) {
        comparator = fComparator;
    } else {
        comparator = checkNotNull(Collections.reverseOrder(fComparator));
    }
    IContentProvider contentProvider = fTableViewer.getContentProvider();
    if (contentProvider instanceof DeferredContentProvider) {
        DeferredContentProvider deferredContentProvider = (DeferredContentProvider) contentProvider;
        deferredContentProvider.setSortOrder(comparator);
    } else if (contentProvider instanceof ISortingLazyContentProvider) {
        ISortingLazyContentProvider sortingLazyContentProvider = (ISortingLazyContentProvider) contentProvider;
        sortingLazyContentProvider.setSortOrder(comparator);
    } else {
        fTableViewer.setComparator(new ElementComparator<>(comparator));
    }
}
 
Example #2
Source File: ZestContentViewer.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a complete {@link Graph} using the given {@link IContentProvider} and
 * {@link ILabelProvider}.
 *
 * @param contentProvider The {@link IContentProvider} for this viewer.
 * @param labelProvider   The {@link ILabelProvider} for this viewer.
 * @return A complete {@link Graph} constructed by using the given providers.
 */
protected Graph createRootGraph(IContentProvider contentProvider, ILabelProvider labelProvider) {
	Graph graph = createEmptyGraph();
	if (labelProvider instanceof IGraphAttributesProvider) {
		IGraphAttributesProvider graphNodeLabelProvider = (IGraphAttributesProvider) labelProvider;
		Map<String, Object> rootGraphAttributes = graphNodeLabelProvider.getGraphAttributes();
		if (rootGraphAttributes != null) {
			graph.attributesProperty().putAll(rootGraphAttributes);
		}
	}
	if (contentProvider instanceof IGraphContentProvider) {
		IGraphContentProvider graphNodeProvider = (IGraphContentProvider) contentProvider;
		Object[] nodes = graphNodeProvider.getNodes();
		if (nodes != null) {
			createNodesAndEdges(graphNodeProvider, labelProvider, graph, nodes);
		}
	}
	return graph;
}
 
Example #3
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Removes filters for the given parent and element
 *
 * @param parent the parent of the element
 * @param element the element
 * @param contentProvider the content provider of the viewer from which
 *  the filters will be removed
 *
 * @return the array of new filter ids
 */
public String[] removeFiltersFor(Object parent, Object element, IContentProvider contentProvider) {
	ArrayList<String> newFilters= new ArrayList<String>();
	for (Iterator<FilterItem> iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
		FilterItem item= iterator.next();
		if (item.enabled) {
			ViewerFilter filter= item.getFilterInstance();
            if (filter != null && isSelected(parent, element, contentProvider, filter))
                newFilters.add(item.id);
		}
	}
	if (fUserDefinedPatternsEnabled && isSelected(parent, element, contentProvider, fPatternFilter))
		newFilters.add(fPatternFilter.getClass().getName());

    return newFilters.toArray(new String[newFilters.size()]);
}
 
Example #4
Source File: ContentProviderRegistry.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
public IContentProvider getProvider() {
    try {
        return (IContentProvider) configElement.createExecutableExtension("class");
    } catch (CoreException e) {
        LogUtils.logError(ContentSupport.PLUGIN_ID, "Could not instantiate content provider", e);
    }
    return null;
}
 
Example #5
Source File: ChangePathsTableProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ChangePathsTableProvider(Composite parent, IContentProvider contentProvider) {
  super(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
  
  TableLayout layout = new TableLayout();
  GridData data = new GridData(GridData.FILL_BOTH);
  
  Table table = (Table) getControl();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  table.setLayoutData(data);    
  table.setLayout(layout);
  table.addDisposeListener(new DisposeListener() {
    public void widgetDisposed(DisposeEvent e) {
      if(currentPathFont != null) {
        currentPathFont.dispose();
      }
    }
  });
  
  createColumns(table, layout);
  
  setLabelProvider(new ChangePathLabelProvider());
  setContentProvider(contentProvider);
  
  ChangePathsSorter sorter = new ChangePathsSorter(COL_PATH);
  setSorter(sorter);
  table.setSortDirection(SWT.UP);
}
 
Example #6
Source File: ChangePathsTreeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ChangePathsTreeViewer(Composite parent, IContentProvider contentProvider) {
    super(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI /*| SWT.FULL_SELECTION*/);
    GridData data = new GridData(GridData.FILL_BOTH);
    getControl().setLayoutData(data);
    getControl().addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if(currentPathFont != null) {
                currentPathFont.dispose();
            }
        }
    });

    setLabelProvider(new ChangePathLabelProvider());
    setContentProvider(contentProvider);
}
 
Example #7
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #8
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Overrides the createContentProvider from JavaBrowsingPart
 * Creates the content provider of this part.
 */
@Override
protected IContentProvider createContentProvider() {
	if(isInListState())
		return new PackagesViewFlatContentProvider(fWrappedViewer.getViewer());
	else return new PackagesViewHierarchicalContentProvider(fWrappedViewer.getViewer());
}
 
Example #9
Source File: GraphicalViewer.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setContentProvider(IContentProvider contentProvider) {
    if (contentProvider != null) {
        if (!(contentProvider instanceof IGraphicalContentProvider))
            throw new IllegalArgumentException(IGraphicalContentProvider.class.getName());
        if (adjustToCanvas && !canvas.isDisposed())
            ((IGraphicalContentProvider) contentProvider).setSuggestedSize(canvas.getSize());
    }
    super.setContentProvider(contentProvider);
}
 
Example #10
Source File: PackageViewerWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setSelection(ISelection selection, boolean reveal) {
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection sel= (IStructuredSelection) selection;

		//try and give the two a common super class
		IContentProvider provider= getContentProvider();
		if (provider instanceof LogicalPackagesProvider) {
			LogicalPackagesProvider fprovider= (LogicalPackagesProvider) provider;

			Object object= sel.getFirstElement();
			if (object instanceof IPackageFragment) {
				IPackageFragment pkgFragment= (IPackageFragment)object;
				LogicalPackage logicalPkg= fprovider.findLogicalPackage(pkgFragment);
				if (logicalPkg != null)
					object= logicalPkg;
				else
					object= pkgFragment;
			}
			if (object != null)
				fViewer.setSelection(new StructuredSelection(object), reveal);
			else
				fViewer.setSelection(StructuredSelection.EMPTY, reveal);
		}
	} else
		fViewer.setSelection(selection, reveal);
}
 
Example #11
Source File: ContentProviderRegistry.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
public IProviderDescription findContentProvider(IContentType target,
        Class<? extends IContentProvider> minimumProtocol) {
    for (ContentProviderDescriptor descriptor : providerDescriptors)
        for (IContentType contentType : descriptor.getAssociations())
            if (target.isKindOf(contentType)) {
                if (minimumProtocol != null && minimumProtocol.isInstance(descriptor.getProvider()))
                    return descriptor;
            }
    return null;
}
 
Example #12
Source File: H5Editor.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The adapter IContentProvider gives the value of the H5Dataset
 */
public Object getAdapter(final Class clazz) {

	if (clazz == IContentProvider.class) {
		return new H5ValuePage();
	}

	return super.getAdapter(clazz);
}
 
Example #13
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void updateGroupWith(StructuredViewer viewer) {
    if (viewer != null) {
        IContentProvider contentProvider = viewer.getContentProvider();
        if (contentProvider instanceof ISearchIndexContentProvider) {
            ISearchIndexContentProvider searchIndexTreeContentProvider = (ISearchIndexContentProvider) contentProvider;
            searchIndexTreeContentProvider.setGroupWith(groupWithConfiguration);
        }
    }
}
 
Example #14
Source File: NativeEnvironmentSelectionDialog.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IContentProvider getContentProvider() {
	return new IStructuredContentProvider() {
		@Override
		public Object[] getElements(Object inputElement) {
			EnvironmentVariable[] elements = null;
			if (inputElement instanceof HashMap) {
				Comparator<Object> comparator = new Comparator<Object>() {
					@Override
					public int compare(Object o1, Object o2) {
						String s1 = (String) o1;
						String s2 = (String) o2;
						return s1.compareTo(s2);
					}
				};
				TreeMap<Object, Object> envVars = new TreeMap<Object, Object>(comparator);
				envVars.putAll((Map<?, ?>) inputElement);
				elements = new EnvironmentVariable[envVars.size()];
				int index = 0;
				for (Iterator<Object> iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
					Object key = iterator.next();
					elements[index] = (EnvironmentVariable) envVars.get(key);
				}
			}
			return elements;
		}
		@Override
		public void dispose() {	
		}
		@Override
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
	};
}
 
Example #15
Source File: SelectConnectorImplementationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public SelectConnectorImplementationWizardPage(String pageTitle, String pageDescription,
        IContentProvider contentProvider, LabelProvider labelProvider,
        IRepositoryStore<? extends IRepositoryFileStore> iRepositoryStore,
        SourceRepositoryStore<? extends AbstractFileStore> sourceRepositoryStore) {
    super(SelectConnectorImplementationWizardPage.class.getName());
    setTitle(pageTitle);
    setDescription(pageDescription);
    this.contentProvider = contentProvider;
    this.labelProvider = labelProvider;
    this.implStore = iRepositoryStore;
    this.sourceStore = sourceRepositoryStore;
}
 
Example #16
Source File: ExportConnectorWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
protected IContentProvider getContentProvider() {
    IRepositoryStore repositoryStore = getRepositoryStore();
    if (connectorImplToExport.isPresent()) {
        return (IStructuredContentProvider) inputElement -> new ConnectorImplementation[] {
                connectorImplToExport.get() };
    }
    if (connectorDefToExport.isPresent()) {
        ConnectorDefinition definition = connectorDefToExport.get();
        return new ConnectorImplementationContentProvider(repositoryStore, definition.getId(),
                definition.getVersion());
    }
    return new ConnectorImplementationContentProvider(repositoryStore, false);
}
 
Example #17
Source File: ExportConnectorWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ExportConnectorWizardPage(final String pageTitle, final String pageDesc, final IContentProvider contentProvider,
        final LabelProvider labelProvider, final IDefinitionRepositoryStore defStore) {
    super(ExportConnectorWizardPage.class.getName());
    setTitle(pageTitle);
    setDescription(pageDesc);
    this.contentProvider = contentProvider;
    this.labelProvider = labelProvider;
    this.defStore = defStore;
}
 
Example #18
Source File: ContributionCutoff.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void setCutoff(StructuredViewer viewer, double value) {
	IContentProvider cp = viewer.getContentProvider();
	if (!(cp instanceof CutoffContentProvider)) {
		Logger log = LoggerFactory.getLogger(getClass());
		log.error("Content provider of viewer with cutoff spinner should "
				+ "implement CutoffContentProvider");
		return;
	}
	CutoffContentProvider provider = (CutoffContentProvider) cp;
	provider.setCutoff(value);
	viewer.refresh();
}
 
Example #19
Source File: BugContentProvider.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static BugContentProvider getProvider(INavigatorContentService service) {
    INavigatorContentExtension extensionById = service.getContentExtensionById(FindbugsPlugin.BUG_CONTENT_PROVIDER_ID);
    IContentProvider provider = extensionById.getContentProvider();
    if (provider instanceof BugContentProvider) {
        return (BugContentProvider) provider;
    }
    return null;
}
 
Example #20
Source File: ListDialogSortableFiltered.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public ListDialogSortableFiltered(String dialogTitle, String dialogMessage, PatternFilter patternFilter, IContentProvider contentProvider, IBaseLabelProvider labelProvider, ViewerSorter viewerSorter) {
   super(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.NONE,
      new String[] {XViewerText.get("button.ok"), XViewerText.get("button.cancel")}, 0); //$NON-NLS-1$ //$NON-NLS-2$
   this.contentProvider = contentProvider;
   this.labelProvider = labelProvider;
   this.patternFilter = patternFilter;
   this.viewerSorter = viewerSorter;
   setShellStyle(getShellStyle() | SWT.RESIZE);
}
 
Example #21
Source File: XCheckFilteredTreeDialog.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public XCheckFilteredTreeDialog(String dialogTitle, String dialogMessage, PatternFilter patternFilter, IContentProvider contentProvider, IBaseLabelProvider labelProvider, ViewerSorter viewerSorter) {
   super(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.NONE, new String[] {
 	  XViewerText.get("button.ok"), XViewerText.get("button.cancel")}, 0); //$NON-NLS-1$ //$NON-NLS-2$
   this.contentProvider = contentProvider;
   this.labelProvider = labelProvider;
   this.patternFilter = patternFilter;
   this.viewerSorter = viewerSorter;
   setShellStyle(getShellStyle() | SWT.RESIZE);
}
 
Example #22
Source File: TimelineViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set the content provider for this viewer.
 *
 * @param provider
 *            provider implementing {@link ITimelineContentProvider}
 */
@Override
public void setContentProvider(IContentProvider provider) {
	if (!(provider instanceof ITimelineContentProvider))
		throw new IllegalArgumentException("Content provider needs to implement ITimelineContentProvider");

	super.setContentProvider(provider);
}
 
Example #23
Source File: CTableTreeViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param element
 * @param index
 */
protected void createItem(Object element, int index) {
	Object parent = null;
	IContentProvider cp = getContentProvider();
	if(cp != null && cp instanceof ITreeContentProvider) {
		parent = ((ITreeContentProvider) cp).getParent(element);
	}
	else if(cp != null && cp instanceof ITreePathContentProvider) {
		TreePath[] paths = ((ITreePathContentProvider) cp).getParents(element);
		if(paths.length > 0) {
			parent = paths[0].getLastSegment();
		}
	}
	createItem(parent, element, index);
}
 
Example #24
Source File: CTreeComboViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.viewers.AbstractTreeViewer#assertContentProviderType(org.eclipse.jface.viewers.IContentProvider)
 */
protected void assertContentProviderType(IContentProvider provider) {
	if (provider instanceof ILazyTreeContentProvider || provider instanceof ILazyTreePathContentProvider) {
		return;
	}
	super.assertContentProviderType(provider);
}
 
Example #25
Source File: GeoMapViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private Object[] getElements() {
	IContentProvider contentProvider = getContentProvider();
	return contentProvider instanceof IStructuredContentProvider
			? ((IStructuredContentProvider) contentProvider)
					.getElements(getInput())
			: null;
}
 
Example #26
Source File: MonthCalendarViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void setContentProvider(IContentProvider contentProvider) {
	if (!(contentProvider instanceof IMonthCalendarContentProvider)) {
		throw new IllegalArgumentException(
				"content provider must be of type IMonthCalendarContentProvider");
	}
	super.setContentProvider(contentProvider);
	calendar.setEventContentProvider(eventContentProvider);
	calendar.setEventCountProvider(eventCountProvider);
}
 
Example #27
Source File: TagCloudViewer.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the content provider of this viewer, which must be an
 * {@link IStructuredContentProvider}.
 */
@Override
public void setContentProvider(IContentProvider contentProvider) {
	Assert.isLegal(contentProvider instanceof IStructuredContentProvider);
	super.setContentProvider(contentProvider);

}
 
Example #28
Source File: SelectUserConnectorImplementationWizard.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
   protected IContentProvider getContentProvider() {
       return new ConnectorImplementationContentProvider(getImplementationStore(), true);
   }
 
Example #29
Source File: SelectActorFilterImplementationWizard.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected IContentProvider getContentProvider() {
    return new ConnectorImplementationContentProvider((IRepositoryStore<IRepositoryFileStore>) getImplementationStore(), definitionId,definitionVersion);
}
 
Example #30
Source File: SelectUserFilterImplementationWizard.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
   protected IContentProvider getContentProvider() {
       return new ConnectorImplementationContentProvider((IRepositoryStore<IRepositoryFileStore>) getImplementationStore(), true);
   }