use of org.knime.core.node.dialog.SubNodeDescriptionProvider in project knime-core by knime.
the class WorkflowConfigArtifactsGenerator method extractTopLevelConfiguration.
@SuppressWarnings("rawtypes")
private static void extractTopLevelConfiguration(final WorkflowManager wfm, final JsonObjectBuilder builder) {
Map<String, DialogNode> configurationNodes = wfm.getConfigurationNodes(true);
if (!configurationNodes.isEmpty()) {
configurationNodes.entrySet().forEach(e -> {
final JsonValue value = e.getValue().getDefaultValue().toJson();
if (e.getValue().getDialogRepresentation() instanceof SubNodeDescriptionProvider && value.getValueType() == ValueType.OBJECT) {
final JsonObject object = enrich((JsonObject) value, "label", ((SubNodeDescriptionProvider) e.getValue().getDialogRepresentation()).getLabel());
builder.add(e.getKey(), object);
} else {
builder.add(e.getKey(), value);
}
});
}
}
use of org.knime.core.node.dialog.SubNodeDescriptionProvider 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