Search in sources :

Example 1 with CheckUpdateMetaNodeLinkAllAction

use of org.knime.workbench.editor2.actions.CheckUpdateMetaNodeLinkAllAction in project knime-core by knime.

the class LoadWorkflowRunnable method postLoadCheckForMetaNodeUpdates.

static void postLoadCheckForMetaNodeUpdates(final WorkflowEditor editor, final WorkflowManager parent, final List<NodeID> links) {
    StringBuilder m = new StringBuilder("The workflow contains ");
    if (links.size() == 1) {
        m.append("one metanode link (\"");
        m.append(parent.findNodeContainer(links.get(0)).getNameWithID());
        m.append("\").");
    } else {
        m.append(links.size()).append(" metanode links.");
    }
    m.append("\n\n").append("Do you want to check for updates now?");
    final String message = m.toString();
    final AtomicBoolean result = new AtomicBoolean(false);
    final IPreferenceStore corePrefStore = KNIMEUIPlugin.getDefault().getPreferenceStore();
    final String pKey = PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD;
    String pref = corePrefStore.getString(pKey);
    boolean showInfoMsg = true;
    if (MessageDialogWithToggle.ALWAYS.equals(pref)) {
        result.set(true);
        showInfoMsg = false;
    } else if (MessageDialogWithToggle.NEVER.equals(pref)) {
        result.set(false);
    } else {
        final Display display = Display.getDefault();
        display.syncExec(new Runnable() {

            @Override
            public void run() {
                Shell activeShell = display.getActiveShell();
                MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoCancelQuestion(activeShell, "Metanode Link Update", message, "Remember my decision", false, corePrefStore, pKey);
                switch(dlg.getReturnCode()) {
                    case IDialogConstants.YES_ID:
                        result.set(true);
                        break;
                    default:
                        result.set(false);
                }
            }
        });
    }
    if (result.get()) {
        new CheckUpdateMetaNodeLinkAllAction(editor, showInfoMsg).run();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Shell(org.eclipse.swt.widgets.Shell) CheckUpdateMetaNodeLinkAllAction(org.knime.workbench.editor2.actions.CheckUpdateMetaNodeLinkAllAction) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Display(org.eclipse.swt.widgets.Display)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 CheckUpdateMetaNodeLinkAllAction (org.knime.workbench.editor2.actions.CheckUpdateMetaNodeLinkAllAction)1