Search in sources :

Example 1 with UpdateListener

use of org.knime.workbench.workflowcoach.prefs.UpdateJob.UpdateListener in project knime-core by knime.

the class WorkflowCoachView method updateTripleProviders.

/**
 * Updates all updatable and enabled triple providers.
 *
 * @param requiredOnly if only the enabled triple providers should be updated that require an update in order to
 *            work
 * @param updateListener to get feedback of the updating process
 * @param block if <code>true</code> the method will block till the update is finished, otherwise it will return
 *            immediately after triggering the update job
 */
private void updateTripleProviders(final UpdateListener updateListener, final boolean requiredOnly, final boolean block) {
    List<UpdatableNodeTripleProvider> toUpdate = NodeRecommendationManager.getInstance().getNodeTripleProviders().stream().filter(ntp -> {
        if (!(ntp instanceof UpdatableNodeTripleProvider)) {
            return false;
        } else {
            UpdatableNodeTripleProvider untp = (UpdatableNodeTripleProvider) ntp;
            return ntp.isEnabled() && (!requiredOnly || untp.updateRequired());
        }
    }).map(ntp -> (UpdatableNodeTripleProvider) ntp).collect(Collectors.toList());
    UpdateJob.schedule(updateListener, toUpdate, block);
}
Also used : Arrays(java.util.Arrays) IUpdateListener(org.knime.workbench.workflowcoach.NodeRecommendationManager.IUpdateListener) TableViewer(org.eclipse.jface.viewers.TableViewer) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) IToolBarManager(org.eclipse.jface.action.IToolBarManager) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) NodeContainer(org.knime.core.node.workflow.NodeContainer) IStatus(org.eclipse.core.runtime.IStatus) ISelectionListener(org.eclipse.ui.ISelectionListener) Composite(org.eclipse.swt.widgets.Composite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Cursor(org.eclipse.swt.graphics.Cursor) IEditorPart(org.eclipse.ui.IEditorPart) NodeProvider(org.knime.workbench.core.nodeprovider.NodeProvider) KNIMEJob(org.knime.core.util.KNIMEJob) CommunityTripleProvider(org.knime.workbench.workflowcoach.data.CommunityTripleProvider) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) Display(org.eclipse.swt.widgets.Display) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) WorkflowCoachPreferenceInitializer(org.knime.workbench.workflowcoach.prefs.WorkflowCoachPreferenceInitializer) RepositoryManager(org.knime.workbench.repository.RepositoryManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Transfer(org.eclipse.swt.dnd.Transfer) IElementComparer(org.eclipse.jface.viewers.IElementComparer) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Wrapper(org.knime.core.ui.wrapper.Wrapper) SWT(org.eclipse.swt.SWT) Optional(java.util.Optional) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MouseAdapter(org.eclipse.swt.events.MouseAdapter) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) ViewPart(org.eclipse.ui.part.ViewPart) WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) LocalDateTime(java.time.LocalDateTime) Table(org.eclipse.swt.widgets.Table) AtomicReference(java.util.concurrent.atomic.AtomicReference) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) UpdateJob(org.knime.workbench.workflowcoach.prefs.UpdateJob) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider) NodeLogger(org.knime.core.node.NodeLogger) GridData(org.eclipse.swt.layout.GridData) NodeRecommendationManager(org.knime.workbench.workflowcoach.NodeRecommendationManager) HeadlessPreferencesConstants(org.knime.workbench.core.preferences.HeadlessPreferencesConstants) NodeFactory(org.knime.core.node.NodeFactory) CombinatoricsUtils(org.apache.commons.math3.util.CombinatoricsUtils) Iterator(java.util.Iterator) Job(org.eclipse.core.runtime.jobs.Job) KNIMECorePlugin(org.knime.workbench.core.KNIMECorePlugin) NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) ChronoUnit(java.time.temporal.ChronoUnit) UpdateListener(org.knime.workbench.workflowcoach.prefs.UpdateJob.UpdateListener) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeRecommendation(org.knime.workbench.workflowcoach.NodeRecommendationManager.NodeRecommendation) Comparator(java.util.Comparator) Collections(java.util.Collections) FrameworkUtil(org.osgi.framework.FrameworkUtil) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider)

Aggregations

LocalDateTime (java.time.LocalDateTime)1 ChronoUnit (java.time.temporal.ChronoUnit)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 CombinatoricsUtils (org.apache.commons.math3.util.CombinatoricsUtils)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1