use of org.knime.core.node.dialog.ValueControlledDialogPane in project knime-core by knime.
the class Node method getDialogPaneWithSettings.
/**
* @param inSpecs The input specs, which will be forwarded to the dialog's
* {@link NodeDialogPane#loadSettingsFrom(NodeSettingsRO,
* PortObjectSpec[])}.
* @param settings The current settings of this node. The settings object
* will also contain the settings of the outer SNC.
* @param isWriteProtected Whether write protected, see
* {@link org.knime.core.node.workflow.WorkflowManager#isWriteProtected()}.
* @return The dialog pane which holds all the settings' components. In
* addition this method loads the settings from the model into the
* dialog pane.
* @throws NotConfigurableException if the dialog cannot be opened because
* of real invalid settings or if any preconditions are not
* fulfilled, e.g. no predecessor node, no nominal column in
* input table, etc.
* @throws IllegalStateException If node has no dialog.
* @see #hasDialog()
* @since 2.6
*/
public NodeDialogPane getDialogPaneWithSettings(final PortObjectSpec[] inSpecs, final PortObject[] inData, final NodeSettingsRO settings, final boolean isWriteProtected) throws NotConfigurableException {
NodeDialogPane dialogPane = getDialogPane();
PortObjectSpec[] corrInSpecs = new PortObjectSpec[inSpecs.length - 1];
PortObject[] corrInData = new PortObject[inData.length - 1];
for (int i = 1; i < inSpecs.length; i++) {
if (inSpecs[i] instanceof InactiveBranchPortObjectSpec) {
if (!isInactiveBranchConsumer()) {
throw new NotConfigurableException("Cannot configure nodes in inactive branches.");
}
}
PortType t = getInputType(i);
if (!t.acceptsPortObjectSpec(inSpecs[i]) && !(inSpecs[i] instanceof InactiveBranchPortObjectSpec)) {
// table(!) connection)
throw new NotConfigurableException("Invalid incoming port object spec \"" + inSpecs[i].getClass().getSimpleName() + "\", expected \"" + t.getPortObjectSpecClass().getSimpleName() + "\"");
} else if (inSpecs[i] == null && BufferedDataTable.TYPE.equals(t) && !t.isOptional()) {
corrInSpecs[i - 1] = new DataTableSpec();
} else {
corrInSpecs[i - 1] = inSpecs[i];
corrInData[i - 1] = inData[i];
}
}
// the sub node virtual input node shows in its dialog all flow variables that are available to the rest
// of the subnode. It's the only case where the flow variables shown in the dialog are not the ones available
// to the node model class ...
final FlowObjectStack flowObjectStack = m_model instanceof VirtualSubNodeInputNodeModel ? ((VirtualSubNodeInputNodeModel) m_model).getSubNodeContainerFlowObjectStack() : getFlowObjectStack();
dialogPane.internalLoadSettingsFrom(settings, corrInSpecs, corrInData, flowObjectStack, getCredentialsProvider(), isWriteProtected);
if (m_model instanceof ValueControlledNode && dialogPane instanceof ValueControlledDialogPane) {
NodeSettings currentValue = new NodeSettings("currentValue");
try {
((ValueControlledNode) m_model).saveCurrentValue(currentValue);
((ValueControlledDialogPane) dialogPane).loadCurrentValue(currentValue);
} catch (Exception ise) {
final String msg = "Could not load current value into dialog: " + ise.getMessage();
if (ise instanceof InvalidSettingsException) {
LOGGER.warn(msg, ise);
} else {
LOGGER.coding(msg, ise);
}
}
}
return dialogPane;
}
Aggregations