use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method openDiagram.
private void openDiagram(final Diagram diagram, final Command callback) {
sessionManager.getSessionFactory(diagram.getMetadata(), ClientFullSession.class).newSession(diagram.getMetadata(), s -> {
final AbstractClientFullSession session = (AbstractClientFullSession) s;
presenter = sessionPresenterFactory.newPresenterEditor();
screenPanelView.setWidget(presenter.getView());
presenter.withToolbar(true).withPalette(true).displayNotifications(type -> true).open(diagram, session, new ScreenPresenterCallback(callback));
expressionEditor.init(presenter);
});
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramEditor method save.
/**
* Considering the diagram valid at this point ,
* it delegates the save operation to the diagram services bean.
* @param commitMessage The commit's message.
*/
@Override
@SuppressWarnings("unchecked")
protected void save(final String commitMessage) {
super.save(commitMessage);
showLoadingViews();
// Update diagram's image data as thumbnail.
final CanvasHandler canvasHandler = getSession().getCanvasHandler();
final Diagram diagram = canvasHandler.getDiagram();
// Perform update operation remote call.
projectDiagramServices.saveOrUpdate(versionRecordManager.getCurrentPath(), getDiagram(), metadata, commitMessage, new ServiceCallback<ProjectDiagram>() {
@Override
public void onSuccess(final ProjectDiagram item) {
getSaveSuccessCallback(item.hashCode());
onSaveSuccess();
hideLoadingViews();
}
@Override
public void onError(final ClientRuntimeError error) {
onSaveError(error);
}
});
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class ClientDiagramServicesTest method testUpdateClientMetadata.
@Test
@SuppressWarnings("unchecked")
public void testUpdateClientMetadata() {
String ssid = "shapeSet1";
ShapeSet shapeSet = mock(ShapeSet.class);
when(shapeSet.getId()).thenReturn(ssid);
when(shapeManager.getDefaultShapeSet(anyString())).thenReturn(shapeSet);
when(metadata.getShapeSetId()).thenReturn(null);
ServiceCallback<Diagram<Graph, Metadata>> callback = mock(ServiceCallback.class);
when(diagramService.getDiagramByPath(eq(path))).thenReturn(diagram);
tested.add(diagram, callback);
tested.saveOrUpdate(diagram, callback);
tested.getByPath(path, callback);
verify(metadata, times(3)).setShapeSetId(eq(ssid));
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class ClientFactoryServicesTest method testNewDiagramByTpeLocal.
@Test
@SuppressWarnings("unchecked")
public void testNewDiagramByTpeLocal() {
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(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(0)).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 ClientFactoryServicesTest method testNewDiagramRemote.
@Test
@SuppressWarnings("unchecked")
public void testNewDiagramRemote() {
String id = "id1";
String name = "name1";
ServiceCallback<Diagram> callback = mock(ServiceCallback.class);
Diagram def = mock(Diagram.class);
when(clientFactoryManager.newDiagram(eq(name), eq(id), any(Metadata.class))).thenReturn(null);
when(factoryService.newDiagram(eq(name), eq(id), any(Metadata.class))).thenReturn(def);
tested.newDiagram(name, id, metadata, callback);
verify(callback, times(1)).onSuccess(eq(def));
verify(clientFactoryManager, times(1)).newDiagram(eq(name), eq(id), any(Metadata.class));
verify(clientFactoryManager, times(0)).newDiagram(anyString(), any(Class.class), any(Metadata.class));
verify(factoryService, times(1)).newDiagram(eq(name), eq(id), any(Metadata.class));
verify(factoryService, times(0)).newDiagram(anyString(), any(Class.class), any(Metadata.class));
}
Aggregations