diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 1c90b0097b..184979b406 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -27,6 +27,7 @@ You have to add `tableWidgetDocumentTransform` to your extensionRegistry to use Given that it is an application service, it comes with some constraints with regard to transactions, for that a new reusable service named `IProjectEditingContextService` has now been added to manipulate the `projectId` and `editingContextId` instead. `IProjectEditingContextApplicationService` has thus been modified to be more focused on its original goal as the behavior of the `Project#currentEditingContext` datafetcher. +- https://github.com/eclipse-sirius/sirius-web/issues/4443[#4443] [table] `ICell` has a new method `getDescriptionId` that all implementors should provide. === Dependency update @@ -42,6 +43,7 @@ Given that it is an application service, it comes with some constraints with reg - https://github.com/eclipse-sirius/sirius-web/issues/4257[#4257] [diagram] Prevent the width of list parent nodes from increasing on each layout. - https://github.com/eclipse-sirius/sirius-web/issues/4534[#4534] [table] Fix an issue that prevent row action to be trigger on row in the next paginated data - https://github.com/eclipse-sirius/sirius-web/issues/4535[#4535] [table] Prevent page size from being reset after global search has been cleared +- https://github.com/eclipse-sirius/sirius-web/issues/4443[#4443] [table] Add missing edit handler for table cells in view === New Features diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableCellControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableCellControllerIntegrationTests.java index 10de69cb27..11491cd2d8 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableCellControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaTableCellControllerIntegrationTests.java @@ -56,8 +56,6 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "sirius.web.test.enabled=studio" }) public class PapayaTableCellControllerIntegrationTests extends AbstractIntegrationTests { - private static final String MISSING_TABLE = "Missing table"; - @Autowired private IGivenInitialServerState givenInitialServerState; diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewCellControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewCellControllerIntegrationTests.java new file mode 100644 index 0000000000..5a44768319 --- /dev/null +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewCellControllerIntegrationTests.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.web.application.controllers.tables; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; + +import com.jayway.jsonpath.JsonPath; + +import java.time.Duration; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; + +import org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput; +import org.eclipse.sirius.components.collaborative.tables.TableRefreshedEventPayload; +import org.eclipse.sirius.components.collaborative.tables.dto.EditTextfieldCellInput; +import org.eclipse.sirius.components.core.api.SuccessPayload; +import org.eclipse.sirius.components.tables.Table; +import org.eclipse.sirius.components.tables.TextfieldCell; +import org.eclipse.sirius.components.tables.tests.graphql.EditTextfieldCellMutationRunner; +import org.eclipse.sirius.web.AbstractIntegrationTests; +import org.eclipse.sirius.web.data.PapayaIdentifiers; +import org.eclipse.sirius.web.services.tables.ViewTableDescriptionProvider; +import org.eclipse.sirius.web.tests.data.GivenSiriusWebServer; +import org.eclipse.sirius.web.tests.services.api.IGivenCreatedDiagramSubscription; +import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +import reactor.core.publisher.Flux; +import reactor.test.StepVerifier; + +/** + * Integration tests of the view table cell description. + * + * @author Jerome Gout + */ +@Transactional +@SuppressWarnings("checkstyle:MultipleStringLiterals") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "sirius.web.test.enabled=studio" }) +public class PapayaViewCellControllerIntegrationTests extends AbstractIntegrationTests { + + @Autowired + private IGivenInitialServerState givenInitialServerState; + + @Autowired + private IGivenCreatedDiagramSubscription givenCreatedDiagramSubscription; + + @Autowired + private ViewTableDescriptionProvider viewTableDescriptionProvider; + + @Autowired + private EditTextfieldCellMutationRunner editTextfieldCellMutationRunner; + + @BeforeEach + public void beforeEach() { + this.givenInitialServerState.initialize(); + } + + private Flux givenSubscriptionToViewTableRepresentation() { + var input = new CreateRepresentationInput( + UUID.randomUUID(), + PapayaIdentifiers.PAPAYA_EDITING_CONTEXT_ID.toString(), + this.viewTableDescriptionProvider.getRepresentationDescriptionId(), + PapayaIdentifiers.SIRIUS_WEB_DOMAIN_PACKAGE.toString(), + "ViewTableDescription" + ); + return this.givenCreatedDiagramSubscription.createAndSubscribe(input); + } + + @Test + @GivenSiriusWebServer + @DisplayName("Given a table, when an cell edit mutation is triggered, then the representation is refreshed with the new cell value") + public void givenTableWhenCellEditMutationTriggeredThenTheRepresentationIsRefreshedWithNewCellValue() { + var flux = this.givenSubscriptionToViewTableRepresentation(); + + var cellId = new AtomicReference(); + var tableId = new AtomicReference(); + + Consumer initialTableContentConsumer = this.getTableSubscriptionConsumer(table -> { + tableId.set(table.getId()); + assertThat(table).isNotNull(); + assertThat(table.getLines()).hasSize(2); + assertThat(table.getLines().get(0).getCells()).hasSize(2); + assertThat(table.getLines().get(0).getCells().get(0)).isInstanceOf(TextfieldCell.class); + assertThat(((TextfieldCell) table.getLines().get(0).getCells().get(0)).getValue()).isEqualTo("Success"); + cellId.set(table.getLines().get(0).getCells().get(0).getId()); + }); + + Runnable editName = () -> { + var input = new EditTextfieldCellInput(UUID.randomUUID(), PapayaIdentifiers.PAPAYA_EDITING_CONTEXT_ID.toString(), tableId.get(), tableId.get(), cellId.get(), "newName"); + var result = this.editTextfieldCellMutationRunner.run(input); + + String typename = JsonPath.read(result, "$.data.editTextfieldCell.__typename"); + assertThat(typename).isEqualTo(SuccessPayload.class.getSimpleName()); + }; + + Consumer updatedTableContentConsumer = this.getTableSubscriptionConsumer(table -> { + assertThat(table).isNotNull(); + assertThat(table.getLines()).hasSize(2); + assertThat(((TextfieldCell) table.getLines().get(0).getCells().get(0)).getValue()).isEqualTo("newName"); + }); + + StepVerifier.create(flux) + .consumeNextWith(initialTableContentConsumer) + .then(editName) + .consumeNextWith(updatedTableContentConsumer) + .thenCancel() + .verify(Duration.ofSeconds(10)); + } + + private Consumer getTableSubscriptionConsumer(Consumer tableConsumer) { + return payload -> Optional.of(payload) + .filter(TableRefreshedEventPayload.class::isInstance) + .map(TableRefreshedEventPayload.class::cast) + .map(TableRefreshedEventPayload::table) + .ifPresentOrElse(tableConsumer, () -> fail("Missing table")); + } + +} diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/tables/ViewTableDescriptionProvider.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/tables/ViewTableDescriptionProvider.java index cea8dd7108..3b5deb1745 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/tables/ViewTableDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/tables/ViewTableDescriptionProvider.java @@ -108,10 +108,16 @@ private TableDescription createTableDescription() { .contextMenuEntries(contextMenuEntry) .build(); + var setNameOperation = new ViewBuilders().newSetValue() + .featureName("name") + .valueExpression("aql:newValue"); + var nameCellDescription = new TableBuilders().newCellDescription() .preconditionExpression("aql:columnTargetObject.equals('Name')") .valueExpression("aql:self.name") - .cellWidgetDescription(new TableBuilders().newCellTextfieldWidgetDescription().build()) + .cellWidgetDescription(new TableBuilders().newCellTextfieldWidgetDescription() + .body(setNameOperation.build()) + .build()) .selectedTargetObjectExpression("aql:self.eContainer()") .build(); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/CheckboxCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/CheckboxCell.java index b55ac5c8fa..eb2b88e4ef 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/CheckboxCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/CheckboxCell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -30,6 +30,8 @@ public final class CheckboxCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -42,23 +44,14 @@ private CheckboxCell() { // Prevent instantiation } - public boolean isValue() { - return this.value; - } - - public static Builder newCheckboxCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.value); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -81,6 +74,20 @@ public UUID getColumnId() { return this.columnId; } + public boolean isValue() { + return this.value; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.value); + } + + public static Builder newCheckboxCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -91,6 +98,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -103,6 +112,11 @@ private Builder(UUID id) { this.id = Objects.requireNonNull(id); } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public Builder targetObjectId(String targetObjectId) { this.targetObjectId = Objects.requireNonNull(targetObjectId); return this; @@ -126,6 +140,7 @@ public Builder value(boolean value) { public CheckboxCell build() { CheckboxCell cell = new CheckboxCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ICell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ICell.java index 35a7fe3dd5..7f1d99d5b9 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ICell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/ICell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,6 +24,8 @@ public interface ICell { UUID getId(); + String getDescriptionId(); + String getType(); String getTargetObjectId(); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/IconLabelCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/IconLabelCell.java index ad1e40a299..0a790826dd 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/IconLabelCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/IconLabelCell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 CEA LIST. + * Copyright (c) 2024, 2025 CEA LIST. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -31,6 +31,8 @@ public final class IconLabelCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -45,27 +47,14 @@ private IconLabelCell() { // Prevent instantiation } - public String getValue() { - return this.value; - } - - public List getIconURLs() { - return this.iconURLs; - } - - public static Builder newIconLabelCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -88,6 +77,24 @@ public UUID getColumnId() { return this.columnId; } + public String getValue() { + return this.value; + } + + public List getIconURLs() { + return this.iconURLs; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + } + + public static Builder newIconLabelCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -98,6 +105,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -112,6 +121,11 @@ private Builder(UUID id) { this.id = Objects.requireNonNull(id); } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public Builder targetObjectId(String targetObjectId) { this.targetObjectId = Objects.requireNonNull(targetObjectId); return this; @@ -140,6 +154,7 @@ public Builder iconURLs(List iconURLs) { public IconLabelCell build() { IconLabelCell cell = new IconLabelCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/MultiSelectCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/MultiSelectCell.java index 72d73d09ea..928e2f80ad 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/MultiSelectCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/MultiSelectCell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -31,6 +31,8 @@ public final class MultiSelectCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -45,27 +47,14 @@ private MultiSelectCell() { // Prevent instantiation } - public List getOptions() { - return this.options; - } - - public List getValues() { - return this.values; - } - - public static Builder newMultiSelectCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, values: {3}', options: {4}}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.values, this.options); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -88,6 +77,24 @@ public UUID getColumnId() { return this.columnId; } + public List getOptions() { + return this.options; + } + + public List getValues() { + return this.values; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, values: {3}', options: {4}}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.values, this.options); + } + + public static Builder newMultiSelectCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -98,6 +105,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -112,6 +121,11 @@ private Builder(UUID id) { this.id = Objects.requireNonNull(id); } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public Builder targetObjectId(String targetObjectId) { this.targetObjectId = Objects.requireNonNull(targetObjectId); return this; @@ -133,18 +147,19 @@ public Builder options(List options) { } public Builder values(List values) { - this.values = values; + this.values = Objects.requireNonNull(values); return this; } public MultiSelectCell build() { MultiSelectCell cell = new MultiSelectCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); cell.options = Objects.requireNonNull(this.options); - cell.values = this.values; + cell.values = Objects.requireNonNull(this.values); return cell; } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/SelectCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/SelectCell.java index cbaf2a71a9..889e3ff4a2 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/SelectCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/SelectCell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -31,6 +31,8 @@ public final class SelectCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -45,27 +47,14 @@ private SelectCell() { // Prevent instantiation } - public List getOptions() { - return this.options; - } - - public String getValue() { - return this.value; - } - - public static Builder newSelectCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}', options: {4}}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.value, this.options); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -88,6 +77,24 @@ public UUID getColumnId() { return this.columnId; } + public List getOptions() { + return this.options; + } + + public String getValue() { + return this.value; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}', options: {4}}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.columnId, this.value, this.options); + } + + public static Builder newSelectCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -98,6 +105,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -112,6 +121,11 @@ private Builder(UUID id) { this.id = Objects.requireNonNull(id); } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public Builder targetObjectId(String targetObjectId) { this.targetObjectId = Objects.requireNonNull(targetObjectId); return this; @@ -133,13 +147,14 @@ public Builder options(List options) { } public Builder value(String value) { - this.value = value; + this.value = Objects.requireNonNull(value); return this; } public SelectCell build() { SelectCell cell = new SelectCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java index 6516dfc54a..36dc8aceed 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java @@ -30,6 +30,8 @@ public final class TextareaCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -42,23 +44,14 @@ private TextareaCell() { // Prevent instantiation } - public String getValue() { - return this.value; - } - - public static Builder newTextareaCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -81,6 +74,20 @@ public UUID getColumnId() { return this.columnId; } + public String getValue() { + return this.value; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + } + + public static Builder newTextareaCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -91,6 +98,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -103,6 +112,11 @@ private Builder(UUID id) { this.id = Objects.requireNonNull(id); } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public Builder targetObjectId(String targetObjectId) { this.targetObjectId = Objects.requireNonNull(targetObjectId); return this; @@ -126,6 +140,7 @@ public Builder value(String value) { public TextareaCell build() { TextareaCell cell = new TextareaCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextfieldCell.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextfieldCell.java index 02742fa5a9..dd5f5cbc98 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextfieldCell.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextfieldCell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -30,6 +30,8 @@ public final class TextfieldCell implements ICell { private UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -42,23 +44,14 @@ private TextfieldCell() { // Prevent instantiation } - public String getValue() { - return this.value; - } - - public static Builder newTextfieldCell(UUID id) { - return new Builder(id); - } - @Override - public String toString() { - String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + public UUID getId() { + return this.id; } @Override - public UUID getId() { - return this.id; + public String getDescriptionId() { + return this.descriptionId; } @Override @@ -81,6 +74,20 @@ public UUID getColumnId() { return this.columnId; } + public String getValue() { + return this.value; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}, columnId: {2}, value: {3}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.columnId, this.value); + } + + public static Builder newTextfieldCell(UUID id) { + return new Builder(id); + } + /** * The builder used to create a cell. * @@ -91,6 +98,8 @@ public static final class Builder { private final UUID id; + private String descriptionId; + private String targetObjectId; private String targetObjectKind; @@ -123,9 +132,15 @@ public Builder value(String value) { return this; } + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + public TextfieldCell build() { TextfieldCell cell = new TextfieldCell(); cell.id = Objects.requireNonNull(this.id); + cell.descriptionId = Objects.requireNonNull(this.descriptionId); cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); cell.columnId = Objects.requireNonNull(this.columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/CheckboxCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/CheckboxCellComponent.java index 27969b0f49..4cfd7e8f2c 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/CheckboxCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/CheckboxCellComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ public Element render() { String targetObjectKind = cellDescription.getTargetObjectKindProvider().apply(variableManager); Boolean value = cellDescription.getCellValueProvider().apply(variableManager, this.props.columnTargetObject()); - CheckboxCellElementProps cellElementProps = new CheckboxCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), value); + CheckboxCellElementProps cellElementProps = new CheckboxCellElementProps(this.props.cellId(), this.props.checkboxCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), value); return new Element(CheckboxCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/IconLabelCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/IconLabelCellComponent.java index 4e42177e21..9462b62505 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/IconLabelCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/IconLabelCellComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 CEA LIST. + * Copyright (c) 2024, 2025 CEA LIST. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -45,7 +45,7 @@ public Element render() { String value = cellDescription.getCellValueProvider().apply(variableManager, this.props.columnTargetObject()); List iconURLs = cellDescription.getCellIconURLsProvider().apply(variableManager, this.props.columnTargetObject()); - IconLabelCellElementProps cellElementProps = new IconLabelCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), value, iconURLs); + IconLabelCellElementProps cellElementProps = new IconLabelCellElementProps(this.props.cellId(), this.props.iconLabelCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), value, iconURLs); return new Element(IconLabelCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/MultiSelectCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/MultiSelectCellComponent.java index 332a81a581..d68debb8c5 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/MultiSelectCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/MultiSelectCellComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -65,7 +65,7 @@ public Element render() { options.add(option); } - MultiSelectCellElementProps cellElementProps = new MultiSelectCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), options, values); + MultiSelectCellElementProps cellElementProps = new MultiSelectCellElementProps(this.props.cellId(), this.props.multiSelectCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), options, values); return new Element(MultiSelectCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/SelectCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/SelectCellComponent.java index 6b07cb4932..bcda44ec12 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/SelectCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/SelectCellComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -64,7 +64,7 @@ public Element render() { options.add(option); } - SelectCellElementProps cellElementProps = new SelectCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), options, value); + SelectCellElementProps cellElementProps = new SelectCellElementProps(this.props.cellId(), this.props.selectCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), options, value); return new Element(SelectCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java index 6eb7bb98ff..8ff374de11 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java @@ -43,7 +43,7 @@ public Element render() { String value = cellDescription.getCellValueProvider().apply(variableManager, this.props.columnTargetObject()); - TextareaCellElementProps cellElementProps = new TextareaCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), value); + TextareaCellElementProps cellElementProps = new TextareaCellElementProps(this.props.cellId(), this.props.textareaCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), value); return new Element(TextareaCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextfieldCellComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextfieldCellComponent.java index 6f7acd41fa..e8e5c6055b 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextfieldCellComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextfieldCellComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -43,7 +43,7 @@ public Element render() { String value = cellDescription.getCellValueProvider().apply(variableManager, this.props.columnTargetObject()); - TextfieldCellElementProps cellElementProps = new TextfieldCellElementProps(this.props.cellId(), targetObjectId, targetObjectKind, this.props.columnId(), value); + TextfieldCellElementProps cellElementProps = new TextfieldCellElementProps(this.props.cellId(), this.props.textfieldCellDescription().getId(), targetObjectId, targetObjectKind, this.props.columnId(), value); return new Element(TextfieldCellElementProps.TYPE, cellElementProps); } } diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/CheckboxCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/CheckboxCellElementProps.java index 655b3c7df6..ccb2a96f9f 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/CheckboxCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/CheckboxCellElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -22,12 +22,13 @@ * * @author lfasani */ -public record CheckboxCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, boolean value) implements IProps { +public record CheckboxCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, boolean value) implements IProps { public static final String TYPE = "CheckboxCell"; public CheckboxCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/IconLabelCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/IconLabelCellElementProps.java index ff66b3cb56..aa424cc5ea 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/IconLabelCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/IconLabelCellElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 CEA LIST. + * Copyright (c) 2024, 2025 CEA LIST. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -23,12 +23,13 @@ * * @author frouene */ -public record IconLabelCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, String value, List iconURLs) implements IProps { +public record IconLabelCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, String value, List iconURLs) implements IProps { public static final String TYPE = "IconLabelCell"; public IconLabelCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/MultiSelectCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/MultiSelectCellElementProps.java index 450fb5480a..73e22722c9 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/MultiSelectCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/MultiSelectCellElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,12 +24,14 @@ * * @author lfasani */ -public record MultiSelectCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, List options, List values) implements IProps { +public record MultiSelectCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, List options, List values) + implements IProps { public static final String TYPE = "MultiSelectCell"; public MultiSelectCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/SelectCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/SelectCellElementProps.java index 27cc73f378..2c1942d8fe 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/SelectCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/SelectCellElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,12 +24,13 @@ * * @author lfasani */ -public record SelectCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, List options, String value) implements IProps { +public record SelectCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, List options, String value) implements IProps { public static final String TYPE = "SelectCell"; public SelectCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java index 20428cdd43..bfb3558886 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java @@ -22,12 +22,13 @@ * * @author Jerome Gout */ -public record TextareaCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, String value) implements IProps { +public record TextareaCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, String value) implements IProps { public static final String TYPE = "TextareaCell"; public TextareaCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextfieldCellElementProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextfieldCellElementProps.java index 4725793cc3..1a3028e26d 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextfieldCellElementProps.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextfieldCellElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -22,12 +22,13 @@ * * @author lfasani */ -public record TextfieldCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, String value) implements IProps { +public record TextfieldCellElementProps(UUID id, String descriptionId, String targetObjectId, String targetObjectKind, UUID columnId, String value) implements IProps { public static final String TYPE = "TextfieldCell"; public TextfieldCellElementProps { Objects.requireNonNull(id); + Objects.requireNonNull(descriptionId); Objects.requireNonNull(targetObjectId); Objects.requireNonNull(targetObjectKind); Objects.requireNonNull(columnId); diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableElementFactory.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableElementFactory.java index 0d08350709..7d9bb6de7a 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableElementFactory.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableElementFactory.java @@ -157,6 +157,7 @@ private ICell instantiateCell(IProps props) { ICell cell = null; if (props instanceof TextfieldCellElementProps textfieldCellElementProps) { cell = TextfieldCell.newTextfieldCell(textfieldCellElementProps.id()) + .descriptionId(textfieldCellElementProps.descriptionId()) .columnId(textfieldCellElementProps.columnId()) .targetObjectId(textfieldCellElementProps.targetObjectId()) .targetObjectKind(textfieldCellElementProps.targetObjectKind()) @@ -164,6 +165,7 @@ private ICell instantiateCell(IProps props) { .build(); } else if (props instanceof TextareaCellElementProps textareaCellElementProps) { cell = TextareaCell.newTextareaCell(textareaCellElementProps.id()) + .descriptionId(textareaCellElementProps.descriptionId()) .columnId(textareaCellElementProps.columnId()) .targetObjectId(textareaCellElementProps.targetObjectId()) .targetObjectKind(textareaCellElementProps.targetObjectKind()) @@ -171,6 +173,7 @@ private ICell instantiateCell(IProps props) { .build(); } else if (props instanceof CheckboxCellElementProps checkboxCellElementProps) { cell = CheckboxCell.newCheckboxCell(checkboxCellElementProps.id()) + .descriptionId(checkboxCellElementProps.descriptionId()) .columnId(checkboxCellElementProps.columnId()) .targetObjectId(checkboxCellElementProps.targetObjectId()) .targetObjectKind(checkboxCellElementProps.targetObjectKind()) @@ -178,6 +181,7 @@ private ICell instantiateCell(IProps props) { .build(); } else if (props instanceof SelectCellElementProps selectCellElementProps) { cell = SelectCell.newSelectCell(selectCellElementProps.id()) + .descriptionId(selectCellElementProps.descriptionId()) .columnId(selectCellElementProps.columnId()) .targetObjectId(selectCellElementProps.targetObjectId()) .targetObjectKind(selectCellElementProps.targetObjectKind()) @@ -186,6 +190,7 @@ private ICell instantiateCell(IProps props) { .build(); } else if (props instanceof MultiSelectCellElementProps multiSelectCellElementProps) { cell = MultiSelectCell.newMultiSelectCell(multiSelectCellElementProps.id()) + .descriptionId(multiSelectCellElementProps.descriptionId()) .columnId(multiSelectCellElementProps.columnId()) .targetObjectId(multiSelectCellElementProps.targetObjectId()) .targetObjectKind(multiSelectCellElementProps.targetObjectKind()) @@ -194,6 +199,7 @@ private ICell instantiateCell(IProps props) { .build(); } else if (props instanceof IconLabelCellElementProps iconLabelCellElementProps) { cell = IconLabelCell.newIconLabelCell(iconLabelCellElementProps.id()) + .descriptionId(iconLabelCellElementProps.descriptionId()) .columnId(iconLabelCellElementProps.columnId()) .targetObjectId(iconLabelCellElementProps.targetObjectId()) .targetObjectKind(iconLabelCellElementProps.targetObjectKind()) diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/configuration/ViewEMFMessageServiceConfiguration.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/configuration/ViewEMFMessageServiceConfiguration.java new file mode 100644 index 0000000000..28d450418d --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/configuration/ViewEMFMessageServiceConfiguration.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +package org.eclipse.sirius.components.view.emf.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.context.support.ResourceBundleMessageSource; + +/** + * Configuration of the internationalization. + * + * @author Jerome Gout + */ +@Configuration +public class ViewEMFMessageServiceConfiguration { + + private static final String PATH = "messages/sirius-web-view-emf"; + + @Bean + public MessageSourceAccessor viewEMFMessageSourceAccessor() { + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.addBasenames(PATH); + return new MessageSourceAccessor(messageSource); + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/IViewEMFMessageService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/IViewEMFMessageService.java new file mode 100644 index 0000000000..e574a4ccb9 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/IViewEMFMessageService.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +package org.eclipse.sirius.components.view.emf.messages; + +/** + * Used to compute internationalized messages. + * + * @author Jerome Gout + */ +public interface IViewEMFMessageService { + + String tableCellEditError(); + + String unsupportedTableCellWidgetError(); + + /** + * Implementation which does nothing, used for mocks in unit tests. + * + * @author Jerome Gout + */ + class NoOp implements IViewEMFMessageService { + + @Override + public String tableCellEditError() { + return ""; + } + + @Override + public String unsupportedTableCellWidgetError() { + return ""; + } + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/ViewEMFMessageService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/ViewEMFMessageService.java new file mode 100644 index 0000000000..4ca6c991af --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/messages/ViewEMFMessageService.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +package org.eclipse.sirius.components.view.emf.messages; + +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.stereotype.Service; + +/** + * Used to provide internationalized messages. + * + * @author Jerome Gout + */ +@Service +public class ViewEMFMessageService implements IViewEMFMessageService { + + private final MessageSourceAccessor messageSourceAccessor; + + public ViewEMFMessageService(@Qualifier("viewEMFMessageSourceAccessor") MessageSourceAccessor messageSourceAccessor) { + this.messageSourceAccessor = Objects.requireNonNull(messageSourceAccessor); + } + + @Override + public String tableCellEditError() { + return this.messageSourceAccessor.getMessage("TABLE_CELL_EDIT_ERROR"); + } + + @Override + public String unsupportedTableCellWidgetError() { + return this.messageSourceAccessor.getMessage("UNSUPPORTED_TABLE_CELL_WIDGET_ERROR"); + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellExecutor.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellExecutor.java new file mode 100644 index 0000000000..ea85f50733 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellExecutor.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +package org.eclipse.sirius.components.view.emf.table; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import org.eclipse.sirius.components.collaborative.api.ChangeKind; +import org.eclipse.sirius.components.core.api.IEditService; +import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.core.api.IFeedbackMessageService; +import org.eclipse.sirius.components.core.api.IObjectSearchService; +import org.eclipse.sirius.components.interpreter.AQLInterpreter; +import org.eclipse.sirius.components.representations.Failure; +import org.eclipse.sirius.components.representations.IStatus; +import org.eclipse.sirius.components.representations.Message; +import org.eclipse.sirius.components.representations.MessageLevel; +import org.eclipse.sirius.components.representations.Success; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.tables.Column; +import org.eclipse.sirius.components.tables.ICell; +import org.eclipse.sirius.components.tables.Line; +import org.eclipse.sirius.components.view.Operation; +import org.eclipse.sirius.components.view.View; +import org.eclipse.sirius.components.view.emf.OperationInterpreter; +import org.eclipse.sirius.components.view.emf.api.IViewAQLInterpreterFactory; +import org.eclipse.sirius.components.view.emf.messages.IViewEMFMessageService; +import org.eclipse.sirius.components.view.emf.table.api.IViewEditCellExecutor; +import org.eclipse.sirius.components.view.table.CellLabelWidgetDescription; +import org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription; +import org.eclipse.sirius.components.view.table.CellTextfieldWidgetDescription; +import org.eclipse.sirius.components.view.table.CellWidgetDescription; +import org.eclipse.sirius.components.view.table.TableDescription; +import org.springframework.stereotype.Service; + +/** + * Service that handles the execution part of edit operation in table cells. + * + * @author Jerome Gout + */ +@Service +public class ViewEditCellExecutor implements IViewEditCellExecutor { + + private final IFeedbackMessageService feedbackMessageService; + + private final IEditService editService; + + private final IObjectSearchService objectSearchService; + + private final IViewAQLInterpreterFactory aqlInterpreterFactory; + + private final ITableIdProvider tableIdProvider; + + private final IViewEMFMessageService viewEMFMessageService; + + public ViewEditCellExecutor(IFeedbackMessageService feedbackMessageService, IEditService editService, IObjectSearchService objectSearchService, IViewAQLInterpreterFactory aqlInterpreterFactory, + ITableIdProvider tableIdProvider, IViewEMFMessageService viewEMFMessageService) { + this.feedbackMessageService = Objects.requireNonNull(feedbackMessageService); + this.editService = Objects.requireNonNull(editService); + this.objectSearchService = Objects.requireNonNull(objectSearchService); + this.aqlInterpreterFactory = Objects.requireNonNull(aqlInterpreterFactory); + this.tableIdProvider = Objects.requireNonNull(tableIdProvider); + this.viewEMFMessageService = Objects.requireNonNull(viewEMFMessageService); + } + + @Override + public IStatus execute(IEditingContext editingContext, TableDescription viewTableDescription, ICell cell, Line row, Column column, Object newValue) { + if (viewTableDescription.eContainer() instanceof View view) { + AQLInterpreter interpreter = this.aqlInterpreterFactory.createInterpreter(editingContext, view); + + var optionalViewCellDescription = viewTableDescription.getCellDescriptions().stream() + .filter(cellDescription -> cell.getDescriptionId().equals(this.tableIdProvider.getId(cellDescription))) + .findFirst(); + + var optionalRowSemanticObject = this.objectSearchService.getObject(editingContext, row.getTargetObjectId()); + if (optionalViewCellDescription.isPresent() && optionalRowSemanticObject.isPresent()) { + var viewCellDescription = optionalViewCellDescription.get(); + var self = optionalRowSemanticObject.get(); + + VariableManager variableManager = new VariableManager(); + variableManager.put(IEditingContext.EDITING_CONTEXT, editingContext); + variableManager.put("cell", cell); + variableManager.put("row", row); + variableManager.put("column", column); + variableManager.put("newValue", newValue); + variableManager.put(VariableManager.SELF, self); + return this.executeCellWidgetDescription(variableManager, interpreter, viewCellDescription.getCellWidgetDescription()); + } + } + return this.buildFailureWithFeedbackMessages(this.viewEMFMessageService.tableCellEditError()); + } + + private IStatus executeCellWidgetDescription(VariableManager variableManager, AQLInterpreter interpreter, CellWidgetDescription cellWidgetDescription) { + IStatus status = this.buildFailureWithFeedbackMessages(this.viewEMFMessageService.unsupportedTableCellWidgetError()); + + if (cellWidgetDescription instanceof CellTextfieldWidgetDescription textfieldDescription) { + status = this.executeOperations(variableManager, interpreter, textfieldDescription.getBody()); + } else if (cellWidgetDescription instanceof CellTextareaWidgetDescription textareaWidgetDescription) { + status = this.executeOperations(variableManager, interpreter, textareaWidgetDescription.getBody()); + } else if (cellWidgetDescription instanceof CellLabelWidgetDescription) { + status = new Success(ChangeKind.SEMANTIC_CHANGE, Map.of(), this.feedbackMessageService.getFeedbackMessages()); + } + + return status; + } + + private IStatus executeOperations(VariableManager variableManager, AQLInterpreter interpreter, List operations) { + OperationInterpreter operationInterpreter = new OperationInterpreter(interpreter, this.editService); + Optional optionalVariableManager = operationInterpreter.executeOperations(operations, variableManager); + if (optionalVariableManager.isEmpty()) { + return this.buildFailureWithFeedbackMessages(this.viewEMFMessageService.tableCellEditError()); + } + return new Success(ChangeKind.SEMANTIC_CHANGE, Map.of(), this.feedbackMessageService.getFeedbackMessages()); + } + + private Failure buildFailureWithFeedbackMessages(String technicalMessage) { + List errorMessages = new ArrayList<>(); + errorMessages.add(new Message(technicalMessage, MessageLevel.ERROR)); + errorMessages.addAll(this.feedbackMessageService.getFeedbackMessages()); + return new Failure(errorMessages); + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellHandler.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellHandler.java new file mode 100644 index 0000000000..4dcf89ae64 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewEditCellHandler.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2025 CEA LIST. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +package org.eclipse.sirius.components.view.emf.table; + +import java.util.Objects; + +import org.eclipse.sirius.components.collaborative.tables.api.IEditCellHandler; +import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.representations.Failure; +import org.eclipse.sirius.components.representations.IStatus; +import org.eclipse.sirius.components.tables.Column; +import org.eclipse.sirius.components.tables.ICell; +import org.eclipse.sirius.components.tables.Line; +import org.eclipse.sirius.components.tables.descriptions.TableDescription; +import org.eclipse.sirius.components.view.emf.IViewRepresentationDescriptionSearchService; +import org.eclipse.sirius.components.view.emf.ViewRepresentationDescriptionPredicate; +import org.eclipse.sirius.components.view.emf.messages.IViewEMFMessageService; +import org.eclipse.sirius.components.view.emf.table.api.IViewEditCellExecutor; +import org.springframework.stereotype.Service; + +/** + * Edit cell generic handler for all tables defined using the view table DSL. + * + * @author Jerome Gout + */ +@Service +public class ViewEditCellHandler implements IEditCellHandler { + + private final ViewRepresentationDescriptionPredicate viewRepresentationDescriptionPredicate; + + private final IViewRepresentationDescriptionSearchService viewRepresentationDescriptionSearchService; + + private final IViewEditCellExecutor viewEditCellExecutor; + + private final IViewEMFMessageService viewEMFMessageService; + + public ViewEditCellHandler(ViewRepresentationDescriptionPredicate viewRepresentationDescriptionPredicate, IViewRepresentationDescriptionSearchService viewRepresentationDescriptionSearchService, IViewEditCellExecutor viewEditCellExecutor, IViewEMFMessageService viewEMFMessageService) { + this.viewRepresentationDescriptionPredicate = Objects.requireNonNull(viewRepresentationDescriptionPredicate); + this.viewRepresentationDescriptionSearchService = Objects.requireNonNull(viewRepresentationDescriptionSearchService); + this.viewEditCellExecutor = Objects.requireNonNull(viewEditCellExecutor); + this.viewEMFMessageService = Objects.requireNonNull(viewEMFMessageService); + } + + @Override + public boolean canHandle(TableDescription tableDescription) { + return this.viewRepresentationDescriptionPredicate.test(tableDescription); + } + + @Override + public IStatus handle(IEditingContext editingContext, TableDescription tableDescription, ICell cell, Line row, Column column, Object newValue) { + var optionalTableDescription = this.viewRepresentationDescriptionSearchService + .findById(editingContext, tableDescription.getId()) + .filter(org.eclipse.sirius.components.view.table.TableDescription.class::isInstance) + .map(org.eclipse.sirius.components.view.table.TableDescription.class::cast); + if (optionalTableDescription.isPresent()) { + return this.viewEditCellExecutor.execute(editingContext, optionalTableDescription.get(), cell, row, column, newValue); + } + return new Failure(this.viewEMFMessageService.tableCellEditError()); + } + +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/api/IViewEditCellExecutor.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/api/IViewEditCellExecutor.java new file mode 100644 index 0000000000..6cb849486f --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/api/IViewEditCellExecutor.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2025 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.view.emf.table.api; + +import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.representations.IStatus; +import org.eclipse.sirius.components.tables.Column; +import org.eclipse.sirius.components.tables.ICell; +import org.eclipse.sirius.components.tables.Line; +import org.eclipse.sirius.components.view.table.TableDescription; + +/** + * Service that handles the execution part of edit operation in table cells. + * + * @author Jerome Gout + */ +public interface IViewEditCellExecutor { + IStatus execute(IEditingContext editingContext, TableDescription viewTableDescription, ICell cell, Line row, Column column, Object newValue); +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/resources/messages/sirius-web-view-emf.properties b/packages/view/backend/sirius-components-view-emf/src/main/resources/messages/sirius-web-view-emf.properties new file mode 100644 index 0000000000..38c0e2fd0c --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/resources/messages/sirius-web-view-emf.properties @@ -0,0 +1,15 @@ +################################################################################ +# Copyright (c) 2025 CEA LIST. +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Obeo - initial API and implementation +################################################################################# + +TABLE_CELL_EDIT_ERROR=Something went wrong while handling the cell edit operations +UNSUPPORTED_TABLE_CELL_WIDGET_ERROR=Not supported cell widget