use of org.eclipse.sirius.components.forms.renderer.FormRenderer 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;
}
use of org.eclipse.sirius.components.forms.renderer.FormRenderer 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);
}
Aggregations