Search in sources :

Example 61 with View

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

the class CaseManagementCanvasHandlerTest method checkApplyElementMutationRenderableShapes.

@Test
@SuppressWarnings("unchecked")
public void checkApplyElementMutationRenderableShapes() {
    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.applyElementMutation(shape, 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(1)).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 62 with View

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

the class CommandTestUtils method makeNode.

public static Node<View<?>, Edge> makeNode(final String uuid, final String content, final double x, final double y, final double w, final double h) {
    final Bounds bounds = new BoundsImpl(new BoundImpl(x, y), new BoundImpl(x + w, y + h));
    final Node<View<?>, Edge> node = new NodeImpl<>(uuid);
    node.setContent(new ViewImpl<>(content, bounds));
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 63 with View

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

the class ProcessVariablesProvider method findElements.

@Override
protected Collection<Pair<Object, String>> findElements(Predicate<Node> filter, Function<Node, Pair<Object, String>> mapper) {
    Collection<Pair<Object, String>> result = new ArrayList<>();
    String elementUUID = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getMetadata().getCanvasRootUUID();
    Node node;
    if (elementUUID != null) {
        node = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph().getNode(elementUUID);
        Object oDefinition = ((View) node.getContent()).getDefinition();
        if (oDefinition instanceof BPMNDiagram) {
            BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
            ProcessVariables processVars = bpmnDiagram.getProcessData().getProcessVariables();
            if (processVars.getValue().length() > 0) {
                List<String> list = Arrays.asList(processVars.getValue().split(","));
                list.forEach(s1 -> {
                    String value = s1.split(":")[0];
                    result.add(new Pair<>(value, value));
                });
            }
        }
    }
    return result;
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Pair(org.uberfire.commons.data.Pair)

Example 64 with View

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

the class AssignmentsEditorWidget method getProcessVariables.

protected String getProcessVariables() {
    Diagram diagram = canvasSessionManager.getCurrentSession().getCanvasHandler().getDiagram();
    Iterator<Element> it = diagram.getGraph().nodes().iterator();
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof BPMNDiagramImpl) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                ProcessVariables variables = bpmnDiagram.getProcessData().getProcessVariables();
                if (variables != null) {
                    return variables.getValue();
                }
                break;
            }
        }
    }
    return null;
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) Element(org.kie.workbench.common.stunner.core.graph.Element) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 65 with View

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEmbeddedSubprocess.

@Test
public void testUnmarshallEmbeddedSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EMBEDDED_SUBPROCESS);
    EmbeddedSubprocess subprocess = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof EmbeddedSubprocess) {
                subprocess = (EmbeddedSubprocess) oDefinition;
                break;
            }
        }
    }
    assertNotNull(subprocess);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

View (org.kie.workbench.common.stunner.core.graph.content.view.View)144 Edge (org.kie.workbench.common.stunner.core.graph.Edge)100 Node (org.kie.workbench.common.stunner.core.graph.Node)57 Test (org.junit.Test)49 Graph (org.kie.workbench.common.stunner.core.graph.Graph)45 Element (org.kie.workbench.common.stunner.core.graph.Element)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)32 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)31 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)31 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)31 FlowElement (org.eclipse.bpmn2.FlowElement)26 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)26 RootElement (org.eclipse.bpmn2.RootElement)26 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)21 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)16 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)14 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 ProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables)10