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
Add support for dynamic widgets in Forms #2287
Conversation
d8fb207
to
36fe920
Compare
ab8a71b
to
ecf0053
Compare
ecf0053
to
69cd73c
Compare
|
||
VariableManager idVariableManager = variableManager.createChild(); | ||
idVariableManager.put(FormComponent.TARGET_OBJECT_ID, buttonDescription.getTargetObjectIdProvider().apply(variableManager)); | ||
idVariableManager.put(FormComponent.TARGET_OBJECT_ID, buttonDescription.getTargetObjectIdProvider().apply(variableManager)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
/** | ||
* The name of the variable used to store the id of widget's description in the {@link VariableManager} for a widget | ||
* to compute its own id. | ||
*/ | ||
public static final String CONTROL_DESCRIPTION_ID = "controlDescriptionId"; | ||
|
||
/** | ||
* The name of the variable used to store the id of widget's description in the {@link VariableManager} for a widget | ||
* to compute its own id. | ||
*/ | ||
public static final String TARGET_OBJECT_ID = "targetObjectId"; | ||
|
||
/** | ||
* The name of the variable used to store the id of widget's description in the {@link VariableManager} for a widget | ||
* to compute its own id. | ||
*/ | ||
public static final String WIDGET_LABEL = "widgetLabel"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same comment for the three variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
List<Element> children = candidates.stream().map(candidate -> { | ||
VariableManager childVariableManager = variableManager.createChild(); | ||
childVariableManager.put(VariableManager.SELF, candidate); | ||
childVariableManager.put(FormComponent.PARENT_ELEMENT_ID, id); | ||
return childVariableManager; | ||
}).flatMap(childVariableManager -> pageDescriptions.stream().filter(pageDescription -> pageDescription.getCanCreatePredicate().test(childVariableManager)).map(pageDescription -> { | ||
PageComponentProps pageComponentProps = new PageComponentProps(childVariableManager, pageDescription, this.props.getWidgetDescriptors()); | ||
return new Element(PageComponent.class, pageComponentProps); | ||
})).toList(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation doesn't seem right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
private Function<VariableManager, Boolean> predicate; | ||
|
||
private AbstractWidgetDescription widgetDescription; | ||
private List<AbstractControlDescription> childrenDescription; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ForDescription, it's named controlDescriptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
.../main/java/org/eclipse/sirius/components/view/emf/diagram/NodeStylePropertiesConfigurer.java
Show resolved
Hide resolved
@@ -0,0 +1,214 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2021, 2023 Obeo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New file, should be only 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,201 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2021, 2023 Obeo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New file, should be only 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/adrs/107_dynamic_widgets.adoc
Outdated
|
||
In this first version, we will only support the same case as in EEF desktop, namely widgets inside a _Group_. | ||
All these four elements (For, If, Groups, Flexbox) behave as containers for an arbitrary number sub-elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
doc/adrs/107_dynamic_widgets.adoc
Outdated
|
||
* `iterationExpression`: an AQL expression to be evaluated when rendering the form, which should return a collection of (arbitrary) elements; | ||
* `iterator`: a (fixed) variable name. | ||
|
||
It will also _contain_ an arbitrary number if _DynamicIf_, which has a `predicateExpression` attribute and a `control: ControlDescription[1]` containment reference. | ||
The semantics of the element is that it's children element will be rendered once for every element in the collection returned by `iterationExpression`, in order. | ||
For each value _V_ returned by `iterationExpression`, all the children are rendered in a context where _V_ is bound to a variable named as specified buy _iterator_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buy -> by
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
CHANGELOG.adoc
Outdated
Existing FormDescription documents will need to be modified to load correctly, and any custom widget's metamodel will need to be regenerated using the new `form.ecore` version as reference. | ||
See [ADR-107] _Add support for dynamic and conditional widgets in Forms_ for the details of the changes. | ||
Also, all widget descriptions now have a `Function<VariableManager, String> targetObjectIdProvider`, needed to compute the widget instance's id. | ||
The new `targetObjectIdProvider` is required to be non-null, so any code which programatically builds core Form Descriptions (not View-based ones), needs to pass a non-null provider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
programatically -> programmatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
69cd73c
to
010ab5f
Compare
010ab5f
to
4509a47
Compare
Bug: #2236 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
4509a47
to
e9b3d3d
Compare
No description provided.