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
}
}
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);
}
}
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();
}
}
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);
}
}
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);
}
}
Aggregations