use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.
the class CancelAllAction method runOnNodes.
/**
* This cancels all running jobs.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText("Confirm cancel all...");
mb.setMessage("Do you really want to cancel all running node(s) ?");
if (mb.open() != SWT.YES) {
return;
}
LOGGER.debug("(Cancel all) cancel all running jobs.");
WorkflowManager manager = getManager();
manager.getParent().cancelExecution(manager);
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 ExpandMetaNodeAction method runOnNodes.
/**
* Expand metanode!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand MetaNode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
WorkflowManagerUI metaNode = (WorkflowManagerUI) nodeParts[0].getNodeContainer();
if (!Wrapper.unwrapWFM(metaNode).unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// reset the metanode
if (manager.canResetNode(metaNode.getID())) {
// yes: ask if we can reset, otherwise bail
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
mb.setMessage("Executed Nodes inside Metanode will be reset" + " - are you sure?");
mb.setText("Reset Executed Nodes");
int dialogreturn = mb.open();
if (dialogreturn == SWT.CANCEL) {
return;
}
// perform reset
if (manager.canResetNode(metaNode.getID())) {
manager.resetAndConfigureNode(metaNode.getID());
}
}
String res = manager.canExpandMetaNode(metaNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandMetaNodeCommand emnc = new ExpandMetaNodeCommand(manager, metaNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Sorry, expanding Metanode failed: " + e.getMessage());
mb.setText("Expand failed");
mb.open();
}
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 NodeContainerEditPart method openNodeDialog.
/**
* Opens the node's dialog (also metanode dialogs).
*
* @since 2.6
*/
public void openNodeDialog() {
final NodeContainerUI container = (NodeContainerUI) getModel();
// if this node does not have a dialog
if (!container.hasDialog()) {
LOGGER.debug("No dialog for " + container.getNameWithID());
return;
}
final Shell shell = Display.getCurrent().getActiveShell();
shell.setEnabled(false);
try {
if (container.hasDataAwareDialogPane() && !container.isAllInputDataAvailable() && container.canExecuteUpToHere()) {
IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
String prefPrompt = store.getString(PreferenceConstants.P_EXEC_NODES_DATA_AWARE_DIALOGS);
boolean isExecuteUpstreamNodes;
if (MessageDialogWithToggle.PROMPT.equals(prefPrompt)) {
int returnCode = MessageDialogWithToggle.openYesNoCancelQuestion(shell, "Execute upstream nodes", "The " + container.getName() + " node can be configured using the full input data.\n\n" + "Execute upstream nodes?", "Remember my decision", false, store, PreferenceConstants.P_EXEC_NODES_DATA_AWARE_DIALOGS).getReturnCode();
if (returnCode == Window.CANCEL) {
return;
} else if (returnCode == IDialogConstants.YES_ID) {
isExecuteUpstreamNodes = true;
} else {
isExecuteUpstreamNodes = false;
}
} else if (MessageDialogWithToggle.ALWAYS.equals(prefPrompt)) {
isExecuteUpstreamNodes = true;
} else {
isExecuteUpstreamNodes = false;
}
if (isExecuteUpstreamNodes) {
try {
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Future<Void> submit = DATA_AWARE_DIALOG_EXECUTOR.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
container.getParent().executePredecessorsAndWait(container.getID());
return null;
}
});
while (!submit.isDone()) {
if (monitor.isCanceled()) {
submit.cancel(true);
throw new InterruptedException();
}
try {
submit.get(300, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
LOGGER.error("Error while waiting for execution to finish", e);
} catch (InterruptedException e) {
submit.cancel(true);
throw e;
} catch (TimeoutException e) {
// do another round
}
}
}
});
} catch (InvocationTargetException e) {
String error = "Exception while waiting for completion of execution";
LOGGER.warn(error, e);
ErrorDialog.openError(shell, "Failed opening dialog", error, new Status(IStatus.ERROR, KNIMEEditorPlugin.PLUGIN_ID, error, e));
} catch (InterruptedException e) {
return;
}
}
}
//
try {
if (Wrapper.wraps(container, NodeContainer.class)) {
WrappedNodeDialog dlg = new WrappedNodeDialog(shell, Wrapper.unwrapNC(container));
dlg.open();
}
} catch (NotConfigurableException ex) {
MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
mb.setText("Dialog cannot be opened");
mb.setMessage("The dialog cannot be opened for the following" + " reason:\n" + ex.getMessage());
mb.open();
} catch (Throwable t) {
LOGGER.error("The dialog pane for node '" + container.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an implementation error.", t);
}
} finally {
shell.setEnabled(true);
}
}
use of org.eclipse.swt.widgets.MessageBox in project knime-core by knime.
the class ExpandSubNodeAction method runOnNodes.
/**
* Expand sub node!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand Wrapped Metanode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
if (!subNode.getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// reset the metanode
if (manager.canResetNode(subNode.getID())) {
// yes: ask if we can reset, otherwise bail
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
mb.setMessage("Executed Nodes inside Wrapped Metanode will be reset" + " - are you sure?");
mb.setText("Reset Executed Nodes");
int dialogreturn = mb.open();
if (dialogreturn == SWT.CANCEL) {
return;
}
// perform reset
if (manager.canResetNode(subNode.getID())) {
manager.resetAndConfigureNode(subNode.getID());
}
}
String res = manager.canExpandSubNode(subNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandSubNodeCommand emnc = new ExpandSubNodeCommand(manager, subNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Expanding Wrapped Metanode failed: " + e.getMessage());
mb.setText("Expand failed");
mb.open();
}
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 OpenViewAction method run.
/**
* {@inheritDoc}
*/
@Override
public void run() {
LOGGER.debug("Open Node View " + m_nodeContainer.getName() + " (#" + m_index + ")");
try {
final String title = m_nodeContainer.getViewName(m_index) + " - " + m_nodeContainer.getDisplayLabel();
final java.awt.Rectangle knimeWindowBounds = OpenViewAction.getAppBoundsAsAWTRec();
SwingUtilities.invokeLater(() -> Node.invokeOpenView(m_nodeContainer.getView(m_index), title, knimeWindowBounds));
} 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 '" + m_nodeContainer.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an " + "implementation error.", t);
}
}
Aggregations