Search in sources :

Example 41 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.

the class ResetAction method runOnNodes.

/**
 * Resets all nodes, this is lightweight and does not need to be executed
 * inside an async job.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    // the following code has mainly been copied from
    // IDEWorkbenchWindowAdvisor#preWindowShellClose
    IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
    if (!store.contains(PreferenceConstants.P_CONFIRM_RESET) || store.getBoolean(PreferenceConstants.P_CONFIRM_RESET)) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(Display.getDefault().getActiveShell(), "Confirm reset...", "Do you really want to reset the selected node(s) ?", "Do not ask again", false, null, null);
        if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
            return;
        }
        if (dialog.getToggleState()) {
            store.setValue(PreferenceConstants.P_CONFIRM_RESET, false);
            KNIMEUIPlugin.getDefault().savePluginPreferences();
        }
    }
    LOGGER.debug("Resetting " + nodeParts.length + " node(s)");
    try {
        for (int i = 0; i < nodeParts.length; i++) {
            // skip locked nodes
            getManager().resetAndConfigureNode(nodeParts[i].getNodeContainer().getID());
        }
    } catch (Exception ex) {
        LOGGER.warn("Reset not allowed", ex);
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_INFORMATION | SWT.OK);
        mb.setText("Reset not allowed");
        mb.setMessage("You cannot reset a node while the workflow is in" + " execution. " + ex.getMessage());
        mb.open();
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 42 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.

the class CreateConnectionCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // check whether it is the same connection
    ConnectionContainer conn = getHostWFM().getIncomingConnectionFor(m_targetNode.getNodeContainer().getID(), m_targetPortID);
    if (conn != null && conn.getSource().equals(m_sourceNode.getNodeContainer().getID()) && conn.getSourcePort() == m_sourcePortID && conn.getDest().equals(m_targetNode.getNodeContainer().getID()) && conn.getDestPort() == m_targetPortID) {
        // it is the very same connection -> do nothing
        return;
    }
    WorkflowManager wm = getHostWFM();
    // displayed to the user
    try {
        // if target nodeport is already connected
        if (conn != null) {
            // ask user if it should be replaced...
            if (m_confirm && m_targetNode.getNodeContainer().getNodeContainerState().isExecuted()) {
                // show confirmation message only if target node is executed
                MessageDialogWithToggle msgD = openReconnectConfirmDialog(m_confirm, "Do you want to replace existing connection? \n" + "This will reset the target node!");
                m_confirm = !msgD.getToggleState();
                if (msgD.getReturnCode() != IDialogConstants.YES_ID) {
                    return;
                }
            }
            // remove existing connection
            wm.removeConnection(conn);
            m_oldConnection = conn;
        }
        LOGGER.debug("adding connection from " + m_sourceNode.getNodeContainer().getID() + " " + m_sourcePortID + " to " + m_targetNode.getNodeContainer().getID() + " " + m_targetPortID);
        m_connection = wm.addConnection(m_sourceNode.getNodeContainer().getID(), m_sourcePortID, m_targetNode.getNodeContainer().getID(), m_targetPortID);
        NodeTimer.GLOBAL_TIMER.addConnectionCreation(unwrapNC(m_sourceNode.getNodeContainer()), unwrapNC(m_targetNode.getNodeContainer()));
        if (m_newConnectionUIInfo != null) {
            m_connection.setUIInfo(m_newConnectionUIInfo);
        }
    } catch (Exception e) {
        LOGGER.error("Connection could not be created.", e);
        m_connection = null;
        m_oldConnection = null;
        m_sourceNode = null;
        m_targetNode = null;
        m_sourcePortID = -1;
        m_targetPortID = -1;
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Connection could not be created", "The two nodes could not be connected due to " + "the following reason:\n " + e.getMessage());
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 43 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.

the class InsertHelper method canInsertNode.

/**
 * Checks execution status of downstream nodes and pops up reset warning if enabled.
 *
 * @param askForReset <code>true</code> if the user should be asked whether executed nodes that are affected by the
 *            insertion are allowed to be reset. If <code>false</code> this question is omitted.
 * @return if new node can be inserted
 */
public boolean canInsertNode(final boolean askForReset) {
    NodeID destNode = m_edge.getDest();
    if (!hostWFM.canRemoveConnection(m_edge)) {
        return false;
    }
    boolean isDestinationExecuted;
    if (destNode.equals(hostWFM.getID())) {
        // TODO missing method in WFM: hasExecutedDownstreamNode(ConnectionContainer)
        isDestinationExecuted = false;
    } else {
        isDestinationExecuted = hostWFM.findNodeContainer(destNode).getNodeContainerState().isExecuted();
    }
    if (isDestinationExecuted && askForReset) {
        IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
        if (!store.contains(PreferenceConstants.P_CONFIRM_RESET) || store.getBoolean(PreferenceConstants.P_CONFIRM_RESET)) {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(Display.getDefault().getActiveShell(), "Confirm reset...", "Do you really want to reset all downstream node(s) ?", "Do not ask again", false, null, null);
            if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
                return false;
            }
            if (dialog.getToggleState()) {
                store.setValue(PreferenceConstants.P_CONFIRM_RESET, false);
                KNIMEUIPlugin.getDefault().savePluginPreferences();
            }
        }
    }
    return true;
}
Also used : NodeID(org.knime.core.node.workflow.NodeID) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 44 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.

the class ReconnectConnectionCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // confirm replacement?
    // check if old target node was executed
    WorkflowManager hostWFM = getHostWFM();
    NodeContainer oldTarget = hostWFM.getNodeContainer(m_oldTarget);
    NodeContainer newTarget = hostWFM.getNodeContainer(m_newTarget);
    if (oldTarget == null || newTarget == null) {
        // something is very wrong here
        return;
    }
    boolean oldExecuted = oldTarget.getNodeContainerState().isExecuted();
    boolean newExecuted = newTarget.getNodeContainerState().isExecuted();
    // or new target node is executed
    if (m_confirm && (oldExecuted || newExecuted)) {
        // create comprehensible and correct confirmation message
        StringBuffer message = new StringBuffer("Do you want to delete the existing connection? \n");
        if (oldExecuted || newExecuted) {
            message.append("This will reset ");
            if (oldExecuted) {
                message.append("the current destination node");
            }
            if (oldExecuted && newExecuted) {
                message.append(" and");
            }
            if (newExecuted) {
                message.append(" the new target node");
            }
            message.append('!');
        }
        MessageDialogWithToggle msgD = CreateConnectionCommand.openReconnectConfirmDialog(m_confirm, message.toString());
        m_confirm = !msgD.getToggleState();
        if (msgD.getReturnCode() != IDialogConstants.YES_ID) {
            return;
        }
    }
    // execute both commands
    m_deleteCommand.execute();
    m_createCommand.setConfirm(false);
    m_createCommand.execute();
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Example 45 with MessageDialogWithToggle

use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.

the class ReplaceHelper method replaceNode.

/**
 * Checks execution status of downstream nodes and pops up reset warning if enabled.
 *
 * @return if new node can be replaced
 */
public boolean replaceNode() {
    boolean hasExecutedSuccessor = false;
    for (ConnectionContainer connectionContainer : m_outgoingConnections) {
        hasExecutedSuccessor = hasExecutedSuccessor || m_wfm.findNodeContainer(connectionContainer.getDest()).getNodeContainerState().isExecuted() || !m_wfm.canRemoveNode(m_oldNode.getID());
    }
    if (hasExecutedSuccessor) {
        IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
        if (!store.contains(PreferenceConstants.P_CONFIRM_RESET) || store.getBoolean(PreferenceConstants.P_CONFIRM_RESET)) {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(Display.getDefault().getActiveShell(), "Confirm reset...", "Do you really want to reset all downstream node(s) ?", "Do not ask again", false, null, null);
            if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
                return false;
            }
            if (dialog.getToggleState()) {
                store.setValue(PreferenceConstants.P_CONFIRM_RESET, false);
                KNIMEUIPlugin.getDefault().savePluginPreferences();
            }
        }
    }
    return true;
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)66 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)16 TableItem (org.eclipse.swt.widgets.TableItem)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)6 Point (org.pentaho.di.core.gui.Point)6 ArrayList (java.util.ArrayList)5 Shell (org.eclipse.swt.widgets.Shell)5 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 File (java.io.File)3 Display (org.eclipse.swt.widgets.Display)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)2 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)2 List (java.util.List)2 Job (org.eclipse.core.runtime.jobs.Job)2 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)2