Search in sources :

Example 26 with Diagram

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);
    });
}
Also used : Session(org.kie.workbench.common.stunner.core.client.session.Session) ShowcaseDiagramService(org.kie.workbench.common.dmn.showcase.client.screens.ShowcaseDiagramService) ValidationUtils(org.kie.workbench.common.stunner.core.validation.impl.ValidationUtils) UUID(org.kie.workbench.common.stunner.core.util.UUID) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) 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) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) Observes(javax.enterprise.event.Observes) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) IsWidget(com.google.gwt.user.client.ui.IsWidget) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) Collection(java.util.Collection) Violation(org.kie.workbench.common.stunner.core.validation.Violation) Menus(org.uberfire.workbench.model.menu.Menus) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Logger(java.util.logging.Logger) ClientFactoryService(org.kie.workbench.common.stunner.core.client.service.ClientFactoryService) PlaceRequest(org.uberfire.mvp.PlaceRequest) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) WorkbenchMenu(org.uberfire.client.annotations.WorkbenchMenu) LogConfiguration(com.google.gwt.logging.client.LogConfiguration) EditorToolbar(org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar) OnOpen(org.uberfire.lifecycle.OnOpen) MenuDevCommandsBuilder(org.kie.workbench.common.stunner.client.widgets.menu.dev.MenuDevCommandsBuilder) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) ExpressionEditorView(org.kie.workbench.common.dmn.client.editors.expressions.ExpressionEditorView) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) DiagramEditor(org.kie.workbench.common.stunner.core.client.annotation.DiagramEditor) OnFocus(org.uberfire.lifecycle.OnFocus) ScreenPanelView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenPanelView) ScreenErrorView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenErrorView) Level(java.util.logging.Level) DMNEditor(org.kie.workbench.common.dmn.api.qualifiers.DMNEditor) Inject(javax.inject.Inject) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) MenuFactory(org.uberfire.workbench.model.menu.MenuFactory) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) WorkbenchPartTitle(org.uberfire.client.annotations.WorkbenchPartTitle) SessionPresenterFactory(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenterFactory) WorkbenchContextId(org.uberfire.client.annotations.WorkbenchContextId) 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) OnStartup(org.uberfire.lifecycle.OnStartup) Command(org.uberfire.mvp.Command) FINE(java.util.logging.Level.FINE) Event(javax.enterprise.event.Event) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Dependent(javax.enterprise.context.Dependent) NavigateToExpressionEditorCommand(org.kie.workbench.common.dmn.client.commands.general.NavigateToExpressionEditorCommand) WorkbenchPartView(org.uberfire.client.annotations.WorkbenchPartView) OnClose(org.uberfire.lifecycle.OnClose) BusyPopup(org.uberfire.ext.widgets.common.client.common.BusyPopup) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession)

Example 27 with Diagram

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);
        }
    });
}
Also used : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)

Example 28 with Diagram

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));
}
Also used : ShapeSet(org.kie.workbench.common.stunner.core.client.ShapeSet) Matchers.anyString(org.mockito.Matchers.anyString) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 29 with Diagram

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));
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 30 with Diagram

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));
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)17 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Collection (java.util.Collection)7 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)7 Graph (org.kie.workbench.common.stunner.core.graph.Graph)7 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)6 Node (org.kie.workbench.common.stunner.core.graph.Node)6 Before (org.junit.Before)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 OnStartup (org.uberfire.lifecycle.OnStartup)5 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Command (org.uberfire.mvp.Command)4 ArrayList (java.util.ArrayList)3 Assert.assertEquals (org.junit.Assert.assertEquals)3