Search in sources :

Example 1 with KNIMEJob

use of org.knime.core.util.KNIMEJob in project knime-core by knime.

the class AbstractRepositoryView method onFilterStreamableNodesClicked.

/* action to be performed if the "Filter Streamable Nodes" button is clicked */
private void onFilterStreamableNodesClicked(final AdditionalInfoViewFilter infoTextFilter, final AdditionalInfoViewFilter infoFuzzyFilter) {
    // ensure that the additional information is available and load it lazily if not
    if (!m_additionalInfoAvailable && m_filterStreamNodesButton.isChecked()) {
        m_filterStreamNodesButton.setEnabled(false);
        m_showAddInfoButton.setEnabled(false);
        final Job nodeInfoUpdater = new KNIMEJob("Additional Node Info Repository Loader", FrameworkUtil.getBundle(getClass())) {

            @Override
            protected IStatus run(final IProgressMonitor monitor) {
                m_nodeCounter = 0;
                // set filters
                infoTextFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
                infoFuzzyFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
                enrichWithAdditionalInfo(RepositoryManager.INSTANCE.getRoot(), monitor, true);
                m_additionalInfoAvailable = true;
                m_filterStreamNodesButton.setEnabled(true);
                m_showAddInfoButton.setEnabled(true);
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (!m_viewer.getControl().isDisposed()) {
                            // update view
                            TreeViewerUpdater.update(m_viewer, true, false);
                        }
                    }
                });
                return Status.OK_STATUS;
            }
        };
        nodeInfoUpdater.setSystem(true);
        nodeInfoUpdater.schedule();
    } else {
        // set filter
        infoTextFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
        infoFuzzyFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
        // update view
        TreeViewerUpdater.update(m_viewer, true, true);
    }
}
Also used : KNIMEJob(org.knime.core.util.KNIMEJob) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) KNIMEJob(org.knime.core.util.KNIMEJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 2 with KNIMEJob

use of org.knime.core.util.KNIMEJob in project knime-core by knime.

the class AbstractRepositoryView method onShowAdditionalInfoClicked.

/* action to be performed if the "Show Additional Info" button is clicked */
private void onShowAdditionalInfoClicked() {
    boolean showCategory = m_fuzzySearchButton.isChecked() && m_fuzzyTextInfoFilter.getDelegateFilter().hasNonEmptyQuery();
    if (m_showAddInfoButton.isChecked()) {
        m_viewer.setLabelProvider(new RepositoryStyledLabelProvider(new RepositoryLabelProvider(), showCategory, KEY_INFO_STREAMABLE));
    } else {
        m_viewer.setLabelProvider(new RepositoryStyledLabelProvider(new RepositoryLabelProvider(), showCategory));
    }
    // ensure that the additional information is available and load it lazily if not
    if (!m_additionalInfoAvailable && m_showAddInfoButton.isChecked()) {
        m_showAddInfoButton.setEnabled(false);
        m_filterStreamNodesButton.setEnabled(false);
        final Job nodeInfoUpdater = new KNIMEJob("Additional Node Info Repository Loader", FrameworkUtil.getBundle(getClass())) {

            @Override
            protected IStatus run(final IProgressMonitor monitor) {
                enrichWithAdditionalInfo(RepositoryManager.INSTANCE.getRoot(), monitor, false);
                m_additionalInfoAvailable = true;
                m_showAddInfoButton.setEnabled(true);
                m_filterStreamNodesButton.setEnabled(true);
                return Status.OK_STATUS;
            }
        };
        nodeInfoUpdater.setSystem(true);
        nodeInfoUpdater.schedule();
    }
}
Also used : KNIMEJob(org.knime.core.util.KNIMEJob) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) KNIMEJob(org.knime.core.util.KNIMEJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 3 with KNIMEJob

use of org.knime.core.util.KNIMEJob in project knime-core by knime.

the class AbstractRepositoryView method createPartControl.

/**
 * This callback creates the content of the view. The TreeViewer is initialized.
 *
 * @see org.eclipse.ui.IWorkbenchPart #createPartControl(org.eclipse.swt.widgets.Composite)
 * @param parent the parent composite
 */
@Override
public void createPartControl(final Composite parent) {
    parent.setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_WAIT));
    m_viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    m_viewer.getControl().setToolTipText("Loading node repository...");
    m_viewer.setContentProvider(new RepositoryContentProvider());
    m_viewer.setLabelProvider(new RepositoryStyledLabelProvider(new RepositoryLabelProvider(), false));
    m_viewer.setInput("Loading node repository...");
    contributeToActionBars();
    hookContextMenu();
    hookDoubleClickAction();
    // The viewer provides the selection to the workbench.
    this.getSite().setSelectionProvider(m_viewer);
    // The viewer supports drag&drop
    // (well, actually only drag - objects are dropped into the editor ;-)
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    m_viewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transfers, new NodeTemplateDragListener(m_viewer));
    PlatformUI.getWorkbench().getHelpSystem().setHelp(m_viewer.getControl(), "org.knime.workbench.help.repository_view_context");
    final Job treeUpdater = new KNIMEJob("Node Repository Loader", FrameworkUtil.getBundle(getClass())) {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            readRepository(parent, monitor);
            return Status.OK_STATUS;
        }
    };
    treeUpdater.setSystem(true);
    treeUpdater.schedule();
}
Also used : KNIMEJob(org.knime.core.util.KNIMEJob) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Cursor(org.eclipse.swt.graphics.Cursor) KNIMEJob(org.knime.core.util.KNIMEJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 4 with KNIMEJob

use of org.knime.core.util.KNIMEJob 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)

Example 5 with KNIMEJob

use of org.knime.core.util.KNIMEJob in project knime-core by knime.

the class NodeUsageRegistry method addNode.

/**
 * @param node the last used node (is added to last used nodes and the
 *            frequency is counted
 */
public static void addNode(final NodeTemplate node) {
    NodeTemplateFrequency nodeFreq = new NodeTemplateFrequency(node);
    NodeTemplateFrequency existing = FREQUENCIES.get(nodeFreq);
    if (existing == null) {
        FREQUENCIES.put(nodeFreq, nodeFreq);
        existing = nodeFreq;
    }
    cachedFrequent = null;
    existing.increment();
    addToLastUsedNodes(node);
    Job favNodeAdder = new KNIMEJob("Favorite Node Adder", FrameworkUtil.getBundle(NodeUsageRegistry.class)) {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            notifyListener();
            return Status.OK_STATUS;
        }
    };
    favNodeAdder.setSystem(true);
    favNodeAdder.schedule();
}
Also used : KNIMEJob(org.knime.core.util.KNIMEJob) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) KNIMEJob(org.knime.core.util.KNIMEJob) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Job (org.eclipse.core.runtime.jobs.Job)6 KNIMEJob (org.knime.core.util.KNIMEJob)6 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)3 Transfer (org.eclipse.swt.dnd.Transfer)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Cursor (org.eclipse.swt.graphics.Cursor)1 GridData (org.eclipse.swt.layout.GridData)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)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 NodeRecommendation (org.knime.workbench.workflowcoach.NodeRecommendationManager.NodeRecommendation)1