use of org.knime.core.node.workflow.NodeContainer.NodeContainerSettings in project knime-core by knime.
the class WrappedMultipleNodeDialog method doApply.
private boolean doApply() {
try {
NodeContainerSettings newSettings = new NodeContainerSettings();
m_dialogPane.saveSettings(newSettings);
if (newSettings.equals(m_initValue) || (m_initValue == null && newSettings.getJobManager() == null)) {
informNothingChanged();
} else {
m_parentMgr.applyCommonSettings(newSettings, m_nodes);
}
return true;
} catch (InvalidSettingsException ise) {
LOGGER.warn("failed to apply settings: " + ise.getMessage(), ise);
showWarningMessage("Invalid settings:\n" + ise.getMessage());
// SWT-AWT-Bridge doesn't properly repaint after dialog disappears
m_dialogPane.repaint();
} catch (Throwable t) {
LOGGER.error("failed to apply settings: " + t.getMessage(), t);
showErrorMessage(t.getClass().getSimpleName() + ": " + t.getMessage());
// SWT-AWT-Bridge doesn't properly repaint after dialog disappears
m_dialogPane.repaint();
}
return false;
}
use of org.knime.core.node.workflow.NodeContainer.NodeContainerSettings in project knime-core by knime.
the class NodeDialogPane method internalLoadSettingsFrom.
/**
* Method being called from the node when the dialog shall load the
* settings from a NodeSettingsRO object. This method will call the
* abstract loadSettingsFrom method and finally load internals
* (i.e. memory policy of outports, if any).
* @param settings To load from.
* @param specs Specs at input ports
* @param data Data from input ports
* @param foStack Flow object stack (contains flow variables)
* @param credentialsProvider The credentials available in the flow
* @param isWriteProtected Whether ok/apply should be disabled
* (write protected metanode)
* @throws NotConfigurableException
* If loadSettingsFrom throws this exception.
* @see #loadSettingsFrom(NodeSettingsRO, PortObjectSpec[])
*/
final void internalLoadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs, final PortObject[] data, final FlowObjectStack foStack, final CredentialsProvider credentialsProvider, final boolean isWriteProtected) throws NotConfigurableException {
NodeSettingsRO modelSettings = null;
NodeSettingsRO flowVariablesSettings = null;
m_flowObjectStack = foStack;
m_credentialsProvider = credentialsProvider;
m_specs = specs;
m_data = data;
m_isWriteProtected = isWriteProtected;
SingleNodeContainerSettings sncSettings;
try {
sncSettings = new SingleNodeContainerSettings(settings);
modelSettings = sncSettings.getModelSettings();
flowVariablesSettings = sncSettings.getVariablesSettings();
} catch (InvalidSettingsException ise) {
// silently ignored here, variables get assigned default values
// if they are null
sncSettings = new SingleNodeContainerSettings();
}
if (modelSettings == null) {
modelSettings = new NodeSettings("empty");
}
if (m_memPolicyTab != null) {
MemoryPolicy memoryPolicy = sncSettings.getMemoryPolicy();
if (memoryPolicy == null) {
memoryPolicy = MemoryPolicy.CacheSmallInMemory;
}
m_memPolicyTab.setStatus(memoryPolicy);
}
final AtomicReference<Throwable> exRef = new AtomicReference<Throwable>();
final NodeSettingsRO ms = modelSettings;
Runnable r = new Runnable() {
@Override
public void run() {
try {
callDerivedLoadSettingsFrom(ms, specs, data);
} catch (Throwable ex) {
exRef.set(ex);
}
}
};
ViewUtils.invokeAndWaitInEDT(r);
if (exRef.get() instanceof NotConfigurableException) {
throw (NotConfigurableException) exRef.get();
} else if (exRef.get() != null) {
m_logger.error("Error loading model settings", exRef.get());
}
// add the flow variables tab
addFlowVariablesTab();
m_flowVariablesModelChanged = false;
initFlowVariablesTab(modelSettings, flowVariablesSettings);
// output memory policy and job manager (stored in NodeContainer)
if (m_memPolicyTab != null || m_jobMgrTab != null) {
NodeContainerSettings ncSettings;
try {
ncSettings = new NodeContainerSettings();
ncSettings.load(settings);
} catch (InvalidSettingsException ise) {
ncSettings = new NodeContainerSettings();
}
if (m_jobMgrTab != null) {
m_jobMgrTab.loadSettings(ncSettings, specs);
}
}
updateFlowVariablesOverwriteWarning();
}
use of org.knime.core.node.workflow.NodeContainer.NodeContainerSettings in project knime-core by knime.
the class NodeDialogPane method internalSaveSettingsTo.
/**
* Called from the node when the current settings shall be written to
* a NodeSettings object. It will call the abstract saveSettingsTo method
* and finally write "misc" settings to the argument object.
* @param settings To write to. Forwarded to abstract saveSettings method.
* @throws InvalidSettingsException If any of the writing fails.
*/
void internalSaveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
NodeSettings model = new NodeSettings("field_ignored");
NodeContext.pushContext(m_nodeContext);
try {
saveSettingsTo(model);
} catch (InvalidSettingsException ise) {
throw ise;
} catch (Throwable e) {
m_logger.coding("Wrong exception type thrown " + "while saving dialog settings", e);
throw new InvalidSettingsException(e);
} finally {
NodeContext.removeLastContext();
}
if (m_flowVariablesModelChanged) {
updateFlowVariablesTab();
}
NodeSettings variables = m_flowVariableTab.getVariableSettings();
SingleNodeContainerSettings s = new SingleNodeContainerSettings();
s.setModelSettings(model);
s.setVariablesSettings(variables);
if (m_memPolicyTab != null) {
s.setMemoryPolicy(m_memPolicyTab.getStatus());
}
NodeContainerSettings ncSet = new NodeContainerSettings();
if (m_jobMgrTab != null) {
m_jobMgrTab.saveSettings(ncSet);
}
ncSet.save(settings);
s.save(settings);
}
use of org.knime.core.node.workflow.NodeContainer.NodeContainerSettings in project knime-core by knime.
the class NodeExecutionJobManagerPool method merge.
/**
* Get the common settings for a set of job managers.
* Used from {@link WorkflowManager#getCommonSettings(org.knime.core.node.workflow.NodeID...)}.
* @param jobManagers ...
* @return ...
* @since 2.7
*/
public static NodeContainerSettings merge(final NodeExecutionJobManager[] jobManagers) {
String factoryID = null;
NodeSettings mgrSettings = null;
boolean isFirst = true;
for (NodeExecutionJobManager jobManager : jobManagers) {
String curFactoryID;
NodeSettings curMgrSettings;
if (jobManager == null) {
curFactoryID = null;
curMgrSettings = null;
} else {
curFactoryID = jobManager.getID();
NodeSettings temp = new NodeSettings(CFG_JOB_MANAGER_SETTINGS);
jobManager.save(temp);
curMgrSettings = temp;
}
if (isFirst) {
isFirst = false;
factoryID = curFactoryID;
mgrSettings = curMgrSettings;
} else if (ConvenienceMethods.areEqual(factoryID, curFactoryID)) {
if (!ConvenienceMethods.areEqual(mgrSettings, curMgrSettings)) {
mgrSettings = null;
}
} else {
// different job managers
// unassigned
curFactoryID = null;
}
}
if (factoryID == null) {
return null;
}
NodeExecutionJobManagerFactory jobManagerFactory = getJobManagerFactory(factoryID);
assert jobManagerFactory != null : "Factory ID " + factoryID + " unknown although job manager present";
NodeExecutionJobManager instance = jobManagerFactory.getInstance();
if (mgrSettings != null) {
try {
instance.load(mgrSettings);
} catch (InvalidSettingsException e) {
LOGGER.error("Settings could not be applied to job manager although " + "they retrieved from another identical instance.", e);
}
}
NodeContainerSettings result = new NodeContainerSettings();
result.setJobManager(instance);
return result;
}
Aggregations