Search in sources :

Example 56 with View

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

the class DMNEditDecisionToolboxAction method onMouseClick.

@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
    // Notice the toolbox factory ensure this action is only being included
    // for Decision definitions, next cast is safe.
    final Node<View<? extends Decision>, Edge> decisionNode = (Node<View<? extends Decision>, Edge>) AbstractToolboxAction.getElement(canvasHandler, uuid).asNode();
    final Decision decision = decisionNode.getContent().getDefinition();
    editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, decision, Optional.of(decision)));
    return this;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision)

Example 57 with View

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

the class BPMN2JsonParser method initialize.

/*
        ****************************************************************
        *               Custom Stunner logic
        ****************************************************************
     */
@SuppressWarnings("unchecked")
private void initialize(final ContextualParser.Context parsingContext) {
    Graph graph = diagram.getGraph();
    final Map<String, EdgeParser> edgeParsers = new HashMap<>();
    new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()).traverse(graph, new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() {

        final Stack<NodeParser> parsers = new Stack<NodeParser>();

        NodeParser currentParser = null;

        @Override
        public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) {
            super.startGraphTraversal(graph);
        }

        @Override
        public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) {
            super.startNodeTraversal(parents, node);
            onNodeTraversal(node);
            return true;
        }

        @Override
        public void startNodeTraversal(final Node<View, Edge> node) {
            super.startNodeTraversal(node);
            onNodeTraversal(node);
        }

        private void onNodeTraversal(final Node node) {
            NodeParser p = new NodeParser("", node);
            if (null != currentParser) {
                parsers.peek().addChild(p);
            } else {
                BPMN2JsonParser.this.rootParser = p;
            }
            currentParser = p;
            List<Edge> outEdges = node.getOutEdges();
            if (null != outEdges && !outEdges.isEmpty()) {
                for (Edge edge : outEdges) {
                    // Only add the edges with view connector types into the resulting structure to generate the bpmn definition.
                    if (edge.getContent() instanceof ViewConnector && !edgeParsers.containsKey(edge.getUUID())) {
                        edgeParsers.put(edge.getUUID(), new EdgeParser("", (Edge) edge));
                    }
                }
            }
        }

        @Override
        public void startEdgeTraversal(Edge<Child, Node> edge) {
            super.startEdgeTraversal(edge);
            parsers.push(currentParser);
        }

        @Override
        public void endEdgeTraversal(Edge<Child, Node> edge) {
            super.endEdgeTraversal(edge);
            currentParser = parsers.pop();
        }

        @Override
        public void endGraphTraversal() {
            super.endGraphTraversal();
        }
    });
    // In oryx format, all edges are added into the main BPMNDiagram node.
    if (null != rootParser && !edgeParsers.isEmpty()) {
        for (EdgeParser edgeParser : edgeParsers.values()) {
            rootParser.addChild(edgeParser);
        }
    }
    // Initialize all the element parsers added in the tree.
    BPMN2JsonParser.this.rootParser.initialize(parsingContext);
    System.out.println("End of children and view traverse");
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) HashMap(java.util.HashMap) Node(org.kie.workbench.common.stunner.core.graph.Node) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Stack(java.util.Stack) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) List(java.util.List) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child)

Example 58 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 checkRemoveChildRenderableShapes.

@Test
@SuppressWarnings("unchecked")
public void checkRemoveChildRenderableShapes() {
    final ActivityShape parentShape = makeShape();
    final ActivityShape childShape = makeShape();
    final Node<View<BPMNViewDefinition>, Edge> parentNode = makeNode("parent", parentShape);
    final Node<View<BPMNViewDefinition>, Edge> childNode = makeNode("child", childShape);
    handler.register(parentShape, parentNode, true);
    handler.register(childShape, childNode, true);
    handler.addChild(parentNode, childNode);
    handler.removeChild(parentNode, childNode);
    verify(canvas, times(1)).deleteChildShape(parentShape, childShape);
    verify(layer, never()).removeShape(childShape);
}
Also used : 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) Test(org.junit.Test)

Example 59 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 checkRegisterRenderableShapes.

@Test
@SuppressWarnings("unchecked")
public void checkRegisterRenderableShapes() {
    final ActivityShape shape = makeShape();
    final Node<View<BPMNViewDefinition>, Edge> node = makeNode("uuid", shape);
    handler.register(shape, node, true);
    verify(canvas, times(1)).addShape(eq(shape));
    verify(canvas, times(1)).draw();
}
Also used : 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) Test(org.junit.Test)

Example 60 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 checkDeregisterRenderableShapes.

@Test
public void checkDeregisterRenderableShapes() {
    final ActivityShape shape = makeShape();
    final Node<View<BPMNViewDefinition>, Edge> node = makeNode("uuid", shape);
    handler.deregister(shape, node, true);
    verify(canvas, times(1)).deleteShape(eq(shape));
    verify(canvas, times(1)).draw();
}
Also used : 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) 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