forked from eclipse-sirius/sirius-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4403] Add support of actions in table rows context menu
Bug: eclipse-sirius#4403 Signed-off-by: Jerome Gout <[email protected]>
- Loading branch information
1 parent
5b0440c
commit 833d045
Showing
36 changed files
with
1,399 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rg/eclipse/sirius/web/papaya/representations/table/DeleteRowContextMenuEntryExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 CEA LIST. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.sirius.web.papaya.representations.table; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeKind; | ||
import org.eclipse.sirius.components.collaborative.tables.api.IRowContextMenuEntryExecutor; | ||
import org.eclipse.sirius.components.core.api.IEditService; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IObjectService; | ||
import org.eclipse.sirius.components.representations.IStatus; | ||
import org.eclipse.sirius.components.representations.Success; | ||
import org.eclipse.sirius.components.tables.Line; | ||
import org.eclipse.sirius.components.tables.Table; | ||
import org.eclipse.sirius.components.tables.descriptions.TableDescription; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* This class is the implementation of {@link IRowContextMenuEntryExecutor} for the example Delete row action. | ||
* | ||
* @author Jerome Gout | ||
*/ | ||
@Service | ||
public class DeleteRowContextMenuEntryExecutor implements IRowContextMenuEntryExecutor { | ||
|
||
private final IEditService editService; | ||
|
||
private final IObjectService objectService; | ||
|
||
public DeleteRowContextMenuEntryExecutor(IEditService editService, IObjectService objectService) { | ||
this.editService = Objects.requireNonNull(editService); | ||
this.objectService = Objects.requireNonNull(objectService); | ||
} | ||
|
||
@Override | ||
public boolean canExecute(TableDescription tableDescription, String tableId, String rowId, String rowMenuContextEntryId) { | ||
return PackageTableRowContextMenuProvider.DELETE_ID.equals(rowMenuContextEntryId); | ||
} | ||
|
||
@Override | ||
public IStatus execute(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row, String rowMenuContextEntryId) { | ||
this.objectService.getObject(editingContext, row.getTargetObjectId()).ifPresent(this.editService::delete); | ||
return new Success(ChangeKind.SEMANTIC_CHANGE, Map.of()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...g/eclipse/sirius/web/papaya/representations/table/PackageTableRowContextMenuProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 CEA LIST. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.sirius.web.papaya.representations.table; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.tables.api.IRowContextMenuEntryProvider; | ||
import org.eclipse.sirius.components.collaborative.tables.dto.RowContextMenuEntry; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.tables.Line; | ||
import org.eclipse.sirius.components.tables.Table; | ||
import org.eclipse.sirius.components.tables.descriptions.TableDescription; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Example of row context menu entries used inside the papaya package table. | ||
* | ||
* @author Jerome Gout | ||
*/ | ||
@Service | ||
public class PackageTableRowContextMenuProvider implements IRowContextMenuEntryProvider { | ||
|
||
public static final String DELETE_ID = "papaya-package-table-delete-row"; | ||
|
||
public static final String DELETE_LABEL = "Delete row"; | ||
|
||
@Override | ||
public boolean canHandle(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row) { | ||
return Objects.equals(tableDescription.getId(), PackageTableRepresentationDescriptionProvider.TABLE_DESCRIPTION_ID); | ||
} | ||
|
||
@Override | ||
public List<RowContextMenuEntry> getRowContextMenuEntries(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row) { | ||
return List.of(new RowContextMenuEntry(DELETE_ID, DELETE_LABEL, List.of("/icons/full/obj16/DeleteTool.svg"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../org/eclipse/sirius/components/collaborative/tables/api/IRowContextMenuEntryExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* 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.collaborative.tables.api; | ||
|
||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.representations.IStatus; | ||
import org.eclipse.sirius.components.tables.Line; | ||
import org.eclipse.sirius.components.tables.Table; | ||
import org.eclipse.sirius.components.tables.descriptions.TableDescription; | ||
|
||
/** | ||
* Interface allowing to perform row context menu entries. | ||
* | ||
* @author Jerome Gout | ||
*/ | ||
public interface IRowContextMenuEntryExecutor { | ||
boolean canExecute(TableDescription tableDescription, String tableId, String rowId, String rowMenuContextEntryId); | ||
|
||
IStatus execute(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row, String rowMenuContextEntryId); | ||
} |
35 changes: 35 additions & 0 deletions
35
.../org/eclipse/sirius/components/collaborative/tables/api/IRowContextMenuEntryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* 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.collaborative.tables.api; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.sirius.components.collaborative.tables.dto.RowContextMenuEntry; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.tables.Line; | ||
import org.eclipse.sirius.components.tables.Table; | ||
import org.eclipse.sirius.components.tables.descriptions.TableDescription; | ||
|
||
/** | ||
* Interface allowing to provide context menu entries in a table row. | ||
* | ||
* @author Jerome Gout | ||
*/ | ||
public interface IRowContextMenuEntryProvider { | ||
|
||
boolean canHandle(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row); | ||
|
||
List<RowContextMenuEntry> getRowContextMenuEntries(IEditingContext editingContext, TableDescription tableDescription, Table table, Line row); | ||
|
||
} |
Oops, something went wrong.