use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramEditor method open.
@SuppressWarnings("unchecked")
protected void open(final ProjectDiagram diagram) {
showLoadingViews();
setOriginalHash(diagram.hashCode());
final Metadata metadata = diagram.getMetadata();
sessionManager.getSessionFactory(metadata, ClientFullSession.class).newSession(metadata, s -> {
final AbstractClientFullSession session = (AbstractClientFullSession) s;
presenter = sessionPresenterFactory.newPresenterEditor();
getView().setWidget(presenter.getView());
presenter.withToolbar(false).withPalette(true).displayNotifications(type -> true).open(diagram, session, new SessionPresenter.SessionPresenterCallback<AbstractClientFullSession, Diagram>() {
@Override
public void afterSessionOpened() {
}
@Override
public void afterCanvasInitialized() {
}
@Override
public void onSuccess() {
bindCommands();
updateTitle(diagram.getMetadata().getTitle());
hideLoadingViews();
setOriginalHash(getCurrentDiagramHash());
}
@Override
public void onError(final ClientRuntimeError error) {
onLoadError(error);
}
});
});
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class StunnerClientLogger method logSessionInfo.
public static void logSessionInfo(final AbstractClientSession session) {
log("************ Session Info ****************");
if (null != session) {
log("Session = " + session.toString());
log("Canvas = " + session.getCanvas().toString());
if (null != session.getCanvasHandler()) {
final CanvasHandler canvasHandler = session.getCanvasHandler();
log("CanvasHandler = " + canvasHandler.toString());
final Diagram diagram = canvasHandler.getDiagram();
if (null != diagram) {
log("Diagram name = " + diagram.getName());
log("Graph uuid = " + (null != diagram.getGraph() ? diagram.getGraph().getUUID() : "null"));
final Metadata metadata = diagram.getMetadata();
if (null != metadata) {
log("Metadata defSetId = " + metadata.getDefinitionSetId());
log("Metadata shapeSetId = " + metadata.getShapeSetId());
log("Metadata canvas root = " + metadata.getCanvasRootUUID());
log("Metadata title = " + metadata.getTitle());
} else {
log("Metadata = null");
}
} else {
log("Diagram = null");
}
} else {
log("CanvasHandler = null");
}
if (session instanceof ClientFullSession) {
logFullSessionInfo((ClientFullSession) session);
}
} else {
log("Session is null");
}
log("******************************************");
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class ClientFactoryServicesTest method testNewDiagramByTpeRemote.
@Test
@SuppressWarnings("unchecked")
public void testNewDiagramByTpeRemote() {
String name = "name1";
ServiceCallback<Diagram> callback = mock(ServiceCallback.class);
Diagram def = mock(Diagram.class);
when(clientFactoryManager.newDiagram(eq(name), eq(MyType.class), any(Metadata.class))).thenReturn(null);
when(factoryService.newDiagram(eq(name), eq(MyType.class), any(Metadata.class))).thenReturn(def);
tested.newDiagram(name, MyType.class, metadata, callback);
verify(callback, times(1)).onSuccess(eq(def));
verify(clientFactoryManager, times(0)).newDiagram(anyString(), anyString(), any(Metadata.class));
verify(clientFactoryManager, times(1)).newDiagram(anyString(), eq(MyType.class), any(Metadata.class));
verify(factoryService, times(0)).newDiagram(anyString(), anyString(), any(Metadata.class));
verify(factoryService, times(1)).newDiagram(anyString(), any(Class.class), any(Metadata.class));
}
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 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);
}
Aggregations