use of org.kie.workbench.common.stunner.core.lookup.domain.CommonDomainLookups in project kie-wb-common by kiegroup.
the class DMNFlowActionsToolboxFactory method getActions.
@Override
@SuppressWarnings("unchecked")
public Collection<ToolboxAction<AbstractCanvasHandler>> getActions(final AbstractCanvasHandler canvasHandler, final Element<?> element) {
final Set<ToolboxAction<AbstractCanvasHandler>> actions = new LinkedHashSet<>();
final Node<Definition<Object>, Edge> node = (Node<Definition<Object>, Edge>) element;
final Diagram diagram = canvasHandler.getDiagram();
final String defSetId = diagram.getMetadata().getDefinitionSetId();
final CommonDomainLookups lookup = toolboxDomainLookups.get(defSetId);
// Look for the allowed connectors present in the Definition Set.
final Set<String> allowedConnectorIds = lookup.lookupTargetConnectors(node);
for (final String allowedConnectorId : allowedConnectorIds) {
// Append a new action for each connector.
actions.add(createConnectorActions.get().setEdgeId(allowedConnectorId));
// Append a new action for each candidate target node (as from the current connector).
final Set<String> defIds = lookup.lookupTargetNodes(diagram.getGraph(), node, allowedConnectorId);
defIds.forEach(definitionId -> actions.add(createNodeActions.get().setEdgeId(allowedConnectorId).setNodeId(definitionId)));
}
return actions;
}
use of org.kie.workbench.common.stunner.core.lookup.domain.CommonDomainLookups in project kie-wb-common by kiegroup.
the class FlowActionsToolboxFactory method getActions.
@Override
@SuppressWarnings("unchecked")
public Collection<ToolboxAction<AbstractCanvasHandler>> getActions(final AbstractCanvasHandler canvasHandler, final Element<?> element) {
final Diagram diagram = canvasHandler.getDiagram();
final Metadata metadata = diagram.getMetadata();
final String defSetId = metadata.getDefinitionSetId();
final Annotation qualifier = definitionUtils.getQualifier(defSetId);
final Node<Definition<Object>, Edge> node = (Node<Definition<Object>, Edge>) element;
// Look for the default connector type and create a button for it.
final CommonDomainLookups lookup = toolboxDomainLookups.get(defSetId);
final Set<String> targetConnectors = lookup.lookupTargetConnectors(node);
return Stream.concat(targetConnectors.stream().map(connectorDefId -> newCreateConnectorToolboxAction(qualifier).setEdgeId(connectorDefId)), targetConnectors.stream().flatMap(defaultConnectorId -> {
final Predicate<String> definitionsAllowedFilter = profileManager.isDefinitionIdAllowed(metadata);
final Set<String> targets = lookup.lookupTargetNodes(diagram.getGraph(), node, defaultConnectorId, definitionsAllowedFilter);
final Set<String> morphTargets = lookup.lookupMorphBaseDefinitions(targets);
return morphTargets.stream().map(defId -> newCreateNodeToolboxAction(qualifier).setEdgeId(defaultConnectorId).setNodeId(defId));
})).collect(Collectors.toList());
}
use of org.kie.workbench.common.stunner.core.lookup.domain.CommonDomainLookups in project kie-wb-common by kiegroup.
the class AbstractAppendNodeShortcut method executeAction.
@Override
public void executeAction(final AbstractCanvasHandler canvasHandler, final String selectedNodeId) {
final Node sourceNode = CanvasLayoutUtils.getElement(canvasHandler, selectedNodeId).asNode();
final String definitionSetId = canvasHandler.getDiagram().getMetadata().getDefinitionSetId();
final CommonDomainLookups commonDomainLookups = toolboxDomainLookups.get(definitionSetId);
final Set<String> connectorDefinitionIds = commonDomainLookups.lookupTargetConnectors(sourceNode);
for (final String connectorDefinitionId : connectorDefinitionIds) {
final Set<String> targetNodesDefinitionIds = commonDomainLookups.lookupTargetNodes(canvasHandler.getDiagram().getGraph(), sourceNode, connectorDefinitionId);
for (final String targetNodeDefinitionId : targetNodesDefinitionIds) {
final Object definition = definitionsCacheRegistry.getDefinitionById(targetNodeDefinitionId);
if (canAppendNodeOfDefinition(definition)) {
generalCreateNodeAction.executeAction(canvasHandler, selectedNodeId, targetNodeDefinitionId, connectorDefinitionId);
break;
}
}
}
}
use of org.kie.workbench.common.stunner.core.lookup.domain.CommonDomainLookups in project kie-wb-common by kiegroup.
the class ToolboxDomainLookups method get.
public CommonDomainLookups get(final String definitionSetId) {
CommonDomainLookups lookup = domainLookups.get(definitionSetId);
if (null == lookup) {
lookup = domainLookupInstances.get();
lookup.setDomain(definitionSetId);
domainLookups.put(definitionSetId, lookup);
}
return lookup;
}
use of org.kie.workbench.common.stunner.core.lookup.domain.CommonDomainLookups in project kie-wb-common by kiegroup.
the class ToolboxDomainLookupsTest method testGetCached.
@Test
public void testGetCached() {
String dsId = "ds1";
CommonDomainLookups lookups = tested.get(dsId);
CommonDomainLookups lookups1 = tested.get(dsId);
assertEquals(domainLookups, lookups);
verify(domainLookups, times(1)).setDomain(eq(dsId));
}
Aggregations