Search in sources :

Example 1 with IRepresentationDescription

use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.

the class NodeResizeTests method createDiagramCreationService.

private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
    IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {

        @Override
        public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
            DiagramDescription diagramDescription = NodeResizeTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
            return Optional.of(diagramDescription);
        }
    };
    NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
    IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
    LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
    return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 2 with IRepresentationDescription

use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.

the class DiagramLayoutTest method createDiagramCreationService.

private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
    IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {

        @Override
        public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
            DiagramDescription diagramDescription = DiagramLayoutTest.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
            return Optional.of(diagramDescription);
        }
    };
    NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
    IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
    LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
    return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 3 with IRepresentationDescription

use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.

the class NodeCreationTests method createDiagramCreationService.

private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
    IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {

        @Override
        public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
            DiagramDescription diagramDescription = NodeCreationTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
            return Optional.of(diagramDescription);
        }
    };
    NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
    IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
    LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
    return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
Also used : TestDiagramCreationService(org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) ImageSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) IELKDiagramConverter(org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ELKLayoutedDiagramProvider(org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider) NodeSizeProvider(org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider) LayoutService(org.eclipse.sirius.components.diagrams.layout.LayoutService) UUID(java.util.UUID) LayoutConfiguratorRegistry(org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)

Example 4 with IRepresentationDescription

use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.

the class EditingContextRepresentationDescriptionsEventHandler method findAllCompatibleRepresentationDescriptions.

private List<IRepresentationDescription> findAllCompatibleRepresentationDescriptions(IEditingContext editingContext, String kind) {
    List<IRepresentationDescription> result = new ArrayList<>();
    Optional<Object> optionalClazz = this.resolveKind(editingContext, kind);
    if (optionalClazz.isPresent()) {
        var allRepresentationDescriptions = this.representationDescriptionSearchService.findAll(editingContext);
        for (IRepresentationDescription description : allRepresentationDescriptions.values()) {
            VariableManager variableManager = new VariableManager();
            variableManager.put(IRepresentationDescription.CLASS, optionalClazz.get());
            Predicate<VariableManager> canCreatePredicate = description.getCanCreatePredicate();
            boolean canCreate = canCreatePredicate.test(variableManager);
            if (canCreate) {
                result.add(description);
            }
        }
    }
    return result;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) ArrayList(java.util.ArrayList) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription)

Example 5 with IRepresentationDescription

use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-web by eclipse-sirius.

the class DynamicRepresentationDescriptionService method findDynamicRepresentationDescriptions.

@Override
public List<IRepresentationDescription> findDynamicRepresentationDescriptions(IEditingContext editingContext) {
    List<IRepresentationDescription> dynamicRepresentationDescriptions = new ArrayList<>();
    if (this.isStudioDefinitionEnabled) {
        List<EPackage> accessibleEPackages = this.getAccessibleEPackages(editingContext);
        this.documentRepository.findAllByType(ViewPackage.eNAME, ViewPackage.eNS_URI).forEach(documentEntity -> {
            Resource resource = this.loadDocumentAsEMF(documentEntity);
            // @formatter:off
            this.getViewDefinitions(resource).forEach(view -> this.viewConverter.convert(view, accessibleEPackages).stream().filter(Objects::nonNull).forEach(dynamicRepresentationDescriptions::add));
        // @formatter:on
        });
    }
    return dynamicRepresentationDescriptions;
}
Also used : ArrayList(java.util.ArrayList) JsonResource(org.eclipse.sirius.emfjson.resource.JsonResource) Resource(org.eclipse.emf.ecore.resource.Resource) Objects(java.util.Objects) IRepresentationDescription(org.eclipse.sirius.components.representations.IRepresentationDescription) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

IRepresentationDescription (org.eclipse.sirius.components.representations.IRepresentationDescription)12 UUID (java.util.UUID)7 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)6 IRepresentationDescriptionSearchService (org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService)6 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)6 ArrayList (java.util.ArrayList)4 ELKLayoutedDiagramProvider (org.eclipse.sirius.components.diagrams.layout.ELKLayoutedDiagramProvider)4 LayoutConfiguratorRegistry (org.eclipse.sirius.components.diagrams.layout.LayoutConfiguratorRegistry)4 LayoutService (org.eclipse.sirius.components.diagrams.layout.LayoutService)4 ImageSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.ImageSizeProvider)4 NodeSizeProvider (org.eclipse.sirius.components.diagrams.layout.incremental.provider.NodeSizeProvider)4 IELKDiagramConverter (org.eclipse.sirius.components.diagrams.layout.IELKDiagramConverter)3 TestDiagramCreationService (org.eclipse.sirius.components.diagrams.layout.services.TestDiagramCreationService)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 List (java.util.List)2 Objects (java.util.Objects)2 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)2 IRepresentationPersistenceService (org.eclipse.sirius.components.collaborative.api.IRepresentationPersistenceService)2 CreateRepresentationInput (org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput)2 CreateRepresentationSuccessPayload (org.eclipse.sirius.components.collaborative.dto.CreateRepresentationSuccessPayload)2