Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type of SELF is not consistent when used in Details View or in Form Description representation #2032

Closed
adaussy opened this issue Jun 6, 2023 · 3 comments · Fixed by #2043

Comments

@adaussy
Copy link
Contributor

adaussy commented Jun 6, 2023

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;
    }
@sbegaudeau
Copy link
Member

  • Add domainType on PageDescription in the view DSL
  • Filter on each instance instead of the whole collection self in the FormDescriptionAggregator
  • In IPropertiesDescriptionRegistry, we should have a method void add(PageDescription pageDescription);
  • We should provide a variable named selection in the FormDescriptionAggregator and the PropertiesEventProcessorFactory for the form description of the details view using multiple selection

@adaussy
Copy link
Contributor Author

adaussy commented Jun 6, 2023

@sbegaudeau I think the org.eclipse.sirius.components.collaborative.forms.FormEventProcessor.refreshForm() should also be modified. SELF is the first object in this.formCreationParameters.getObjects() and selection is the entire collection this.formCreationParameters.getObjects() right?

frouene added a commit to frouene/sirius-components that referenced this issue Jun 7, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 7, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 7, 2023
…escriptionRegistry

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 7, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
@sbegaudeau
Copy link
Member

  • We can't set the value of selection automatically like that since only some usage of FormEventProcessor would use formCreationParameters.getObjects() as selection. It has does not match the reality for instances of FormEventProcessor created from FormEventProcessorFactory.
  • The FormComponent performs the iteration on the list of objects so I don't think that it's necessary change the value of self here

frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
…uated

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
…escriptionRegistry

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
@sbegaudeau sbegaudeau added this to the 2023.8.0 milestone Jun 8, 2023
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
…uated

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
…escriptionRegistry

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 8, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 16, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 16, 2023
…uated

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 16, 2023
…escriptionRegistry

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
frouene added a commit to frouene/sirius-components that referenced this issue Jun 16, 2023
Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
sbegaudeau pushed a commit to frouene/sirius-components that referenced this issue Jun 19, 2023
… view

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
sbegaudeau pushed a commit to frouene/sirius-components that referenced this issue Jun 19, 2023
… view

Bug: eclipse-sirius#2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
sbegaudeau pushed a commit that referenced this issue Jun 19, 2023
… view

Bug: #2032
Signed-off-by: Florian Rouëné <florian.rouene@obeosoft.com>
pcdavid added a commit that referenced this issue Jun 29, 2023
Since #2032, `self` is a single element, not a list.

Bug: #2133
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
AxelRICHARD pushed a commit that referenced this issue Jun 30, 2023
Since #2032, `self` is a single element, not a list.

Bug: #2133
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
AxelRICHARD pushed a commit that referenced this issue Jun 30, 2023
Since #2032, `self` is a single element, not a list.

Bug: #2133
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
AxelRICHARD pushed a commit that referenced this issue Jun 30, 2023
Since #2032, `self` is a single element, not a list.

Bug: #2133
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment