Skip to content

Commit

Permalink
[4556] Add the support of row hierarchy in tables
Browse files Browse the repository at this point in the history
Bug: #4556
Signed-off-by: Jerome Gout <[email protected]>
  • Loading branch information
jerome-obeo committed Feb 13, 2025
1 parent 55a45d5 commit 1761c0c
Show file tree
Hide file tree
Showing 38 changed files with 606 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ To achieve that a new concept, `ProjectSemanticData` has been added along with a
- https://github.com/eclipse-sirius/sirius-web/issues/4514[#4514] [sirius-web] Added support for Ctrl+Shift+Z (Linux/macOS) to trigger redo in addition to Ctrl+Y (Windows)
- https://github.com/eclipse-sirius/sirius-web/issues/4372[#4372] [sirius-web] Lower the coupling between project and editing context

- https://github.com/eclipse-sirius/sirius-web/issues/4556[#4556] [table] Add the support of row hierarchy in tables

== v2025.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import org.eclipse.sirius.components.core.api.ILabelService;
import org.eclipse.sirius.components.emf.tables.CursorBasedNavigationServices;
import org.eclipse.sirius.components.papaya.AnnotableElement;
import org.eclipse.sirius.components.papaya.Operation;
import org.eclipse.sirius.components.papaya.PapayaFactory;
import org.eclipse.sirius.components.papaya.PapayaPackage;
import org.eclipse.sirius.components.papaya.Parameter;
import org.eclipse.sirius.components.papaya.Type;
import org.eclipse.sirius.components.papaya.spec.PackageSpec;
import org.eclipse.sirius.components.representations.IRepresentationDescription;
Expand Down Expand Up @@ -101,6 +103,7 @@ public List<IRepresentationDescription> getRepresentationDescriptions(IEditingCo
.headerIndexLabelProvider(headerIndexLabelProvider)
.isResizablePredicate(variableManager -> true)
.initialHeightProvider(variableManager -> 53)
.depthLevelProvider(this::getSemanticElementDepthLevel)
.build();

var tableDescription = TableDescription.newTableDescription(TABLE_DESCRIPTION_ID)
Expand Down Expand Up @@ -135,9 +138,10 @@ private PaginatedData getSemanticElements(VariableManager variableManager) {
List<ColumnFilter> columnFilters = variableManager.get(TableRenderer.COLUMN_FILTERS, List.class).orElse(List.of());

Predicate<EObject> predicate = eObject -> {
boolean isValidCandidate = eObject instanceof Type && EcoreUtil.isAncestor(self, eObject);
if (isValidCandidate) {
var type = (Type) eObject;
boolean isValidCandidate = (eObject instanceof Type && EcoreUtil.isAncestor(self, eObject)) ||
eObject instanceof Operation ||
eObject instanceof Parameter;
if (isValidCandidate && eObject instanceof Type type) {
if (globalFilter != null && !globalFilter.isBlank()) {
isValidCandidate = type.getName() != null && type.getName().contains(globalFilter);
isValidCandidate = isValidCandidate || type.getDescription() != null && type.getDescription().contains(globalFilter);
Expand All @@ -152,6 +156,17 @@ private PaginatedData getSemanticElements(VariableManager variableManager) {
return new CursorBasedNavigationServices().collect(self, cursor, direction, size, predicate);
}

private Integer getSemanticElementDepthLevel(VariableManager variableManager) {
int result = 0;
var self = variableManager.get(VariableManager.SELF, EObject.class).orElse(null);
if (self instanceof Operation) {
result = 1;
} else if (self instanceof Parameter) {
result = 2;
}
return result;
}

private List<ColumnDescription> getColumnDescriptions() {
var provider = new StructuralFeatureToDisplayNameProvider(new DisplayNameProvider(this.composedAdapterFactory));
Map<EStructuralFeature, String> featureToDisplayName = provider.getColumnsStructuralFeaturesDisplayName(PapayaFactory.eINSTANCE.createClass(), PapayaPackage.eINSTANCE.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public List<IRepresentationDescription> getRepresentationDescriptions(IEditingCo
.headerIndexLabelProvider(variableManager -> "")
.isResizablePredicate(variableManager -> false)
.initialHeightProvider(variableManager -> -1)
.depthLevelProvider(variableManager -> 0)
.build();

var tableDescription = TableDescription.newTableDescription(TABLE_DESCRIPTION_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public TableDescription getTableDescription() {
.headerIndexLabelProvider(variableManager -> "")
.isResizablePredicate(variableManager -> false)
.initialHeightProvider(variableManager -> 0)
.depthLevelProvider(variableManager -> 0)
.build();

var nameColumnDescription = ColumnDescription.newColumnDescription("name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,25 @@ INSERT INTO document (
"id": "b0f27d20-4705-40a7-9d28-67d605b5e9d1",
"eClass": "papaya:Class",
"data": {
"name": "Failure"
"name": "Failure",
"operations": [
{
"eClass": "papaya:Operation",
"id": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"data": {
"name": "fooOperation",
"parameters": [
{
"eClass": "papaya:Parameter",
"id": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"data": {
"name": "fooParameter"
}
}
]
}
}
]
}
}
]
Expand Down Expand Up @@ -471,6 +489,134 @@ INSERT INTO public.representation_content (
"initialHeight": 53,
"height":100,
"resizable": true
},
{
"cells": [
{
"columnId": "d0fd98f3-dfae-3a2d-9cbe-f9a1d6ebee56",
"id": "4bf6dc01-4da7-330e-a7f6-18c9789408d7",
"targetObjectId": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Operation",
"type": "TEXTFIELD",
"value": "barOperation"
},
{
"columnId": "b6e82202-fe33-3b19-bf2c-5c9648cb96ce",
"id": "8b566c5e-6877-3f35-91dc-dd27f3ead414",
"targetObjectId": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Operation",
"type": "TEXTAREA",
"value": ""
},
{
"columnId": "eabb569d-f99e-3e6e-86a6-db600b1fa526",
"id": "c4dafa63-2bf8-3e8c-bdc0-fe8f93f70ca2",
"options": [
{
"id": "PUBLIC",
"label": "PUBLIC"
},
{
"id": "PROTECTED",
"label": "PROTECTED"
},
{
"id": "PACKAGE",
"label": "PACKAGE"
},
{
"id": "PRIVATE",
"label": "PRIVATE"
}
],
"targetObjectId": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Operation",
"type": "SELECT",
"value": ""
},
{
"columnId": "94277463-12c8-34bc-b69b-99bb5bfb0fc4",
"id": "580e07af-51cd-39f3-bffd-272ad274dcbd",
"options": [
],
"targetObjectId": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Operation",
"type": "MULTI_SELECT",
"values": [
]
}
],
"id": "40ffe0b3-3fb4-35f1-b2bd-3634679398ad",
"targetObjectId": "6f531172-8314-4145-8b36-d8fa45bf3b20",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Operation",
"descriptionId": "6c9154c7-a924-3bd1-b5e4-28aff1d4e5c8",
"depthLevel": 1,
"initialHeight": 53,
"height": 53,
"resizable": true
},
{
"id": "7127b7a2-50b0-3b39-8fcd-ad2910856e0a",
"targetObjectId": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Parameter",
"cells": [
{
"columnId": "d0fd98f3-dfae-3a2d-9cbe-f9a1d6ebee56",
"id": "40c134b9-3969-398e-85fc-573ae8b18c05",
"targetObjectId": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Parameter",
"type": "TEXTFIELD",
"value": "fooParameter"
},
{
"columnId": "b6e82202-fe33-3b19-bf2c-5c9648cb96ce",
"id": "f672ab49-a2d8-38d8-9600-60f736642cff",
"targetObjectId": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Parameter",
"type": "TEXTAREA",
"value": ""
},
{
"columnId": "eabb569d-f99e-3e6e-86a6-db600b1fa526",
"id": "5404877a-fe46-3e00-ad3d-1dfe476a714f",
"options": [
{
"id": "PUBLIC",
"label": "PUBLIC"
},
{
"id": "PROTECTED",
"label": "PROTECTED"
},
{
"id": "PACKAGE",
"label": "PACKAGE"
},
{
"id": "PRIVATE",
"label": "PRIVATE"
}
],
"targetObjectId": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Parameter",
"type": "SELECT",
"value": ""
},
{
"columnId": "94277463-12c8-34bc-b69b-99bb5bfb0fc4",
"id": "7b212e76-3220-3235-9f25-df8724633bfc",
"options": [],
"targetObjectId": "69ead9da-9302-45a7-86d8-c4ad54056e39",
"targetObjectKind": "siriusComponents://semantic?domain=papaya&entity=Parameter",
"type": "MULTI_SELECT",
"values": []
}
],
"depthLevel": 2,
"descriptionId": "6c9154c7-a924-3bd1-b5e4-28aff1d4e5c8",
"headerLabel": "fooParameter",
"height": 53,
"resizable": true
}
],
"columns": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void givenTableWhenEditTextareaMutationTriggeredThenTheRepresentationIsRe

Consumer<Object> initialTableContentConsumer = this.getTableSubscriptionConsumer(table -> {
assertThat(table).isNotNull();
assertThat(table.getLines()).hasSize(2);
assertThat(table.getLines()).hasSize(4);
assertThat(table.getLines().get(0).getCells()).hasSize(6);
assertThat(table.getLines().get(0).getCells().get(1)).isInstanceOf(TextareaCell.class);
assertThat(table.getLines().get(0).getCells().get(1)).isInstanceOf(TextareaCell.class);
Expand All @@ -120,7 +120,7 @@ public void givenTableWhenEditTextareaMutationTriggeredThenTheRepresentationIsRe

Consumer<Object> updatedTableContentConsumer = this.getTableSubscriptionConsumer(table -> {
assertThat(table).isNotNull();
assertThat(table.getLines()).hasSize(2);
assertThat(table.getLines()).hasSize(4);
assertThat(table.getLines().get(0).getCells()).hasSize(6);
assertThat(table.getLines().get(0).getCells().get(1)).isInstanceOf(TextareaCell.class);
assertThat(((TextareaCell) table.getLines().get(0).getCells().get(1)).getValue()).isEqualTo("new description");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
*/
@Transactional
@SuppressWarnings("checkstyle:MultipleStringLiterals")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"sirius.web.test.enabled=studio"})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "sirius.web.test.enabled=studio" })
public class PapayaTableControllerIntegrationTests extends AbstractIntegrationTests {

private static final String MISSING_TABLE = "Missing table";
Expand Down Expand Up @@ -122,7 +122,7 @@ public void givenTableRepresentationWhenWeSubscribeToItsEventThenTheRepresentati
.ifPresentOrElse(table -> {
assertThat(table).isNotNull();
assertThat(table.getColumns()).hasSize(6);
assertThat(table.getLines()).hasSize(2);
assertThat(table.getLines()).hasSize(4);
}, () -> fail(MISSING_TABLE));

StepVerifier.create(flux)
Expand All @@ -146,7 +146,7 @@ public void givenTableWhenRefreshTriggeredThenTableIsRefreshed() {
.ifPresentOrElse(table -> {
assertThat(table).isNotNull();
assertThat(table.getColumns()).hasSize(6);
assertThat(table.getLines()).hasSize(2);
assertThat(table.getLines()).hasSize(4);

tableId.set(table.getId());
}, () -> fail("Missing table"));
Expand Down
Loading

0 comments on commit 1761c0c

Please sign in to comment.