Search in sources :

Example 1 with FormComponentProps

use of org.eclipse.sirius.components.forms.components.FormComponentProps in project sirius-components by eclipse-sirius.

the class FormEventProcessor method refreshForm.

private Form refreshForm() {
    VariableManager variableManager = new VariableManager();
    variableManager.put(VariableManager.SELF, this.formCreationParameters.getObjects());
    variableManager.put(GetOrCreateRandomIdProvider.PREVIOUS_REPRESENTATION_ID, this.formCreationParameters.getId());
    variableManager.put(IEditingContext.EDITING_CONTEXT, this.formCreationParameters.getEditingContext());
    FormComponentProps formComponentProps = new FormComponentProps(variableManager, this.formCreationParameters.getFormDescription());
    Element element = new Element(FormComponent.class, formComponentProps);
    Form form = new FormRenderer().render(element);
    // $NON-NLS-1$
    this.logger.trace("Form refreshed: {}", form.getId());
    return form;
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Form(org.eclipse.sirius.components.forms.Form) Element(org.eclipse.sirius.components.representations.Element) FormRenderer(org.eclipse.sirius.components.forms.renderer.FormRenderer) FormComponentProps(org.eclipse.sirius.components.forms.components.FormComponentProps)

Example 2 with FormComponentProps

use of org.eclipse.sirius.components.forms.components.FormComponentProps in project sirius-components by eclipse-sirius.

the class FormRendererTests method checkResult.

private void checkResult(FormDescription description) {
    // test SiriusViewExtensionDescriptionConverter
    assertThat(description).isNotNull();
    assertThat(description.getGroupDescriptions()).hasSize(1);
    assertThat(description.getPageDescriptions()).hasSize(1);
    assertThat(description.getPageDescriptions().get(0).getGroupDescriptions()).hasSize(1);
    assertThat(description.getPageDescriptions()).hasSize(1);
    assertThat(description.getPageDescriptions().get(0).getGroupDescriptions().get(0)).isEqualTo(description.getGroupDescriptions().get(0));
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream())).hasSize(6);
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(CheckboxDescription.class::isInstance)).hasSize(1);
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(RadioDescription.class::isInstance)).hasSize(1);
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(SelectDescription.class::isInstance)).hasSize(1);
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(TextfieldDescription.class::isInstance)).hasSize(1);
    assertThat(description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(TextfieldDescription.class::isInstance)).hasSize(1);
    Optional<ForDescription> forOptional = description.getGroupDescriptions().stream().flatMap(g -> g.getControlDescriptions().stream()).filter(ForDescription.class::isInstance).map(ForDescription.class::cast).findFirst();
    assertThat(forOptional).isNotEmpty();
    assertThat(forOptional.get().getIfDescriptions()).hasSize(1);
    assertThat(forOptional.get().getIfDescriptions().stream().findFirst().get().getWidgetDescription()).isNotNull();
    // Test FormRenderer
    VariableManager variableManager = new VariableManager();
    variableManager.put(VariableManager.SELF, List.of(EcorePackage.eINSTANCE));
    FormRenderer formRenderer = new FormRenderer();
    FormComponentProps props = new FormComponentProps(variableManager, description);
    Element element = new Element(FormComponent.class, props);
    Form form = formRenderer.render(element);
    assertThat(form.getPages()).hasSize(1);
    assertThat(form.getPages().stream().flatMap(p -> p.getGroups().stream())).hasSize(1);
    assertThat(form.getPages().stream().flatMap(p -> p.getGroups().stream()).flatMap(g -> g.getWidgets().stream())).hasSize(5);
    List<Group> groups = form.getPages().stream().flatMap(p -> p.getGroups().stream()).collect(Collectors.toList());
    this.checkIdsInGroups(groups);
}
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) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Group(org.eclipse.sirius.components.forms.Group) RadioDescription(org.eclipse.sirius.components.forms.description.RadioDescription) Form(org.eclipse.sirius.components.forms.Form) Element(org.eclipse.sirius.components.representations.Element) FormRenderer(org.eclipse.sirius.components.forms.renderer.FormRenderer) SelectDescription(org.eclipse.sirius.components.forms.description.SelectDescription) TextfieldDescription(org.eclipse.sirius.components.forms.description.TextfieldDescription) FormComponentProps(org.eclipse.sirius.components.forms.components.FormComponentProps) ForDescription(org.eclipse.sirius.components.forms.description.ForDescription)

Aggregations

Form (org.eclipse.sirius.components.forms.Form)2 FormComponentProps (org.eclipse.sirius.components.forms.components.FormComponentProps)2 FormRenderer (org.eclipse.sirius.components.forms.renderer.FormRenderer)2 Element (org.eclipse.sirius.components.representations.Element)2 VariableManager (org.eclipse.sirius.components.representations.VariableManager)2 List (java.util.List)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 EcorePackage (org.eclipse.emf.ecore.EcorePackage)1 IIdentifierProvider (org.eclipse.sirius.components.compatibility.api.IIdentifierProvider)1 IModelOperationHandlerSwitchProvider (org.eclipse.sirius.components.compatibility.api.IModelOperationHandlerSwitchProvider)1 ISemanticCandidatesProviderFactory (org.eclipse.sirius.components.compatibility.api.ISemanticCandidatesProviderFactory)1 ViewExtensionDescriptionConverter (org.eclipse.sirius.components.compatibility.forms.ViewExtensionDescriptionConverter)1 IdentifiedElementLabelProvider (org.eclipse.sirius.components.compatibility.services.representations.IdentifiedElementLabelProvider)1 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)1 IRepresentationMetadataSearchService (org.eclipse.sirius.components.core.api.IRepresentationMetadataSearchService)1 AQLInterpreterFactory (org.eclipse.sirius.components.emf.compatibility.AQLInterpreterFactory)1 SemanticCandidatesProvider (org.eclipse.sirius.components.emf.compatibility.SemanticCandidatesProvider)1