Search in sources :

Example 1 with RepositoryLabelProvider

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();
}
Also used : Root(org.knime.workbench.repository.model.Root) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RepositoryLabelProvider(org.knime.workbench.repository.view.RepositoryLabelProvider) KNIMEJob(org.knime.core.util.KNIMEJob) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryContentProvider(org.knime.workbench.repository.view.RepositoryContentProvider) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) KNIMEJob(org.knime.core.util.KNIMEJob) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 KNIMEJob (org.knime.core.util.KNIMEJob)1 Root (org.knime.workbench.repository.model.Root)1 RepositoryContentProvider (org.knime.workbench.repository.view.RepositoryContentProvider)1 RepositoryLabelProvider (org.knime.workbench.repository.view.RepositoryLabelProvider)1