use of org.kie.workbench.common.stunner.project.diagram.ProjectDiagram 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.project.diagram.ProjectDiagram in project kie-wb-common by kiegroup.
the class BPMNProjectDiagramFactoryTest method testBuild.
@Test
@SuppressWarnings("unchecked")
public void testBuild() {
final String pName = "p1";
when(metadata.getProjectPackage()).thenReturn(PKG);
when(metadata.getModuleName()).thenReturn(pName);
ProjectDiagram pdiagram = tested.build(NAME, metadata, graph);
assertNotNull(pdiagram);
assertEquals(graph, pdiagram.getGraph());
assertEquals(pName + "." + NAME, diagram.getDiagramSet().getId().getValue());
assertEquals("packageName", diagram.getDiagramSet().getPackageProperty().getValue());
verify(metadata, times(1)).setCanvasRootUUID(eq(DIAGRAM_NODE_UUID));
}
use of org.kie.workbench.common.stunner.project.diagram.ProjectDiagram in project kie-wb-common by kiegroup.
the class BPMNProjectDiagramFactoryTest method testBuildNoPackageSpecified.
@Test
@SuppressWarnings("unchecked")
public void testBuildNoPackageSpecified() {
when(metadata.getProjectPackage()).thenReturn(null);
ProjectDiagram pdiagram = tested.build(NAME, metadata, graph);
assertNotNull(pdiagram);
assertEquals(graph, pdiagram.getGraph());
assertEquals(NAME, diagram.getDiagramSet().getId().getValue());
assertEquals(Package.DEFAULT_PACKAGE, diagram.getDiagramSet().getPackageProperty().getValue());
verify(metadata, times(1)).setCanvasRootUUID(eq(DIAGRAM_NODE_UUID));
}
use of org.kie.workbench.common.stunner.project.diagram.ProjectDiagram in project kie-wb-common by kiegroup.
the class ProjectDiagramServiceImpl method constructContent.
@Override
protected ProjectDiagram constructContent(final Path path, final Overview overview) {
ProjectDiagram diagram = getDiagramByPath(path);
if (null != diagram) {
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo));
return diagram;
}
LOG.error("Failed to construct diagram content for path [" + path + "].");
return null;
}
use of org.kie.workbench.common.stunner.project.diagram.ProjectDiagram in project kie-wb-common by kiegroup.
the class ProjectDiagramServiceImplTest method testConstructContent.
@Test
public void testConstructContent() {
Overview overview = mock(Overview.class);
when(diagramServiceController.getDiagramByPath(path)).thenReturn(diagram);
ProjectDiagram result = diagramService.constructContent(path, overview);
verify(diagramServiceController, times(1)).getDiagramByPath(path);
verify(resourceOpenedEvent, times(1)).fire(eventArgumentCaptor.capture());
assertEquals(sessionInfo, eventArgumentCaptor.getValue().getSessionInfo());
assertEquals(path, eventArgumentCaptor.getValue().getPath());
assertEquals(result, diagram);
}
Aggregations