Search in sources :

Example 1 with ProjectDiagram

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);
            }
        });
    });
}
Also used : CopySelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.CopySelectionSessionCommand) ClearStatesSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ClearStatesSessionCommand) ValidationUtils(org.kie.workbench.common.stunner.core.validation.impl.ValidationUtils) StunnerProjectClientConstants(org.kie.workbench.common.stunner.project.client.resources.i18n.StunnerProjectClientConstants) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) ClientResourceType(org.uberfire.client.workbench.type.ClientResourceType) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) KieEditorView(org.kie.workbench.common.widgets.metadata.client.KieEditorView) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) SessionCommandFactory(org.kie.workbench.common.stunner.core.client.session.command.impl.SessionCommandFactory) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) ProjectMessagesListener(org.kie.workbench.common.stunner.project.client.screens.ProjectMessagesListener) Map(java.util.Map) Observes(javax.enterprise.event.Observes) PlaceGainFocusEvent(org.uberfire.client.workbench.events.PlaceGainFocusEvent) IsWidget(com.google.gwt.user.client.ui.IsWidget) UberView(org.uberfire.client.mvp.UberView) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) ExportToPdfSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToPdfSessionCommand) OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) Collection(java.util.Collection) Violation(org.kie.workbench.common.stunner.core.validation.Violation) ClientProjectDiagramService(org.kie.workbench.common.stunner.project.client.service.ClientProjectDiagramService) YesNoCancelPopup(org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup) Menus(org.uberfire.workbench.model.menu.Menus) ClearSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ClearSessionCommand) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Logger(java.util.logging.Logger) DeleteSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.DeleteSelectionSessionCommand) PlaceRequest(org.uberfire.mvp.PlaceRequest) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) LogConfiguration(com.google.gwt.logging.client.LogConfiguration) PasteSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.PasteSelectionSessionCommand) RedoSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.RedoSessionCommand) CutSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.CutSelectionSessionCommand) KieEditor(org.kie.workbench.common.widgets.metadata.client.KieEditor) ObservablePath(org.uberfire.backend.vfs.ObservablePath) UndoSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.UndoSessionCommand) ExportToPngSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToPngSessionCommand) PostConstruct(javax.annotation.PostConstruct) ExportToBpmnSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToBpmnSessionCommand) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ErrorPopupPresenter(org.uberfire.client.workbench.widgets.common.ErrorPopupPresenter) HashMap(java.util.HashMap) SavePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.SavePopUpPresenter) PlaceManager(org.uberfire.client.mvp.PlaceManager) VisitGraphSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.VisitGraphSessionCommand) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Inject(javax.inject.Inject) AbstractPlaceEvent(org.uberfire.client.workbench.events.AbstractPlaceEvent) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DiagramClientErrorHandler(org.kie.workbench.common.stunner.core.client.error.DiagramClientErrorHandler) CommonConstants(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants) SessionPresenterFactory(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenterFactory) AbstractClientReadOnlySession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientReadOnlySession) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Command(org.uberfire.mvp.Command) FINE(java.util.logging.Level.FINE) Event(javax.enterprise.event.Event) PlaceHiddenEvent(org.uberfire.client.workbench.events.PlaceHiddenEvent) OnDiagramFocusEvent(org.kie.workbench.common.stunner.project.client.editor.event.OnDiagramFocusEvent) ExportToJpgSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToJpgSessionCommand) HashUtil(org.kie.workbench.common.stunner.core.util.HashUtil) OnDiagramLoseFocusEvent(org.kie.workbench.common.stunner.project.client.editor.event.OnDiagramLoseFocusEvent) FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) SwitchGridSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.SwitchGridSessionCommand) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 2 with ProjectDiagram

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));
}
Also used : ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Example 3 with ProjectDiagram

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));
}
Also used : ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Example 4 with ProjectDiagram

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;
}
Also used : ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)

Example 5 with ProjectDiagram

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);
}
Also used : Overview(org.guvnor.common.services.shared.metadata.model.Overview) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Aggregations

ProjectDiagram (org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)7 Test (org.junit.Test)4 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)2 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)2 LogConfiguration (com.google.gwt.logging.client.LogConfiguration)1 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Level (java.util.logging.Level)1 FINE (java.util.logging.Level.FINE)1 Logger (java.util.logging.Logger)1 PostConstruct (javax.annotation.PostConstruct)1 Event (javax.enterprise.event.Event)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 SessionPresenter (org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter)1