Search in sources :

Example 1 with ISemanticCandidatesProviderFactory

use of org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory 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 2 with ISemanticCandidatesProviderFactory

use of org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory 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)

Example 3 with ISemanticCandidatesProviderFactory

use of org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory in project sirius-components by eclipse-sirius.

the class EdgeMappingConverterTests method testEdgeFromContainerToNode.

/**
 * Non-regression test for the create edges issue. This test will ensure that a container description can be used as
 * a valid source for an edge.
 */
@Test
public void testEdgeFromContainerToNode() {
    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(containerMapping);
    edgeMapping.getTargetMapping().add(nodeMapping);
    // @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() {

        @Override
        public String getIdentifier(Object element) {
            return containerMappingUUID.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);
    assertThat(edgeDescription.getSourceNodeDescriptions()).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 4 with ISemanticCandidatesProviderFactory

use of org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory in project sirius-components by eclipse-sirius.

the class MappingConverterTests method testContainerWithImageSubNode.

/**
 * Test that nodes inside a list are always typed as list items with a matching style, regardless of their "native"
 * style.
 */
@Test
public void testContainerWithImageSubNode() {
    ContainerMapping containerMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
    // $NON-NLS-1$
    containerMapping.setName("EClass");
    // $NON-NLS-1$
    containerMapping.setDomainClass("ecore::EClass");
    // $NON-NLS-1$
    containerMapping.setSemanticCandidatesExpression("aql:self.eClassifiers");
    containerMapping.setChildrenPresentation(ContainerLayout.LIST);
    ContainerStyleDescription containerStyle = StyleFactory.eINSTANCE.createFlatContainerStyleDescription();
    // $NON-NLS-1$
    containerStyle.setLabelExpression("aql:self.name");
    containerMapping.setStyle(containerStyle);
    NodeMapping itemMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
    // $NON-NLS-1$
    itemMapping.setDomainClass("ecore::EAttribute");
    // $NON-NLS-1$
    itemMapping.setSemanticCandidatesExpression("aql:self.eStructuralFeatures");
    WorkspaceImageDescription imageStyle = StyleFactory.eINSTANCE.createWorkspaceImageDescription();
    // $NON-NLS-1$
    imageStyle.setLabelExpression("aql:self.name");
    // $NON-NLS-1$
    imageStyle.setWorkspacePath("path/to/image.svg");
    itemMapping.setStyle(imageStyle);
    containerMapping.getSubNodeMappings().add(itemMapping);
    IIdentifierProvider identifierProvider = new IIdentifierProvider() {

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

        @Override
        public Optional<String> findVsmElementId(UUID id) {
            return Optional.empty();
        }
    };
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = (interpreter, domainClass, semanticCandidatesExpression, preconditionExpression) -> variableManager -> List.of();
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> modelOperation -> Optional.empty();
    AQLInterpreter interpreter = new AQLInterpreter(List.of(), List.of(EcorePackage.eINSTANCE));
    var converter = new AbstractNodeMappingConverter(new IObjectService.NoOp(), new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
    NodeDescription convertedNodeDescription = converter.convert(containerMapping, interpreter, new HashMap<UUID, NodeDescription>());
    VariableManager variableManager = new VariableManager();
    variableManager.put(VariableManager.SELF, EcorePackage.Literals.ECLASS);
    assertThat(convertedNodeDescription.getTypeProvider().apply(variableManager)).isEqualTo(NodeType.NODE_LIST);
    assertThat(convertedNodeDescription.getStyleProvider().apply(variableManager)).isInstanceOf(ListNodeStyle.class);
    assertThat(convertedNodeDescription.getChildNodeDescriptions()).hasSize(1);
    NodeDescription subNodeDescription = convertedNodeDescription.getChildNodeDescriptions().get(0);
    variableManager.put(VariableManager.SELF, EcorePackage.Literals.ECLASS__ABSTRACT);
    assertThat(subNodeDescription.getTypeProvider().apply(variableManager)).isEqualTo(NodeType.NODE_LIST_ITEM);
    assertThat(subNodeDescription.getStyleProvider().apply(variableManager)).isInstanceOf(ListItemNodeStyle.class);
}
Also used : LabelDescription(org.eclipse.sirius.components.diagrams.description.LabelDescription) EcorePackage(org.eclipse.emf.ecore.EcorePackage) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ContainerStyleDescription(org.eclipse.sirius.diagram.description.style.ContainerStyleDescription) HashMap(java.util.HashMap) NodeDescription(org.eclipse.sirius.components.diagrams.description.NodeDescription) ListNodeStyle(org.eclipse.sirius.components.diagrams.ListNodeStyle) NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) ContainerLayout(org.eclipse.sirius.diagram.ContainerLayout) NodeStyleDescription(org.eclipse.sirius.diagram.description.style.NodeStyleDescription) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) FixedColor(org.eclipse.sirius.viewpoint.description.FixedColor) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) IEditService(org.eclipse.sirius.components.core.api.IEditService) WorkspaceImageDescription(org.eclipse.sirius.diagram.description.style.WorkspaceImageDescription) StyleFactory(org.eclipse.sirius.diagram.description.style.StyleFactory) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) ListItemNodeStyle(org.eclipse.sirius.components.diagrams.ListItemNodeStyle) LabelStyleDescription(org.eclipse.sirius.components.diagrams.description.LabelStyleDescription) UUID(java.util.UUID) ConditionalContainerStyleDescription(org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) DescriptionFactory(org.eclipse.sirius.diagram.description.DescriptionFactory) ConditionalNodeStyleDescription(org.eclipse.sirius.diagram.description.ConditionalNodeStyleDescription) Test(org.junit.jupiter.api.Test) 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) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) ContainerStyleDescription(org.eclipse.sirius.diagram.description.style.ContainerStyleDescription) ConditionalContainerStyleDescription(org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription) 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) WorkspaceImageDescription(org.eclipse.sirius.diagram.description.style.WorkspaceImageDescription) 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 ISemanticCandidatesProviderFactory

use of org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory in project sirius-components by eclipse-sirius.

the class FormRendererTests method testEcoreModel.

@Test
public void testEcoreModel() {
    ViewExtensionDescription viewExtensionDescription = this.createSiriusProperties();
    AQLInterpreterFactory interpreterFactory = new AQLInterpreterFactory() {

        @Override
        public AQLInterpreter create(ViewExtensionDescription viewExtensionDescription) {
            return new AQLInterpreter(List.of(), List.of(EcorePackage.eINSTANCE));
        }
    };
    IObjectService objectService = new IObjectService.NoOp();
    IRepresentationMetadataSearchService representationMetadataSearchService = new IRepresentationMetadataSearchService.NoOp();
    IIdentifierProvider identifierProvider = new IIdentifierProvider.NoOp() {

        @Override
        public String getIdentifier(Object element) {
            return UUID.randomUUID().toString();
        }
    };
    IdentifiedElementLabelProvider identifiedElementLabelProvider = new IdentifiedElementLabelProvider();
    ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = SemanticCandidatesProvider::new;
    IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpeter -> new ModelOperationHandlerSwitch(objectService, representationMetadataSearchService, identifierProvider, List.of(), interpeter);
    ViewExtensionDescriptionConverter converter = new ViewExtensionDescriptionConverter(objectService, interpreterFactory, identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider, identifiedElementLabelProvider);
    FormDescription description = converter.convert(viewExtensionDescription);
    this.checkResult(description);
}
Also used : Form(org.eclipse.sirius.components.forms.Form) EcorePackage(org.eclipse.emf.ecore.EcorePackage) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) Category(org.eclipse.sirius.properties.Category) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FormRenderer(org.eclipse.sirius.components.forms.renderer.FormRenderer) AbstractWidget(org.eclipse.sirius.components.forms.AbstractWidget) ViewExtensionDescription(org.eclipse.sirius.properties.ViewExtensionDescription) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) FormComponent(org.eclipse.sirius.components.forms.components.FormComponent) TextfieldDescription(org.eclipse.sirius.components.forms.description.TextfieldDescription) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ForDescription(org.eclipse.sirius.components.forms.description.ForDescription) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) PropertiesFactory(org.eclipse.sirius.properties.PropertiesFactory) SemanticCandidatesProvider(org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider) ViewExtensionDescriptionConverter(org.eclipse.sirius.components.compatibility.forms.ViewExtensionDescriptionConverter) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) SelectDescription(org.eclipse.sirius.components.forms.description.SelectDescription) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) Element(org.eclipse.sirius.components.representations.Element) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) Test(org.junit.jupiter.api.Test) List(java.util.List) Group(org.eclipse.sirius.components.forms.Group) FormComponentProps(org.eclipse.sirius.components.forms.components.FormComponentProps) Optional(java.util.Optional) RadioDescription(org.eclipse.sirius.components.forms.description.RadioDescription) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IdentifiedElementLabelProvider(org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider) AQLInterpreterFactory(org.eclipse.sirius.components.emf.compatibility.AQLInterpreterFactory) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) ViewExtensionDescriptionConverter(org.eclipse.sirius.components.compatibility.forms.ViewExtensionDescriptionConverter) ModelOperationHandlerSwitch(org.eclipse.sirius.components.emf.compatibility.modeloperations.ModelOperationHandlerSwitch) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) ViewExtensionDescription(org.eclipse.sirius.properties.ViewExtensionDescription) AQLInterpreterFactory(org.eclipse.sirius.components.emf.compatibility.AQLInterpreterFactory) IdentifiedElementLabelProvider(org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IRepresentationMetadataSearchService(org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) Test(org.junit.jupiter.api.Test)

Aggregations

List (java.util.List)7 Optional (java.util.Optional)7 UUID (java.util.UUID)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 IIdentifierProvider (org.eclipse.sirius.components.compatibility.api.IIdentifierProvider)7 IModelOperationHandlerSwitchProvider (org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider)7 ISemanticCandidatesProviderFactory (org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory)7 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)7 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)7 Test (org.junit.jupiter.api.Test)7 IEditService (org.eclipse.sirius.components.core.api.IEditService)6 LabelDescription (org.eclipse.sirius.components.diagrams.description.LabelDescription)6 LabelStyleDescription (org.eclipse.sirius.components.diagrams.description.LabelStyleDescription)6 NodeDescription (org.eclipse.sirius.components.diagrams.description.NodeDescription)6 ContainerMapping (org.eclipse.sirius.diagram.description.ContainerMapping)6 DescriptionFactory (org.eclipse.sirius.diagram.description.DescriptionFactory)6 NodeMapping (org.eclipse.sirius.diagram.description.NodeMapping)6 EcorePackage (org.eclipse.emf.ecore.EcorePackage)4 IRepresentationMetadataSearchService (org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService)4 SemanticCandidatesProvider (org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider)4