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);
}
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);
}
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();
}
});
}
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());
}
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;
}
Aggregations