use of org.knime.workbench.repository.view.RepositoryLabelProvider in project knime-core by knime.
the class FavoritesView method createPartControl.
/**
* {@inheritDoc}
*/
@Override
public void createPartControl(final Composite parent) {
m_viewer = new TreeViewer(parent, SWT.SINGLE | SWT.V_SCROLL);
this.getSite().setSelectionProvider(m_viewer);
Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
m_viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new FavoriteNodesDragSource(this));
m_viewer.addDropSupport(DND.DROP_COPY, transfers, new FavoriteNodesDropTarget(this));
m_viewer.setLabelProvider(new RepositoryLabelProvider());
m_viewer.setContentProvider(new RepositoryContentProvider());
// no sorting
m_viewer.setComparator(null);
m_viewer.setInput("Loading favorite nodes...");
Job treeUpdater = new KNIMEJob("Favorite Nodes Loader", FrameworkUtil.getBundle(getClass())) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
final Root root = FavoriteNodesManager.getInstance().getRoot();
final Object category = root.getChildByID(FavoriteNodesManager.FAV_CAT_ID, false);
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!parent.isDisposed()) {
m_viewer.setInput(root);
m_viewer.expandToLevel(category, 1);
}
}
});
}
return Status.OK_STATUS;
}
};
treeUpdater.setSystem(true);
treeUpdater.schedule();
NodeUsageRegistry.addNodeUsageListener(FavoritesView.this);
hookDoubleClickAction();
}
Aggregations