use of org.knime.core.node.dialog.EnabledDialogNodeModelFilter in project knime-core by knime.
the class SubNodeContainer method getDialogDescriptions.
/**
* @return a list of descriptions for all the visible dialog options
* @since 4.3
*/
// raw types
@SuppressWarnings({ "java:S1452", "java:S3740", "rawtypes" })
public List<SubNodeDescriptionProvider<? extends DialogNodeValue>> getDialogDescriptions() {
Map<NodeID, DialogNode> nodes = m_wfm.findNodes(DialogNode.class, new EnabledDialogNodeModelFilter(), false);
List<Integer> order = ConfigurationLayoutUtil.getConfigurationOrder(m_subnodeConfigurationStringProvider, nodes, m_wfm);
// Will contain the nodes in the ordering given by `order`.
// Nodes not mentioned in `order` will be placed at the end in arbitrary order.
TreeMap<Integer, DialogNode> orderedNodes = new TreeMap<>();
List<DialogNode> unorderedNodes = new ArrayList<>(nodes.size());
nodes.forEach((nodeId, metaNodeDialogNode) -> {
int targetIndex = order.indexOf(nodeId.getIndex());
if (targetIndex == -1) {
unorderedNodes.add(metaNodeDialogNode);
} else {
orderedNodes.put(targetIndex, metaNodeDialogNode);
}
});
List<DialogNode> res = new ArrayList<>();
// `values` is ordered
res.addAll(orderedNodes.values());
res.addAll(unorderedNodes);
return res.stream().map(DialogNode::getDialogRepresentation).filter(r -> r instanceof SubNodeDescriptionProvider).map(p -> (SubNodeDescriptionProvider) p).collect(toList());
}
Aggregations