Search in sources :

Example 1 with CommunityTripleProvider

use of org.knime.workbench.workflowcoach.data.CommunityTripleProvider in project knime-core by knime.

the class WorkflowCoachPreferencePage method performOk.

/**
 * {@inheritDoc}
 */
@Override
public boolean performOk() {
    IPreferenceStore prefStore = getPreferenceStore();
    List<NodeTripleProvider> providers = NodeRecommendationManager.getInstance().getNodeTripleProviders();
    // check whether the selected providers need an update
    for (NodeTripleProvider ntp : providers) {
        if (ntp instanceof CommunityTripleProvider) {
            if (m_checkCommunityProvider.getSelection() && ((CommunityTripleProvider) ntp).updateRequired()) {
                setErrorMessage("Please update the community node usage statistics.");
            }
        }
    }
    if (m_checkCommunityProvider.getSelection()) {
        // make sure that the user statistics are sent when the community node recommendation is used
        KNIMECorePlugin.getDefault().getPreferenceStore().setValue(HeadlessPreferencesConstants.P_SEND_ANONYMOUS_STATISTICS, true);
    }
    // store values
    prefStore.setValue(WorkflowCoachPreferenceInitializer.P_COMMUNITY_NODE_TRIPLE_PROVIDER, m_checkCommunityProvider.getSelection());
    if (m_noAutoUpdateButton.getSelection()) {
        prefStore.setValue(WorkflowCoachPreferenceInitializer.P_AUTO_UPDATE_SCHEDULE, WorkflowCoachPreferenceInitializer.NO_AUTO_UPDATE);
    } else if (m_weeklyUpdateButton.getSelection()) {
        prefStore.setValue(WorkflowCoachPreferenceInitializer.P_AUTO_UPDATE_SCHEDULE, WorkflowCoachPreferenceInitializer.WEEKLY_UPDATE);
    } else if (m_monthlyUpdateButton.getSelection()) {
        prefStore.setValue(WorkflowCoachPreferenceInitializer.P_AUTO_UPDATE_SCHEDULE, WorkflowCoachPreferenceInitializer.MONTHLY_UPDATE);
    }
    return true;
}
Also used : CommunityTripleProvider(org.knime.workbench.workflowcoach.data.CommunityTripleProvider) NodeTripleProvider(org.knime.workbench.workflowcoach.data.NodeTripleProvider) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 2 with CommunityTripleProvider

use of org.knime.workbench.workflowcoach.data.CommunityTripleProvider in project knime-core by knime.

the class WorkflowCoachPreferencePage method onUpate.

/**
 * Called when the update button has been pressed.
 */
private void onUpate() {
    Display.getDefault().syncExec(() -> {
        m_updateButton.setEnabled(false);
        m_lastUpdate.setText("Updating ...");
        m_lastUpdate.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
        setValid(false);
    });
    // update the currently enabled providers
    List<UpdatableNodeTripleProvider> toUpdate = new ArrayList<>();
    for (NodeTripleProvider ntp : NodeRecommendationManager.getInstance().getNodeTripleProviders()) {
        if (m_checkCommunityProvider.getSelection() && (ntp instanceof CommunityTripleProvider)) {
            toUpdate.add((CommunityTripleProvider) ntp);
        }
    }
    UpdateJob.schedule(e -> {
        if (e.isPresent()) {
            Display.getDefault().syncExec(() -> {
                m_updateButton.setEnabled(true);
                m_lastUpdate.setText("Update failed.");
                setErrorMessage("Error loading the community node recommendations:" + e.get().getMessage() + ". Please check your internet connection.");
                if (!m_checkCommunityProvider.getSelection()) {
                    setValid(true);
                }
            });
        } else {
            Display.getDefault().syncExec(() -> {
                m_updateButton.setEnabled(true);
                m_lastUpdate.setText("Update finished!");
                setValid(true);
                setErrorMessage(null);
            });
        }
    }, toUpdate, false);
}
Also used : CommunityTripleProvider(org.knime.workbench.workflowcoach.data.CommunityTripleProvider) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider) ArrayList(java.util.ArrayList) NodeTripleProvider(org.knime.workbench.workflowcoach.data.NodeTripleProvider) UpdatableNodeTripleProvider(org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider)

Aggregations

CommunityTripleProvider (org.knime.workbench.workflowcoach.data.CommunityTripleProvider)2 NodeTripleProvider (org.knime.workbench.workflowcoach.data.NodeTripleProvider)2 UpdatableNodeTripleProvider (org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider)2 ArrayList (java.util.ArrayList)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1