From a82573d50ec83eb92585a3b5b536aba12e9b7107 Mon Sep 17 00:00:00 2001 From: Jerome Gout Date: Fri, 17 Jan 2025 12:01:14 +0100 Subject: [PATCH] [4425] Add new table cell widget description for textarea Bug: https://github.com/eclipse-sirius/sirius-web/issues/4425 Signed-off-by: Jerome Gout --- CHANGELOG.adoc | 2 +- .../table/CellTypePredicate.java | 11 +- ...ableRepresentationDescriptionProvider.java | 10 +- ...ableRepresentationDescriptionProvider.java | 9 +- ...yaViewTableControllerIntegrationTests.java | 8 +- .../FormWithTableDescriptionProvider.java | 9 +- .../tables/ViewTableDescriptionProvider.java | 18 +- .../tables/dto/EditTextareaCellInput.java | 30 +++ .../ChangeGlobalFilterValueEventHandler.java | 3 +- .../tables/handlers/EditCellEventHandler.java | 4 + .../src/main/resources/schema/table.graphqls | 20 ++ .../MutationEditTextareaCellDataFetcher.java | 58 ++++++ .../components/tables/TextareaCell.java | 136 +++++++++++++ .../tables/components/LineComponent.java | 4 + .../components/TextareaCellComponent.java | 49 +++++ .../TextareaCellComponentProps.java | 36 ++++ .../descriptions/TextareaCellDescription.java | 136 +++++++++++++ .../elements/TextareaCellElementProps.java | 36 ++++ .../TableComponentPropsValidator.java | 4 + .../tables/renderer/TableElementFactory.java | 18 +- .../renderer/TableInstancePropsValidator.java | 5 +- .../src/actions/ExportAllDataButton.tsx | 14 +- .../src/cells/Cell.tsx | 17 +- .../src/cells/TextareaCell.tsx | 75 +++++++ .../src/cells/TextareaCell.types.ts | 26 +++ .../src/cells/useEditTextareaCell.tsx | 74 +++++++ .../src/cells/useEditTextareaCell.types.ts | 37 ++++ .../representation/useTableSubscription.ts | 5 +- .../src/table/TableContent.types.ts | 6 +- .../CellTextareaWidgetDescriptionBuilder.java | 59 ++++++ .../generated/table/TableBuilders.java | 12 +- .../table/ViewTableDescriptionConverter.java | 22 ++- .../provider/CellDescriptionItemProvider.java | 5 +- ...TextareaWidgetDescriptionItemProvider.java | 183 ++++++++++++++++++ .../TableItemProviderAdapterFactory.java | 28 ++- .../obj16/CellTextareaWidgetDescription.svg | 2 + .../src/main/resources/plugin.properties | 4 +- .../table/CellTextareaWidgetDescription.java | 45 +++++ .../components/view/table/TableFactory.java | 11 +- .../components/view/table/TablePackage.java | 81 +++++++- .../CellTextareaWidgetDescriptionImpl.java | 158 +++++++++++++++ .../view/table/impl/TableFactoryImpl.java | 18 +- .../view/table/impl/TablePackageImpl.java | 40 +++- .../view/table/util/TableAdapterFactory.java | 22 ++- .../view/table/util/TableSwitch.java | 27 ++- .../src/main/resources/model/table.ecore | 4 + .../src/main/resources/model/table.genmodel | 5 +- 47 files changed, 1546 insertions(+), 40 deletions(-) create mode 100644 packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/dto/EditTextareaCellInput.java create mode 100644 packages/tables/backend/sirius-components-tables-graphql/src/main/java/org/eclipse/sirius/components/tables/graphql/datafetchers/mutation/MutationEditTextareaCellDataFetcher.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponentProps.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/descriptions/TextareaCellDescription.java create mode 100644 packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java create mode 100644 packages/tables/frontend/sirius-components-tables/src/cells/TextareaCell.tsx create mode 100644 packages/tables/frontend/sirius-components-tables/src/cells/TextareaCell.types.ts create mode 100644 packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.tsx create mode 100644 packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.types.ts create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/CellTextareaWidgetDescriptionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellTextareaWidgetDescriptionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-table-edit/src/main/resources/icons/full/obj16/CellTextareaWidgetDescription.svg create mode 100644 packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/CellTextareaWidgetDescription.java create mode 100644 packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/CellTextareaWidgetDescriptionImpl.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 942307aa87..a153ff4d6d 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -78,7 +78,7 @@ It can be activated using `sirius.web.graphql.tracing=true` since it is not enab Some additional log has also been contributed on the frontend in order to view more easily the order and time of the GraphQL requests and responses. - https://github.com/eclipse-sirius/sirius-web/issues/4430[#4430] [diagram] Add the PNG export of a diagram. - https://github.com/eclipse-sirius/sirius-web/issues/4346[#4346] [query] The current selection is now available using both the variables `selection: Sequence{Object}` for the full selection and `self: Object` for the first selected object. - +- https://github.com/eclipse-sirius/sirius-web/issues/4425[#4425] [table] Add new table cell widget description for textarea === Improvements diff --git a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/CellTypePredicate.java b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/CellTypePredicate.java index 2040ca0741..591b788da6 100644 --- a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/CellTypePredicate.java +++ b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/CellTypePredicate.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 @@ -28,6 +28,7 @@ import org.eclipse.sirius.components.tables.elements.IconLabelCellElementProps; import org.eclipse.sirius.components.tables.elements.MultiSelectCellElementProps; import org.eclipse.sirius.components.tables.elements.SelectCellElementProps; +import org.eclipse.sirius.components.tables.elements.TextareaCellElementProps; import org.eclipse.sirius.components.tables.elements.TextfieldCellElementProps; /** @@ -59,6 +60,10 @@ private String getCellType(VariableManager variableManager) { type = SelectCellElementProps.TYPE; } } + // description column should be multiline + if ("description".equals(eStructuralFeature.getName())) { + type = TextareaCellElementProps.TYPE; + } if (type.isEmpty()) { type = TextfieldCellElementProps.TYPE; } @@ -70,6 +75,10 @@ public Predicate isTextfieldCell() { return (variableManager) -> this.getCellType(variableManager).equals(TextfieldCellElementProps.TYPE); } + public Predicate isTextareaCell() { + return (variableManager) -> this.getCellType(variableManager).equals(TextareaCellElementProps.TYPE); + } + public Predicate isCheckboxCell() { return (variableManager) -> this.getCellType(variableManager).equals(CheckboxCellElementProps.TYPE); } diff --git a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java index 06ae925fd5..4ba7567542 100644 --- a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/PackageTableRepresentationDescriptionProvider.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 @@ -44,6 +44,7 @@ import org.eclipse.sirius.components.tables.descriptions.PaginatedData; import org.eclipse.sirius.components.tables.descriptions.SelectCellDescription; import org.eclipse.sirius.components.tables.descriptions.TableDescription; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; import org.eclipse.sirius.components.tables.descriptions.TextfieldCellDescription; import org.eclipse.sirius.components.tables.renderer.TableRenderer; import org.springframework.stereotype.Service; @@ -202,6 +203,13 @@ private List getCellDescriptions() { .cellValueProvider(new CellStringValueProvider(this.identityService)) .build()); + cellDescriptions.add(TextareaCellDescription.newTextareaCellDescription("textareaCells") + .canCreatePredicate(new CellTypePredicate().isTextareaCell()) + .targetObjectIdProvider(new TableTargetObjectIdProvider(this.identityService)) + .targetObjectKindProvider(new TableTargetObjectKindProvider(this.identityService)) + .cellValueProvider(new CellStringValueProvider(this.identityService)) + .build()); + cellDescriptions.add(SelectCellDescription.newSelectCellDescription("selectCells") .canCreatePredicate(new CellTypePredicate().isSelectCell()) .targetObjectIdProvider(new TableTargetObjectIdProvider(this.identityService)) diff --git a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/ProjectTableRepresentationDescriptionProvider.java b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/ProjectTableRepresentationDescriptionProvider.java index 50b98ab221..42207c1839 100644 --- a/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/ProjectTableRepresentationDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web-papaya/src/main/java/org/eclipse/sirius/web/papaya/representations/table/ProjectTableRepresentationDescriptionProvider.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 @@ -39,6 +39,7 @@ import org.eclipse.sirius.components.tables.descriptions.PaginatedData; import org.eclipse.sirius.components.tables.descriptions.SelectCellDescription; import org.eclipse.sirius.components.tables.descriptions.TableDescription; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; import org.eclipse.sirius.components.tables.descriptions.TextfieldCellDescription; import org.eclipse.sirius.components.tables.renderer.TableRenderer; import org.springframework.stereotype.Service; @@ -202,6 +203,12 @@ private List getCellDescriptions() { .targetObjectKindProvider(new TableTargetObjectKindProvider(this.identityService)) .cellValueProvider(new CellStringValueProvider(this.identityService)) .build()); + cellDescriptions.add(TextareaCellDescription.newTextareaCellDescription("textareaCells") + .canCreatePredicate(new CellTypePredicate().isTextareaCell()) + .targetObjectIdProvider(new TableTargetObjectIdProvider(this.identityService)) + .targetObjectKindProvider(new TableTargetObjectKindProvider(this.identityService)) + .cellValueProvider(new CellStringValueProvider(this.identityService)) + .build()); cellDescriptions.add(CheckboxCellDescription.newCheckboxCellDescription("checkboxCells") .canCreatePredicate(new CellTypePredicate().isCheckboxCell()) .targetObjectIdProvider(new TableTargetObjectIdProvider(this.identityService)) diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewTableControllerIntegrationTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewTableControllerIntegrationTests.java index 9660fe330c..b936e72bf8 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewTableControllerIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/tables/PapayaViewTableControllerIntegrationTests.java @@ -22,6 +22,7 @@ import org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput; import org.eclipse.sirius.components.collaborative.tables.TableRefreshedEventPayload; +import org.eclipse.sirius.components.tables.TextareaCell; import org.eclipse.sirius.components.tables.TextfieldCell; import org.eclipse.sirius.web.AbstractIntegrationTests; import org.eclipse.sirius.web.data.PapayaIdentifiers; @@ -46,7 +47,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 PapayaViewTableControllerIntegrationTests extends AbstractIntegrationTests { @Autowired @@ -87,12 +88,15 @@ public void givenSimpleViewTableDescriptionWhenSubscriptionIsCreatedThenTableIsR .map(TableRefreshedEventPayload::table) .ifPresentOrElse(table -> { assertThat(table).isNotNull(); - assertThat(table.getColumns()).hasSize(1); + assertThat(table.getColumns()).hasSize(2); assertThat(table.getColumns().get(0).getHeaderLabel()).isEqualTo("Name"); assertThat(table.getColumns().get(0).getHeaderIndexLabel()).isEqualTo("0"); + assertThat(table.getColumns().get(1).getHeaderLabel()).isEqualTo("Description"); + assertThat(table.getColumns().get(1).getHeaderIndexLabel()).isEqualTo("1"); assertThat(table.getLines()).hasSize(2); assertThat(table.getLines().get(0).getHeaderIndexLabel()).isEqualTo("0"); assertThat(table.getLines().get(0).getCells().get(0)).isInstanceOf(TextfieldCell.class); + assertThat(table.getLines().get(0).getCells().get(1)).isInstanceOf(TextareaCell.class); assertThat(((TextfieldCell) table.getLines().get(0).getCells().get(0)).getValue()).isEqualTo("Success"); assertThat(table.getLines().get(1).getHeaderIndexLabel()).isEqualTo("1"); assertThat(table.getLines().get(1).getCells().get(0)).isInstanceOf(TextfieldCell.class); diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/forms/FormWithTableDescriptionProvider.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/forms/FormWithTableDescriptionProvider.java index a7e2fd4b00..b0fcda9c1e 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/forms/FormWithTableDescriptionProvider.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/services/forms/FormWithTableDescriptionProvider.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 @@ -61,6 +61,7 @@ import org.eclipse.sirius.components.tables.descriptions.PaginatedData; import org.eclipse.sirius.components.tables.descriptions.SelectCellDescription; import org.eclipse.sirius.components.tables.descriptions.TableDescription; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; import org.eclipse.sirius.components.tables.descriptions.TextfieldCellDescription; import org.eclipse.sirius.web.papaya.representations.table.CellTypePredicate; import org.eclipse.sirius.web.papaya.representations.table.ColumnTargetObjectIdProvider; @@ -175,6 +176,12 @@ private List getCellDescriptions() { .targetObjectKindProvider(variableManager -> "") .cellValueProvider(this.getCellStringValueProvider()) .build()); + cellDescriptions.add(TextareaCellDescription.newTextareaCellDescription("textareaCells") + .canCreatePredicate(new CellTypePredicate().isTextareaCell()) + .targetObjectIdProvider(variableManager -> "") + .targetObjectKindProvider(variableManager -> "") + .cellValueProvider(this.getCellStringValueProvider()) + .build()); cellDescriptions.add(CheckboxCellDescription.newCheckboxCellDescription("checkboxCells") .canCreatePredicate(new CellTypePredicate().isCheckboxCell()) .targetObjectIdProvider(vm -> "") 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 b7aea7cf0d..a48d50ddc2 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 @@ -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 @@ -83,8 +83,8 @@ private View createView() { private TableDescription createTableDescription() { var columnDescription = new TableBuilders().newColumnDescription() - .semanticCandidatesExpression("aql:'Name'") - .headerLabelExpression("Name") + .semanticCandidatesExpression("aql:Sequence{'Name', 'Description'}") + .headerLabelExpression("aql:self") .headerIndexLabelExpression("aql:columnIndex") .build(); @@ -93,18 +93,24 @@ private TableDescription createTableDescription() { .headerIndexLabelExpression("aql:rowIndex") .build(); - var cellDescription = new TableBuilders().newCellDescription() - .preconditionExpression("aql:true") + var nameCellDescription = new TableBuilders().newCellDescription() + .preconditionExpression("aql:columnTargetObject.equals('Name')") .valueExpression("aql:self.name") .cellWidgetDescription(new TableBuilders().newCellTextfieldWidgetDescription().build()) .build(); + var descriptionCellDescription = new TableBuilders().newCellDescription() + .preconditionExpression("aql:columnTargetObject.equals('Description')") + .valueExpression("aql:self.description") + .cellWidgetDescription(new TableBuilders().newCellTextareaWidgetDescription().build()) + .build(); + this.tableDescription = new TableBuilders().newTableDescription() .domainType("papaya::Package") .titleExpression("View Package Table") .columnDescriptions(columnDescription) .rowDescription(rowDescription) - .cellDescriptions(cellDescription) + .cellDescriptions(nameCellDescription, descriptionCellDescription) .useStripedRowsExpression("aql:false") .build(); diff --git a/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/dto/EditTextareaCellInput.java b/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/dto/EditTextareaCellInput.java new file mode 100644 index 0000000000..666852ec52 --- /dev/null +++ b/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/dto/EditTextareaCellInput.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.collaborative.tables.dto; + +import java.util.UUID; + +/** + * The input object for the Textarea-based cell edition mutation. + * + * @author Jerome Gout + */ +public record EditTextareaCellInput( + UUID id, + String editingContextId, + String representationId, + String tableId, + UUID cellId, + String newValue) implements IEditCellInput { + +} diff --git a/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/handlers/ChangeGlobalFilterValueEventHandler.java b/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/handlers/ChangeGlobalFilterValueEventHandler.java index 1dcbf442dd..bf4d3d4146 100644 --- a/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/handlers/ChangeGlobalFilterValueEventHandler.java +++ b/packages/tables/backend/sirius-components-collaborative-tables/src/main/java/org/eclipse/sirius/components/collaborative/tables/handlers/ChangeGlobalFilterValueEventHandler.java @@ -22,7 +22,6 @@ import org.eclipse.sirius.components.collaborative.tables.api.ITableEventHandler; import org.eclipse.sirius.components.collaborative.tables.api.ITableInput; import org.eclipse.sirius.components.collaborative.tables.dto.ChangeGlobalFilterValueInput; -import org.eclipse.sirius.components.collaborative.tables.dto.EditTextfieldCellInput; import org.eclipse.sirius.components.collaborative.tables.messages.ICollaborativeTableMessageService; import org.eclipse.sirius.components.core.api.ErrorPayload; import org.eclipse.sirius.components.core.api.IEditingContext; @@ -64,7 +63,7 @@ public void handle(Sinks.One payloadSink, Sinks.Many> { + + private static final String INPUT_ARGUMENT = "input"; + + private final ObjectMapper objectMapper; + + private final IExceptionWrapper exceptionWrapper; + + private final IEditingContextDispatcher editingContextDispatcher; + + public MutationEditTextareaCellDataFetcher(ObjectMapper objectMapper, IExceptionWrapper exceptionWrapper, IEditingContextDispatcher editingContextDispatcher) { + this.objectMapper = Objects.requireNonNull(objectMapper); + this.exceptionWrapper = Objects.requireNonNull(exceptionWrapper); + this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher); + } + + @Override + public CompletableFuture get(DataFetchingEnvironment environment) throws Exception { + Object argument = environment.getArgument(INPUT_ARGUMENT); + var input = this.objectMapper.convertValue(argument, EditTextareaCellInput.class); + + return this.exceptionWrapper.wrapMono(() -> this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input), input).toFuture(); + } +} 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 new file mode 100644 index 0000000000..6516dfc54a --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/TextareaCell.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * 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.tables; + +import java.text.MessageFormat; +import java.util.Objects; +import java.util.UUID; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * Textarea-based Cell concept of the table representation. + * + * @author Jerome Gout + */ +@Immutable +public final class TextareaCell implements ICell { + + public static final String TYPE = "TEXTAREA"; + + private UUID id; + + private String targetObjectId; + + private String targetObjectKind; + + private UUID columnId; + + private String value; + + 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); + } + + @Override + public UUID getId() { + return this.id; + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public String getTargetObjectId() { + return this.targetObjectId; + } + + @Override + public String getTargetObjectKind() { + return this.targetObjectKind; + } + + @Override + public UUID getColumnId() { + return this.columnId; + } + + /** + * The builder used to create a cell. + * + * @author arichard + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private final UUID id; + + private String targetObjectId; + + private String targetObjectKind; + + private UUID columnId; + + private String value; + + private Builder(UUID id) { + this.id = Objects.requireNonNull(id); + } + + public Builder targetObjectId(String targetObjectId) { + this.targetObjectId = Objects.requireNonNull(targetObjectId); + return this; + } + + public Builder targetObjectKind(String targetObjectKind) { + this.targetObjectKind = Objects.requireNonNull(targetObjectKind); + return this; + } + + public Builder columnId(UUID columnId) { + this.columnId = Objects.requireNonNull(columnId); + return this; + } + + public Builder value(String value) { + this.value = Objects.requireNonNull(value); + return this; + } + + public TextareaCell build() { + TextareaCell cell = new TextareaCell(); + cell.id = Objects.requireNonNull(this.id); + cell.targetObjectId = Objects.requireNonNull(this.targetObjectId); + cell.targetObjectKind = Objects.requireNonNull(this.targetObjectKind); + cell.columnId = Objects.requireNonNull(this.columnId); + cell.value = Objects.requireNonNull(this.value); + return cell; + } + } +} diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/LineComponent.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/LineComponent.java index d678a0163a..c50f1c95a4 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/LineComponent.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/LineComponent.java @@ -32,6 +32,7 @@ import org.eclipse.sirius.components.tables.descriptions.LineDescription; import org.eclipse.sirius.components.tables.descriptions.MultiSelectCellDescription; import org.eclipse.sirius.components.tables.descriptions.SelectCellDescription; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; import org.eclipse.sirius.components.tables.descriptions.TextfieldCellDescription; import org.eclipse.sirius.components.tables.elements.LineElementProps; import org.eclipse.sirius.components.tables.events.ResetTableRowsHeightEvent; @@ -154,6 +155,9 @@ private List getCells(VariableManager lineVariableManager, UUID parentL } else if (cellDescription instanceof TextfieldCellDescription textfieldCellDescription) { var cellComponentProps = new TextfieldCellComponentProps(variableManager, textfieldCellDescription, cellId, columnId, columnTargetObject); cellElement = new Element(TextfieldCellComponent.class, cellComponentProps); + } else if (cellDescription instanceof TextareaCellDescription textareaCellDescription) { + var cellComponentProps = new TextareaCellComponentProps(variableManager, textareaCellDescription, cellId, columnId, columnTargetObject); + cellElement = new Element(TextareaCellComponent.class, cellComponentProps); } else if (cellDescription instanceof IconLabelCellDescription iconLabelCellDescription) { var cellComponentProps = new IconLabelCellComponentProps(variableManager, iconLabelCellDescription, cellId, columnId, columnTargetObject); cellElement = new Element(IconLabelCellComponent.class, cellComponentProps); 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 new file mode 100644 index 0000000000..6eb7bb98ff --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponent.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.tables.components; + +import java.util.Objects; + +import org.eclipse.sirius.components.representations.Element; +import org.eclipse.sirius.components.representations.IComponent; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; +import org.eclipse.sirius.components.tables.elements.TextareaCellElementProps; + +/** + * The component used to render Textarea-based cells. + * + * @author Jerome Gout + */ +public class TextareaCellComponent implements IComponent { + + private final TextareaCellComponentProps props; + + public TextareaCellComponent(TextareaCellComponentProps props) { + this.props = Objects.requireNonNull(props); + } + + @Override + public Element render() { + VariableManager variableManager = this.props.variableManager(); + TextareaCellDescription cellDescription = this.props.textareaCellDescription(); + + String targetObjectId = cellDescription.getTargetObjectIdProvider().apply(variableManager); + String targetObjectKind = cellDescription.getTargetObjectKindProvider().apply(variableManager); + + String value = cellDescription.getCellValueProvider().apply(variableManager, this.props.columnTargetObject()); + + TextareaCellElementProps cellElementProps = new TextareaCellElementProps(this.props.cellId(), 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/TextareaCellComponentProps.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponentProps.java new file mode 100644 index 0000000000..86658ba993 --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/components/TextareaCellComponentProps.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.tables.components; + +import java.util.Objects; +import java.util.UUID; + +import org.eclipse.sirius.components.representations.IProps; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; + +/** + * The props of the Textarea-based cell component. + * + * @author Jerome Gout + */ +public record TextareaCellComponentProps(VariableManager variableManager, TextareaCellDescription textareaCellDescription, UUID cellId, UUID columnId, Object columnTargetObject) implements IProps { + + public TextareaCellComponentProps { + Objects.requireNonNull(variableManager); + Objects.requireNonNull(textareaCellDescription); + Objects.requireNonNull(cellId); + Objects.requireNonNull(columnId); + Objects.requireNonNull(columnTargetObject); + } +} diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/descriptions/TextareaCellDescription.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/descriptions/TextareaCellDescription.java new file mode 100644 index 0000000000..294700fced --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/descriptions/TextareaCellDescription.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.tables.descriptions; + +import java.text.MessageFormat; +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.representations.VariableManager; + +/** + * Description of a textarea cell. + * + * @author Jerome Gout + */ +@Immutable +public final class TextareaCellDescription implements ICellDescription { + + private String id; + + private Predicate canCreatePredicate; + + private Function targetObjectIdProvider; + + private Function targetObjectKindProvider; + + private BiFunction cellValueProvider; + + private TextareaCellDescription() { + // Prevent instantiation + } + + @Override + public String getId() { + return this.id; + } + + @Override + public Predicate getCanCreatePredicate() { + return this.canCreatePredicate; + } + + @Override + public Function getTargetObjectIdProvider() { + return this.targetObjectIdProvider; + } + + @Override + public Function getTargetObjectKindProvider() { + return this.targetObjectKindProvider; + } + + public BiFunction getCellValueProvider() { + return this.cellValueProvider; + } + + + public static Builder newTextareaCellDescription(String id) { + return new Builder(id); + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id); + } + + /** + * Builder used to create a textarea cell widget description. + * + * @author Jerome Gout + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private final String id; + + private Predicate canCreatePredicate; + + private Function targetObjectIdProvider; + + private Function targetObjectKindProvider; + + private BiFunction cellValueProvider; + + + private Builder(String id) { + this.id = Objects.requireNonNull(id); + } + + public Builder canCreatePredicate(Predicate canCreatePredicate) { + this.canCreatePredicate = Objects.requireNonNull(canCreatePredicate); + return this; + } + + public Builder targetObjectIdProvider(Function targetObjectIdProvider) { + this.targetObjectIdProvider = Objects.requireNonNull(targetObjectIdProvider); + return this; + } + + public Builder targetObjectKindProvider(Function targetObjectKindProvider) { + this.targetObjectKindProvider = Objects.requireNonNull(targetObjectKindProvider); + return this; + } + + public Builder cellValueProvider(BiFunction cellValueProvider) { + this.cellValueProvider = Objects.requireNonNull(cellValueProvider); + return this; + } + + + public TextareaCellDescription build() { + TextareaCellDescription textareaCellDescription = new TextareaCellDescription(); + textareaCellDescription.id = Objects.requireNonNull(this.id); + textareaCellDescription.canCreatePredicate = Objects.requireNonNull(this.canCreatePredicate); + textareaCellDescription.targetObjectIdProvider = Objects.requireNonNull(this.targetObjectIdProvider); + textareaCellDescription.targetObjectKindProvider = Objects.requireNonNull(this.targetObjectKindProvider); + textareaCellDescription.cellValueProvider = Objects.requireNonNull(this.cellValueProvider); + return textareaCellDescription; + } + } + +} 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 new file mode 100644 index 0000000000..20428cdd43 --- /dev/null +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/elements/TextareaCellElementProps.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.tables.elements; + +import java.util.Objects; +import java.util.UUID; + +import org.eclipse.sirius.components.representations.IProps; + +/** + * Properties of the cell element. + * + * @author Jerome Gout + */ +public record TextareaCellElementProps(UUID id, String targetObjectId, String targetObjectKind, UUID columnId, String value) implements IProps { + + public static final String TYPE = "TextareaCell"; + + public TextareaCellElementProps { + Objects.requireNonNull(id); + Objects.requireNonNull(targetObjectId); + Objects.requireNonNull(targetObjectKind); + Objects.requireNonNull(columnId); + Objects.requireNonNull(value); + } +} diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableComponentPropsValidator.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableComponentPropsValidator.java index df7d6d8f2f..a583d4705d 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableComponentPropsValidator.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableComponentPropsValidator.java @@ -28,6 +28,8 @@ import org.eclipse.sirius.components.tables.components.SelectCellComponentProps; import org.eclipse.sirius.components.tables.components.TableComponent; import org.eclipse.sirius.components.tables.components.TableComponentProps; +import org.eclipse.sirius.components.tables.components.TextareaCellComponent; +import org.eclipse.sirius.components.tables.components.TextareaCellComponentProps; import org.eclipse.sirius.components.tables.components.TextfieldCellComponent; import org.eclipse.sirius.components.tables.components.TextfieldCellComponentProps; @@ -50,6 +52,8 @@ public boolean validateComponentProps(Class componentType, IProps props) { checkValidProps = props instanceof ColumnComponentProps; } else if (TextfieldCellComponent.class.equals(componentType)) { checkValidProps = props instanceof TextfieldCellComponentProps; + } else if (TextareaCellComponent.class.equals(componentType)) { + checkValidProps = props instanceof TextareaCellComponentProps; } else if (CheckboxCellComponent.class.equals(componentType)) { checkValidProps = props instanceof CheckboxCellComponentProps; } else if (SelectCellComponent.class.equals(componentType)) { 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 4e1e05d283..05a39a153f 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 @@ -25,6 +25,7 @@ import org.eclipse.sirius.components.tables.MultiSelectCell; import org.eclipse.sirius.components.tables.SelectCell; import org.eclipse.sirius.components.tables.Table; +import org.eclipse.sirius.components.tables.TextareaCell; import org.eclipse.sirius.components.tables.TextfieldCell; import org.eclipse.sirius.components.tables.elements.CheckboxCellElementProps; import org.eclipse.sirius.components.tables.elements.ColumnElementProps; @@ -33,6 +34,7 @@ import org.eclipse.sirius.components.tables.elements.MultiSelectCellElementProps; import org.eclipse.sirius.components.tables.elements.SelectCellElementProps; import org.eclipse.sirius.components.tables.elements.TableElementProps; +import org.eclipse.sirius.components.tables.elements.TextareaCellElementProps; import org.eclipse.sirius.components.tables.elements.TextfieldCellElementProps; /** @@ -49,8 +51,8 @@ public Object instantiateElement(String type, IProps props, List childre case TableElementProps.TYPE -> this.instantiateTable(props, children); case LineElementProps.TYPE -> this.instantiateLine(props, children); case ColumnElementProps.TYPE -> this.instantiateColumn(props); - case TextfieldCellElementProps.TYPE, CheckboxCellElementProps.TYPE, SelectCellElementProps.TYPE, MultiSelectCellElementProps.TYPE, IconLabelCellElementProps.TYPE -> - this.instantiateCell(props); + case TextfieldCellElementProps.TYPE, TextareaCellElementProps.TYPE, CheckboxCellElementProps.TYPE, SelectCellElementProps.TYPE, MultiSelectCellElementProps.TYPE, + IconLabelCellElementProps.TYPE -> this.instantiateCell(props); default -> null; }; } @@ -89,6 +91,11 @@ private Line instantiateLine(IProps props, List children) { .map(TextfieldCell.class::cast) .collect(Collectors.toList()); + cells.addAll(children.stream() + .filter(TextareaCell.class::isInstance) + .map(TextareaCell.class::cast) + .toList()); + cells.addAll(children.stream() .filter(CheckboxCell.class::isInstance) .map(CheckboxCell.class::cast) @@ -153,6 +160,13 @@ private ICell instantiateCell(IProps props) { .targetObjectKind(textfieldCellElementProps.targetObjectKind()) .value(textfieldCellElementProps.value()) .build(); + } else if (props instanceof TextareaCellElementProps textareaCellElementProps) { + cell = TextareaCell.newTextareaCell(textareaCellElementProps.id()) + .columnId(textareaCellElementProps.columnId()) + .targetObjectId(textareaCellElementProps.targetObjectId()) + .targetObjectKind(textareaCellElementProps.targetObjectKind()) + .value(textareaCellElementProps.value()) + .build(); } else if (props instanceof CheckboxCellElementProps checkboxCellElementProps) { cell = CheckboxCell.newCheckboxCell(checkboxCellElementProps.id()) .columnId(checkboxCellElementProps.columnId()) diff --git a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableInstancePropsValidator.java b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableInstancePropsValidator.java index 4e6d7974b1..ac64ffe053 100644 --- a/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableInstancePropsValidator.java +++ b/packages/tables/backend/sirius-components-tables/src/main/java/org/eclipse/sirius/components/tables/renderer/TableInstancePropsValidator.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 @@ -21,6 +21,7 @@ import org.eclipse.sirius.components.tables.elements.MultiSelectCellElementProps; import org.eclipse.sirius.components.tables.elements.SelectCellElementProps; import org.eclipse.sirius.components.tables.elements.TableElementProps; +import org.eclipse.sirius.components.tables.elements.TextareaCellElementProps; import org.eclipse.sirius.components.tables.elements.TextfieldCellElementProps; /** @@ -42,6 +43,8 @@ public boolean validateInstanceProps(String type, IProps props) { checkValidProps = props instanceof ColumnElementProps; } else if (TextfieldCellElementProps.TYPE.equals(type)) { checkValidProps = props instanceof TextfieldCellElementProps; + } else if (TextareaCellElementProps.TYPE.equals(type)) { + checkValidProps = props instanceof TextareaCellElementProps; } else if (CheckboxCellElementProps.TYPE.equals(type)) { checkValidProps = props instanceof CheckboxCellElementProps; } else if (SelectCellElementProps.TYPE.equals(type)) { diff --git a/packages/tables/frontend/sirius-components-tables/src/actions/ExportAllDataButton.tsx b/packages/tables/frontend/sirius-components-tables/src/actions/ExportAllDataButton.tsx index befcc5b4b0..6f87f32ad3 100644 --- a/packages/tables/frontend/sirius-components-tables/src/actions/ExportAllDataButton.tsx +++ b/packages/tables/frontend/sirius-components-tables/src/actions/ExportAllDataButton.tsx @@ -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 @@ -15,17 +15,25 @@ import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import MenuItem from '@mui/material/MenuItem'; import { download, generateCsv, mkConfig } from 'export-to-csv'; -import { GQLCell, GQLMultiSelectCell, GQLSelectCell, GQLTable, GQLTextfieldCell } from '../table/TableContent.types'; +import { + GQLCell, + GQLMultiSelectCell, + GQLSelectCell, + GQLTable, + GQLTextareaCell, + GQLTextfieldCell, +} from '../table/TableContent.types'; import { CsvData, ExportAllDataButtonProps } from './ExportAllDataButton.types'; const isSelectCell = (cell: GQLCell): cell is GQLSelectCell => cell.__typename === 'SelectCell'; const isMultiSelectCell = (cell: GQLCell): cell is GQLMultiSelectCell => cell.__typename === 'MultiSelectCell'; const isTextfieldCell = (cell: GQLCell): cell is GQLTextfieldCell => cell.__typename === 'TextfieldCell'; +const isTextareaCell = (cell: GQLCell): cell is GQLTextareaCell => cell.__typename === 'TextareaCell'; const getCellLabel = (cell: GQLCell | undefined): string => { let value = ''; if (cell) { - if (isTextfieldCell(cell)) { + if (isTextfieldCell(cell) || isTextareaCell(cell)) { value = cell.stringValue; } else if (isMultiSelectCell(cell)) { value = cell.options diff --git a/packages/tables/frontend/sirius-components-tables/src/cells/Cell.tsx b/packages/tables/frontend/sirius-components-tables/src/cells/Cell.tsx index 10b5e2e4a1..33bdeb9316 100644 --- a/packages/tables/frontend/sirius-components-tables/src/cells/Cell.tsx +++ b/packages/tables/frontend/sirius-components-tables/src/cells/Cell.tsx @@ -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 @@ -16,22 +16,25 @@ import { memo } from 'react'; import { GQLCell, GQLCheckboxCell, + GQLIconLabelCell, GQLMultiSelectCell, GQLSelectCell, + GQLTextareaCell, GQLTextfieldCell, - GQLIconLabelCell, } from '../table/TableContent.types'; import { CellProps } from './Cell.types'; import { CheckboxCell } from './CheckboxCell'; import { IconLabelCell } from './IconLabelCell'; import { MultiSelectCell } from './MultiSelectCell'; import { SelectCell } from './SelectCell'; +import { TextareaCell } from './TextareaCell'; import { TextfieldCell } from './TextfieldCell'; const isCheckboxCell = (cell: GQLCell): cell is GQLCheckboxCell => cell.__typename === 'CheckboxCell'; const isSelectCell = (cell: GQLCell): cell is GQLSelectCell => cell.__typename === 'SelectCell'; const isMultiSelectCell = (cell: GQLCell): cell is GQLMultiSelectCell => cell.__typename === 'MultiSelectCell'; const isTextfieldCell = (cell: GQLCell): cell is GQLTextfieldCell => cell.__typename === 'TextfieldCell'; +const isTextareaCell = (cell: GQLCell): cell is GQLTextareaCell => cell.__typename === 'TextareaCell'; const isIconLabelCell = (cell: GQLCell): cell is GQLIconLabelCell => cell.__typename === 'IconLabelCell'; export const Cell = memo(({ editingContextId, representationId, tableId, cell, disabled }: CellProps) => { @@ -56,6 +59,16 @@ export const Cell = memo(({ editingContextId, representationId, tableId, cell, d disabled={disabled} /> ); + } else if (isTextareaCell(cell)) { + return ( + + ); } else if (isSelectCell(cell)) { return ( ({ + wrapper: { + overflow: 'auto', + width: '100%', + height: '100%', + }, +})); + +export const TextareaCell = ({ editingContextId, representationId, tableId, cell, disabled }: TextareaCellProps) => { + const { classes } = useStyles(); + const [state, setState] = useState({ + value: cell.stringValue, + }); + + useEffect(() => { + setState((prevState) => ({ ...prevState, value: cell.stringValue })); + }, [cell.stringValue]); + + const { editTextareaCell, loading } = useEditTextareaCell(editingContextId, representationId, tableId, cell.id); + + const handleChange: React.ChangeEventHandler = (event) => { + const { value } = event.target; + setState((prevState) => ({ ...prevState, value })); + }; + + const handleBlur: React.FocusEventHandler = () => { + editTextareaCell(state.value); + }; + + return ( +
+ +
+ ); +}; diff --git a/packages/tables/frontend/sirius-components-tables/src/cells/TextareaCell.types.ts b/packages/tables/frontend/sirius-components-tables/src/cells/TextareaCell.types.ts new file mode 100644 index 0000000000..4e78c7205f --- /dev/null +++ b/packages/tables/frontend/sirius-components-tables/src/cells/TextareaCell.types.ts @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ + +import { GQLTextareaCell } from '../table/TableContent.types'; + +export interface TextareaCellProps { + editingContextId: string; + representationId: string; + tableId: string; + cell: GQLTextareaCell; + disabled: boolean; +} + +export interface TextareaCellState { + value: string; +} diff --git a/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.tsx b/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.tsx new file mode 100644 index 0000000000..3e04458f1c --- /dev/null +++ b/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.tsx @@ -0,0 +1,74 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +import { useMutation } from '@apollo/client/react/hooks/useMutation'; +import { useReporting } from '@eclipse-sirius/sirius-components-core'; +import { + GQLEditTextareaCellMutationData, + GQLEditTextareaCellMutationVariables, + UseEditTextareaCellValue, +} from './useEditTextareaCell.types'; + +import { gql } from '@apollo/client/core'; + +const editTextareaCellMutation = gql` + mutation editTextareaCell($input: EditTextareaCellInput!) { + editTextareaCell(input: $input) { + __typename + ... on ErrorPayload { + messages { + body + level + } + } + ... on SuccessPayload { + messages { + body + level + } + } + } + } +`; + +export const useEditTextareaCell = ( + editingContextId: string, + representationId: string, + tableId: string, + cellId: string +): UseEditTextareaCellValue => { + const [mutationEditTextareaCell, mutationEditTextareaCellResult] = useMutation< + GQLEditTextareaCellMutationData, + GQLEditTextareaCellMutationVariables + >(editTextareaCellMutation); + + useReporting(mutationEditTextareaCellResult, (data: GQLEditTextareaCellMutationData) => data?.editTextareaCell); + + const editTextareaCell = (newValue: string) => { + const variables: GQLEditTextareaCellMutationVariables = { + input: { + id: crypto.randomUUID(), + editingContextId, + representationId, + tableId, + cellId, + newValue, + }, + }; + mutationEditTextareaCell({ variables }); + }; + + return { + editTextareaCell, + loading: mutationEditTextareaCellResult.loading, + }; +}; diff --git a/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.types.ts b/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.types.ts new file mode 100644 index 0000000000..775e221c45 --- /dev/null +++ b/packages/tables/frontend/sirius-components-tables/src/cells/useEditTextareaCell.types.ts @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +import { GQLErrorPayload, GQLSuccessPayload } from '@eclipse-sirius/sirius-components-core'; + +export interface UseEditTextareaCellValue { + editTextareaCell: (newValue: string) => void; + loading: boolean; +} + +export interface GQLEditTextareaCellMutationData { + editTextareaCell: GQLEditTextareaCellPayload; +} + +export interface GQLEditTextareaCellMutationVariables { + input: GQLEditTextareaCellInput; +} + +export interface GQLEditTextareaCellInput { + id: string; + editingContextId: string; + representationId: string; + tableId: string; + cellId: string; + newValue: string; +} + +export type GQLEditTextareaCellPayload = GQLErrorPayload | GQLSuccessPayload; diff --git a/packages/tables/frontend/sirius-components-tables/src/representation/useTableSubscription.ts b/packages/tables/frontend/sirius-components-tables/src/representation/useTableSubscription.ts index c9d122d7b3..79bba0caf6 100644 --- a/packages/tables/frontend/sirius-components-tables/src/representation/useTableSubscription.ts +++ b/packages/tables/frontend/sirius-components-tables/src/representation/useTableSubscription.ts @@ -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 @@ -100,6 +100,9 @@ export const getTableEventSubscription = ` ... on TextfieldCell { stringValue: value } + ... on TextareaCell { + stringValue: value + } ... on IconLabelCell { label: value iconURLs diff --git a/packages/tables/frontend/sirius-components-tables/src/table/TableContent.types.ts b/packages/tables/frontend/sirius-components-tables/src/table/TableContent.types.ts index b7259cd642..a96be77526 100644 --- a/packages/tables/frontend/sirius-components-tables/src/table/TableContent.types.ts +++ b/packages/tables/frontend/sirius-components-tables/src/table/TableContent.types.ts @@ -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 @@ -110,6 +110,10 @@ export interface GQLTextfieldCell extends GQLCell { stringValue: string; } +export interface GQLTextareaCell extends GQLCell { + stringValue: string; +} + export interface GQLIconLabelCell extends GQLCell { label: string; iconURLs: string[]; diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/CellTextareaWidgetDescriptionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/CellTextareaWidgetDescriptionBuilder.java new file mode 100644 index 0000000000..608decb861 --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/CellTextareaWidgetDescriptionBuilder.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2023, 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.builder.generated.table; + +/** + * Builder for CellTextareaWidgetDescriptionBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class CellTextareaWidgetDescriptionBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription. + * @generated + */ + private org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription cellTextareaWidgetDescription = org.eclipse.sirius.components.view.table.TableFactory.eINSTANCE.createCellTextareaWidgetDescription(); + + /** + * Return instance org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription. + * @generated + */ + protected org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription getCellTextareaWidgetDescription() { + return this.cellTextareaWidgetDescription; + } + + /** + * Return instance org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription. + * @generated + */ + public org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription build() { + return this.getCellTextareaWidgetDescription(); + } + + /** + * Setter for Body. + * + * @generated + */ + public CellTextareaWidgetDescriptionBuilder body(org.eclipse.sirius.components.view.Operation ... values) { + for (org.eclipse.sirius.components.view.Operation value : values) { + this.getCellTextareaWidgetDescription().getBody().add(value); + } + return this; + } + + +} + diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/TableBuilders.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/TableBuilders.java index 4d7ee2a773..8fdfa910e6 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/TableBuilders.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/table/TableBuilders.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 Obeo. + * Copyright (c) 2023, 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 @@ -79,5 +79,15 @@ public CellLabelWidgetDescriptionBuilder newCellLabelWidgetDescription() { return new CellLabelWidgetDescriptionBuilder(); } + /** + * Instantiate a CellTextareaWidgetDescriptionBuilder . + * + * @author BuilderGenerator + * @generated + */ + public CellTextareaWidgetDescriptionBuilder newCellTextareaWidgetDescription() { + return new CellTextareaWidgetDescriptionBuilder(); + } + } diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewTableDescriptionConverter.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewTableDescriptionConverter.java index 8c5f5aabb3..a1a65d1fe8 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewTableDescriptionConverter.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/table/ViewTableDescriptionConverter.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 @@ -32,11 +32,13 @@ import org.eclipse.sirius.components.tables.descriptions.LineDescription; import org.eclipse.sirius.components.tables.descriptions.PaginatedData; import org.eclipse.sirius.components.tables.descriptions.TableDescription; +import org.eclipse.sirius.components.tables.descriptions.TextareaCellDescription; import org.eclipse.sirius.components.tables.descriptions.TextfieldCellDescription; import org.eclipse.sirius.components.view.RepresentationDescription; import org.eclipse.sirius.components.view.emf.IRepresentationDescriptionConverter; import org.eclipse.sirius.components.view.emf.ViewIconURLsProvider; 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.springframework.stereotype.Service; @@ -62,7 +64,12 @@ public ViewTableDescriptionConverter(ITableIdProvider tableIdProvider, IObjectSe this.tableIdProvider = Objects.requireNonNull(tableIdProvider); this.objectService = Objects.requireNonNull(objectService); - this.semanticTargetIdProvider = variableManager -> this.self(variableManager).map(this.objectService::getId).orElse(""); + this.semanticTargetIdProvider = variableManager -> { + Optional optionalSelf = this.self(variableManager); + return optionalSelf + .map(this.objectService::getId) + .orElseGet(() -> optionalSelf.map(Object::toString).orElse("")); + }; this.semanticTargetKindProvider = variableManager -> this.self(variableManager).map(this.objectService::getKind).orElse(""); } @@ -172,6 +179,17 @@ private Optional convertCellDescription(org.eclipse.sirius.com return new ViewIconURLsProvider(interpreter, cellLabelWidgetDescription.getIconExpression()).apply(child); }) .build()); + } else if (viewCellDescription.getCellWidgetDescription() instanceof CellTextareaWidgetDescription) { + optionalICellDescription = Optional.of(TextareaCellDescription.newTextareaCellDescription(this.tableIdProvider.getId(viewCellDescription)) + .targetObjectIdProvider(this.semanticTargetIdProvider) + .targetObjectKindProvider(this.semanticTargetKindProvider) + .canCreatePredicate(variableManager -> interpreter.evaluateExpression(variableManager.getVariables(), viewCellDescription.getPreconditionExpression()).asBoolean().orElse(false)) + .cellValueProvider((variableManager, columnTargetObject) -> { + var child = variableManager.createChild(); + child.put("columnTargetObject", columnTargetObject); + return this.evaluateString(interpreter, child, viewCellDescription.getValueExpression()); + }) + .build()); } return optionalICellDescription; } diff --git a/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellDescriptionItemProvider.java index 92525cd72c..58a2d33fad 100644 --- a/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellDescriptionItemProvider.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 @@ -199,6 +199,9 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_DESCRIPTION__CELL_WIDGET_DESCRIPTION, TableFactory.eINSTANCE.createCellLabelWidgetDescription())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_DESCRIPTION__CELL_WIDGET_DESCRIPTION, + TableFactory.eINSTANCE.createCellTextareaWidgetDescription())); } } diff --git a/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellTextareaWidgetDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellTextareaWidgetDescriptionItemProvider.java new file mode 100644 index 0000000000..ee42d9a8e4 --- /dev/null +++ b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/CellTextareaWidgetDescriptionItemProvider.java @@ -0,0 +1,183 @@ +/******************************************************************************* + * 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.table.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.ResourceLocator; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IChildCreationExtender; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.ViewFactory; +import org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription; +import org.eclipse.sirius.components.view.table.TablePackage; + +/** + * This is the item provider adapter for a + * {@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription} object. + * + * @generated + */ +public class CellTextareaWidgetDescriptionItemProvider extends ItemProviderAdapter + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public CellTextareaWidgetDescriptionItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + } + return this.itemPropertyDescriptors; + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (this.childrenFeatures == null) { + super.getChildrenFeatures(object); + this.childrenFeatures.add(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY); + } + return this.childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns CellTextareaWidgetDescription.gif. + * + * @generated + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/CellTextareaWidgetDescription.svg")); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + return this.getString("_UI_CellTextareaWidgetDescription_type"); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(CellTextareaWidgetDescription.class)) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createChangeContext())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createCreateInstance())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createSetValue())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createUnsetValue())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createDeleteElement())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createLet())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createIf())); + + newChildDescriptors.add(this.createChildParameter(TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createFor())); + } + + /** + * Return the resource locator for this item provider's resources. + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return ((IChildCreationExtender) this.adapterFactory).getResourceLocator(); + } + +} diff --git a/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/TableItemProviderAdapterFactory.java b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/TableItemProviderAdapterFactory.java index 8c0fe63310..b78f370395 100644 --- a/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/TableItemProviderAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-table-edit/src/main/java/org/eclipse/sirius/components/view/table/provider/TableItemProviderAdapterFactory.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 @@ -140,6 +140,15 @@ public class TableItemProviderAdapterFactory extends TableAdapterFactory */ protected CellLabelWidgetDescriptionItemProvider cellLabelWidgetDescriptionItemProvider; + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription} instances. + * + * + * @generated + */ + protected CellTextareaWidgetDescriptionItemProvider cellTextareaWidgetDescriptionItemProvider; + /** * This constructs an instance. * @@ -249,6 +258,21 @@ public Adapter createCellLabelWidgetDescriptionAdapter() { return this.cellLabelWidgetDescriptionItemProvider; } + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription}. + * + * + * @generated + */ + @Override + public Adapter createCellTextareaWidgetDescriptionAdapter() { + if (this.cellTextareaWidgetDescriptionItemProvider == null) { + this.cellTextareaWidgetDescriptionItemProvider = new CellTextareaWidgetDescriptionItemProvider(this); + } + + return this.cellTextareaWidgetDescriptionItemProvider; + } + /** * This returns the root adapter factory that contains this factory. @@ -391,6 +415,8 @@ public void dispose() { this.cellTextfieldWidgetDescriptionItemProvider.dispose(); if (this.cellLabelWidgetDescriptionItemProvider != null) this.cellLabelWidgetDescriptionItemProvider.dispose(); + if (this.cellTextareaWidgetDescriptionItemProvider != null) + this.cellTextareaWidgetDescriptionItemProvider.dispose(); } /** diff --git a/packages/view/backend/sirius-components-view-table-edit/src/main/resources/icons/full/obj16/CellTextareaWidgetDescription.svg b/packages/view/backend/sirius-components-view-table-edit/src/main/resources/icons/full/obj16/CellTextareaWidgetDescription.svg new file mode 100644 index 0000000000..e398fdf8de --- /dev/null +++ b/packages/view/backend/sirius-components-view-table-edit/src/main/resources/icons/full/obj16/CellTextareaWidgetDescription.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/packages/view/backend/sirius-components-view-table-edit/src/main/resources/plugin.properties b/packages/view/backend/sirius-components-view-table-edit/src/main/resources/plugin.properties index b03260e896..ad32873d3d 100644 --- a/packages/view/backend/sirius-components-view-table-edit/src/main/resources/plugin.properties +++ b/packages/view/backend/sirius-components-view-table-edit/src/main/resources/plugin.properties @@ -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,7 @@ _UI_CellDescription_type=Cell Description _UI_CellWidgetDescription_type=Cell Widget Description _UI_CellTextfieldWidgetDescription_type=Cell Textfield Widget Description _UI_CellLabelWidgetDescription_type=Cell Label Widget Description +_UI_CellTextareaWidgetDescription_type=Cell Textarea Widget Description _UI_Unknown_type=Object _UI_Unknown_datatype=Value @@ -59,4 +60,5 @@ _UI_CellDescription_tooltipExpression_feature=Tooltip Expression _UI_CellDescription_cellWidgetDescription_feature=Cell Widget Description _UI_CellTextfieldWidgetDescription_body_feature=Body _UI_CellLabelWidgetDescription_iconExpression_feature=Icon Expression +_UI_CellTextareaWidgetDescription_body_feature=Body _UI_Unknown_feature=Unspecified diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/CellTextareaWidgetDescription.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/CellTextareaWidgetDescription.java new file mode 100644 index 0000000000..73af33a4ca --- /dev/null +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/CellTextareaWidgetDescription.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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.table; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.sirius.components.view.Operation; + +/** + * A representation of the model object 'Cell Textarea Widget Description'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription#getBody Body}
  • + *
+ * + * @see org.eclipse.sirius.components.view.table.TablePackage#getCellTextareaWidgetDescription() + * @model + * @generated + */ +public interface CellTextareaWidgetDescription extends CellWidgetDescription { + /** + * Returns the value of the 'Body' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.Operation}. + * + * @return the value of the 'Body' containment reference list. + * @see org.eclipse.sirius.components.view.table.TablePackage#getCellTextareaWidgetDescription_Body() + * @model containment="true" + * @generated + */ + EList getBody(); + +} // CellTextareaWidgetDescription diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TableFactory.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TableFactory.java index 8705460386..0667961a58 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TableFactory.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TableFactory.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 @@ -80,6 +80,15 @@ public interface TableFactory extends EFactory { */ CellLabelWidgetDescription createCellLabelWidgetDescription(); + /** + * Returns a new object of class 'Cell Textarea Widget Description'. + * + * @return a new object of class 'Cell Textarea Widget Description'. + * @generated + */ + CellTextareaWidgetDescription createCellTextareaWidgetDescription(); + /** * Returns the package supported by this factory. * diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TablePackage.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TablePackage.java index 47bdb31d7e..34207b3977 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TablePackage.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/TablePackage.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 @@ -642,6 +642,44 @@ public interface TablePackage extends EPackage { */ int CELL_LABEL_WIDGET_DESCRIPTION_OPERATION_COUNT = CELL_WIDGET_DESCRIPTION_OPERATION_COUNT; + /** + * The meta object id for the + * '{@link org.eclipse.sirius.components.view.table.impl.CellTextareaWidgetDescriptionImpl Cell Textarea Widget + * Description}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.table.impl.CellTextareaWidgetDescriptionImpl + * @see org.eclipse.sirius.components.view.table.impl.TablePackageImpl#getCellTextareaWidgetDescription() + */ + int CELL_TEXTAREA_WIDGET_DESCRIPTION = 8; + + /** + * The feature id for the 'Body' containment reference list. + * + * @generated + * @ordered + */ + int CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY = CELL_WIDGET_DESCRIPTION_FEATURE_COUNT; + + /** + * The number of structural features of the 'Cell Textarea Widget Description' class. + * + * @generated + * @ordered + */ + int CELL_TEXTAREA_WIDGET_DESCRIPTION_FEATURE_COUNT = CELL_WIDGET_DESCRIPTION_FEATURE_COUNT + 1; + + /** + * The number of operations of the 'Cell Textarea Widget Description' class. + * + * @generated + * @ordered + */ + int CELL_TEXTAREA_WIDGET_DESCRIPTION_OPERATION_COUNT = CELL_WIDGET_DESCRIPTION_OPERATION_COUNT; + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.table.TableDescription * Description}'. @@ -1010,6 +1048,28 @@ public interface TablePackage extends EPackage { */ EAttribute getCellLabelWidgetDescription_IconExpression(); + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription + * Cell Textarea Widget Description}'. + * + * @return the meta object for class 'Cell Textarea Widget Description'. + * @generated + * @see org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription + */ + EClass getCellTextareaWidgetDescription(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription#getBody Body}'. + * + * @return the meta object for the containment reference list 'Body'. + * @generated + * @see org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription#getBody() + * @see #getCellTextareaWidgetDescription() + */ + EReference getCellTextareaWidgetDescription_Body(); + /** * Returns the factory that creates the instances of the model. * @@ -1308,6 +1368,25 @@ interface Literals { */ EAttribute CELL_LABEL_WIDGET_DESCRIPTION__ICON_EXPRESSION = eINSTANCE.getCellLabelWidgetDescription_IconExpression(); + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.table.impl.CellTextareaWidgetDescriptionImpl Cell Textarea + * Widget Description}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.table.impl.CellTextareaWidgetDescriptionImpl + * @see org.eclipse.sirius.components.view.table.impl.TablePackageImpl#getCellTextareaWidgetDescription() + */ + EClass CELL_TEXTAREA_WIDGET_DESCRIPTION = eINSTANCE.getCellTextareaWidgetDescription(); + + /** + * The meta object literal for the 'Body' containment reference list feature. + * + * @generated + */ + EReference CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY = eINSTANCE.getCellTextareaWidgetDescription_Body(); + } } // TablePackage diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/CellTextareaWidgetDescriptionImpl.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/CellTextareaWidgetDescriptionImpl.java new file mode 100644 index 0000000000..dbfebf19a3 --- /dev/null +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/CellTextareaWidgetDescriptionImpl.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * 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.table.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.Operation; +import org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription; +import org.eclipse.sirius.components.view.table.TablePackage; + +/** + * An implementation of the model object 'Cell Textarea Widget Description'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.table.impl.CellTextareaWidgetDescriptionImpl#getBody + * Body}
  • + *
+ * + * @generated + */ +public class CellTextareaWidgetDescriptionImpl extends MinimalEObjectImpl.Container implements CellTextareaWidgetDescription { + /** + * The cached value of the '{@link #getBody() Body}' containment reference list. + * + * + * @see #getBody() + * @generated + * @ordered + */ + protected EList body; + + /** + * + * + * @generated + */ + protected CellTextareaWidgetDescriptionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return TablePackage.Literals.CELL_TEXTAREA_WIDGET_DESCRIPTION; + } + + /** + * + * + * @generated + */ + @Override + public EList getBody() { + if (this.body == null) { + this.body = new EObjectContainmentEList<>(Operation.class, this, TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY); + } + return this.body; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + return ((InternalEList) this.getBody()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + return this.getBody(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + this.getBody().clear(); + this.getBody().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + this.getBody().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY: + return this.body != null && !this.body.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // CellTextareaWidgetDescriptionImpl diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TableFactoryImpl.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TableFactoryImpl.java index d0f73fbfcf..f0fef5c64d 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TableFactoryImpl.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TableFactoryImpl.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 @@ -19,6 +19,7 @@ import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.sirius.components.view.table.CellDescription; 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.ColumnDescription; import org.eclipse.sirius.components.view.table.RowDescription; @@ -79,6 +80,8 @@ public EObject create(EClass eClass) { return this.createCellTextfieldWidgetDescription(); case TablePackage.CELL_LABEL_WIDGET_DESCRIPTION: return this.createCellLabelWidgetDescription(); + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION: + return this.createCellTextareaWidgetDescription(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -150,6 +153,17 @@ public CellLabelWidgetDescription createCellLabelWidgetDescription() { return cellLabelWidgetDescription; } + /** + * + * + * @generated + */ + @Override + public CellTextareaWidgetDescription createCellTextareaWidgetDescription() { + CellTextareaWidgetDescriptionImpl cellTextareaWidgetDescription = new CellTextareaWidgetDescriptionImpl(); + return cellTextareaWidgetDescription; + } + /** * * @@ -170,5 +184,5 @@ public TablePackage getTablePackage() { public static TablePackage getPackage() { return TablePackage.eINSTANCE; } - + } // TableFactoryImpl diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TablePackageImpl.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TablePackageImpl.java index d06cbe2470..18ff9b0401 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TablePackageImpl.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/impl/TablePackageImpl.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 @@ -20,6 +20,7 @@ import org.eclipse.sirius.components.view.ViewPackage; import org.eclipse.sirius.components.view.table.CellDescription; 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.ColumnDescription; @@ -97,8 +98,15 @@ public class TablePackageImpl extends EPackageImpl implements TablePackage { * * @generated */ - private static boolean isInited = false; + private EClass cellTextareaWidgetDescriptionEClass = null; + /** + * + * + * @generated + */ + private static boolean isInited = false; + /** * * @@ -490,6 +498,26 @@ public EAttribute getCellLabelWidgetDescription_IconExpression() { return (EAttribute) this.cellLabelWidgetDescriptionEClass.getEStructuralFeatures().get(0); } + /** + * + * + * @generated + */ + @Override + public EClass getCellTextareaWidgetDescription() { + return this.cellTextareaWidgetDescriptionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getCellTextareaWidgetDescription_Body() { + return (EReference) this.cellTextareaWidgetDescriptionEClass.getEStructuralFeatures().get(0); + } + /** * * @@ -551,6 +579,9 @@ public void createPackageContents() { this.cellLabelWidgetDescriptionEClass = this.createEClass(CELL_LABEL_WIDGET_DESCRIPTION); this.createEAttribute(this.cellLabelWidgetDescriptionEClass, CELL_LABEL_WIDGET_DESCRIPTION__ICON_EXPRESSION); + + this.cellTextareaWidgetDescriptionEClass = this.createEClass(CELL_TEXTAREA_WIDGET_DESCRIPTION); + this.createEReference(this.cellTextareaWidgetDescriptionEClass, CELL_TEXTAREA_WIDGET_DESCRIPTION__BODY); } /** @@ -583,6 +614,7 @@ public void initializePackageContents() { this.cellDescriptionEClass.getESuperTypes().add(this.getTableElementDescription()); this.cellTextfieldWidgetDescriptionEClass.getESuperTypes().add(this.getCellWidgetDescription()); this.cellLabelWidgetDescriptionEClass.getESuperTypes().add(this.getCellWidgetDescription()); + this.cellTextareaWidgetDescriptionEClass.getESuperTypes().add(this.getCellWidgetDescription()); // Initialize classes, features, and operations; add parameters this.initEClass(this.tableDescriptionEClass, TableDescription.class, "TableDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -652,6 +684,10 @@ public void initializePackageContents() { this.initEAttribute(this.getCellLabelWidgetDescription_IconExpression(), theViewPackage.getInterpretedExpression(), "iconExpression", "", 0, 1, CellLabelWidgetDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.cellTextareaWidgetDescriptionEClass, CellTextareaWidgetDescription.class, "CellTextareaWidgetDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getCellTextareaWidgetDescription_Body(), theViewPackage.getOperation(), null, "body", null, 0, -1, CellTextareaWidgetDescription.class, !IS_TRANSIENT, !IS_VOLATILE, + IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + // Create resource this.createResource(eNS_URI); } diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableAdapterFactory.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableAdapterFactory.java index 9e6e1b5509..6dd1e55d9d 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableAdapterFactory.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 @@ -19,6 +19,7 @@ import org.eclipse.sirius.components.view.RepresentationDescription; import org.eclipse.sirius.components.view.table.CellDescription; 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.ColumnDescription; @@ -89,6 +90,11 @@ public Adapter caseCellLabelWidgetDescription(CellLabelWidgetDescription object) return TableAdapterFactory.this.createCellLabelWidgetDescriptionAdapter(); } + @Override + public Adapter caseCellTextareaWidgetDescription(CellTextareaWidgetDescription object) { + return TableAdapterFactory.this.createCellTextareaWidgetDescriptionAdapter(); + } + @Override public Adapter caseRepresentationDescription(RepresentationDescription object) { return TableAdapterFactory.this.createRepresentationDescriptionAdapter(); @@ -255,6 +261,20 @@ public Adapter createCellLabelWidgetDescriptionAdapter() { return null; } + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription Cell Textarea Widget + * Description}'. This default implementation returns null so that we can easily ignore + * cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @generated + * @see org.eclipse.sirius.components.view.table.CellTextareaWidgetDescription + */ + public Adapter createCellTextareaWidgetDescriptionAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.RepresentationDescription * Representation Description}'. This default implementation returns null so that diff --git a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableSwitch.java b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableSwitch.java index e15a4a238b..70f46a87ca 100644 --- a/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableSwitch.java +++ b/packages/view/backend/sirius-components-view-table/src/main/java/org/eclipse/sirius/components/view/table/util/TableSwitch.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 @@ -18,6 +18,7 @@ import org.eclipse.sirius.components.view.RepresentationDescription; import org.eclipse.sirius.components.view.table.CellDescription; 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.ColumnDescription; @@ -146,6 +147,15 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case TablePackage.CELL_TEXTAREA_WIDGET_DESCRIPTION: { + CellTextareaWidgetDescription cellTextareaWidgetDescription = (CellTextareaWidgetDescription) theEObject; + T result = this.caseCellTextareaWidgetDescription(cellTextareaWidgetDescription); + if (result == null) + result = this.caseCellWidgetDescription(cellTextareaWidgetDescription); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } default: return this.defaultCase(theEObject); } @@ -270,6 +280,21 @@ public T caseCellLabelWidgetDescription(CellLabelWidgetDescription object) { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Cell Textarea Widget Description'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Cell Textarea Widget Description'. + * @generated + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + */ + public T caseCellTextareaWidgetDescription(CellTextareaWidgetDescription object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Representation Description'. This implementation returns null; returning a non-null result will terminate the switch.