Search in sources :

Example 86 with MessageBox

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

the class DefaultOpenViewAction method runOnNodes.

/**
 * This opens the first view of all the selected nodes.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating open default view job for " + nodeParts.length + " node(s)...");
    for (NodeContainerEditPart p : nodeParts) {
        final NodeContainer cont = unwrapNC(p.getNodeContainer());
        final InteractiveWebViewsResult webViewsResult = cont.getInteractiveWebViews();
        boolean hasView = cont.getNrViews() > 0;
        hasView |= cont.hasInteractiveView() || webViewsResult.size() > 0;
        hasView |= OpenSubnodeWebViewAction.hasContainerView(cont);
        if (cont.getNodeContainerState().isExecuted() && hasView) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        final IAction action;
                        if (cont.hasInteractiveView()) {
                            action = new OpenInteractiveViewAction(cont);
                        } else if (cont instanceof SubNodeContainer) {
                            action = new OpenSubnodeWebViewAction((SubNodeContainer) cont);
                        } else if (webViewsResult.size() > 0) {
                            action = new OpenInteractiveWebViewAction(cont, webViewsResult.get(0));
                        } else {
                            action = new OpenViewAction(cont, 0);
                        }
                        action.run();
                    } catch (Throwable t) {
                        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
                        mb.setText("View cannot be opened");
                        mb.setMessage("The view cannot be opened for the " + "following reason:\n" + t.getMessage());
                        mb.open();
                        LOGGER.error("The view for node '" + cont.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an " + "implementation error.", t);
                    }
                }
            });
        }
    }
    try {
        // Give focus to the editor again. Otherwise the actions (selection)
        // is not updated correctly.
        getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
    } catch (Exception e) {
    // ignore
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) MessageBox(org.eclipse.swt.widgets.MessageBox) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult)

Example 87 with MessageBox

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

the class OpenInteractiveViewAction method run.

/**
 * {@inheritDoc}
 */
@Override
public void run() {
    LOGGER.debug("Open Interactive Node View " + m_nodeContainer.getName());
    try {
        AbstractNodeView<?> view = m_nodeContainer.getInteractiveView();
        final String title = m_nodeContainer.getInteractiveViewName();
        Node.invokeOpenView(view, title, OpenViewAction.getAppBoundsAsAWTRec());
    } catch (Throwable t) {
        final MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Interactive View cannot be opened");
        mb.setMessage("The interactive view cannot be opened for the following reason:\n" + t.getMessage());
        mb.open();
        LOGGER.error("The interactive view for node '" + m_nodeContainer.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
    }
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 88 with MessageBox

use of org.eclipse.swt.widgets.MessageBox 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 89 with MessageBox

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

the class OpenInteractiveWebViewAction method run.

@Override
public void run() {
    LOGGER.debug("Open Interactive Web Node View " + m_nodeContainer.getName());
    NativeNodeContainer nativeNC = m_webViewForNode.getNativeNodeContainer();
    try {
        @SuppressWarnings("rawtypes") AbstractWizardNodeView view = null;
        NodeContext.pushContext(nativeNC);
        try {
            NodeModel nodeModel = nativeNC.getNodeModel();
            view = getConfiguredWizardNodeView(nodeModel);
        } finally {
            NodeContext.removeLastContext();
        }
        view.setWorkflowManagerAndNodeID(nativeNC.getParent(), nativeNC.getID());
        final String title = m_webViewForNode.getViewName();
        Node.invokeOpenView(view, title, OpenViewAction.getAppBoundsAsAWTRec());
    } catch (Throwable t) {
        final MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Interactive View cannot be opened");
        mb.setMessage("The interactive view cannot be opened for the following reason:\n" + t.getMessage());
        mb.open();
        LOGGER.error("The interactive view for node '" + nativeNC.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
    }
}
Also used : NodeModel(org.knime.core.node.NodeModel) AbstractWizardNodeView(org.knime.core.node.wizard.AbstractWizardNodeView) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 90 with MessageBox

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

the class OpenSubnodeWebViewAction method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    LOGGER.debug("Open Interactive Web Node View " + getSubnodeViewName());
    try {
        @SuppressWarnings("rawtypes") AbstractWizardNodeView view = null;
        NodeContext.pushContext(m_nodeContainer);
        try {
            SubnodeViewableModel model = new SubnodeViewableModel(m_nodeContainer, getSubnodeViewName());
            view = OpenInteractiveWebViewAction.getConfiguredWizardNodeView(model);
            model.registerView(view);
        } finally {
            NodeContext.removeLastContext();
        }
        view.setWorkflowManagerAndNodeID(m_nodeContainer.getParent(), m_nodeContainer.getID());
        final String title = m_nodeContainer.getName();
        Node.invokeOpenView(view, title, OpenViewAction.getAppBoundsAsAWTRec());
    } catch (Throwable t) {
        final MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
        mb.setText("Interactive View cannot be opened");
        mb.setMessage("The interactive view cannot be opened for the following reason:\n" + t.getMessage());
        mb.open();
        LOGGER.error("The interactive view for node '" + m_nodeContainer.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
    }
}
Also used : SubnodeViewableModel(org.knime.core.wizard.SubnodeViewableModel) AbstractWizardNodeView(org.knime.core.node.wizard.AbstractWizardNodeView) 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