Search in sources :

Example 1 with DiagramRepresentation

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method loadByName.

public void loadByName(final String name, final ServiceCallback<Diagram> callback) {
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().withName(name).build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(LookupManager.LookupResponse<DiagramRepresentation> diagramRepresentations) {
            if (null != diagramRepresentations && !diagramRepresentations.getResults().isEmpty()) {
                final Path path = diagramRepresentations.getResults().get(0).getPath();
                loadByPath(path, callback);
            }
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) Path(org.uberfire.backend.vfs.Path) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 2 with DiagramRepresentation

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method loadByName.

public void loadByName(final String name, final ServiceCallback<Diagram> callback) {
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().withName(name).build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(LookupManager.LookupResponse<DiagramRepresentation> diagramRepresentations) {
            if (null != diagramRepresentations && !diagramRepresentations.getResults().isEmpty()) {
                final Path path = diagramRepresentations.getResults().get(0).getPath();
                loadByPath(path, callback);
            }
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) Path(org.uberfire.backend.vfs.Path) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 3 with DiagramRepresentation

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation in project kie-wb-common by kiegroup.

the class DiagramsNavigatorImpl method show.

public DiagramsNavigatorImpl show() {
    // Notify some processing starts.
    fireProcessingStarted();
    clear();
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(final LookupManager.LookupResponse<DiagramRepresentation> response) {
            final List<DiagramRepresentation> items = response.getResults();
            if (null != items && !items.isEmpty()) {
                for (final DiagramRepresentation diagram : items) {
                    addEntry(diagram);
                }
            }
            // Notify some processing ends.
            fireProcessingCompleted();
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            showError(error);
        }
    });
    return this;
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) List(java.util.List) LinkedList(java.util.LinkedList) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 4 with DiagramRepresentation

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation in project kie-wb-common by kiegroup.

the class DiagramNavigatorItemImplTest method checkSizeIsSetBeforeDataWhenShowing.

@Test
public void checkSizeIsSetBeforeDataWhenShowing() {
    final InOrder inOrder = inOrder(view, view);
    final DiagramRepresentation diagramRepresentation = mock(DiagramRepresentation.class);
    when(diagramRepresentation.getThumbImageData()).thenReturn("thumbData");
    diagramNavigatorItem.show(diagramRepresentation, 100, 200, () -> {
    });
    inOrder.verify(view).setItemPxSize(eq(100), eq(200));
    inOrder.verify(view).setThumbData(eq("thumbData"));
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 5 with DiagramRepresentation

use of org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation in project kie-wb-common by kiegroup.

the class DiagramNavigatorItemImplTest method checkSizeIsSetBeforeUriWhenShowing.

@Test
public void checkSizeIsSetBeforeUriWhenShowing() {
    final InOrder inOrder = inOrder(view, view);
    final SafeUri uri = mock(SafeUri.class);
    final DiagramRepresentation diagramRepresentation = mock(DiagramRepresentation.class);
    when(diagramRepresentation.getDefinitionSetId()).thenReturn("defId");
    when(shapeManager.getThumbnail(eq("defId"))).thenReturn(uri);
    when(diagramRepresentation.getThumbImageData()).thenReturn(null);
    diagramNavigatorItem.show(diagramRepresentation, 100, 200, () -> {
    });
    inOrder.verify(view).setItemPxSize(eq(100), eq(200));
    inOrder.verify(view).setThumbUri(eq(uri));
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) InOrder(org.mockito.InOrder) SafeUri(com.google.gwt.safehtml.shared.SafeUri) Test(org.junit.Test)

Aggregations

DiagramRepresentation (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation)5 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)3 LookupManager (org.kie.workbench.common.stunner.core.lookup.LookupManager)3 DiagramLookupRequest (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)3 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 Path (org.uberfire.backend.vfs.Path)2 SafeUri (com.google.gwt.safehtml.shared.SafeUri)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1