Skip to content

Commit d9344d7

Browse files
committed
[5715] Add hasChildrenExpression to RowDescription in table
Bug: #5715 Signed-off-by: Florian ROUËNÉ <[email protected]>
1 parent 678114e commit d9344d7

File tree

34 files changed

+355
-46
lines changed

34 files changed

+355
-46
lines changed

CHANGELOG.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The code responsible for the import has been refactor with:
3232
* `ProjectImporter` no longer exist. Its code has been split among `IProjectContentImportParticipant`.
3333

3434

35+
- https://github.com/eclipse-sirius/sirius-web/issues/5715[#5715] [table] In table, `RowDescription` must now declare a `hasChildrenExpression` if `subRows` is enabled.
3536

3637
=== Dependency update
3738

@@ -59,7 +60,7 @@ Use `org.eclipse.emf.ecore.util.ECrossReferenceAdapter.getCrossReferenceAdapter(
5960
=== Improvements
6061

6162
- https://github.com/eclipse-sirius/sirius-web/issues/5608[#5608] [diagram] Hide empty sections on the palette
62-
63+
- https://github.com/eclipse-sirius/sirius-web/issues/5715[#5715] [table] Add `hasChildrenExpression` to `RowDescription` to block the expand action on rows that have no children
6364

6465

6566
== 2025.10.0

packages/formdescriptioneditors/backend/sirius-components-collaborative-formdescriptioneditors-widget-table/src/main/java/org/eclipse/sirius/components/formdescriptioneditors/widget/table/TableWidgetPreviewConverterProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private TableWidgetDescription getTableWidgetDescription(org.eclipse.sirius.comp
5959
.isResizablePredicate(vm -> false)
6060
.initialHeightProvider(vm -> -1)
6161
.depthLevelProvider(vm -> 0)
62+
.hasChildrenProvider(vm -> false)
6263
.build();
6364
var tableDescription = TableDescription.newTableDescription(UUID.randomUUID().toString())
6465
.label("")

packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public List<IRepresentationDescription> getRepresentationDescriptions(IEditingCo
107107
.isResizablePredicate(variableManager -> true)
108108
.initialHeightProvider(variableManager -> 53)
109109
.depthLevelProvider(this::getSemanticElementDepthLevel)
110+
.hasChildrenProvider(this::hasChildren)
110111
.build();
111112

112113
var tableDescription = TableDescription.newTableDescription(TABLE_DESCRIPTION_ID)
@@ -203,6 +204,18 @@ private boolean hasExpandedParent(EObject eObject, List<String> expandedIds) {
203204
return true;
204205
}
205206

207+
private boolean hasChildren(VariableManager variableManager) {
208+
return variableManager.get(VariableManager.SELF, EObject.class)
209+
.map(eObject -> {
210+
if (eObject instanceof Package) {
211+
return false;
212+
} else {
213+
return !eObject.eContents().isEmpty();
214+
}
215+
})
216+
.orElse(false);
217+
}
218+
206219
private Integer getSemanticElementDepthLevel(VariableManager variableManager) {
207220
return variableManager.get(VariableManager.SELF, EObject.class)
208221
.map(this::getEObjectDepthLevel)

packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/ProjectTableRepresentationDescriptionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public List<IRepresentationDescription> getRepresentationDescriptions(IEditingCo
7979
.isResizablePredicate(variableManager -> false)
8080
.initialHeightProvider(variableManager -> -1)
8181
.depthLevelProvider(variableManager -> 0)
82+
.hasChildrenProvider(variableManager -> false)
8283
.build();
8384

8485
var tableDescription = TableDescription.newTableDescription(TABLE_DESCRIPTION_ID)

packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewTableControllerIntegrationTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,30 @@ public void givenViewTableWithSubElementsWhenSubscriptionIsCreatedThenTheDepthLe
254254
.verify(Duration.ofSeconds(10));
255255
}
256256

257+
@Test
258+
@GivenSiriusWebServer
259+
@DisplayName("Given a view table description with sub elements, when a subscription is created, then hasChildren is correctly set")
260+
public void givenViewTableWithSubElementsWhenSubscriptionIsCreatedThenHasChildrenIsCorrectlySet() {
261+
var flux = this.givenSubscriptionToViewTableRepresentation();
262+
263+
Consumer<Object> tableContentConsumer = assertRefreshedTableThat(table -> {
264+
assertThat(table).isNotNull();
265+
assertThat(table.isEnableSubRows()).isTrue();
266+
assertThat(table.getLines()).hasSize(6);
267+
assertThat(table.getLines().get(0).isHasChildren()).isTrue();
268+
assertThat(table.getLines().get(1).isHasChildren()).isFalse();
269+
assertThat(table.getLines().get(2).isHasChildren()).isFalse();
270+
assertThat(table.getLines().get(3).isHasChildren()).isTrue();
271+
assertThat(table.getLines().get(4).isHasChildren()).isTrue();
272+
assertThat(table.getLines().get(5).isHasChildren()).isTrue();
273+
});
274+
275+
StepVerifier.create(flux)
276+
.consumeNextWith(tableContentConsumer)
277+
.thenCancel()
278+
.verify(Duration.ofSeconds(10));
279+
}
280+
257281
@Test
258282
@GivenSiriusWebServer
259283
@DisplayName("Given a view table description with Failure element, when hide-failure row filter is activated, then the failure row is not in table")

packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/forms/FormWithTableDescriptionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private TableWidgetDescription getTableWidgetDescription() {
146146
.isResizablePredicate(variableManager -> false)
147147
.initialHeightProvider(variableManager -> 0)
148148
.depthLevelProvider(variableManager -> 0)
149+
.hasChildrenProvider(variableManager -> false)
149150
.build();
150151

151152
TableDescription tableDescription = TableDescription.newTableDescription(FORM_WITH_TABLE_ID)

packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/tables/ViewTableDescriptionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private TableDescription createTableDescription() {
114114
.contextMenuEntries(contextMenuEntry)
115115
.depthLevelExpression(
116116
"aql:if self.oclIsKindOf(papaya::Type) then 0 else if self.oclIsKindOf(papaya::Operation) then 1 else if self.oclIsKindOf(papaya::Parameter) then 2 else endif endif endif")
117+
.hasChildrenExpression("aql:self.eContents()->filter({papaya::Type | papaya::Operation | papaya::Parameter})->size() == 0")
117118
.build();
118119

119120
var setNameOperation = new ViewBuilders().newSetValue()

packages/sirius-web/frontend/sirius-web-application/src/extension/TableWidgetDocumentTransform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const tableWidgetDocumentTransform = new DocumentTransform((document) =>
135135
fieldBuilder('height'),
136136
fieldBuilder('isResizable'),
137137
fieldBuilder('depthLevel'),
138+
fieldBuilder('hasChildren'),
138139
structuredFieldBuilder('cells', [
139140
fieldBuilder('id'),
140141
fieldBuilder('targetObjectId'),

packages/tables/backend/sirius-components-collaborative-tables/src/main/resources/schema/table.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type Line {
9393
height: Int!
9494
isResizable: Boolean!
9595
depthLevel: Int!
96+
hasChildren: Boolean!
9697
}
9798

9899
type PaginationData {

packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/Line.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ public final class Line {
4949

5050
private int depthLevel;
5151

52+
private boolean hasChildren;
53+
5254
private Line() {
5355
// Prevent instantiation
5456
}
5557

58+
public static Builder newLine(UUID id) {
59+
return new Builder(id);
60+
}
61+
5662
public UUID getId() {
5763
return this.id;
5864
}
@@ -97,8 +103,8 @@ public int getDepthLevel() {
97103
return this.depthLevel;
98104
}
99105

100-
public static Builder newLine(UUID id) {
101-
return new Builder(id);
106+
public boolean isHasChildren() {
107+
return this.hasChildren;
102108
}
103109

104110
@Override
@@ -137,6 +143,8 @@ public static final class Builder {
137143

138144
private int depthLevel;
139145

146+
private boolean hasChildren;
147+
140148
private Builder(UUID id) {
141149
this.id = Objects.requireNonNull(id);
142150
}
@@ -191,6 +199,11 @@ public Builder depthLevel(int depthLevel) {
191199
return this;
192200
}
193201

202+
public Builder hasChildren(boolean hasChildren) {
203+
this.hasChildren = hasChildren;
204+
return this;
205+
}
206+
194207
public Line build() {
195208
Line line = new Line();
196209
line.id = Objects.requireNonNull(this.id);
@@ -204,6 +217,7 @@ public Line build() {
204217
line.height = this.height;
205218
line.resizable = this.resizable;
206219
line.depthLevel = this.depthLevel;
220+
line.hasChildren = this.hasChildren;
207221
return line;
208222
}
209223
}

0 commit comments

Comments
 (0)