-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Description
In a detail view context, the type of self is a List of object.
public Optional<FormDescription> aggregate(List<FormDescription> formDescriptions, List<Object> objects, IObjectService objectService, IEditingContext editingContext) {
VariableManager pageVariableManager = new VariableManager();
pageVariableManager.put(VariableManager.SELF, objects);Whereas in EditingContextRepresentationDescriptionsEventHandler
private List<RepresentationDescriptionMetadata> findAllCompatibleRepresentationDescriptions(IEditingContext editingContext, Object object) {
List<RepresentationDescriptionMetadata> result = new ArrayList<>();
var kind = this.objectService.getKind(object);
var clazz = this.resolveKind(editingContext, kind);
if (clazz.isPresent()) {
var allRepresentationDescriptions = this.representationDescriptionSearchService.findAll(editingContext);
for (IRepresentationDescription description : allRepresentationDescriptions.values()) {
VariableManager variableManager = new VariableManager();
variableManager.put(VariableManager.SELF, object);
variableManager.put(IRepresentationDescription.CLASS, clazz.get());
Predicate<VariableManager> canCreatePredicate = description.getCanCreatePredicate();This cause issues when evaluating the PreconditionExpression since the same service can not be reused in both cases.
Moreover, it seems the Domain Type of the FormDescription is not used to filter the PageDescriptions available in the Detail View. If we want to reuse the org.eclipse.sirius.components.view.emf.form.ViewFormDescriptionConverter.canCreateForm(FormDescription, VariableManager, AQLInterpreter) method it seems that the implementation does not expected a list of element here.
private List<RepresentationDescriptionMetadata> findAllCompatibleRepresentationDescriptions(IEditingContext editingContext, Object object) {
List<RepresentationDescriptionMetadata> result = new ArrayList<>();
var kind = this.objectService.getKind(object);
var clazz = this.resolveKind(editingContext, kind);
if (clazz.isPresent()) {
var allRepresentationDescriptions = this.representationDescriptionSearchService.findAll(editingContext);
for (IRepresentationDescription description : allRepresentationDescriptions.values()) {
VariableManager variableManager = new VariableManager();
variableManager.put(VariableManager.SELF, object);
variableManager.put(IRepresentationDescription.CLASS, clazz.get());
Predicate<VariableManager> canCreatePredicate = description.getCanCreatePredicate();
boolean canCreate = canCreatePredicate.test(variableManager);
if (canCreate) {
Object targetObject = object;
this.representationDescriptionsProviders.forEach(provider -> {
if (provider.canHandle(description)) {
var descriptions = provider.handle(editingContext, targetObject, description);
result.addAll(descriptions);
}
});
}
}
}
return result;
}Reactions are currently unavailable