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;
}
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
}
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);
}
Aggregations