Search in sources :

Example 96 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class CaseManagementCanvasHandlerTest method checkApplyShapeElementMutationRenderableShapes.

@Test
@SuppressWarnings("unchecked")
public void checkApplyShapeElementMutationRenderableShapes() {
    final ActivityShape shape = spy(makeShape());
    final Node<View<BPMNViewDefinition>, Edge> node = makeNode("uuid", shape);
    final MutationContext mutationContext = mock(MutationContext.class);
    doNothing().when(shape).applyPosition(eq(node), eq(mutationContext));
    doNothing().when(shape).applyProperties(eq(node), eq(mutationContext));
    doNothing().when(shape).applyTitle(anyString(), any(Node.class), eq(mutationContext));
    handler.register(shape, node, true);
    verify(canvas, times(1)).draw();
    handler.applyElementMutation(node, true, true, mutationContext);
    verify(shape, times(1)).applyPosition(eq(node), eq(mutationContext));
    verify(shape, times(1)).applyProperties(eq(node), eq(mutationContext));
    verify(canvas, times(2)).draw();
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ActivityShape(org.kie.workbench.common.stunner.cm.client.shape.ActivityShape) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) ActivityView(org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) MutationContext(org.kie.workbench.common.stunner.core.client.shape.MutationContext) Test(org.junit.Test)

Example 97 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class CaseManagementContainmentAcceptorControlImplTest method getDeleteEdgeCommand.

@Test
public void getDeleteEdgeCommand() {
    final Node parent = mock(Node.class);
    final Node child = mock(Node.class);
    control.getDeleteEdgeCommand(parent, child);
    verify(canvasCommandFactory, times(1)).removeChild(eq(parent), eq(child));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Test(org.junit.Test)

Example 98 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class CaseManagementRemoveChildCommandTest method setup.

@Before
public void setup() {
    super.setup();
    this.parent = CommandTestUtils.makeNode("uuid1", "parent", 10.0, 20.0, 50.0, 50.0);
    this.candidate = CommandTestUtils.makeNode("uuid2", "candidate", 10.0, 20.0, 50.0, 50.0);
    this.command = new CaseManagementRemoveChildCommand(parent, candidate);
    final Edge<Child, Node> edge = new EdgeImpl<>("edge1");
    edge.setContent(new Child());
    edge.setSourceNode(parent);
    edge.setTargetNode(candidate);
    parent.getOutEdges().add(edge);
    candidate.getInEdges().add(edge);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Before(org.junit.Before)

Example 99 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class DefaultRouteFormProvider method findElements.

@Override
protected Collection<Pair<Object, String>> findElements(Predicate<Node> filter, Function<Node, Pair<Object, String>> mapper) {
    Node selectedNode = getSelectedElement();
    Collection<Pair<Object, String>> result = new ArrayList<>();
    if (selectedNode != null) {
        List<Edge> outEdges = selectedNode.getOutEdges();
        if (outEdges != null) {
            result = outEdges.stream().map(outEdge -> {
                String routeIdentifier = outEdge.getUUID();
                // UI value for the route is the target node name or target node type
                String targetName = null;
                String targetNodeType = null;
                BPMNDefinition bpmnDefinition = getEdgeTarget(outEdge);
                if (bpmnDefinition != null) {
                    targetNodeType = definitionManager.adapters().forDefinition().getTitle(bpmnDefinition);
                    if (bpmnDefinition instanceof BaseStartEvent || bpmnDefinition instanceof BaseCatchingIntermediateEvent || bpmnDefinition instanceof BaseThrowingIntermediateEvent || bpmnDefinition instanceof BaseEndEvent || bpmnDefinition instanceof BaseTask || bpmnDefinition instanceof BaseGateway || bpmnDefinition instanceof BaseSubprocess) {
                        targetName = bpmnDefinition.getGeneral().getName().getValue();
                    }
                }
                if (targetName != null && !targetName.isEmpty()) {
                    return new Pair<Object, String>(routeIdentifier, targetName);
                } else if (targetNodeType != null && !targetNodeType.isEmpty()) {
                    return new Pair<Object, String>(routeIdentifier, targetNodeType);
                } else {
                    return new Pair<Object, String>(routeIdentifier, routeIdentifier);
                }
            }).collect(Collectors.toList());
        }
    }
    return result;
}
Also used : BaseGateway(org.kie.workbench.common.stunner.bpmn.definition.BaseGateway) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) BaseEndEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseEndEvent) BaseTask(org.kie.workbench.common.stunner.bpmn.definition.BaseTask) BaseSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess) BaseStartEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseStartEvent) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) BaseCatchingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BaseThrowingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseThrowingIntermediateEvent) Pair(org.uberfire.commons.data.Pair)

Example 100 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNProcessVariableDeleteHandler method isVariableBoundToNodes.

public boolean isVariableBoundToNodes(Graph graph, String propertyId) {
    final Collection<String> result = new ArrayList();
    graph.nodes().forEach(node -> {
        Node nodeVar = (Node) node;
        boolean process = this.isVariableBoundToNode(nodeVar, propertyId);
        if (process) {
            result.add(nodeVar.getUUID());
        }
    });
    return result.size() > 0;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList)

Aggregations

Node (org.kie.workbench.common.stunner.core.graph.Node)153 Edge (org.kie.workbench.common.stunner.core.graph.Edge)85 View (org.kie.workbench.common.stunner.core.graph.content.view.View)59 Test (org.junit.Test)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)32 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)24 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)21 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)17 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)13 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)13 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)13 Matchers.anyString (org.mockito.Matchers.anyString)13 List (java.util.List)12 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 Before (org.junit.Before)11 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)11 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11