Search in sources :

Example 91 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.

the class CreateMetaNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // Add node to workflow and get the container
    try {
        WorkflowManager wfm = getHostWFM();
        m_copyContent = wfm.paste(m_persistor);
        NodeID[] nodeIDs = m_copyContent.getNodeIDs();
        if (nodeIDs.length > 0) {
            NodeID first = nodeIDs[0];
            m_container = wfm.getNodeContainer(first);
            // create extra info and set it
            NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
            m_container.setUIInformation(info);
        }
    } catch (Throwable t) {
        // if fails notify the user
        String error = "Metanode cannot be created";
        LOGGER.debug(error + ": " + t.getMessage(), t);
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        mb.setText(error);
        mb.setMessage("The metanode could not be created " + "due to the following reason:\n" + t.getMessage());
        mb.open();
        return;
    }
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 92 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.

the class CreateNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager hostWFM = getHostWFM();
    // Add node to workflow and get the container
    try {
        NodeID id = hostWFM.createAndAddNode(m_factory);
        m_container = hostWFM.getNodeContainer(id);
        NodeTimer.GLOBAL_TIMER.addNodeCreation(m_container);
    } catch (Throwable t) {
        // if fails notify the user
        LOGGER.debug("Node cannot be created.", t);
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        mb.setText("Node cannot be created.");
        mb.setMessage("The selected node could not be created " + "due to the following reason:\n" + t.getMessage());
        mb.open();
        return;
    }
    // create extra info and set it
    NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
    m_container.setUIInformation(info);
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 93 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.

the class AbstractWrappedDialog method showErrorMessage.

/**
 * Shows the latest error message of the dialog in a MessageBox.
 *
 * @param message The error string.
 */
protected void showErrorMessage(final String message) {
    MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR);
    mb.setText("Error");
    mb.setMessage(message != null ? message : "(no message)");
    mb.open();
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 94 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.

the class MasterKeyPreferencePage method checkMasterKeys.

private String checkMasterKeys(final String masterKey, final String confirmMasterKey) {
    setErrorMessage(null);
    if (masterKey == null || masterKey.isEmpty()) {
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Empty master key...");
        mb.setMessage("Master Key must not be empty.");
        setErrorMessage(mb.getMessage());
        mb.open();
        return null;
    }
    if (!masterKey.equals(confirmMasterKey)) {
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setMessage("Make sure both master keys are the same.");
        setErrorMessage(mb.getMessage());
        mb.open();
        return null;
    }
    try {
        SecretKey secretKey = KnimeEncryption.createSecretKey(HeadlessPreferencesConstants.P_MASTER_KEY);
        return KnimeEncryption.encrypt(secretKey, masterKey.toCharArray());
    } catch (Exception e) {
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Master Key Encryption...");
        mb.setMessage("Master Key Encryption failed:\n" + e.getMessage());
        setErrorMessage(mb.getMessage());
        mb.open();
        return null;
    }
}
Also used : SecretKey(javax.crypto.SecretKey) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 95 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.

the class DeleteAction method showCantDeleteMessage.

private void showCantDeleteMessage() {
    MessageBox mb = new MessageBox(m_shell, SWT.ICON_ERROR | SWT.OK);
    mb.setText("Can't Lock for Deletion");
    mb.setMessage("At least one of the workflows " + "can't be deleted.\n" + " It is probably in use by another user/instance.\n" + "Cancel deletion.");
    mb.open();
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)99 Shell (org.eclipse.swt.widgets.Shell)17 ArrayList (java.util.ArrayList)13 File (java.io.File)11 IOException (java.io.IOException)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)9 Point (org.eclipse.swt.graphics.Point)8 Button (org.eclipse.swt.widgets.Button)8 Display (org.eclipse.swt.widgets.Display)8 Composite (org.eclipse.swt.widgets.Composite)7 FileDialog (org.eclipse.swt.widgets.FileDialog)7 Label (org.eclipse.swt.widgets.Label)7 List (java.util.List)6 SWTError (org.eclipse.swt.SWTError)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionListener (org.eclipse.swt.events.SelectionListener)6 SWT (org.eclipse.swt.SWT)5