use of org.knime.core.node.dialog.MetaNodeDialogNode in project knime-core by knime.
the class WorkflowManager method getDialogPaneWithSettings.
/**
* {@inheritDoc}
*/
@Override
NodeDialogPane getDialogPaneWithSettings(final PortObjectSpec[] inSpecs, final PortObject[] inData) throws NotConfigurableException {
NodeDialogPane dialogPane = getDialogPane();
// find all quickform input nodes and update meta dialog
Map<NodeID, MetaNodeDialogNode> nodes = findNodes(MetaNodeDialogNode.class, false);
((MetaNodeDialogPane) dialogPane).setQuickformNodes(nodes);
NodeSettings settings = getNodeSettings();
Node.invokeDialogInternalLoad(dialogPane, settings, inSpecs, inData, new FlowObjectStack(getID()), new CredentialsProvider(this, m_credentialsStore), getDirectNCParent().isWriteProtected());
return dialogPane;
}
use of org.knime.core.node.dialog.MetaNodeDialogNode in project knime-core by knime.
the class MetaNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
// we may have quickform nodes to allow a column selection?)
for (Map.Entry<NodeID, MetaNodeDialogNode> e : m_nodes.entrySet()) {
if (e.getValue() instanceof QuickFormInputNode) {
AbstractQuickFormConfiguration config = ((QuickFormInputNode) e.getValue()).getConfiguration();
AbstractQuickFormValueInConfiguration valueConfig = config.getValueConfiguration();
try {
NodeSettingsRO subSettings = settings.getNodeSettings(Integer.toString(e.getKey().getIndex()));
valueConfig.loadValueInDialog(subSettings);
QuickFormConfigurationPanel panel = m_quickFormInputNodePanels.get(e.getKey());
assert panel != null : "No panel instance for node " + e.getKey();
panel.loadSettings(valueConfig);
} catch (InvalidSettingsException ise) {
// no op
}
} else if (e.getValue() instanceof DialogNode) {
final DialogNode dialogNode = (DialogNode) e.getValue();
final DialogNodeValue nodeValue = dialogNode.createEmptyDialogValue();
final String parameterName = SubNodeContainer.getDialogNodeParameterName(dialogNode, e.getKey());
try {
NodeSettingsRO subSettings = settings.getNodeSettings(parameterName);
nodeValue.loadFromNodeSettingsInDialog(subSettings);
final DialogNodePanel dialogNodePanel = m_dialogNodePanels.get(e.getKey());
dialogNodePanel.loadNodeValue(nodeValue);
} catch (InvalidSettingsException ex) {
// no op
}
}
}
}
use of org.knime.core.node.dialog.MetaNodeDialogNode in project knime-core by knime.
the class MetaNodeDialogPane method saveSettingsTo.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
for (Map.Entry<NodeID, MetaNodeDialogNode> e : m_nodes.entrySet()) {
final NodeID key = e.getKey();
if (e.getValue() instanceof QuickFormInputNode) {
AbstractQuickFormConfiguration config = ((QuickFormInputNode) e.getValue()).getConfiguration();
AbstractQuickFormValueInConfiguration valueConfig = config.createValueConfiguration();
QuickFormConfigurationPanel value = m_quickFormInputNodePanels.get(key);
value.saveSettings(valueConfig);
NodeSettingsWO subSettings = settings.addNodeSettings((Integer.toString(key.getIndex())));
valueConfig.saveValue(subSettings);
} else if (e.getValue() instanceof DialogNode) {
DialogNode dialogNode = (DialogNode) e.getValue();
DialogNodePanel nodePanel = m_dialogNodePanels.get(key);
DialogNodeValue nodeValue = nodePanel.getNodeValue();
final String parameterName = SubNodeContainer.getDialogNodeParameterName(dialogNode, key);
if (nodeValue != null) {
NodeSettingsWO subSettings = settings.addNodeSettings((parameterName));
nodeValue.saveToNodeSettings(subSettings);
}
}
}
}
use of org.knime.core.node.dialog.MetaNodeDialogNode in project knime-core by knime.
the class MetaNodeDialogPane method setQuickformNodes.
/**
* Set quickform nodes into this dialog; called just before
* {@link #loadSettingsFrom(NodeSettingsRO,
* org.knime.core.data.DataTableSpec[])} is called.
* @param nodes the quickform nodes to show settings for
*/
final void setQuickformNodes(final Map<NodeID, MetaNodeDialogNode> nodes) {
m_nodes.clear();
m_quickFormInputNodePanels.clear();
m_dialogNodePanels.clear();
// remove all quickform components from current panel
m_panel.removeAll();
List<Pair<Integer, Pair<NodeID, MetaNodeDialogNode>>> sortedNodeList = new ArrayList<Pair<Integer, Pair<NodeID, MetaNodeDialogNode>>>();
for (Map.Entry<NodeID, MetaNodeDialogNode> e : nodes.entrySet()) {
// only accept old qf nodes for metanodes
if (!m_usedInSubnode && e.getValue() instanceof QuickFormInputNode) {
AbstractQuickFormConfiguration<? extends AbstractQuickFormValueInConfiguration> config = ((QuickFormInputNode) e.getValue()).getConfiguration();
if (config == null) {
// quickform nodes has no valid configuration
continue;
}
QuickFormConfigurationPanel<? extends AbstractQuickFormValueInConfiguration> quickform = config.createController();
m_nodes.put(e.getKey(), e.getValue());
m_quickFormInputNodePanels.put(e.getKey(), quickform);
Pair<Integer, Pair<NodeID, MetaNodeDialogNode>> weightNodePair = new Pair<Integer, Pair<NodeID, MetaNodeDialogNode>>(config.getWeight(), new Pair<NodeID, MetaNodeDialogNode>(e.getKey(), e.getValue()));
sortedNodeList.add(weightNodePair);
// only accept new qf nodes for subnodes
} else if (m_usedInSubnode && e.getValue() instanceof DialogNode) {
DialogNodeRepresentation<? extends DialogNodeValue> representation = ((DialogNode) e.getValue()).getDialogRepresentation();
if (((DialogNode) e.getValue()).isHideInDialog() || representation == null) {
// no valid representation
continue;
}
try {
DialogNodePanel dialogPanel = representation.createDialogPanel();
m_nodes.put(e.getKey(), e.getValue());
m_dialogNodePanels.put(e.getKey(), dialogPanel);
Pair<Integer, Pair<NodeID, MetaNodeDialogNode>> weightNodePair = new Pair<Integer, Pair<NodeID, MetaNodeDialogNode>>(Integer.MAX_VALUE, new Pair<NodeID, MetaNodeDialogNode>(e.getKey(), e.getValue()));
sortedNodeList.add(weightNodePair);
} catch (Exception ex) {
LOGGER.error("The dialog pane for node " + e.getKey() + " could not be created.", ex);
}
}
}
Collections.sort(sortedNodeList, new Comparator<Pair<Integer, Pair<NodeID, MetaNodeDialogNode>>>() {
/**
* {@inheritDoc}
*/
@Override
public int compare(final Pair<Integer, Pair<NodeID, MetaNodeDialogNode>> o1, final Pair<Integer, Pair<NodeID, MetaNodeDialogNode>> o2) {
return o1.getFirst() - o2.getFirst();
}
});
for (Pair<Integer, Pair<NodeID, MetaNodeDialogNode>> weightNodePair : sortedNodeList) {
NodeID id = weightNodePair.getSecond().getFirst();
MetaNodeDialogNode node = weightNodePair.getSecond().getSecond();
if (node instanceof QuickFormInputNode) {
final QuickFormConfigurationPanel<?> qconfPanel = m_quickFormInputNodePanels.get(id);
JPanel qpanel = new JPanel();
final BoxLayout boxLayout2 = new BoxLayout(qpanel, BoxLayout.Y_AXIS);
qpanel.setLayout(boxLayout2);
qpanel.setBorder(BorderFactory.createTitledBorder((String) null));
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(qconfPanel);
qpanel.add(p);
m_panel.add(qpanel);
} else if (node instanceof DialogNode) {
DialogNodePanel<? extends DialogNodeValue> nodePanel = m_dialogNodePanels.get(id);
JPanel dpanel = new JPanel();
final BoxLayout boxLayout2 = new BoxLayout(dpanel, BoxLayout.Y_AXIS);
dpanel.setLayout(boxLayout2);
dpanel.setBorder(BorderFactory.createTitledBorder((String) null));
JPanel p = new JPanel(new BorderLayout());
p.add(nodePanel, BorderLayout.CENTER);
dpanel.add(p);
m_panel.add(dpanel);
}
}
if (m_nodes.isEmpty()) {
m_panel.add(new JLabel("No valid Quickform configurations."));
}
}
use of org.knime.core.node.dialog.MetaNodeDialogNode in project knime-core by knime.
the class SubNodeContainer method getDialogPaneWithSettings.
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("rawtypes")
NodeDialogPane getDialogPaneWithSettings(final PortObjectSpec[] inSpecs, final PortObject[] inData) throws NotConfigurableException {
NodeDialogPane dialogPane = getDialogPane();
// find all dialog nodes and update subnode dialog
Map<NodeID, MetaNodeDialogNode> nodes = m_wfm.findNodes(MetaNodeDialogNode.class, new NodeModelFilter<MetaNodeDialogNode>() {
@Override
public boolean include(final MetaNodeDialogNode nodeModel) {
return nodeModel instanceof DialogNode && !((DialogNode) nodeModel).isHideInDialog();
}
}, false);
((MetaNodeDialogPane) dialogPane).setQuickformNodes(nodes);
NodeSettings settings = new NodeSettings("subnode_settings");
saveSettings(settings);
// remove the flow variable port from the specs and data
PortObjectSpec[] correctedInSpecs = ArrayUtils.remove(inSpecs, 0);
PortObject[] correctedInData = ArrayUtils.remove(inData, 0);
// the next call will call dialogPane.internalLoadSettingsFrom()
// dialogPane is a MetaNodeDialogPane and does not handle the flow variable port correctly
// this is why we remove it first
Node.invokeDialogInternalLoad(dialogPane, settings, correctedInSpecs, correctedInData, getFlowObjectStack(), new CredentialsProvider(this, m_wfm.getCredentialsStore()), getParent().isWriteProtected());
return dialogPane;
}
Aggregations