Search in sources :

Example 6 with ViewImpl

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

the class CaseManagementCanvasHandlerTest method makeNode.

@SuppressWarnings("unchecked")
private Node<View<BPMNViewDefinition>, Edge> makeNode(final String uuid, final AbstractElementShape shape) {
    final Node<View<BPMNViewDefinition>, Edge> node = new NodeImpl<>(uuid);
    node.setContent(new ViewImpl(shape.getShapeDefinition(), new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(10.0, 20.0))));
    when(canvas.getShape(eq(uuid))).thenReturn(shape);
    when(clientDefinitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.NAME), anyObject())).thenReturn(PropertyMetaTypes.NAME);
    when(propertyAdapter.getValue(eq(PropertyMetaTypes.NAME))).thenReturn("name");
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) 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)

Example 7 with ViewImpl

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

the class NodeFactoryImpl method build.

@Override
@SuppressWarnings("unchecked")
public Node<Definition<Object>, Edge> build(final String uuid, final Object definition) {
    final NodeImpl node = new NodeImpl<>(uuid);
    final Bounds bounds = definitionUtils.buildBounds(definition, 0d, 0d);
    View<Object> content = new ViewImpl<>(definition, bounds);
    node.setContent(content);
    addLabels(node.getLabels(), definition);
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)

Example 8 with ViewImpl

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

the class DMNCommonActionsToolboxFactoryTest method testBuildToolboxForDecisionType.

@Test
@SuppressWarnings("unchecked")
public void testBuildToolboxForDecisionType() {
    final Node<View<Decision>, Edge> decisionNode = new NodeImpl<>("decisionNode1");
    final Decision decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    final Optional<Toolbox<?>> _toolbox = tested.build(canvasHandler, decisionNode);
    assertTrue(_toolbox.isPresent());
    Toolbox<?> toolbox = _toolbox.get();
    assertTrue(toolbox instanceof ActionsToolbox);
    final ActionsToolbox actionsToolbox = (ActionsToolbox) toolbox;
    assertEquals("decisionNode1", actionsToolbox.getElementUUID());
    assertEquals(2, actionsToolbox.size());
    final Iterator<ToolboxAction> actionsIt = actionsToolbox.iterator();
    assertEquals(deleteNodeAction, actionsIt.next());
    assertEquals(editDecisionToolboxAction, actionsIt.next());
    assertFalse(actionsIt.hasNext());
    verify(view, times(1)).init(eq(actionsToolbox));
    verify(view, times(2)).addButton(any(Glyph.class), anyString(), any(Consumer.class));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ActionsToolboxView(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolboxView) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Consumer(java.util.function.Consumer) ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Toolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.Toolbox) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 9 with ViewImpl

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

the class DMNEditDecisionToolboxActionTest method setup.

@Before
public void setup() throws Exception {
    decisionNode = new NodeImpl<>(E_UUID);
    decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(E_UUID))).thenReturn(decisionNode);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    this.tested = new DMNEditDecisionToolboxAction(sessionManager, translationService, editExpressionEvent);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Before(org.junit.Before)

Aggregations

ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)9 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)7 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)6 Before (org.junit.Before)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Test (org.junit.Test)4 Consumer (java.util.function.Consumer)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)3 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)3 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 RunWith (org.junit.runner.RunWith)2 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition)2 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)2 AdapterManager (org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager)2