本文整理匯總了Java中org.eclipse.jface.viewers.IContentProvider類的典型用法代碼示例。如果您正苦於以下問題:Java IContentProvider類的具體用法?Java IContentProvider怎麽用?Java IContentProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IContentProvider類屬於org.eclipse.jface.viewers包,在下文中一共展示了IContentProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setFocus
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
@Override
public void setFocus(){
super.setFocus();
if (viewer == null) {
Konsultation selectedKons =
(Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
viewer = commonViewer.getViewerWidget();
IContentProvider contentProvider = viewer.getContentProvider();
if (contentProvider instanceof TarmedCodeSelectorContentProvider) {
if (selectedKons != null) {
updateLawFilter(selectedKons);
}
viewer.addFilter(lawFilter);
}
if (selectedKons != null) {
updateValidFilter(selectedKons);
}
viewer.addFilter(validDateFilter);
ElexisEventDispatcher.getInstance().addListeners(konsFilter);
}
refreshViewer();
}
示例2: createTableFromData
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
/**
* Creates a tableviewer from the given provider.
*
* @param parent
* Composite that holds the table.
* @param dataset
* @param labelProvider
* @param contentProvider
* @return Table
*/
public TableViewer createTableFromData(final Composite parent, final DataSet dataset,
final ILabelProvider labelProvider, final IContentProvider contentProvider) {
Table table = this.createTable(parent, dataset);
// Create table viewer and set providers.
TableViewer tableViewer = new TableViewer(table);
// Set providers.
tableViewer.setLabelProvider(labelProvider);
tableViewer.setContentProvider(contentProvider);
// Invoke the inputChanged method after a content provider is set.
tableViewer.setInput(table);
// add column sorters.
this.addColumnSort(tableViewer);
return tableViewer;
}
示例3: hasUnfilteredChild
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private boolean hasUnfilteredChild(TreeViewer viewer, TreePath parentPath, Object element) {
TreePath elementPath = parentPath.createChildPath(element);
IContentProvider contentProvider = viewer.getContentProvider();
Object[] children = contentProvider instanceof ITreePathContentProvider
? ((ITreePathContentProvider) contentProvider).getChildren(elementPath)
: ((ITreeContentProvider) contentProvider).getChildren(element);
/* avoid NPE + guard close */
if (children == null || children.length == 0) {
return false;
}
for (int i = 0; i < children.length; i++) {
if (selectTreePath(viewer, elementPath, children[i])) {
return true;
}
}
return false;
}
示例4: initViewer
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private static void initViewer(StructuredViewer viewer, ElementTypes elementTypes, Object input,
IElementBinding elementBinding, IViewerType viewerType, Class<?> contentProviderInterfaceType) {
PluggableContentProvider pluggableContentProvider = new PluggableContentProvider(viewerType, elementTypes,
elementBinding);
ElementTypesLabelProvider labelProvider = new ElementTypesLabelProvider(elementTypes);
DelegatingInvocationHandler invocationHandler = new DelegatingInvocationHandler(pluggableContentProvider);
IContentProvider contentProvider = (IContentProvider) Proxy.newProxyInstance(contentProviderInterfaceType
.getClassLoader(), new Class[] { contentProviderInterfaceType }, invocationHandler);
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(labelProvider);
viewer.setUseHashlookup(true);
viewer.setInput(input);
}
示例5: createContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private IContentProvider createContentProvider() {
return new IStructuredContentProvider() {
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public Object[] getElements(Object inputElement) {
Object model = null;
if (inputElement instanceof IPointGenerator) {
IPointGenerator<IScanPathModel> op = (IPointGenerator<IScanPathModel>)inputElement;
model = op.getModel();
} else {
model = inputElement;
}
try {
final Collection<FieldValue> col = FieldUtils.getModelFields(model);
return col.toArray(new FieldValue[col.size()]);
} catch (Exception ne) {
return new FieldValue[]{};
}
}
};
}
示例6: createContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private IContentProvider createContentProvider() {
return new IStructuredContentProvider() {
private Set<Entry<Object, Object>> entries;
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
@SuppressWarnings("unchecked")
Map<Object,Object> tmp = (Map<Object,Object>)newInput;
if (tmp==null) return;
this.entries = tmp.entrySet();
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return entries.toArray(new Entry[entries.size()]);
}
};
}
示例7: createContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private IContentProvider createContentProvider() {
return new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
if (consumers!=null) consumers.clear();
}
@Override
public Object[] getElements(Object inputElement) {
if (consumers==null) return new HeartbeatBean[]{HeartbeatBean.EMPTY};
final List<HeartbeatBean> beats = new ArrayList<>(consumers.values());
Collections.sort(beats, new Comparator<HeartbeatBean>() {
@Override
public int compare(HeartbeatBean o1, HeartbeatBean o2) {
return (int)(o2.getConceptionTime()-o1.getConceptionTime());
}
});
return beats.toArray(new HeartbeatBean[consumers.size()]);
}
};
}
示例8: createContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
@SuppressWarnings("squid:S3776")
private IContentProvider createContentProvider() {
return new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
queue = (Map<String, StatusBean>)newInput;
}
@Override
public void dispose() {
if (queue!=null) queue.clear();
}
@Override
public Object[] getElements(Object inputElement) {
if (queue==null) return new StatusBean[]{StatusBean.EMPTY};
final List<StatusBean> retained = new ArrayList<>(queue.values());
// This preference is not secure people could hack DAWN to do this.
if (!Boolean.getBoolean("org.dawnsci.commandserver.ui.view.showWholeQueue")) {
// Old fashioned loop. In Java8 we will use a predicate...
final String userName = getUserName();
for (Iterator it = retained.iterator(); it.hasNext();) {
StatusBean statusBean = (StatusBean) it.next();
if (statusBean.getUserName()==null) continue;
if (hideOtherUsersResults && !userName.equals(statusBean.getUserName())) it.remove();
}
// This form of filtering is not at all secure because we
// give the full list of the queue to the clients.
}
return retained.toArray(new StatusBean[retained.size()]);
}
};
}
示例9: getContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
protected IContentProvider getContentProvider(final boolean undo) {
return new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
//
}
@Override
public void dispose() {
//
}
@Override
public Object[] getElements(Object inputElement) {
ICommandExecutor cmdExecutor = (ICommandExecutor) inputElement;
if (undo) {
return cmdExecutor.getUndoableCommandStack().toArray();
} else {
return cmdExecutor.getRedoableCommandStack().toArray();
}
}
};
}
示例10: hasUnfilteredChild
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private boolean hasUnfilteredChild(TreeViewer viewer, TreePath parentPath, Object element) {
TreePath elementPath = parentPath.createChildPath(element);
IContentProvider contentProvider = viewer.getContentProvider();
Object[] children = contentProvider instanceof ITreePathContentProvider
? ((ITreePathContentProvider) contentProvider).getChildren(elementPath)
: ((ITreeContentProvider) contentProvider).getChildren(element);
/* avoid NPE + guard close */
if (children == null || children.length == 0) {
return false;
}
for (int i = 0; i < children.length; i++) {
if (selectTreePath(viewer, elementPath, children[i])) {
return true;
}
}
return false;
}
示例11: setupBranchViewers
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private void setupBranchViewers() {
final IContentProvider contentProvider = new ContentProviderAdapter() {
@Override
public Object[] getElements(final Object input) {
@SuppressWarnings("unchecked")
final List<GitBranch> branches = ((List<GitBranch>) input);
return branches.toArray(new GitBranch[branches.size()]);
}
};
branchViewer.setContentProvider(contentProvider);
branchComboViewer.setContentProvider(contentProvider);
final LabelProvider labelProvider = new LabelProvider() {
@Override
public String getText(final Object element) {
return ((GitBranch) element).getRemoteName();
}
};
branchViewer.setLabelProvider(labelProvider);
branchComboViewer.setLabelProvider(labelProvider);
final ViewerComparator viewerComparator = new ViewerComparator() {
@Override
public int compare(final Viewer viewer, final Object e1, final Object e2) {
return ((GitBranch) e1).compareTo(((GitBranch) e2));
}
};
branchViewer.setComparator(viewerComparator);
branchComboViewer.setComparator(viewerComparator);
}
示例12: ChangePathsTableProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
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);
}
示例13: ChangePathsTreeViewer
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
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);
}
示例14: createContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
protected IContentProvider createContentProvider(AbstractTraceEditor<?> editor, TableViewer logViewerTable, boolean supportsVariableRowHeight){
ILogMessage root = ((StaticTraceEditorInput)editor.getEditorInput()).getRoot();
if (supportsVariableRowHeight)
return new DetailedLinuxTableContentProvider(this, root);
else
return new DetailedWindowsTableContentProvider(this, root);
}
示例15: setContentProvider
import org.eclipse.jface.viewers.IContentProvider; //導入依賴的package包/類
private void setContentProvider(ViewerComparator viewerComparator, IContentProvider contentProvider,
boolean supportsFilters, boolean supportsPlugins) {
viewer.setComparator(viewerComparator);
viewer.setContentProvider(contentProvider);
setViewerFilterActionsEnabled(supportsFilters);
showPluginsAction.setEnabled(supportsPlugins);
if (supportsFilters) {
resetViewerFilters();
} else {
viewer.setFilters(new ViewerFilter[] { patternFilter });
}
}