use of org.knime.core.node.workflow.TemplateNodeContainerPersistor in project knime-core by knime.
the class LoadMetaNodeTemplateRunnable method run.
/**
* {@inheritDoc}
*/
@SuppressWarnings("null")
@Override
public void run(final IProgressMonitor pm) {
try {
// create progress monitor
ProgressHandler progressHandler = new ProgressHandler(pm, 101, "Loading metanode template...");
final CheckCancelNodeProgressMonitor progressMonitor = new CheckCancelNodeProgressMonitor(pm);
progressMonitor.addProgressListener(progressHandler);
URI sourceURI = m_templateKNIMEFolder.toURI();
File parentFile = ResolverUtil.resolveURItoLocalOrTempFile(sourceURI, pm);
if (pm.isCanceled()) {
throw new InterruptedException();
}
Display d = Display.getDefault();
GUIWorkflowLoadHelper loadHelper = new GUIWorkflowLoadHelper(d, parentFile.getName(), sourceURI, parentFile, null, true);
TemplateNodeContainerPersistor loadPersistor = loadHelper.createTemplateLoadPersistor(parentFile, sourceURI);
MetaNodeLinkUpdateResult loadResult = new MetaNodeLinkUpdateResult("Template from \"" + sourceURI + "\"");
m_parentWFM.load(loadPersistor, loadResult, new ExecutionMonitor(progressMonitor), false);
m_result = loadResult;
if (pm.isCanceled()) {
throw new InterruptedException();
}
pm.subTask("Finished.");
pm.done();
final IStatus status = createStatus(m_result, !m_result.getGUIMustReportDataLoadErrors());
final String message;
switch(status.getSeverity()) {
case IStatus.OK:
message = "No problems during load.";
break;
case IStatus.WARNING:
message = "Warnings during load";
logPreseveLineBreaks("Warnings during load: " + m_result.getFilteredError("", LoadResultEntryType.Warning), false);
break;
default:
message = "Errors during load";
logPreseveLineBreaks("Errors during load: " + m_result.getFilteredError("", LoadResultEntryType.Warning), true);
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// will not open if status is OK.
ErrorDialog.openError(Display.getDefault().getActiveShell(), "Workflow Load", message, status);
}
});
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
// IMPORTANT: Remove the reference to the file and the
// editor!!! Otherwise the memory cannot be freed later
m_parentWFM = null;
m_templateKNIMEFolder = null;
}
}
Aggregations