Search in sources :

Example 11 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class SessionPreviewImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.preview = new SessionPreviewImpl(definitionManager, shapeManager, textPropertyProviderFactory, canvasCommandManager, definitionUtils, graphUtils, canvasHandlerFactories, canvasCommandFactories, selectionControl, view);
    final DiagramImpl diagram = new DiagramImpl("diagram", new MetadataImpl());
    final GraphImpl graph = new GraphImpl("graph", new GraphNodeStoreImpl());
    final DefinitionSetImpl definitionSet = new DefinitionSetImpl("id");
    diagram.setGraph(graph);
    graph.setContent(definitionSet);
    definitionSet.setBounds(new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(100.0, 100.0)));
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(session.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(shapeManager.getCanvasFactory(any(Diagram.class))).thenReturn(canvasFactory);
    when(canvasFactory.newCanvas()).thenReturn(canvas);
    when(canvasFactory.newControl(eq(ZoomControl.class))).thenReturn(zoomControl);
    when(canvasHandlerFactories.select(any(Annotation.class))).thenReturn(canvasHandlerFactories);
    when(canvasHandlerFactories.get()).thenReturn(canvasHandler);
    when(canvas.getView()).thenReturn(canvasView);
    preview.open(session, callback);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) ZoomControl(org.kie.workbench.common.stunner.core.client.canvas.controls.zoom.ZoomControl) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) DefinitionSetImpl(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSetImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before)

Example 12 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method save.

public void save(final AbstractClientFullSession session, final ServiceCallback<Diagram<Graph, Metadata>> diagramServiceCallback) {
    // Update diagram's image data as thumbnail.
    final String thumbData = toImageData(session);
    final CanvasHandler canvasHandler = session.getCanvasHandler();
    final Diagram diagram = canvasHandler.getDiagram();
    diagram.getMetadata().setThumbData(thumbData);
    save(diagram, diagramServiceCallback);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 13 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method newDiagram.

private void newDiagram(final String uuid, final String title, final String definitionSetId, final String shapeSetId, final Command callback) {
    BusyPopup.showMessage("Loading");
    final Metadata metadata = buildMetadata(definitionSetId, shapeSetId, title);
    clientFactoryServices.newDiagram(uuid, definitionSetId, metadata, new ServiceCallback<Diagram>() {

        @Override
        public void onSuccess(final Diagram diagram) {
            final Metadata metadata = diagram.getMetadata();
            metadata.setShapeSetId(shapeSetId);
            metadata.setTitle(title);
            openDiagram(diagram, callback);
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            showError(error);
            callback.execute();
        }
    });
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 14 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class AbstractProcessFilteredNodeProvider method findElements.

protected Collection<Pair<Object, String>> findElements(final Predicate<Node> filter, final Function<Node, Pair<Object, String>> mapper) {
    final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
    @SuppressWarnings("unchecked") Iterable<Node> it = diagram.getGraph().nodes();
    return StreamSupport.stream(it.spliterator(), false).filter(filter).map(mapper).filter(pair -> pair != null).collect(Collectors.toSet());
}
Also used : SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) Predicate(java.util.function.Predicate) Collection(java.util.Collection) SelectorDataProvider(org.kie.workbench.common.forms.dynamic.model.config.SelectorDataProvider) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) TreeMap(java.util.TreeMap) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) Comparator(java.util.Comparator) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Pair(org.uberfire.commons.data.Pair) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Node(org.kie.workbench.common.stunner.core.graph.Node) Node(org.kie.workbench.common.stunner.core.graph.Node) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 15 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram 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)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)17 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Collection (java.util.Collection)7 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)7 Graph (org.kie.workbench.common.stunner.core.graph.Graph)7 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)6 Node (org.kie.workbench.common.stunner.core.graph.Node)6 Before (org.junit.Before)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 OnStartup (org.uberfire.lifecycle.OnStartup)5 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Command (org.uberfire.mvp.Command)4 ArrayList (java.util.ArrayList)3 Assert.assertEquals (org.junit.Assert.assertEquals)3