Search in sources :

Example 1 with NodeDescription

use of org.eclipse.sirius.components.diagrams.description.NodeDescription in project sirius-components by eclipse-sirius.

the class AbstractNodeMappingConverter method convert.

public NodeDescription convert(AbstractNodeMapping abstractNodeMapping, AQLInterpreter interpreter, Map<UUID, NodeDescription> id2NodeDescriptions) {
    LabelStyleDescriptionConverter labelStyleDescriptionConverter = new LabelStyleDescriptionConverter(interpreter, this.objectService);
    Function<VariableManager, org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription> abstractNodeMappingDescriptionProvider = new LabelStyleDescriptionProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> labelIdProvider = this.getLabelIdProvider();
    Function<VariableManager, String> labelExpressionProvider = this.getLabelExpressionProvider(interpreter, abstractNodeMappingDescriptionProvider);
    Function<VariableManager, LabelStyleDescription> labelStyleDescriptionProvider = this.getLabelStyleDescriptionProvider(labelStyleDescriptionConverter, abstractNodeMappingDescriptionProvider);
    // @formatter:off
    LabelDescription labelDescription = LabelDescription.newLabelDescription(this.identifierProvider.getIdentifier(abstractNodeMapping) + LabelDescription.LABEL_SUFFIX).idProvider(labelIdProvider).textProvider(labelExpressionProvider).styleDescriptionProvider(labelStyleDescriptionProvider).build();
    // @formatter:on
    Function<VariableManager, String> semanticTargetIdProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null);
    };
    Function<VariableManager, String> semanticTargetKindProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getKind).orElse(null);
    };
    Function<VariableManager, String> semanticTargetLabelProvider = variableManager -> {
        return variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getLabel).orElse(null);
    };
    Function<VariableManager, INodeStyle> styleProvider = new AbstractNodeMappingStyleProvider(interpreter, abstractNodeMapping);
    Function<VariableManager, String> typeProvider = variableManager -> {
        var result = NodeType.NODE_RECTANGLE;
        INodeStyle style = styleProvider.apply(variableManager);
        if (style instanceof ImageNodeStyle) {
            result = NodeType.NODE_IMAGE;
        } else if (style instanceof ListItemNodeStyle) {
            result = NodeType.NODE_LIST_ITEM;
        } else if (style instanceof ListNodeStyle) {
            result = NodeType.NODE_LIST;
        }
        return result;
    };
    AbstractNodeMappingSizeProvider sizeProvider = new AbstractNodeMappingSizeProvider(interpreter, abstractNodeMapping);
    String domainClass = abstractNodeMapping.getDomainClass();
    String semanticCandidatesExpression = abstractNodeMapping.getSemanticCandidatesExpression();
    String preconditionExpression = abstractNodeMapping.getPreconditionExpression();
    Function<VariableManager, List<?>> semanticElementsProvider = this.semanticCandidatesProviderFactory.getSemanticCandidatesProvider(interpreter, domainClass, semanticCandidatesExpression, preconditionExpression);
    List<NodeDescription> childNodeDescriptions = this.getChildNodeDescriptions(abstractNodeMapping, interpreter, id2NodeDescriptions);
    // @formatter:off
    List<NodeDescription> borderNodeDescriptions = abstractNodeMapping.getBorderedNodeMappings().stream().map(borderNodeMapping -> this.convert(borderNodeMapping, interpreter, id2NodeDescriptions)).collect(Collectors.toList());
    // @formatter:on
    ToolConverter toolConverter = new ToolConverter(interpreter, this.editService, this.modelOperationHandlerSwitchProvider);
    var deleteHandler = toolConverter.createDeleteToolHandler(abstractNodeMapping.getDeletionDescription());
    var labelEditHandler = toolConverter.createDirectEditToolHandler(abstractNodeMapping.getLabelDirectEdit());
    SynchronizationPolicy synchronizationPolicy = SynchronizationPolicy.SYNCHRONIZED;
    if (!abstractNodeMapping.isCreateElements()) {
        synchronizationPolicy = SynchronizationPolicy.UNSYNCHRONIZED;
    }
    // @formatter:off
    NodeDescription description = NodeDescription.newNodeDescription(UUID.fromString(this.identifierProvider.getIdentifier(abstractNodeMapping))).typeProvider(typeProvider).targetObjectIdProvider(semanticTargetIdProvider).targetObjectKindProvider(semanticTargetKindProvider).targetObjectLabelProvider(semanticTargetLabelProvider).semanticElementsProvider(semanticElementsProvider).synchronizationPolicy(synchronizationPolicy).labelDescription(labelDescription).styleProvider(styleProvider).sizeProvider(sizeProvider).borderNodeDescriptions(borderNodeDescriptions).childNodeDescriptions(childNodeDescriptions).labelEditHandler(labelEditHandler).deleteHandler(deleteHandler).build();
    // @formatter:on
    id2NodeDescriptions.put(description.getId(), description);
    return description;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle) Function(java.util.function.Function) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) StringValueProvider(org.eclipse.sirius.components.compatibility.utils.StringValueProvider) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) IEditService(org.eclipse.sirius.components.core.api.IEditService) StyleFactory(org.eclipse.sirius.viewpoint.description.style.StyleFactory) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Objects(java.util.Objects) List(java.util.List) NodeType(org.eclipse.sirius.components.diagrams.NodeType) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) BasicLabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) List(java.util.List) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) ImageNodeStyle(org.eclipse.sirius.components.diagrams.ImageNodeStyle) INodeStyle(org.eclipse.sirius.components.diagrams.INodeStyle)

Example 2 with NodeDescription

use of org.eclipse.sirius.components.diagrams.description.NodeDescription in project sirius-components by eclipse-sirius.

the class ViewToolSectionsProvider method createExtraToolSections.

private List<ToolSection> createExtraToolSections(Object diagramElementDescription) {
    List<ToolSection> extraToolSections = new ArrayList<>();
    List<NodeDescription> targetDescriptions = new ArrayList<>();
    boolean unsynchronizedMapping = false;
    // @formatter:off
    if (diagramElementDescription instanceof NodeDescription) {
        targetDescriptions.add((NodeDescription) diagramElementDescription);
        unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(((NodeDescription) diagramElementDescription).getSynchronizationPolicy());
    } else if (diagramElementDescription instanceof EdgeDescription) {
        EdgeDescription edgeDescription = (EdgeDescription) diagramElementDescription;
        targetDescriptions.addAll(edgeDescription.getSourceNodeDescriptions());
        unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(((EdgeDescription) diagramElementDescription).getSynchronizationPolicy());
    }
    Function<VariableManager, IStatus> fakeHandler = variableManager -> new Success();
    // Graphical Delete Tool for unsynchronized mapping only (the handler is never called)
    if (diagramElementDescription instanceof NodeDescription || diagramElementDescription instanceof EdgeDescription) {
        // Edit Tool (the handler is never called)
        SingleClickOnDiagramElementTool editTool = // $NON-NLS-1$
        SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("edit").label(// $NON-NLS-1$
        "Edit").imageURL(DiagramImageConstants.EDIT_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
        var editToolSection = // $NON-NLS-1$
        ToolSection.newToolSection("edit-section").label(// $NON-NLS-1$
        "").imageURL(// $NON-NLS-1$
        "").tools(List.of(editTool)).build();
        extraToolSections.add(editToolSection);
        if (unsynchronizedMapping) {
            SingleClickOnDiagramElementTool graphicalDeleteTool = // $NON-NLS-1$
            SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("graphical-delete").label(// $NON-NLS-1$
            "Delete from diagram").imageURL(DiagramImageConstants.GRAPHICAL_DELETE_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
            var graphicalDeleteToolSection = // $NON-NLS-1$
            ToolSection.newToolSection("graphical-delete-section").label(// $NON-NLS-1$
            "").imageURL(// $NON-NLS-1$
            "").tools(List.of(graphicalDeleteTool)).build();
            extraToolSections.add(graphicalDeleteToolSection);
        }
        // Semantic Delete Tool (the handler is never called)
        SingleClickOnDiagramElementTool semanticDeleteTool = // $NON-NLS-1$
        SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool("semantic-delete").label(// $NON-NLS-1$
        "Delete from model").imageURL(DiagramImageConstants.SEMANTIC_DELETE_SVG).targetDescriptions(targetDescriptions).handler(fakeHandler).appliesToDiagramRoot(false).build();
        var semanticDeleteToolSection = // $NON-NLS-1$
        ToolSection.newToolSection("semantic-delete-section").label(// $NON-NLS-1$
        "").imageURL(// $NON-NLS-1$
        "").tools(List.of(semanticDeleteTool)).build();
        extraToolSections.add(semanticDeleteToolSection);
    }
    return extraToolSections;
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Node(org.eclipse.sirius.components.diagrams.Node) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Success(org.eclipse.sirius.components.representations.Success) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) IToolSectionsProvider(org.eclipse.sirius.components.collaborative.diagrams.api.IToolSectionsProvider) Objects(java.util.Objects) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IStatus(org.eclipse.sirius.components.representations.IStatus) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) Service(org.springframework.stereotype.Service) DiagramImageConstants(org.eclipse.sirius.components.collaborative.diagrams.api.DiagramImageConstants) VariableManager(org.eclipse.sirius.components.representations.VariableManager) SingleClickOnTwoDiagramElementsTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IStatus(org.eclipse.sirius.components.representations.IStatus) ArrayList(java.util.ArrayList) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Success(org.eclipse.sirius.components.representations.Success) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection)

Example 3 with NodeDescription

use of org.eclipse.sirius.components.diagrams.description.NodeDescription in project sirius-components by eclipse-sirius.

the class ViewToolSectionsProvider method getNodeToolSections.

private List<ToolSection> getNodeToolSections(DiagramDescription diagramDescription, NodeDescription nodeDescription) {
    List<ToolSection> toolSections = new ArrayList<>();
    for (ToolSection toolSection : diagramDescription.getToolSections()) {
        List<ITool> tools = toolSection.getTools().stream().filter(tool -> this.isValidTool(tool, nodeDescription)).collect(Collectors.toList());
        if (!tools.isEmpty()) {
            ToolSection filteredToolSection = ToolSection.newToolSection(toolSection).tools(tools).build();
            toolSections.add(filteredToolSection);
        }
    }
    return toolSections;
}
Also used : Node(org.eclipse.sirius.components.diagrams.Node) SynchronizationPolicy(org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy) Success(org.eclipse.sirius.components.representations.Success) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ArrayList(java.util.ArrayList) IToolSectionsProvider(org.eclipse.sirius.components.collaborative.diagrams.api.IToolSectionsProvider) Objects(java.util.Objects) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IStatus(org.eclipse.sirius.components.representations.IStatus) ITool(org.eclipse.sirius.components.diagrams.tools.ITool) SingleClickOnDiagramElementTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool) Service(org.springframework.stereotype.Service) DiagramImageConstants(org.eclipse.sirius.components.collaborative.diagrams.api.DiagramImageConstants) VariableManager(org.eclipse.sirius.components.representations.VariableManager) SingleClickOnTwoDiagramElementsTool(org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) ToolSection(org.eclipse.sirius.components.diagrams.tools.ToolSection) ArrayList(java.util.ArrayList) ITool(org.eclipse.sirius.components.diagrams.tools.ITool)

Example 4 with NodeDescription

use of org.eclipse.sirius.components.diagrams.description.NodeDescription in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromNodeToContainer.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * a valid target for an edge.
 */
@Test
public void testEdgeFromNodeToContainer() {
    EdgeMapping edgeMapping = DescriptionFactory.eINSTANCE.createEdgeMapping();
    NodeMapping nodeMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
    // $NON-NLS-1$
    nodeMapping.setName("nodeMapping");
    ContainerMapping containerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    containerMapping.setName("containerMapping");
    edgeMapping.getSourceMapping().add(nodeMapping);
    edgeMapping.getTargetMapping().add(containerMapping);
    // @formatter:off
    UUID nodeMappingUUID = UUID.nameUUIDFromBytes(nodeMapping.getName().getBytes());
    UUID containerMappingUUID = UUID.nameUUIDFromBytes(containerMapping.getName().getBytes());
    Map<UUID, NodeDescription> id2NodeDescriptions = Map.of(nodeMappingUUID, this.createNodeDescription(nodeMappingUUID), containerMappingUUID, this.createNodeDescription(containerMappingUUID));
    // @formatter:on
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() {

        @Override
        public String getIdentifier(Object element) {
            return containerMappingUUID.toString();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(new IObjectService.NoOp(), new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    EdgeDescription edgeDescription = edgeMappingConverter.convert(edgeMapping, new AQLInterpreter(List.of(), List.of()), id2NodeDescriptions);
    assertThat(edgeDescription.getTargetNodeDescriptions()).contains(id2NodeDescriptions.get(containerMappingUUID));
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Optional(java.util.Optional) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 5 with NodeDescription

use of org.eclipse.sirius.components.diagrams.description.NodeDescription in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromContainerToContainer.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * both a valid source and a valid target for an edge.
 */
@Test
public void testEdgeFromContainerToContainer() {
    EdgeMapping edgeMapping = DescriptionFactory.eINSTANCE.createEdgeMapping();
    ContainerMapping sourceContainerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    sourceContainerMapping.setName("sourceContainerMapping");
    ContainerMapping targetContainerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    targetContainerMapping.setName("targetContainerMapping");
    edgeMapping.getSourceMapping().add(sourceContainerMapping);
    edgeMapping.getTargetMapping().add(targetContainerMapping);
    // @formatter:off
    UUID sourceContainerMappingUUID = UUID.nameUUIDFromBytes(sourceContainerMapping.getName().getBytes());
    UUID targetContainerMappingUUID = UUID.nameUUIDFromBytes(targetContainerMapping.getName().getBytes());
    Map<UUID, NodeDescription> id2NodeDescriptions = Map.of(sourceContainerMappingUUID, this.createNodeDescription(sourceContainerMappingUUID), targetContainerMappingUUID, this.createNodeDescription(targetContainerMappingUUID));
    // @formatter:on
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider() {

        @Override
        public String getIdentifier(Object element) {
            return targetContainerMappingUUID.toString();
        }

        @Override
        public Optional<String> findVsmElementId(UUID id) {
            return Optional.empty();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    EdgeMappingConverter edgeMappingConverter = new EdgeMappingConverter(objectService, new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    EdgeDescription edgeDescription = edgeMappingConverter.convert(edgeMapping, new AQLInterpreter(List.of(), List.of()), id2NodeDescriptions);
    edgeDescription.getSourceNodeDescriptions().contains(id2NodeDescriptions.get(sourceContainerMappingUUID));
    assertThat(edgeDescription.getTargetNodeDescriptions()).contains(id2NodeDescriptions.get(targetContainerMappingUUID));
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) Size(org.eclipse.sirius.components.diagrams.Size) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) Success(org.eclipse.sirius.components.representations.Success) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) Optional(java.util.Optional) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) EdgeMappingConverter(org.eclipse.sirius.components.compatibility.diagrams.EdgeMappingConverter) EdgeMapping(org.eclipse.sirius.diagram.description.EdgeMapping) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) EdgeDescription(org.eclipse.sirius.components.diagrams.description.EdgeDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) IEditService(org.eclipse.sirius.components.core.api.IEditService) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)46 UUID (java.util.UUID)31 List (java.util.List)30 VariableManager (org.eclipse.sirius.components.representations.VariableManager)29 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)27 ArrayList (java.util.ArrayList)26 Optional (java.util.Optional)23 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)23 Size (org.eclipse.sirius.components.diagrams.Size)21 EdgeDescription (org.eclipse.sirius.components.diagrams.description.EdgeDescription)21 Function (java.util.function.Function)20 INodeStyle (org.eclipse.sirius.components.diagrams.INodeStyle)19 Node (org.eclipse.sirius.components.diagrams.Node)18 Objects (java.util.Objects)17 Collectors (java.util.stream.Collectors)17 Success (org.eclipse.sirius.components.representations.Success)17 Test (org.junit.jupiter.api.Test)17 DiagramDescription (org.eclipse.sirius.components.diagrams.description.DiagramDescription)16 Element (org.eclipse.sirius.components.representations.Element)16 Map (java.util.Map)15