Search in sources :

Example 1 with ViewExtensionDescription

use of org.eclipse.sirius.properties.ViewExtensionDescription in project sirius-components by eclipse-sirius.

the class FormRendererTests method createSiriusProperties.

private ViewExtensionDescription createSiriusProperties() {
    ViewExtensionDescription viewExtensionDescription = PropertiesFactory.eINSTANCE.createViewExtensionDescription();
    Category category = PropertiesFactory.eINSTANCE.createCategory();
    viewExtensionDescription.getCategories().add(category);
    org.eclipse.sirius.properties.GroupDescription groupDescription = this.createGroupDescription();
    org.eclipse.sirius.properties.PageDescription pageDescription = this.createPageDescription(groupDescription);
    org.eclipse.sirius.properties.TextDescription textDescription = this.createTextfield();
    org.eclipse.sirius.properties.TextAreaDescription textAreaDescription = this.createTextArea();
    org.eclipse.sirius.properties.CheckboxDescription checkboxDescription = this.createCheckbox();
    org.eclipse.sirius.properties.RadioDescription radioDescription = this.createRadio();
    org.eclipse.sirius.properties.SelectDescription selectDescription = this.createSelect();
    org.eclipse.sirius.properties.DynamicMappingForDescription forDescription = this.createForDescription();
    org.eclipse.sirius.properties.CheckboxDescription ifCheckboxDescription = this.createCheckbox();
    org.eclipse.sirius.properties.DynamicMappingIfDescription ifDescription = this.createIfDescription(ifCheckboxDescription);
    forDescription.getIfs().add(ifDescription);
    groupDescription.getControls().add(textDescription);
    groupDescription.getControls().add(textAreaDescription);
    groupDescription.getControls().add(checkboxDescription);
    groupDescription.getControls().add(radioDescription);
    groupDescription.getControls().add(selectDescription);
    groupDescription.getControls().add(forDescription);
    category.getGroups().add(groupDescription);
    category.getPages().add(pageDescription);
    return viewExtensionDescription;
}
Also used : Category(org.eclipse.sirius.properties.Category) ViewExtensionDescription(org.eclipse.sirius.properties.ViewExtensionDescription)

Example 2 with ViewExtensionDescription

use of org.eclipse.sirius.properties.ViewExtensionDescription in project sirius-components by eclipse-sirius.

the class ViewExtensionDescriptionConverter method convert.

@Override
public FormDescription convert(ViewExtensionDescription viewExtensionDescription) {
    AQLInterpreter interpreter = this.interpreterFactory.create(viewExtensionDescription);
    PageDescriptionConverter pageDescriptionConverter = new PageDescriptionConverter(interpreter, this.identifierProvider, this.semanticCandidatesProviderFactory);
    GroupDescriptionConverter groupDescriptionConverter = new GroupDescriptionConverter(interpreter, this.objectService, this.identifierProvider, this.modelOperationHandlerSwitchProvider);
    // @formatter:off
    Map<org.eclipse.sirius.properties.GroupDescription, GroupDescription> siriusGroup2SiriusWebGroup = new HashMap<>();
    List<GroupDescription> groupDescriptions = viewExtensionDescription.getCategories().stream().flatMap(category -> category.getPages().stream()).flatMap(page -> page.getGroups().stream()).map(groupDescription -> groupDescriptionConverter.convert(groupDescription, siriusGroup2SiriusWebGroup)).collect(Collectors.toList());
    List<PageDescription> pageDescriptions = viewExtensionDescription.getCategories().stream().flatMap(category -> category.getPages().stream()).map(pageDescription -> pageDescriptionConverter.convert(pageDescription, siriusGroup2SiriusWebGroup)).collect(Collectors.toList());
    Function<VariableManager, String> labelProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).filter(self -> self instanceof List<?>).map(self -> (List<?>) self).flatMap(self -> self.stream().findFirst()).map(this.objectService::getFullLabel).orElse(// $NON-NLS-1$
    "Properties");
    Function<VariableManager, String> targetObjectIdProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).filter(self -> self instanceof List<?>).map(self -> (List<?>) self).flatMap(self -> self.stream().findFirst()).map(this.objectService::getId).orElse(null);
    return FormDescription.newFormDescription(UUID.fromString(this.identifierProvider.getIdentifier(viewExtensionDescription))).label(this.identifiedElementLabelProvider.getLabel(viewExtensionDescription)).idProvider(new GetOrCreateRandomIdProvider()).labelProvider(labelProvider).canCreatePredicate(variableManager -> false).targetObjectIdProvider(targetObjectIdProvider).pageDescriptions(pageDescriptions).groupDescriptions(groupDescriptions).build();
// @formatter:on
}
Also used : PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) IModelOperationHandlerSwitchProvider(org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) HashMap(java.util.HashMap) UUID(java.util.UUID) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) ViewExtensionDescription(org.eclipse.sirius.properties.ViewExtensionDescription) Objects(java.util.Objects) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) List(java.util.List) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider) IViewExtensionDescriptionConverter(org.eclipse.sirius.components.compatibility.services.forms.api.IViewExtensionDescriptionConverter) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISemanticCandidatesProviderFactory(org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IdentifiedElementLabelProvider(org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider) IIdentifierProvider(org.eclipse.sirius.components.compatibility.api.IIdentifierProvider) IAQLInterpreterFactory(org.eclipse.sirius.components.compatibility.api.IAQLInterpreterFactory) VariableManager(org.eclipse.sirius.components.representations.VariableManager) AQLInterpreter(org.eclipse.sirius.components.interpreter.AQLInterpreter) HashMap(java.util.HashMap) PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) GroupDescription(org.eclipse.sirius.components.forms.description.GroupDescription) List(java.util.List) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider)

Example 3 with ViewExtensionDescription

use of org.eclipse.sirius.properties.ViewExtensionDescription 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

ViewExtensionDescription (org.eclipse.sirius.properties.ViewExtensionDescription)3 List (java.util.List)2 UUID (java.util.UUID)2 Collectors (java.util.stream.Collectors)2 IIdentifierProvider (org.eclipse.sirius.components.compatibility.api.IIdentifierProvider)2 IModelOperationHandlerSwitchProvider (org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider)2 ISemanticCandidatesProviderFactory (org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory)2 IdentifiedElementLabelProvider (org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider)2 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)2 FormDescription (org.eclipse.sirius.components.forms.description.FormDescription)2 AQLInterpreter (org.eclipse.sirius.components.interpreter.AQLInterpreter)2 VariableManager (org.eclipse.sirius.components.representations.VariableManager)2 Category (org.eclipse.sirius.properties.Category)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 EcorePackage (org.eclipse.emf.ecore.EcorePackage)1