From 293c4648d8e4545b31d317890c1ae2a704e5b66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20ROU=C3=8BN=C3=89?= Date: Mon, 21 Aug 2023 17:06:02 +0200 Subject: [PATCH] [2253] Add the possibility of organizing palette tools into sections Bug: https://github.com/eclipse-sirius/sirius-web/issues/2253 --- CHANGELOG.adoc | 11 +- .../cypress/e2e/project/edit/studio.cy.js | 63 +++ .../CreateViewOperationHandlerTests.java | 2 +- .../DeleteViewOperationHandlerTests.java | 3 +- ...java => CompatibilityPaletteProvider.java} | 64 +-- .../diagrams/ConnectorToolsProvider.java | 27 +- ...ptionNodeAndEdgeDescriptionsPopulator.java | 5 +- .../services/diagrams/IToolProvider.java | 5 +- .../services/diagrams/ToolProvider.java | 28 +- .../collaborative/diagrams/ToolService.java | 29 +- ...onsProvider.java => IPaletteProvider.java} | 10 +- ...ectionsInput.java => GetPaletteInput.java} | 4 +- ...oad.java => GetPaletteSuccessPayload.java} | 10 +- .../collaborative/diagrams/dto/Palette.java | 69 +++ ...ndler.java => GetPaletteEventHandler.java} | 34 +- .../main/resources/schema/diagram.graphqls | 14 +- .../CreateDiagramEventHandlerTests.java | 3 +- .../GetConnectorToolsEventHandlerTests.java | 9 +- ...DiagramDescriptionPaletteDataFetcher.java} | 27 +- ...DefaultTestDiagramDescriptionProvider.java | 17 +- .../tests/TestDiagramDescriptionBuilder.java | 7 +- .../description/DiagramDescription.java | 37 +- .../components/diagrams/tools/Palette.java | 104 ++++ .../DiagramElementChangeVisibilityTests.java | 6 +- .../renderer/DiagramRendererEdgeTests.java | 2 +- .../renderer/DiagramRendererNodeTests.java | 22 +- .../renderer/UnsynchronizedDiagramTests.java | 2 +- .../src/renderer/Tool.tsx | 8 +- .../src/renderer/Tool.types.ts | 1 + .../src/renderer/palette/Palette.tsx | 73 +-- .../src/renderer/palette/Palette.types.ts | 8 + .../palette/tool-section/ToolSection.tsx | 137 +++++ .../palette/tool-section/ToolSection.types.ts | 22 + .../src/palette/ContextualPalette.tsx | 124 +++-- .../src/palette/ContextualPalette.types.ts | 17 +- .../src/palette/ContextualPaletteMachine.ts | 24 +- .../representation/DiagramRepresentation.tsx | 12 +- .../view/ViewDiagramIntegrationTests.java | 162 +++--- ...tElementLabelProviderIntegrationTests.java | 30 +- .../builder/generated/DiagramBuilders.java | 30 ++ .../generated/DiagramPaletteBuilder.java | 12 + .../generated/DiagramToolSectionBuilder.java | 68 +++ .../builder/generated/EdgePaletteBuilder.java | 12 + .../generated/EdgeToolSectionBuilder.java | 81 +++ .../builder/generated/NodePaletteBuilder.java | 12 + .../generated/NodeToolSectionBuilder.java | 80 +++ .../builder/generated/ToolSectionBuilder.java | 40 ++ .../diagram/provider/DiagramEditPlugin.java | 11 +- .../DiagramItemProviderAdapterFactory.java | 78 +++ .../provider/DiagramPaletteItemProvider.java | 4 + .../DiagramToolSectionItemProvider.java | 151 ++++++ .../provider/EdgeDescriptionItemProvider.java | 2 +- .../provider/EdgePaletteItemProvider.java | 7 +- .../provider/EdgeToolSectionItemProvider.java | 157 ++++++ .../provider/NodePaletteItemProvider.java | 6 + .../provider/NodeToolSectionItemProvider.java | 155 ++++++ .../provider/ToolSectionItemProvider.java | 139 +++++ .../icons/full/obj16/DiagramToolSection.svg | 1 + .../icons/full/obj16/EdgeToolSection.svg | 1 + .../icons/full/obj16/NodeToolSection.svg | 1 + .../src/main/resources/plugin.properties | 30 +- .../view/diagram/DiagramFactory.java | 24 + .../view/diagram/DiagramPackage.java | 488 +++++++++++++++++- .../view/diagram/DiagramPalette.java | 13 + .../view/diagram/DiagramToolSection.java | 44 ++ .../components/view/diagram/EdgePalette.java | 13 + .../view/diagram/EdgeToolSection.java | 59 +++ .../components/view/diagram/NodePalette.java | 13 + .../view/diagram/NodeToolSection.java | 57 ++ .../components/view/diagram/ToolSection.java | 55 ++ .../view/diagram/impl/DiagramFactoryImpl.java | 42 ++ .../view/diagram/impl/DiagramPackageImpl.java | 208 ++++++++ .../view/diagram/impl/DiagramPaletteImpl.java | 39 ++ .../diagram/impl/DiagramToolSectionImpl.java | 157 ++++++ .../view/diagram/impl/EdgePaletteImpl.java | 39 ++ .../diagram/impl/EdgeToolSectionImpl.java | 196 +++++++ .../view/diagram/impl/NodePaletteImpl.java | 39 ++ .../diagram/impl/NodeToolSectionImpl.java | 195 +++++++ .../view/diagram/impl/ToolSectionImpl.java | 171 ++++++ .../diagram/util/DiagramAdapterFactory.java | 80 +++ .../view/diagram/util/DiagramSwitch.java | 96 ++++ .../src/main/resources/model/diagram.ecore | 26 + .../src/main/resources/model/diagram.genmodel | 17 + ...epresentationDescriptionSearchService.java | 23 + .../ConnectorToolsProviderDiagram.java | 14 +- .../view/emf/diagram/ToolConverter.java | 218 ++++---- .../view/emf/diagram/ToolFinder.java | 35 +- .../ViewDiagramDescriptionConverter.java | 12 +- ...Provider.java => ViewPaletteProvider.java} | 231 +++++---- .../emf/diagram/ViewPaletteProviderTests.java | 223 ++++++++ 90 files changed, 4499 insertions(+), 638 deletions(-) rename packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/{CompatibilityToolSectionsProvider.java => CompatibilityPaletteProvider.java} (84%) rename packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/{IToolSectionsProvider.java => IPaletteProvider.java} (74%) rename packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/{GetToolSectionsInput.java => GetPaletteInput.java} (78%) rename packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/{GetToolSectionSuccessPayload.java => GetPaletteSuccessPayload.java} (72%) create mode 100644 packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/Palette.java rename packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/{GetToolSectionsEventHandler.java => GetPaletteEventHandler.java} (87%) rename packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/{DiagramDescriptionToolSectionsDataFetcher.java => DiagramDescriptionPaletteDataFetcher.java} (70%) create mode 100644 packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Palette.java create mode 100644 packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.tsx create mode 100644 packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.types.ts create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramToolSectionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgeToolSectionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodeToolSectionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ToolSectionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramToolSectionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeToolSectionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodeToolSectionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ToolSectionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/DiagramToolSection.svg create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/EdgeToolSection.svg create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/NodeToolSection.svg create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramToolSection.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeToolSection.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeToolSection.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ToolSection.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramToolSectionImpl.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeToolSectionImpl.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodeToolSectionImpl.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ToolSectionImpl.java rename packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/{ViewToolSectionsProvider.java => ViewPaletteProvider.java} (66%) create mode 100644 packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/diagram/ViewPaletteProviderTests.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5bbc39e1e9e..67146857251 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -4,10 +4,8 @@ === Shapes - === Architectural decision records - === Breaking changes - https://github.com/eclipse-sirius/sirius-components/issues/2250[#2250] [core] Remove all references to notistack from `sirius-components-core`. @@ -51,7 +49,7 @@ As a result the development of applications consuming Sirius Components packages === New Features - https://github.com/eclipse-sirius/sirius-web/issues/2185[#2185] [diagram] Add support for drop tool from the explorer with React Flow. - +- https://github.com/eclipse-sirius/sirius-web/issues/2253[#2253] [diagram] Add the possibility of organizing palette tools into sections === Improvements @@ -61,7 +59,6 @@ As a result the development of applications consuming Sirius Components packages - https://github.com/eclipse-sirius/sirius-web/issues/2298[#2298] [diagram] Support keyboard shortcut for "Delete from model" action on react-flow diagrams - https://github.com/eclipse-sirius/sirius-web/issues/2231[#2231] [diagram] Extract the support for fullscreen in a dedicated hook - == v2023.8.0 === Shapes @@ -122,7 +119,8 @@ An absent/empty candidates expression now simply means the widget is empty. - https://github.com/eclipse-sirius/sirius-components/issues/2194[#2194] [view] Fix an issue where it was impossible to set the None value to a color property in a View Node/Edge Description from the Details view. - https://github.com/eclipse-sirius/sirius-components/issues/2225[#2225] [form] Fix an issue where tabs displaying page name could be hidden. - https://github.com/eclipse-sirius/sirius-components/issues/2220[#2220] [vs-code] Fix an issue where some React contexts where missing, the treeID variable was missing in graphQLSubscription for the explorer and the Forms were not parts of the list of representations availables. -- https://github.com/eclipse-sirius/sirius-components/issues/2217[#2217] [diagram] Fix the svg export when the file extension was not available. It falls back to the image content type to determine the image type. +- https://github.com/eclipse-sirius/sirius-components/issues/2217[#2217] [diagram] Fix the svg export when the file extension was not available. +It falls back to the image content type to determine the image type. === New Features @@ -209,7 +207,8 @@ The node palette with hide and fade: + image:doc/images/NodePaletteWithHideFade.png[Hide and Fade on node palette] - https://github.com/eclipse-sirius/sirius-components/issues/2095[#2095] [diagram] Add support for the creation of new edges in the alternate diagram rendering solution -- https://github.com/eclipse-sirius/sirius-components/issues/2104[#2104] [diagram] Improve the frontend rendering. Labels and node list are rendered with css. +- https://github.com/eclipse-sirius/sirius-components/issues/2104[#2104] [diagram] Improve the frontend rendering. +Labels and node list are rendered with css. == v2023.6.0 diff --git a/integration-tests/cypress/e2e/project/edit/studio.cy.js b/integration-tests/cypress/e2e/project/edit/studio.cy.js index 90a76797f39..18b0b0211ea 100644 --- a/integration-tests/cypress/e2e/project/edit/studio.cy.js +++ b/integration-tests/cypress/e2e/project/edit/studio.cy.js @@ -48,4 +48,67 @@ describe('/projects/:projectId/edit - Studio', () => { cy.getByTestId('domain').get('[data-value="http://www.eclipse.org/sirius-web/view"]').should('exist'); cy.getByTestId('domain').get('[data-value="http://www.obeo.fr/dsl/designer/sample/flow"]').should('exist'); }); + + it('Check the DiagramPalette toolSection creation', () => { + cy.getByTestId('ViewNewModel').dblclick(); + cy.getByTestId('View').dblclick(); + cy.get('[data-testid$=" Diagram Description"]').dblclick(); + cy.getByTestId('DiagramPalette').should('exist'); + cy.getByTestId('DiagramPalette-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Diagram Tool Section"]').should('exist').click(); + cy.getByTestId('create-object').click(); + cy.getByTestId('Tool Section').should('exist'); + cy.getByTestId('Tool Section-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Node Tool"]').should('exist'); + cy.get('[data-value="Edge Tool"]').should('not.exist'); + }); + + it('Check the NodePalette toolSection creation', () => { + cy.getByTestId('ViewNewModel').dblclick(); + cy.getByTestId('View').dblclick(); + cy.get('[data-testid$=" Diagram Description"]').dblclick(); + cy.getByTestId('Entity1 Node').dblclick(); + cy.getByTestId('NodePalette-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Node Tool Section"]').should('exist').click(); + cy.getByTestId('create-object').click(); + cy.getByTestId('Tool Section').should('exist'); + cy.getByTestId('Tool Section-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Node Tool"]').should('exist'); + cy.get('[data-value="Edge Tool"]').should('exist'); + cy.get('[data-value="Source Edge End Reconnection Tool"]').should('not.exist'); + }); + + it('Check the EdgePalette toolSection creation', () => { + cy.getByTestId('ViewNewModel').dblclick(); + cy.getByTestId('View').dblclick(); + cy.get('[data-testid$=" Diagram Description"]').dblclick(); + cy.getByTestId('LinkedTo Edge').dblclick(); + cy.getByTestId('EdgePalette-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Edge Tool Section"]').should('exist').click(); + cy.getByTestId('create-object').click(); + cy.getByTestId('Tool Section').should('exist'); + cy.getByTestId('Tool Section-more').click(); + cy.getByTestId('new-object').click(); + cy.getByTestId('childCreationDescription').find('input').invoke('val').should('not.be.empty'); + cy.getByTestId('childCreationDescription').click(); + cy.get('[data-value="Node Tool"]').should('exist'); + cy.get('[data-value="Edge Tool"]').should('not.exist'); + cy.get('[data-value="Source Edge End Reconnection Tool"]').should('exist'); + cy.get('[data-value="Target Edge End Reconnection Tool"]').should('exist'); + }); }); diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java index 0376cbf5d9f..a6c63d2db43 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/CreateViewOperationHandlerTests.java @@ -84,7 +84,7 @@ public void initialize() { .targetObjectIdProvider(variableManager -> "diagramTargetObjectId") .canCreatePredicate(variableManager -> true) .labelProvider(variableManager -> "Diagram") - .toolSections(List.of()) + .palettes(List.of()) .nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID().toString()))) .edgeDescriptions(List.of()) .dropHandler(variableManager -> new Failure("")) diff --git a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java index afa2f28671f..35f1409bcdb 100644 --- a/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java +++ b/packages/compatibility/backend/sirius-components-compatibility-emf/src/test/java/org/eclipse/sirius/components/compatibility/emf/compatibility/operations/DeleteViewOperationHandlerTests.java @@ -63,6 +63,7 @@ * @author arichard */ public class DeleteViewOperationHandlerTests { + private static final String AQL = "aql:"; private static final String VARIABLE_NAME = "myVariableName"; @@ -85,7 +86,7 @@ public void initialize() { .targetObjectIdProvider(variableManager -> "diagramTargetObjectId") .canCreatePredicate(variableManager -> true) .labelProvider(variableManager -> "Diagram") - .toolSections(List.of()) + .palettes(List.of()) .nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID().toString()))) .edgeDescriptions(List.of()) .dropHandler(variableManager -> new Failure("")) diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityToolSectionsProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java similarity index 84% rename from packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityToolSectionsProvider.java rename to packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java index 8532920a369..335628da2d4 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityToolSectionsProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java @@ -22,8 +22,9 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramImageConstants; -import org.eclipse.sirius.components.collaborative.diagrams.api.IToolSectionsProvider; +import org.eclipse.sirius.components.collaborative.diagrams.api.IPaletteProvider; import org.eclipse.sirius.components.collaborative.diagrams.dto.ITool; +import org.eclipse.sirius.components.collaborative.diagrams.dto.Palette; import org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnDiagramElementTool; import org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnTwoDiagramElementsCandidate; import org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnTwoDiagramElementsTool; @@ -63,7 +64,7 @@ * @author arichard */ @Service -public class CompatibilityToolSectionsProvider implements IToolSectionsProvider { +public class CompatibilityPaletteProvider implements IPaletteProvider { private final IIdentifierProvider identifierProvider; @@ -71,7 +72,7 @@ public class CompatibilityToolSectionsProvider implements IToolSectionsProvider private final IAQLInterpreterFactory interpreterFactory; - public CompatibilityToolSectionsProvider(IIdentifierProvider identifierProvider, IODesignRegistry odesignRegistry, IAQLInterpreterFactory interpreterFactory) { + public CompatibilityPaletteProvider(IIdentifierProvider identifierProvider, IODesignRegistry odesignRegistry, IAQLInterpreterFactory interpreterFactory) { this.identifierProvider = Objects.requireNonNull(identifierProvider); this.odesignRegistry = Objects.requireNonNull(odesignRegistry); this.interpreterFactory = Objects.requireNonNull(interpreterFactory); @@ -83,10 +84,9 @@ public boolean canHandle(DiagramDescription diagramDescription) { } @Override - public List handle(Object targetElement, Object diagramElement, Object diagramElementDescription, DiagramDescription diagramDescription) { + public Palette handle(Object targetElement, Object diagramElement, Object diagramElementDescription, DiagramDescription diagramDescription) { var optionalVsmElementId = this.identifierProvider.findVsmElementId(diagramDescription.getId()); - // @formatter:off var optionalSiriusDiagramDescription = this.odesignRegistry.getODesigns().stream() .map(EObject::eResource) .map(resource -> resource.getResourceSet().getEObject(URI.createURI(optionalVsmElementId.get()), false)) @@ -94,49 +94,55 @@ public List handle(Object targetElement, Object diagramElement, Obj .filter(org.eclipse.sirius.diagram.description.DiagramDescription.class::isInstance) .map(org.eclipse.sirius.diagram.description.DiagramDescription.class::cast) .findFirst(); - // @formatter:on List toolSections = new ArrayList<>(); if (optionalSiriusDiagramDescription.isPresent()) { org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription = optionalSiriusDiagramDescription.get(); - // @formatter:off List filteredToolSections = this.getToolSectionFromDiagramDescriptionToolSection(diagramDescription).stream() .map(toolSection -> this.filteredTools(targetElement, diagramElement, toolSection, siriusDiagramDescription, diagramElementDescription)) .filter(toolSection -> !toolSection.tools().isEmpty()) .toList(); - // @formatter:on toolSections.addAll(filteredToolSections); toolSections.addAll(this.createExtraToolSections(diagramElementDescription)); } - return toolSections; + String paletteId = "siriusComponents://palette?diagramId=" + optionalVsmElementId.get(); + return Palette.newPalette(paletteId).tools(List.of()).toolSections(toolSections).build(); } private List getToolSectionFromDiagramDescriptionToolSection(DiagramDescription diagramDescription) { List toolSections = new ArrayList<>(); - diagramDescription.getToolSections().forEach(toolSection -> { - List tools = new ArrayList<>(); - toolSection.getTools().forEach(tool -> { - if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool singleClickOnDiagramElementTool) { - SingleClickOnDiagramElementTool convertedTool = new SingleClickOnDiagramElementTool(singleClickOnDiagramElementTool.getId(), singleClickOnDiagramElementTool.getLabel(), singleClickOnDiagramElementTool.getImageURL(), singleClickOnDiagramElementTool.getTargetDescriptions(), singleClickOnDiagramElementTool.getSelectionDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); - tools.add(convertedTool); - } - if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool singleClickOnTwoDiagramElementsTool) { - List candidates = new ArrayList<>(); - singleClickOnTwoDiagramElementsTool.getCandidates().forEach(candidate -> { - SingleClickOnTwoDiagramElementsCandidate convertedCandidate = new SingleClickOnTwoDiagramElementsCandidate(candidate.getSources(), candidate.getTargets()); - candidates.add(convertedCandidate); - }); - SingleClickOnTwoDiagramElementsTool convertedTool = new SingleClickOnTwoDiagramElementsTool(singleClickOnTwoDiagramElementsTool.getId(), singleClickOnTwoDiagramElementsTool.getLabel(), singleClickOnTwoDiagramElementsTool.getImageURL(), candidates); - tools.add(convertedTool); - } - }); - ToolSection convertedToolSection = new ToolSection(toolSection.getId(), toolSection.getLabel(), toolSection.getImageURL(), tools); + diagramDescription.getPalettes().forEach(palette -> { + List tools = palette.getTools().stream().map(this::convertTool).filter(Objects::nonNull).toList(); + ToolSection convertedToolSection = new ToolSection(palette.getId(), "", "", tools); toolSections.add(convertedToolSection); }); + diagramDescription.getPalettes().stream() + .flatMap(palette -> palette.getToolSections().stream()) + .forEach(toolSection -> { + List tools = toolSection.getTools().stream().map(this::convertTool).filter(Objects::nonNull).toList(); + ToolSection convertedToolSection = new ToolSection(toolSection.getId(), toolSection.getLabel(), toolSection.getImageURL(), tools); + toolSections.add(convertedToolSection); + }); return toolSections; } + private ITool convertTool(org.eclipse.sirius.components.diagrams.tools.ITool tool) { + ITool convertedTool = null; + if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool singleClickOnDiagramElementTool) { + convertedTool = new SingleClickOnDiagramElementTool(singleClickOnDiagramElementTool.getId(), singleClickOnDiagramElementTool.getLabel(), singleClickOnDiagramElementTool.getImageURL(), singleClickOnDiagramElementTool.getTargetDescriptions(), singleClickOnDiagramElementTool.getSelectionDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); + } + if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool singleClickOnTwoDiagramElementsTool) { + List candidates = new ArrayList<>(); + singleClickOnTwoDiagramElementsTool.getCandidates().forEach(candidate -> { + SingleClickOnTwoDiagramElementsCandidate convertedCandidate = new SingleClickOnTwoDiagramElementsCandidate(candidate.getSources(), candidate.getTargets()); + candidates.add(convertedCandidate); + }); + convertedTool = new SingleClickOnTwoDiagramElementsTool(singleClickOnTwoDiagramElementsTool.getId(), singleClickOnTwoDiagramElementsTool.getLabel(), singleClickOnTwoDiagramElementsTool.getImageURL(), candidates); + } + return convertedTool; + } + private ToolSection filteredTools(Object targetElement, Object diagramElement, ToolSection toolSection, org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription, Object diagramElementDescription) { // @formatter:off @@ -245,9 +251,9 @@ private String getDescriptionId(Object diagramElementDescription) { if (diagramElementDescription instanceof DiagramDescription) { descriptionId = ((DiagramDescription) diagramElementDescription).getId(); } else if (diagramElementDescription instanceof NodeDescription) { - descriptionId = ((NodeDescription) diagramElementDescription).getId().toString(); + descriptionId = ((NodeDescription) diagramElementDescription).getId(); } else if (diagramElementDescription instanceof EdgeDescription) { - descriptionId = ((EdgeDescription) diagramElementDescription).getId().toString(); + descriptionId = ((EdgeDescription) diagramElementDescription).getId(); } return descriptionId; } diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ConnectorToolsProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ConnectorToolsProvider.java index b534ea39a40..0611e52d0d3 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ConnectorToolsProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ConnectorToolsProvider.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Stream; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; @@ -34,7 +35,6 @@ import org.eclipse.sirius.components.diagrams.description.DiagramDescription; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.interpreter.Result; import org.eclipse.sirius.components.interpreter.Status; @@ -81,7 +81,6 @@ public boolean canHandle(DiagramDescription diagramDescription) { @Override public List getConnectorTools(Object sourceDiagramElement, Object targetDiagramElement, Diagram diagram, IEditingContext editingContext) { var optDiagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagram.getDescriptionId()); - //@formatter:off var optSourceSemanticElement = Optional.of(sourceDiagramElement) .map(this::mapDiagramElementToTargetObjectId) .filter(Optional::isPresent) @@ -92,17 +91,14 @@ public List getConnectorTools(Object sourceDiagramElement, Object targetD .filter(Optional::isPresent) .map(Optional::get) .map(targetObjectId -> this.objectService.getObject(editingContext, targetObjectId)); - //@formatter:on var optSourceDiagramElementDescriptionId = this.mapDiagramElementToDescriptionId(sourceDiagramElement); var optTargetDiagramElementDescriptionId = this.mapDiagramElementToDescriptionId(targetDiagramElement); boolean semanticElementsPresent = optSourceSemanticElement.isPresent() && optTargetSemanticElement.isPresent(); boolean diagramElementDescriptionsPresent = optDiagramDescription.isPresent() && optSourceDiagramElementDescriptionId.isPresent() && optTargetDiagramElementDescriptionId.isPresent(); - if (semanticElementsPresent && diagramElementDescriptionsPresent && optDiagramDescription.get() instanceof DiagramDescription) { - DiagramDescription diagramDescription = (DiagramDescription) optDiagramDescription.get(); + if (semanticElementsPresent && diagramElementDescriptionsPresent && optDiagramDescription.get() instanceof DiagramDescription diagramDescription) { var optionalVsmElementId = this.identifierProvider.findVsmElementId(diagramDescription.getId()); if (optionalVsmElementId.isPresent()) { - // @formatter:off var optionalSiriusDiagramDescription = this.odesignRegistry.getODesigns().stream() .map(EObject::eResource) .map(resource -> resource.getResourceSet().getEObject(URI.createURI(optionalVsmElementId.get()), false)) @@ -110,7 +106,6 @@ public List getConnectorTools(Object sourceDiagramElement, Object targetD .filter(org.eclipse.sirius.diagram.description.DiagramDescription.class::isInstance) .map(org.eclipse.sirius.diagram.description.DiagramDescription.class::cast) .findFirst(); - // @formatter:on var optSourceDiagramElementDescription = this.mapDescriptionIdToDescription(optSourceDiagramElementDescriptionId.get(), diagramDescription, sourceDiagramElement); var optTargetDiagramElementDescription = this.mapDescriptionIdToDescription(optTargetDiagramElementDescriptionId.get(), diagramDescription, targetDiagramElement); @@ -120,17 +115,20 @@ public List getConnectorTools(Object sourceDiagramElement, Object targetD Object sourceDiagramElementDescription = optSourceDiagramElementDescription.get(); Object targetDiagramElementDescription = optTargetDiagramElementDescription.get(); - //@formatter:off - return diagramDescription.getToolSections().stream() - .map(ToolSection::getTools) - .flatMap(List::stream) + return diagramDescription.getPalettes().stream() + .flatMap(palette -> Stream.concat( + palette.getTools().stream(), + palette.getToolSections().stream() + .flatMap(section -> section.getTools().stream()) + )) .filter(SingleClickOnTwoDiagramElementsTool.class::isInstance) .map(SingleClickOnTwoDiagramElementsTool.class::cast) - .filter(tool -> tool.getCandidates().stream().anyMatch(candidate -> candidate.getSources().contains(sourceDiagramElementDescription) && candidate.getTargets().contains(targetDiagramElementDescription))) + .filter(tool -> tool.getCandidates().stream() + .anyMatch(candidate -> candidate.getSources().contains(sourceDiagramElementDescription) && candidate.getTargets() + .contains(targetDiagramElementDescription))) .filter(tool -> this.filterTool(tool, optSourceSemanticElement.get(), optTargetSemanticElement.get(), sourceDiagramElement, targetDiagramElement, siriusDiagramDescription)) .map(ITool.class::cast) .toList(); - //@formatter:on } } @@ -180,7 +178,8 @@ private boolean filterTool(ITool tool, Object sourceSemanticElement, Object targ var optionalVsmElementId = this.identifierProvider.findVsmElementId(tool.getId()); if (optionalVsmElementId.isPresent()) { var optionalSiriusTool = this.odesignRegistry.getODesigns().stream().map(EObject::eResource) - .map(resource -> resource.getResourceSet().getEObject(URI.createURI(optionalVsmElementId.get()), false)).filter(Objects::nonNull).filter(AbstractToolDescription.class::isInstance) + .map(resource -> resource.getResourceSet().getEObject(URI.createURI(optionalVsmElementId.get()), false)).filter(Objects::nonNull) + .filter(AbstractToolDescription.class::isInstance) .map(AbstractToolDescription.class::cast).findFirst(); if (optionalSiriusTool.isPresent()) { AbstractToolDescription siriusTool = optionalSiriusTool.get(); diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionNodeAndEdgeDescriptionsPopulator.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionNodeAndEdgeDescriptionsPopulator.java index 4de1ac5c6a4..86157c6b809 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionNodeAndEdgeDescriptionsPopulator.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionNodeAndEdgeDescriptionsPopulator.java @@ -123,13 +123,12 @@ public Builder populate(Builder builder, DiagramDescription siriusDiagramDescrip return builder.nodeDescriptions(allNodeDescriptions) .edgeDescriptions(edgeDescriptions) .dropHandler(dropHandler) - .toolSections(this.toolProvider.getToolSections(id2NodeDescriptions, edgeDescriptions, siriusDiagramDescription, layers)); + .palettes(List.of(this.toolProvider.getPalette(id2NodeDescriptions, edgeDescriptions, siriusDiagramDescription, layers))); // @formatter:on } private boolean isEnabledByDefault(Layer layer) { - if (layer instanceof AdditionalLayer) { - AdditionalLayer additionalLayer = (AdditionalLayer) layer; + if (layer instanceof AdditionalLayer additionalLayer) { return !additionalLayer.isOptional() || additionalLayer.isActiveByDefault(); } return true; diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/IToolProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/IToolProvider.java index a2039d840b6..86e547cccaf 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/IToolProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/IToolProvider.java @@ -17,7 +17,7 @@ import org.eclipse.sirius.components.diagrams.description.EdgeDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.diagram.description.DiagramDescription; import org.eclipse.sirius.diagram.description.Layer; @@ -27,5 +27,6 @@ * @author sbegaudeau */ public interface IToolProvider { - List getToolSections(Map id2NodeDescriptions, List edgeDescriptions, DiagramDescription siriusDiagramDescription, List layers); + + Palette getPalette(Map id2NodeDescriptions, List edgeDescriptions, DiagramDescription siriusDiagramDescription, List layers); } diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java index 5b49490c433..1419d3e9300 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java @@ -35,6 +35,7 @@ import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; import org.eclipse.sirius.components.diagrams.tools.ITool; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool; @@ -123,7 +124,8 @@ public ToolProvider(IIdentifierProvider identifierProvider, IAQLInterpreterFacto } @Override - public List getToolSections(Map id2NodeDescriptions, List edgeDescriptions, DiagramDescription siriusDiagramDescription, List layers) { + public Palette getPalette(Map id2NodeDescriptions, List edgeDescriptions, DiagramDescription siriusDiagramDescription, + List layers) { List result = new ArrayList<>(); var siriusToolSections = layers @@ -135,19 +137,17 @@ public List getToolSections(Map id2NodeDes AQLInterpreter interpreter = this.interpreterFactory.create(siriusDiagramDescription); for (var siriusToolSection : siriusToolSections) { - // @formatter:off List tools = this.getToolDescriptions(siriusToolSection).stream() .filter(this::isSupported) .map(toolDescription -> this.convertTool(id2NodeDescriptions, edgeDescriptions, siriusDiagramDescription, toolDescription, interpreter)) .flatMap(Optional::stream) .toList(); - // @formatter:on if (!tools.isEmpty()) { ToolSection toolSection = this.convertToolSection(siriusToolSection, tools); result.add(toolSection); } } - return result; + return Palette.newPalette("").tools(List.of()).toolSections(result).build(); } private boolean isSupported(AbstractToolDescription toolDescription) { @@ -211,23 +211,17 @@ private boolean atLeastOneRootMapping(List nodeMa private Optional convertTool(Map id2NodeDescriptions, List edgeDescriptions, org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription, AbstractToolDescription siriusTool, AQLInterpreter interpreter) { Optional result = Optional.empty(); - if (siriusTool instanceof NodeCreationDescription) { - NodeCreationDescription nodeCreationTool = (NodeCreationDescription) siriusTool; + if (siriusTool instanceof NodeCreationDescription nodeCreationTool) { result = Optional.of(this.convertNodeCreationDescription(id2NodeDescriptions, interpreter, nodeCreationTool)); - } else if (siriusTool instanceof ContainerCreationDescription) { - ContainerCreationDescription containerCreationDescription = (ContainerCreationDescription) siriusTool; + } else if (siriusTool instanceof ContainerCreationDescription containerCreationDescription) { result = Optional.of(this.convertContainerCreationDescription(id2NodeDescriptions, interpreter, containerCreationDescription)); - } else if (siriusTool instanceof org.eclipse.sirius.viewpoint.description.tool.ToolDescription) { - org.eclipse.sirius.viewpoint.description.tool.ToolDescription toolDescription = (org.eclipse.sirius.viewpoint.description.tool.ToolDescription) siriusTool; + } else if (siriusTool instanceof ToolDescription toolDescription) { result = Optional.of(this.convertToolDescription(id2NodeDescriptions, edgeDescriptions, interpreter, siriusDiagramDescription, toolDescription)); - } else if (siriusTool instanceof EdgeCreationDescription) { - EdgeCreationDescription edgeCreationDescription = (EdgeCreationDescription) siriusTool; + } else if (siriusTool instanceof EdgeCreationDescription edgeCreationDescription) { result = Optional.of(this.convertEdgeCreationDescription(id2NodeDescriptions, interpreter, edgeCreationDescription)); - } else if (siriusTool instanceof DeleteElementDescription) { - DeleteElementDescription deleteElementDescription = (DeleteElementDescription) siriusTool; + } else if (siriusTool instanceof DeleteElementDescription deleteElementDescription) { result = Optional.of(this.convertDeleteElementDescription(id2NodeDescriptions, interpreter, deleteElementDescription)); - } else if (siriusTool instanceof OperationAction) { - OperationAction operationAction = (OperationAction) siriusTool; + } else if (siriusTool instanceof OperationAction operationAction) { result = Optional.of(this.convertOperationAction(id2NodeDescriptions, edgeDescriptions, interpreter, siriusDiagramDescription, operationAction)); } @@ -468,7 +462,7 @@ private Function createContainerCreationHandler(AQLInt Optional.ofNullable(variables.get(IDiagramContext.DIAGRAM_CONTEXT)) .filter(IDiagramContext.class::isInstance) .map(IDiagramContext.class::cast) - .ifPresent(diagramContext -> variables.put(CONTAINER_VIEW, diagramContext.getDiagram())); + .ifPresent(diagramContext -> variables.put(CONTAINER_VIEW, diagramContext.getDiagram())); } var selectModelelementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(toolDescription.getVariable()); if (selectModelelementVariableOpt.isPresent()) { diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/ToolService.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/ToolService.java index dbcf8bbbb53..359312e9480 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/ToolService.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/ToolService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Obeo. + * Copyright (c) 2019, 2023 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 @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.sirius.components.collaborative.diagrams; -import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Stream; import org.eclipse.sirius.components.collaborative.diagrams.api.IToolService; import org.eclipse.sirius.components.core.api.IEditingContext; @@ -23,7 +23,7 @@ import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.diagrams.description.DiagramDescription; import org.eclipse.sirius.components.diagrams.tools.ITool; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.springframework.stereotype.Service; /** @@ -40,26 +40,25 @@ public ToolService(IRepresentationDescriptionSearchService representationDescrip this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService); } - private List getToolSections(IEditingContext editingContext, Diagram diagram) { - // @formatter:off + private List getPalettes(IEditingContext editingContext, Diagram diagram) { return this.representationDescriptionSearchService.findById(editingContext, diagram.getDescriptionId()) - .filter(DiagramDescription.class::isInstance) - .map(DiagramDescription.class::cast) - .map(DiagramDescription::getToolSections) - .orElse(List.of()); - // @formatter:on + .filter(DiagramDescription.class::isInstance) + .map(DiagramDescription.class::cast) + .map(DiagramDescription::getPalettes) + .orElse(List.of()); } @Override public Optional findToolById(IEditingContext editingContext, Diagram diagram, String toolId) { - // @formatter:off - return this.getToolSections(editingContext, diagram) + return this.getPalettes(editingContext, diagram) .stream() - .map(ToolSection::getTools) - .flatMap(Collection::stream) + .flatMap(palette -> Stream.concat( + palette.getTools().stream(), + palette.getToolSections().stream() + .flatMap(toolSection -> toolSection.getTools().stream()) + )) .filter(tool -> Objects.equals(tool.getId(), toolId)) .findFirst(); - // @formatter:on } } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IToolSectionsProvider.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IPaletteProvider.java similarity index 74% rename from packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IToolSectionsProvider.java rename to packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IPaletteProvider.java index 26575e0a4c5..0cd21c23ea4 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IToolSectionsProvider.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/api/IPaletteProvider.java @@ -12,20 +12,18 @@ *******************************************************************************/ package org.eclipse.sirius.components.collaborative.diagrams.api; -import java.util.List; - -import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolSection; +import org.eclipse.sirius.components.collaborative.diagrams.dto.Palette; import org.eclipse.sirius.components.diagrams.description.DiagramDescription; /** - * Provide the tool sections for a given diagram element. + * Provide the tool palette for a given diagram element. * * @author arichard */ -public interface IToolSectionsProvider { +public interface IPaletteProvider { boolean canHandle(DiagramDescription diagramDescription); - List handle(Object targetElement, Object diagramElement, Object diagramElementDescription, DiagramDescription diagramDescription); + Palette handle(Object targetElement, Object diagramElement, Object diagramElementDescription, DiagramDescription diagramDescription); } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionsInput.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteInput.java similarity index 78% rename from packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionsInput.java rename to packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteInput.java index 6e4b212d56a..ae39ccfde3d 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionsInput.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteInput.java @@ -17,9 +17,9 @@ import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput; /** - * The input for the "Get Tool Sections" query. + * The input for the "Get Palette" query. * * @author arichard */ -public record GetToolSectionsInput(UUID id, String editingContextId, String representationId, String diagramElementId) implements IDiagramInput { +public record GetPaletteInput(UUID id, String editingContextId, String representationId, String diagramElementId) implements IDiagramInput { } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionSuccessPayload.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteSuccessPayload.java similarity index 72% rename from packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionSuccessPayload.java rename to packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteSuccessPayload.java index 25604d46949..2f3faa9efbe 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetToolSectionSuccessPayload.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/GetPaletteSuccessPayload.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.components.collaborative.diagrams.dto; -import java.util.List; import java.util.Objects; import java.util.UUID; @@ -20,13 +19,14 @@ /** - * The payload of the "Get Tool Sections" query returned on success. + * The payload of the "Get Palette" query returned on success. * * @author arichard */ -public record GetToolSectionSuccessPayload(UUID id, List toolSections) implements IPayload { - public GetToolSectionSuccessPayload { +public record GetPaletteSuccessPayload(UUID id, Palette palette) implements IPayload { + + public GetPaletteSuccessPayload { Objects.requireNonNull(id); - Objects.requireNonNull(toolSections); + Objects.requireNonNull(palette); } } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/Palette.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/Palette.java new file mode 100644 index 00000000000..fbde2fb1fe0 --- /dev/null +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/Palette.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagrams.dto; + +import java.util.List; +import java.util.Objects; + +/** + * A palette, contains direct tools and toolSections. + * + * @author frouene + */ +public record Palette(String id, List tools, List toolSections) { + + public Palette { + Objects.requireNonNull(id); + Objects.requireNonNull(tools); + Objects.requireNonNull(toolSections); + } + + public static Builder newPalette(String id) { + return new Builder(id); + } + + /** + * The builder used to create a pallette. + * + * @author frouene + */ + @SuppressWarnings("checkstyle:HiddenField") + @org.eclipse.sirius.components.annotations.Builder + public static final class Builder { + + private final String id; + + private List tools; + + private List toolSections; + + private Builder(String id) { + this.id = Objects.requireNonNull(id); + } + + public Builder tools(List tools) { + this.tools = Objects.requireNonNull(tools); + return this; + } + + public Builder toolSections(List toolSections) { + this.toolSections = Objects.requireNonNull(toolSections); + return this; + } + + public Palette build() { + return new Palette(this.id, this.tools, this.toolSections); + } + } + +} diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetToolSectionsEventHandler.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetPaletteEventHandler.java similarity index 87% rename from packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetToolSectionsEventHandler.java rename to packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetPaletteEventHandler.java index e81b48ae107..50218c0c661 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetToolSectionsEventHandler.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetPaletteEventHandler.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.components.collaborative.diagrams.handlers; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -25,10 +24,10 @@ import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramQueryService; -import org.eclipse.sirius.components.collaborative.diagrams.api.IToolSectionsProvider; -import org.eclipse.sirius.components.collaborative.diagrams.dto.GetToolSectionSuccessPayload; -import org.eclipse.sirius.components.collaborative.diagrams.dto.GetToolSectionsInput; -import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolSection; +import org.eclipse.sirius.components.collaborative.diagrams.api.IPaletteProvider; +import org.eclipse.sirius.components.collaborative.diagrams.dto.GetPaletteInput; +import org.eclipse.sirius.components.collaborative.diagrams.dto.GetPaletteSuccessPayload; +import org.eclipse.sirius.components.collaborative.diagrams.dto.Palette; import org.eclipse.sirius.components.collaborative.messages.ICollaborativeMessageService; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; @@ -51,7 +50,7 @@ * @author arichard */ @Service -public class GetToolSectionsEventHandler implements IDiagramEventHandler { +public class GetPaletteEventHandler implements IDiagramEventHandler { private final IRepresentationDescriptionSearchService representationDescriptionSearchService; @@ -61,14 +60,14 @@ public class GetToolSectionsEventHandler implements IDiagramEventHandler { private final IObjectService objectService; - private final List toolSectionsProviders; + private final List toolSectionsProviders; private final ICollaborativeMessageService messageService; private final Counter counter; - public GetToolSectionsEventHandler(IRepresentationDescriptionSearchService representationDescriptionSearchService, IDiagramQueryService diagramQueryService, - IDiagramDescriptionService diagramDescriptionService, IObjectService objectService, List toolSectionsProviders, ICollaborativeMessageService messageService, + public GetPaletteEventHandler(IRepresentationDescriptionSearchService representationDescriptionSearchService, IDiagramQueryService diagramQueryService, + IDiagramDescriptionService diagramDescriptionService, IObjectService objectService, List toolSectionsProviders, ICollaborativeMessageService messageService, MeterRegistry meterRegistry) { this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService); this.diagramQueryService = Objects.requireNonNull(diagramQueryService); @@ -77,35 +76,30 @@ public GetToolSectionsEventHandler(IRepresentationDescriptionSearchService repre this.toolSectionsProviders = Objects.requireNonNull(toolSectionsProviders); this.messageService = Objects.requireNonNull(messageService); - // @formatter:off this.counter = Counter.builder(Monitoring.EVENT_HANDLER) .tag(Monitoring.NAME, this.getClass().getSimpleName()) .register(meterRegistry); - // @formatter:on } @Override public boolean canHandle(IDiagramInput diagramInput) { - return diagramInput instanceof GetToolSectionsInput; + return diagramInput instanceof GetPaletteInput; } @Override public void handle(One payloadSink, Many changeDescriptionSink, IEditingContext editingContext, IDiagramContext diagramContext, IDiagramInput diagramInput) { this.counter.increment(); - List toolSections = new ArrayList<>(); + Palette palette = null; ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, editingContext.getId(), diagramInput); - if (diagramInput instanceof GetToolSectionsInput) { - GetToolSectionsInput toolSectionsInput = (GetToolSectionsInput) diagramInput; + if (diagramInput instanceof GetPaletteInput toolSectionsInput) { String diagramElementId = toolSectionsInput.diagramElementId(); Diagram diagram = diagramContext.getDiagram(); - // @formatter:off var optionalDiagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagram.getDescriptionId()) .filter(DiagramDescription.class::isInstance) .map(DiagramDescription.class::cast); - // @formatter:on if (optionalDiagramDescription.isPresent()) { DiagramDescription diagramDescription = optionalDiagramDescription.get(); var optionalToolSectionsProvider = this.toolSectionsProviders.stream().filter(toolSectionProvider -> toolSectionProvider.canHandle(diagramDescription)).findFirst(); @@ -114,13 +108,13 @@ public void handle(One payloadSink, Many changeDesc var optionalDiagramElementDescription = this.findDiagramElementDescription(diagram, diagramElementId, diagramDescription, optionalDiagramElement.orElse(null)); if (optionalToolSectionsProvider.isPresent() && optionalTargetElement.isPresent() && optionalDiagramElementDescription.isPresent()) { - IToolSectionsProvider toolSectionsProvider = optionalToolSectionsProvider.get(); - toolSections = toolSectionsProvider.handle(optionalTargetElement.get(), optionalDiagramElement.orElse(null), optionalDiagramElementDescription.get(), + IPaletteProvider toolSectionsProvider = optionalToolSectionsProvider.get(); + palette = toolSectionsProvider.handle(optionalTargetElement.get(), optionalDiagramElement.orElse(null), optionalDiagramElementDescription.get(), diagramDescription); } } } - payloadSink.tryEmitValue(new GetToolSectionSuccessPayload(diagramInput.id(), toolSections)); + payloadSink.tryEmitValue(new GetPaletteSuccessPayload(diagramInput.id(), palette)); changeDescriptionSink.tryEmitNext(changeDescription); } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls index 5091f4c18d2..5a4caa3475e 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls @@ -159,6 +159,12 @@ type Size { width: Float! } +type Palette { + id: ID! + tools: [Tool]! + toolSections: [ToolSection]! +} + type ToolSection { id: ID! label: String! @@ -199,7 +205,7 @@ type DiagramDescription implements RepresentationDescription { autoLayout: Boolean! nodeDescriptions: [NodeDescription!]! edgeDescriptions: [EdgeDescription!]! - toolSections(diagramElementId: ID!): [ToolSection!]! + palette(diagramElementId: ID!): Palette! connectorTools(sourceDiagramElementId: ID!, targetDiagramElementId: ID!): [Tool!]! initialDirectEditElementLabel(labelId: ID!): String! debug: Boolean @@ -324,9 +330,9 @@ input InvokeSingleClickOnDiagramElementToolInput { union InvokeSingleClickOnDiagramElementToolPayload = ErrorPayload | InvokeSingleClickOnDiagramElementToolSuccessPayload type InvokeSingleClickOnDiagramElementToolSuccessPayload { - id: ID! - newSelection: WorkbenchSelection - messages: [Message]! + id: ID! + newSelection: WorkbenchSelection + messages: [Message]! } input UpdateNodeBoundsInput { diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/CreateDiagramEventHandlerTests.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/CreateDiagramEventHandlerTests.java index bbe3a729476..8dda7865197 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/CreateDiagramEventHandlerTests.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/CreateDiagramEventHandlerTests.java @@ -49,6 +49,7 @@ * @author sbegaudeau */ public class CreateDiagramEventHandlerTests { + @Test public void testDiagramCreation() { IRepresentationDescriptionSearchService representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() { @@ -60,7 +61,7 @@ public Optional findById(IEditingContext editingCont .canCreatePredicate(variableManager -> Boolean.TRUE) .edgeDescriptions(new ArrayList<>()) .labelProvider(variableManager -> "label") - .toolSections(List.of()) + .palettes(List.of()) .nodeDescriptions(new ArrayList<>()) .targetObjectIdProvider(variableManager -> "targetObjectId") .dropHandler(variableManager -> new Failure("")) diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetConnectorToolsEventHandlerTests.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetConnectorToolsEventHandlerTests.java index 7ca97a3f446..88bd56d48a1 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetConnectorToolsEventHandlerTests.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/GetConnectorToolsEventHandlerTests.java @@ -45,9 +45,9 @@ import org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder; import org.eclipse.sirius.components.diagrams.tests.TestDiagramDescriptionBuilder; import org.eclipse.sirius.components.diagrams.tools.ITool; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsCandidate; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; import org.eclipse.sirius.components.representations.Failure; import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.eclipse.sirius.components.representations.Success; @@ -153,10 +153,9 @@ public void testGetConnectorTools() { .imageURL("") .build(); - ToolSection toolSection = ToolSection.newToolSection(TOOLSECTION_ID) - .label(TOOLSECTION_LABEL) + Palette palette = Palette.newPalette(TOOLSECTION_ID) .tools(List.of(connectorTool, notConnectorTool)) - .imageURL("") + .toolSections(List.of()) .build(); DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription(DIAGRAM_DESCRIPTION_ID.toString()) @@ -166,7 +165,7 @@ public void testGetConnectorTools() { .labelProvider(variableManager -> DIAGRAM_LABEL) .nodeDescriptions(List.of(nodeDescription)) .edgeDescriptions(new ArrayList<>()) - .toolSections(List.of(toolSection)) + .palettes(List.of(palette)) .dropHandler(variableManager -> new Failure("")) .build(); //@formatter:on diff --git a/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionToolSectionsDataFetcher.java b/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionPaletteDataFetcher.java similarity index 70% rename from packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionToolSectionsDataFetcher.java rename to packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionPaletteDataFetcher.java index b88ece85647..35ed7c6ef9a 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionToolSectionsDataFetcher.java +++ b/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/diagram/DiagramDescriptionPaletteDataFetcher.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.sirius.components.diagrams.graphql.datafetchers.diagram; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +20,9 @@ import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry; -import org.eclipse.sirius.components.collaborative.diagrams.dto.GetToolSectionSuccessPayload; -import org.eclipse.sirius.components.collaborative.diagrams.dto.GetToolSectionsInput; -import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolSection; +import org.eclipse.sirius.components.collaborative.diagrams.dto.GetPaletteSuccessPayload; +import org.eclipse.sirius.components.collaborative.diagrams.dto.GetPaletteInput; +import org.eclipse.sirius.components.collaborative.diagrams.dto.Palette; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; import org.eclipse.sirius.components.graphql.api.LocalContextConstants; @@ -35,37 +34,35 @@ * * @author sbegaudeau */ -@QueryDataFetcher(type = "DiagramDescription", field = "toolSections") -public class DiagramDescriptionToolSectionsDataFetcher implements IDataFetcherWithFieldCoordinates>> { +@QueryDataFetcher(type = "DiagramDescription", field = "palette") +public class DiagramDescriptionPaletteDataFetcher implements IDataFetcherWithFieldCoordinates> { private static final String DIAGRAM_ELEMENT_ID = "diagramElementId"; private final IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry; - public DiagramDescriptionToolSectionsDataFetcher(IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry) { + public DiagramDescriptionPaletteDataFetcher(IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry) { this.editingContextEventProcessorRegistry = Objects.requireNonNull(editingContextEventProcessorRegistry); } @Override - public CompletableFuture> get(DataFetchingEnvironment environment) throws Exception { + public CompletableFuture get(DataFetchingEnvironment environment) throws Exception { Map localContext = environment.getLocalContext(); String editingContextId = Optional.ofNullable(localContext.get(LocalContextConstants.EDITING_CONTEXT_ID)).map(Object::toString).orElse(null); String representationId = Optional.ofNullable(localContext.get(LocalContextConstants.REPRESENTATION_ID)).map(Object::toString).orElse(null); String diagramElementId = environment.getArgument(DIAGRAM_ELEMENT_ID); if (editingContextId != null && representationId != null) { - GetToolSectionsInput input = new GetToolSectionsInput(UUID.randomUUID(), editingContextId, representationId, diagramElementId); + GetPaletteInput input = new GetPaletteInput(UUID.randomUUID(), editingContextId, representationId, diagramElementId); - // @formatter:off return this.editingContextEventProcessorRegistry.dispatchEvent(input.editingContextId(), input) - .filter(GetToolSectionSuccessPayload.class::isInstance) - .map(GetToolSectionSuccessPayload.class::cast) - .map(GetToolSectionSuccessPayload::toolSections) + .filter(GetPaletteSuccessPayload.class::isInstance) + .map(GetPaletteSuccessPayload.class::cast) + .map(GetPaletteSuccessPayload::palette) .toFuture(); - // @formatter:on } - return Mono.> empty().toFuture(); + return Mono.empty().toFuture(); } } diff --git a/packages/diagrams/backend/sirius-components-diagrams-layout/src/test/java/org/eclipse/sirius/components/diagrams/layout/services/DefaultTestDiagramDescriptionProvider.java b/packages/diagrams/backend/sirius-components-diagrams-layout/src/test/java/org/eclipse/sirius/components/diagrams/layout/services/DefaultTestDiagramDescriptionProvider.java index 66d19fd3efc..ed53551fd35 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-layout/src/test/java/org/eclipse/sirius/components/diagrams/layout/services/DefaultTestDiagramDescriptionProvider.java +++ b/packages/diagrams/backend/sirius-components-diagrams-layout/src/test/java/org/eclipse/sirius/components/diagrams/layout/services/DefaultTestDiagramDescriptionProvider.java @@ -69,7 +69,7 @@ public class DefaultTestDiagramDescriptionProvider { private IObjectService objectService; - private Function targetObjectIdProvider = variableManager -> { + private final Function targetObjectIdProvider = variableManager -> { // @formatter:off return variableManager.get(VariableManager.SELF, Object.class) .map(this.objectService::getId) @@ -77,7 +77,7 @@ public class DefaultTestDiagramDescriptionProvider { // @formatter:on }; - private Function nodeStyleProvider = variableManager -> { + private final Function nodeStyleProvider = variableManager -> { // @formatter:off String prefix = variableManager.get(VariableManager.SELF, Element.class) .map(Element::getName) @@ -127,7 +127,7 @@ public class DefaultTestDiagramDescriptionProvider { return nodeStyle; }; - private Function nodeTypeProvider = variableManager -> { + private final Function nodeTypeProvider = variableManager -> { // @formatter:off return variableManager.get(VariableManager.SELF, Element.class) .map(Element::getName) @@ -159,7 +159,7 @@ public class DefaultTestDiagramDescriptionProvider { // @formatter:on }; - private Function childrenLayoutStrategyProvider = variableManager -> { + private final Function childrenLayoutStrategyProvider = variableManager -> { // @formatter:off return variableManager.get(VariableManager.SELF, Element.class) .map(Element::getName) @@ -188,7 +188,7 @@ public class DefaultTestDiagramDescriptionProvider { // @formatter:on }; - private Function labelProvider = variableManager -> { + private final Function labelProvider = variableManager -> { // @formatter:off return variableManager.get(VariableManager.SELF, Element.class) .map(Element::getName) @@ -199,7 +199,7 @@ public class DefaultTestDiagramDescriptionProvider { // @formatter:on }; - private Function> nodeSemanticElementProvider = variableManager -> { + private final Function> nodeSemanticElementProvider = variableManager -> { return variableManager.get(VariableManager.SELF, Element.class) .map(Element::getChildren) .orElse(List.of()) @@ -286,7 +286,7 @@ public DiagramDescription getDefaultDiagramDescription(Diagram diagram) { .targetObjectIdProvider(this.targetObjectIdProvider) .canCreatePredicate(variableManager -> false) .labelProvider(variableManager -> variableManager.get(DiagramDescription.LABEL, String.class).orElse("")) - .toolSections(List.of()) + .palettes(List.of()) .nodeDescriptions(List.of(nodeDescription)) .edgeDescriptions(List.of(edgeDescription)) .dropHandler(variableManager -> new Failure("")) @@ -312,8 +312,7 @@ private EdgeDescription getDefaultEdgeDescription(Diagram diagram, LabelDescript List objects = new ArrayList<>(); DiagramRenderingCache cache = optionalCache.get(); for (org.eclipse.sirius.components.representations.Element nodeElement : cache.getNodeToObject().keySet()) { - if (nodeElement.getProps() instanceof NodeElementProps) { - NodeElementProps props = (NodeElementProps) nodeElement.getProps(); + if (nodeElement.getProps() instanceof NodeElementProps props) { if (nodeDescriptionIds.contains(props.getDescriptionId())) { Object object = cache.getNodeToObject().get(nodeElement); objects.add(object); diff --git a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/TestDiagramDescriptionBuilder.java b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/TestDiagramDescriptionBuilder.java index d6a52d0884b..5a03567f8ea 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/TestDiagramDescriptionBuilder.java +++ b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/TestDiagramDescriptionBuilder.java @@ -28,7 +28,7 @@ import org.eclipse.sirius.components.diagrams.description.LabelDescription; import org.eclipse.sirius.components.diagrams.description.LabelStyleDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.representations.Element; import org.eclipse.sirius.components.representations.Failure; import org.eclipse.sirius.components.representations.Success; @@ -41,7 +41,8 @@ */ public class TestDiagramDescriptionBuilder { - public DiagramDescription getDiagramDescription(String diagramDescriptionId, List nodeDescriptions, List edgeDescriptions, List toolSections) { + public DiagramDescription getDiagramDescription(String diagramDescriptionId, List nodeDescriptions, List edgeDescriptions, + List palettes) { // @formatter:off return DiagramDescription.newDiagramDescription(diagramDescriptionId) .label("") @@ -50,7 +51,7 @@ public DiagramDescription getDiagramDescription(String diagramDescriptionId, Lis .labelProvider(variableManager -> "Diagram") .nodeDescriptions(nodeDescriptions) .edgeDescriptions(edgeDescriptions) - .toolSections(toolSections) + .palettes(palettes) .dropHandler(variableManager -> new Failure("")) .build(); // @formatter:on diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/description/DiagramDescription.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/description/DiagramDescription.java index d0305fd429b..452fcb81746 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/description/DiagramDescription.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/description/DiagramDescription.java @@ -19,7 +19,7 @@ import java.util.function.Predicate; import org.eclipse.sirius.components.annotations.Immutable; -import org.eclipse.sirius.components.diagrams.tools.ToolSection; +import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; @@ -53,7 +53,7 @@ public final class DiagramDescription implements IRepresentationDescription { private Function labelProvider; - private List toolSections; + private List palettes; private List nodeDescriptions; @@ -65,6 +65,14 @@ private DiagramDescription() { // Prevent instantiation } + public static Builder newDiagramDescription(String id) { + return new Builder(id); + } + + public static Builder newDiagramDescription(DiagramDescription diagramDescription) { + return new Builder(diagramDescription); + } + @Override public String getId() { return this.id; @@ -92,8 +100,8 @@ public Function getLabelProvider() { return this.labelProvider; } - public List getToolSections() { - return this.toolSections; + public List getPalettes() { + return this.palettes; } public List getNodeDescriptions() { @@ -108,14 +116,6 @@ public Function getDropHandler() { return this.dropHandler; } - public static Builder newDiagramDescription(String id) { - return new Builder(id); - } - - public static Builder newDiagramDescription(DiagramDescription diagramDescription) { - return new Builder(diagramDescription); - } - @Override public String toString() { String pattern = "{0} '{'id: {1}, label: {2}, nodeDescriptionCount: {3}, edgeDescriptionCount: {4}'}'"; @@ -129,7 +129,8 @@ public String toString() { */ @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private String id; + + private final String id; private String label; @@ -141,7 +142,7 @@ public static final class Builder { private Function labelProvider; - private List toolSections; + private List palettes; private List nodeDescriptions; @@ -160,7 +161,7 @@ private Builder(DiagramDescription diagramDescription) { this.targetObjectIdProvider = diagramDescription.getTargetObjectIdProvider(); this.canCreatePredicate = diagramDescription.getCanCreatePredicate(); this.labelProvider = diagramDescription.getLabelProvider(); - this.toolSections = diagramDescription.getToolSections(); + this.palettes = diagramDescription.getPalettes(); this.nodeDescriptions = diagramDescription.getNodeDescriptions(); this.edgeDescriptions = diagramDescription.getEdgeDescriptions(); this.dropHandler = diagramDescription.getDropHandler(); @@ -191,8 +192,8 @@ public Builder labelProvider(Function labelProvider) { return this; } - public Builder toolSections(List toolSections) { - this.toolSections = Objects.requireNonNull(toolSections); + public Builder palettes(List palettes) { + this.palettes = Objects.requireNonNull(palettes); return this; } @@ -219,7 +220,7 @@ public DiagramDescription build() { diagramDescription.targetObjectIdProvider = Objects.requireNonNull(this.targetObjectIdProvider); diagramDescription.canCreatePredicate = Objects.requireNonNull(this.canCreatePredicate); diagramDescription.labelProvider = Objects.requireNonNull(this.labelProvider); - diagramDescription.toolSections = Objects.requireNonNull(this.toolSections); + diagramDescription.palettes = Objects.requireNonNull(this.palettes); diagramDescription.nodeDescriptions = Objects.requireNonNull(this.nodeDescriptions); diagramDescription.edgeDescriptions = Objects.requireNonNull(this.edgeDescriptions); diagramDescription.dropHandler = Objects.requireNonNull(this.dropHandler); diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Palette.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Palette.java new file mode 100644 index 00000000000..5328f518915 --- /dev/null +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Palette.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagrams.tools; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * A group of tools and toolSections. + * + * @author frouene + */ +@Immutable +public final class Palette { + + private String id; + + private List tools; + + private List toolSections; + + + private Palette() { + // Prevent instantiation + } + + public static Builder newPalette(String id) { + return new Builder(id); + } + + public String getId() { + return this.id; + } + + public List getTools() { + return this.tools; + } + + public List getToolSections() { + return this.toolSections; + } + + @Override + public String toString() { + String pattern = "{0} '{'id: {1}'}'"; + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id); + } + + /** + * The builder used to create a palette. + * + * @author frouene + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private final String id; + + private List tools; + + private List toolSections; + + private Builder(String id) { + this.id = Objects.requireNonNull(id); + } + + private Builder(Palette palette) { + this.id = Objects.requireNonNull(palette.id); + this.tools = Objects.requireNonNull(palette.tools); + this.toolSections = Objects.requireNonNull(palette.toolSections); + } + + public Builder tools(List tools) { + this.tools = Objects.requireNonNull(tools); + return this; + } + + public Builder toolSections(List toolSections) { + this.toolSections = Objects.requireNonNull(toolSections); + return this; + } + + public Palette build() { + Palette palette = new Palette(); + palette.id = Objects.requireNonNull(this.id); + palette.tools = Objects.requireNonNull(this.tools); + palette.toolSections = Objects.requireNonNull(this.toolSections); + return palette; + } + } +} diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementChangeVisibilityTests.java b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementChangeVisibilityTests.java index 174935df6f3..2b878ddcaa5 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementChangeVisibilityTests.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementChangeVisibilityTests.java @@ -104,7 +104,7 @@ private NodeDescription createNodeDescription(String elementId, List targetObjectIdProvider = variableManager -> { Object object = variableManager.getVariables().get(VariableManager.SELF); if (object instanceof String) { - return id.toString() + "__" + object; + return id + "__" + object; } return null; }; @@ -195,7 +195,7 @@ private Diagram createDiagram(Optional previousDiagram, List DIAGRAM_LABEL) .nodeDescriptions(nodeDescriptions) .edgeDescriptions(edgeDescriptions) - .toolSections(List.of()) + .palettes(List.of()) .dropHandler(variableManager -> new Failure("")) .build(); @@ -317,7 +317,7 @@ public DiagramTestData testHideSpreadToEdgesRendering() { assertThat(newDiagram2.getNodes()).filteredOn(n -> modifiedNodeId.contains(n.getId())).extracting(Node::getState).allMatch(s -> s == ViewModifier.Hidden); assertThat(newDiagram2.getNodes()).filteredOn(n -> !modifiedNodeIds.contains(n.getId())).extracting(Node::getState).allMatch(s -> s == ViewModifier.Normal); assertThat(newDiagram2.getEdges()).filteredOn(e -> modifiedNodeIds.contains(e.getSourceId()) || modifiedNodeIds.contains(e.getTargetId())).extracting(Edge::getState) - .allMatch(s -> s == ViewModifier.Hidden); + .allMatch(s -> s == ViewModifier.Hidden); return new DiagramTestData(diagram, nodeDescriptions, List.of(edgeDescription, edge2Description)); } diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererEdgeTests.java b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererEdgeTests.java index dc8c7c0b375..b8f85085e26 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererEdgeTests.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererEdgeTests.java @@ -144,7 +144,7 @@ private Diagram renderDiagram(List nodeDescriptions, List "Diagram") .nodeDescriptions(nodeDescriptions) .edgeDescriptions(edgeDescriptions) - .toolSections(List.of()) + .palettes(List.of()) .dropHandler(variableManager -> new Failure("")) .build(); // @formatter:on diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererNodeTests.java b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererNodeTests.java index 76e329cfa0f..9d9b4524652 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererNodeTests.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/DiagramRendererNodeTests.java @@ -92,15 +92,15 @@ public void testSimpleNodeRendering() { assertThat(diagram.getNodes()).hasSize(1); assertThat(diagram.getNodes()).extracting(Node::getTargetObjectId).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(t -> t.toString().isBlank()); + assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(String::isBlank); assertThat(diagram.getNodes()).extracting(Node::getType).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(t -> NODE_RECTANGULAR.equals(t)); + assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(NODE_RECTANGULAR::equals); assertThat(diagram.getNodes()).extracting(Node::getBorderNodes).allMatch(List::isEmpty); assertThat(diagram.getNodes()).extracting(Node::getStyle).allMatch(s -> s instanceof RectangularNodeStyle); assertThat(diagram.getNodes()).extracting(Node::getSize).allMatch(s -> s.getHeight() == -1 && s.getWidth() == -1); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getId).allMatch(id -> UUID.nameUUIDFromBytes(LABEL_ID.getBytes()).toString().equals(id)); - assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getText).allMatch(text -> LABEL_TEXT.equals(text)); - assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getColor).allMatch(color -> LABEL_COLOR.equals(color)); + assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getText).allMatch(LABEL_TEXT::equals); + assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getColor).allMatch(LABEL_COLOR::equals); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getFontSize).allMatch(size -> LABEL_FONT_SIZE == size); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::isBold).allMatch(bold -> bold); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::isItalic).allMatch(italic -> italic); @@ -129,15 +129,15 @@ public void testSimpleNodeRenderingWithSizeProvider() { assertThat(diagram.getNodes()).hasSize(1); assertThat(diagram.getNodes()).extracting(Node::getTargetObjectId).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(t -> t.toString().isBlank()); + assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(String::isBlank); assertThat(diagram.getNodes()).extracting(Node::getType).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(t -> NODE_RECTANGULAR.equals(t)); + assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(NODE_RECTANGULAR::equals); assertThat(diagram.getNodes()).extracting(Node::getBorderNodes).allMatch(List::isEmpty); assertThat(diagram.getNodes()).extracting(Node::getStyle).allMatch(s -> s instanceof RectangularNodeStyle); assertThat(diagram.getNodes()).extracting(Node::getSize).allMatch(s -> s.getHeight() == 200 && s.getWidth() == 10); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getId).allMatch(id -> UUID.nameUUIDFromBytes(LABEL_ID.getBytes()).toString().equals(id)); - assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getText).allMatch(text -> LABEL_TEXT.equals(text)); - assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getColor).allMatch(color -> LABEL_COLOR.equals(color)); + assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getText).allMatch(LABEL_TEXT::equals); + assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getColor).allMatch(LABEL_COLOR::equals); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::getFontSize).allMatch(size -> LABEL_FONT_SIZE == size); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::isBold).allMatch(bold -> bold); assertThat(diagram.getNodes()).extracting(Node::getLabel).extracting(Label::getStyle).extracting(LabelStyle::isItalic).allMatch(italic -> italic); @@ -217,9 +217,9 @@ public void testImageNodeRendering() { assertThat(diagram.getNodes()).hasSize(1); assertThat(diagram.getNodes()).extracting(Node::getTargetObjectId).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(t -> t.toString().isBlank()); + assertThat(diagram.getNodes()).extracting(Node::getDescriptionId).noneMatch(String::isBlank); assertThat(diagram.getNodes()).extracting(Node::getType).noneMatch(String::isBlank); - assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(t -> NODE_IMAGE.equals(t)); + assertThat(diagram.getNodes()).extracting(Node::getType).allMatch(NODE_IMAGE::equals); assertThat(diagram.getNodes()).extracting(Node::getBorderNodes).allMatch(List::isEmpty); assertThat(diagram.getNodes()).extracting(Node::getStyle).allMatch(s -> s instanceof ImageNodeStyle); @@ -277,7 +277,7 @@ private Diagram createDiagram(Function styleProvide .labelProvider(variableManager -> DIAGRAM_LABEL) .nodeDescriptions(List.of(nodeDescription)) .edgeDescriptions(new ArrayList<>()) - .toolSections(List.of()) + .palettes(List.of()) .dropHandler(variableManager -> new Failure("")) .build(); // @formatter:on diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/UnsynchronizedDiagramTests.java b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/UnsynchronizedDiagramTests.java index bd586b01bd3..20e91420172 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/UnsynchronizedDiagramTests.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/test/java/org/eclipse/sirius/components/diagrams/renderer/UnsynchronizedDiagramTests.java @@ -361,7 +361,7 @@ private DiagramDescription getDiagramDescription(Function "label") .nodeDescriptions(List.of(unsynchronizedNodeDescription, synchronizedNodeDescription)) .edgeDescriptions(List.of()) - .toolSections(List.of()) + .palettes(List.of()) .dropHandler(variableManager -> new Failure("")) .build(); // @formatter:on diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.tsx b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.tsx index 092dc8fef4d..265ce47f9e7 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.tsx @@ -12,6 +12,7 @@ *******************************************************************************/ import { ServerContext, ServerContextValue } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; +import Typography from '@material-ui/core/Typography'; import { useContext } from 'react'; import { ToolProps } from './Tool.types'; @@ -25,7 +26,7 @@ const useToolStyle = makeStyles(() => ({ }, })); -export const Tool = ({ tool, onClick }: ToolProps) => { +export const Tool = ({ tool, onClick, thumbnail }: ToolProps) => { const { id, label, imageURL } = tool; const { httpOrigin } = useContext(ServerContext); const classes = useToolStyle(); @@ -33,6 +34,10 @@ export const Tool = ({ tool, onClick }: ToolProps) => { if (imageURL) { image = ; } + let labelContent: JSX.Element | null = null; + if (!thumbnail) { + labelContent = {label}; + } const onToolClick: React.MouseEventHandler = () => { onClick(tool); @@ -41,6 +46,7 @@ export const Tool = ({ tool, onClick }: ToolProps) => { return (
{image} + {labelContent}
); }; diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.types.ts b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.types.ts index 83ccc189627..34b254f2f3a 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/Tool.types.ts @@ -16,4 +16,5 @@ import { GQLTool } from './palette/Palette.types'; export interface ToolProps { tool: GQLTool; onClick: (tool: GQLTool) => void; + thumbnail?: boolean; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.tsx b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.tsx index 51c53b1e4dd..a717218c0c4 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.tsx @@ -19,9 +19,9 @@ import VisibilityOffIcon from '@material-ui/icons/VisibilityOff'; import { useCallback, useContext, useEffect, useState } from 'react'; import { DiagramContext } from '../../contexts/DiagramContext'; import { DiagramContextValue } from '../../contexts/DiagramContext.types'; -import { Tool } from '../Tool'; import { useFadeDiagramElements } from '../fade/useFadeDiagramElements'; import { useHideDiagramElements } from '../hide/useHideDiagramElements'; +import { Tool } from '../Tool'; import { ContextualPaletteStyleProps, GQLCollapsingState, @@ -35,6 +35,7 @@ import { GQLInvokeSingleClickOnDiagramElementToolData, GQLInvokeSingleClickOnDiagramElementToolInput, GQLInvokeSingleClickOnDiagramElementToolVariables, + GQLPalette, GQLRepresentationDescription, GQLSingleClickOnDiagramElementTool, GQLTool, @@ -43,6 +44,7 @@ import { GQLUpdateCollapsingStateVariables, PaletteProps, } from './Palette.types'; +import { ToolSection } from './tool-section/ToolSection'; const usePaletteStyle = makeStyles((theme) => ({ toolEntries: { @@ -57,17 +59,15 @@ const usePaletteStyle = makeStyles((theme) => ({ }, })); -export const getToolSectionsQuery = gql` - query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { +export const getPaletteQuery = gql` + query getPalette($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { viewer { editingContext(editingContextId: $editingContextId) { representation(representationId: $diagramId) { description { ... on DiagramDescription { - toolSections(diagramElementId: $diagramElementId) { + palette(diagramElementId: $diagramElementId) { id - label - imageURL tools { __typename id @@ -81,6 +81,24 @@ export const getToolSectionsQuery = gql` selectionDescriptionId } } + toolSections { + id + label + imageURL + tools { + __typename + id + label + imageURL + ... on SingleClickOnDiagramElementTool { + targetDescriptions { + id + } + appliesToDiagramRoot + selectionDescriptionId + } + } + } } } } @@ -143,52 +161,42 @@ const isDiagramDescription = ( ): representationDescription is GQLDiagramDescription => representationDescription.__typename === 'DiagramDescription'; export const Palette = ({ diagramElementId, onDirectEditClick, isNodePalette }: PaletteProps) => { - const [tools, setTools] = useState([]); + const [palette, setPalette] = useState(undefined); const { fadeDiagramElements } = useFadeDiagramElements(); const { hideDiagramElements } = useHideDiagramElements(); const { diagramId, editingContextId } = useContext(DiagramContext); - const toolCount = tools.length + (isNodePalette ? 2 : 0); + const toolCount = + (palette ? palette.tools.filter(isSingleClickOnDiagramElementTool).length + palette.toolSections.length : 0) + + (isNodePalette ? 2 : 0); const classes = usePaletteStyle({ toolCount }); - const [getTools, { loading: toolSectionsLoading, data: toolSectionsData, error: toolSectionsError }] = useLazyQuery< + const [getPalette, { loading: paletteLoading, data: paletteData, error: paletteError }] = useLazyQuery< GQLGetToolSectionsData, GQLGetToolSectionsVariables - >(getToolSectionsQuery); + >(getPaletteQuery); useEffect(() => { - if (!toolSectionsLoading) { - if (toolSectionsData) { + if (!paletteLoading) { + if (paletteData) { const representationDescription: GQLRepresentationDescription = - toolSectionsData.viewer.editingContext.representation.description; + paletteData.viewer.editingContext.representation.description; if (isDiagramDescription(representationDescription)) { - const nodeTools = representationDescription.toolSections - .flatMap((toolSection) => { - return toolSection.tools; - }) - .filter(isSingleClickOnDiagramElementTool); - setTools(nodeTools); + setPalette(representationDescription.palette); } } } - }, [ - toolSectionsLoading, - toolSectionsData, - toolSectionsError, - setTools, - isSingleClickOnDiagramElementTool, - isDiagramDescription, - ]); + }, [paletteLoading, paletteData, paletteError, setPalette, isSingleClickOnDiagramElementTool, isDiagramDescription]); useEffect(() => { - getTools({ + getPalette({ variables: { editingContextId: editingContextId, diagramId, diagramElementId, }, }); - }, [editingContextId, diagramId, getTools]); + }, [editingContextId, diagramId, getPalette]); const [deleteElementsMutation] = useMutation( deleteFromDiagramMutation @@ -292,8 +300,11 @@ export const Palette = ({ diagramElementId, onDirectEditClick, isNodePalette }: return (
- {tools.filter(isSingleClickOnDiagramElementTool).map((tool) => ( - + {palette?.tools.filter(isSingleClickOnDiagramElementTool).map((tool) => ( + + ))} + {palette?.toolSections.map((toolSection) => ( + ))} {isNodePalette ? ( <> diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.types.ts b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.types.ts index efabe460a0c..0f07fecb6dd 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/Palette.types.ts @@ -66,6 +66,7 @@ export interface GQLInvokeSingleClickOnDiagramElementToolInput { startingPositionY: number; selectedObjectId: string | null; } + export interface GQLTool { id: string; label: string; @@ -83,6 +84,7 @@ export interface GQLGetToolSectionsVariables { diagramId: string; diagramElementId: string; } + export interface GQLGetToolSectionsData { viewer: GQLViewer; } @@ -108,6 +110,12 @@ export interface GQLRepresentationDescription { } export interface GQLDiagramDescription extends GQLRepresentationDescription { + palette: GQLPalette; +} + +export interface GQLPalette { + id: string; + tools: GQLTool[]; toolSections: GQLToolSection[]; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.tsx b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.tsx new file mode 100644 index 00000000000..ea895a17734 --- /dev/null +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.tsx @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2023 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 { makeStyles } from '@material-ui/core/styles'; +import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import { useCallback, useState } from 'react'; +import { Tool } from '../../Tool'; +import { GQLSingleClickOnDiagramElementTool, GQLTool } from '../Palette.types'; +import { ToolSectionProps, ToolSectionState } from './ToolSection.types'; + +const useToolSectionStyles = makeStyles(() => ({ + toolSection: { + display: 'flex', + flexDirection: 'row', + justifyContent: 'center', + alignItems: 'center', + marginLeft: '8px', + }, + toolChoiceWrapper: { + justifyContent: 'center', + alignItems: 'center', + }, + toolChoice: { + position: 'fixed', + zIndex: 100, + marginLeft: '-20px', + marginTop: '10px', + }, + toolList: { + display: 'grid', + gridTemplateColumns: '1fr', + gridGap: '4px', + padding: '4px', + background: '#fafafa', + border: '1px solid #d1dadb', + boxShadow: '0px 2px 5px #002b3c40', + borderRadius: '2px', + color: '#002d37', + }, + modal: { + position: 'fixed', + zIndex: 1, + left: 0, + top: 0, + width: '100%', + height: '100%', + overflow: 'auto', + }, + arrow: { + cursor: 'pointer', + height: '14px', + width: '14px', + marginLeft: '-4px', + marginTop: '12px', + }, +})); + +const isSingleClickOnDiagramElementTool = (tool: GQLTool): tool is GQLSingleClickOnDiagramElementTool => + tool.__typename === 'SingleClickOnDiagramElementTool'; + +export const ToolSection = ({ toolSection, onToolClick }: ToolSectionProps) => { + const tools = toolSection.tools.filter(isSingleClickOnDiagramElementTool); + const initialState = { + expanded: false, + }; + const [state, setState] = useState(initialState); + const { expanded } = state; + + const classes = useToolSectionStyles(); + + const onActiveTool = useCallback( + (tool) => { + onToolClick(tool); + setState(() => { + return { + expanded: false, + }; + }); + }, + [onToolClick] + ); + const onExpand = useCallback(() => { + setState((prevState) => { + return { + expanded: !prevState.expanded, + }; + }); + }, []); + + let caretContent; + if (tools.length > 1) { + caretContent = ( + onExpand()} + data-testid="expand" + /> + ); + } + let toolChoiceContent: JSX.Element | undefined; + if (expanded) { + toolChoiceContent = ( + <> +
+
+
+ {tools.map((tool) => { + return onActiveTool(tool)} key={tool.id} />; + })} +
+
+
+
onExpand()}>
+ + ); + } + let defaultTool: GQLTool = tools[0]; + return ( + <> +
+ onToolClick(defaultTool)} thumbnail /> + {caretContent} +
+ {toolChoiceContent} + + ); +}; diff --git a/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.types.ts b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.types.ts new file mode 100644 index 00000000000..642c378c08a --- /dev/null +++ b/packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/palette/tool-section/ToolSection.types.ts @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2022, 2023 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 { GQLTool, GQLToolSection } from '../Palette.types'; + +export interface ToolSectionProps { + toolSection: GQLToolSection; + onToolClick: (tool: GQLTool) => void; +} + +export interface ToolSectionState { + expanded: boolean; +} diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx index f816bc719d3..c34f9ffd066 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.tsx @@ -15,7 +15,7 @@ import { Toast } from '@eclipse-sirius/sirius-components-core'; import { makeStyles } from '@material-ui/core/styles'; import { useMachine } from '@xstate/react'; import { useCallback, useEffect } from 'react'; -import { EditLabelAction, SModelElement, isWithEditableLabel } from 'sprotty'; +import { EditLabelAction, isWithEditableLabel, SModelElement } from 'sprotty'; import { GQLDeletionPolicy } from '../representation/DiagramRepresentation.types'; import { BorderNode, Diagram, Edge, Node, ViewModifier } from '../sprotty/Diagram.types'; import { HIDE_CONTEXTUAL_TOOLBAR_ACTION } from '../sprotty/DiagramServer'; @@ -27,8 +27,8 @@ import { GQLFadeDiagramElementData, GQLFadeDiagramElementInput, GQLFadeDiagramElementVariables, - GQLGetToolSectionsData, - GQLGetToolSectionsVariables, + GQLGetPaletteData, + GQLGetPaletteVariables, GQLHideDiagramElementData, GQLHideDiagramElementInput, GQLHideDiagramElementVariables, @@ -41,11 +41,11 @@ import { import { ContextualPaletteContext, ContextualPaletteEvent, + contextualPaletteMachine, HandleToolSectionsResultEvent, HideToastEvent, SchemaValue, ShowToastEvent, - contextualPaletteMachine, } from './ContextualPaletteMachine'; import closeImagePath from './icons/close.svg'; import connectorImagePath from './icons/connector.svg'; @@ -54,17 +54,15 @@ import fadeImagePath from './icons/tonality.svg'; import { ToolSection } from './tool-section/ToolSection'; import { Tool } from './tool/Tool'; -export const getToolSectionsQuery = gql` - query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { +export const getPaletteQuery = gql` + query getPalette($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { viewer { editingContext(editingContextId: $editingContextId) { representation(representationId: $diagramId) { description { ... on DiagramDescription { - toolSections(diagramElementId: $diagramElementId) { + palette(diagramElementId: $diagramElementId) { id - label - imageURL tools { __typename id @@ -88,6 +86,34 @@ export const getToolSectionsQuery = gql` } } } + toolSections { + id + label + imageURL + tools { + __typename + id + label + imageURL + ... on SingleClickOnDiagramElementTool { + targetDescriptions { + id + } + appliesToDiagramRoot + selectionDescriptionId + } + ... on SingleClickOnTwoDiagramElementsTool { + candidates { + sources { + id + } + targets { + id + } + } + } + } + } } } } @@ -226,16 +252,16 @@ export const ContextualPalette = ({ contextualPaletteMachine ); const { toast, contextualPalette } = value as SchemaValue; - const { toolSections, message } = context; + const { palette, message } = context; const diagramElementId = diagramElement.id; const isRoot: boolean = diagramElement instanceof Diagram; const { - loading: toolSectionsLoading, - data: toolSectionsData, - error: toolSectionsError, - } = useQuery(getToolSectionsQuery, { + loading: paletteLoading, + data: paletteData, + error: paletteError, + } = useQuery(getPaletteQuery, { variables: { editingContextId, diagramId: representationId, @@ -244,22 +270,23 @@ export const ContextualPalette = ({ }); useEffect(() => { - if (!toolSectionsLoading) { - if (toolSectionsData) { - const event: HandleToolSectionsResultEvent = { type: 'HANDLE_TOOL_SECTIONS_RESULT', result: toolSectionsData }; + if (!paletteLoading) { + if (paletteData) { + const event: HandleToolSectionsResultEvent = { type: 'HANDLE_PALETTE_RESULT', result: paletteData }; dispatch(event); } - if (toolSectionsError) { - const { message } = toolSectionsError; + if (paletteError) { + const { message } = paletteError; const showToastEvent: ShowToastEvent = { type: 'SHOW_TOAST', message }; dispatch(showToastEvent); } } - }, [toolSectionsLoading, toolSectionsData, toolSectionsError, dispatch]); + }, [paletteLoading, paletteData, paletteError, dispatch]); - const atLeastOneSingleClickOnTwoDiagramElementsTool = toolSections.some((toolSection) => { - return toolSection.tools.some((tool) => tool.__typename === 'SingleClickOnTwoDiagramElementsTool'); - }); + const atLeastOneSingleClickOnTwoDiagramElementsTool = + palette?.toolSections.some((toolSection) => { + return toolSection.tools.some((tool) => tool.__typename === 'SingleClickOnTwoDiagramElementsTool'); + }) || palette?.tools.some((tool) => tool.__typename === 'SingleClickOnTwoDiagramElementsTool'); let invokeLabelEdit; if (renameable && isWithEditableLabel(diagramElement)) { @@ -354,7 +381,9 @@ export const ContextualPalette = ({ const updateCollapsingState = (collapsingState: GQLCollapsingState) => collapseExpandElement(diagramElement.id, collapsingState); - let toolSectionsCount = toolSections.length + 1; + let toolSectionsCount = palette + ? palette.toolSections.filter((toolSection) => toolSection.tools.length > 0).length + palette.tools.length + 1 + : 0; if (atLeastOneSingleClickOnTwoDiagramElementsTool) { toolSectionsCount = toolSectionsCount + 1; } @@ -416,7 +445,7 @@ export const ContextualPalette = ({ const props: ContextualPaletteStyleProps = { toolSectionsCount }; const classes = useContextualPaletteStyle(props); - const toolSectionElements: JSX.Element[] = toolSections.map((toolSection: GQLToolSection) => { + const toolElements: JSX.Element[] = palette?.tools.map((tool: GQLTool) => { const handleToolClick = (tool: GQLTool) => { if (tool.id === 'edit') { invokeLabelEdit(); @@ -429,21 +458,47 @@ export const ContextualPalette = ({ } else if (tool.id === 'collapse') { updateCollapsingState(GQLCollapsingState.COLLAPSED); } else { - invokeTool(tool, toolSection); + invokeTool(tool, null); } }; - const defaultToolId: string | undefined = defaultTools.find( - (ts) => ts.toolSectionId === toolSection.id - )?.defaultToolId; - return ( -
- +
+
); }); + const toolSectionElements: JSX.Element[] = palette?.toolSections + .filter((toolSection) => toolSection.tools.length > 0) + .map((toolSection: GQLToolSection) => { + const handleToolClick = (tool: GQLTool) => { + if (tool.id === 'edit') { + invokeLabelEdit(); + } else if (tool.id === 'semantic-delete') { + invokeDelete(GQLDeletionPolicy.SEMANTIC); + } else if (tool.id === 'graphical-delete') { + invokeDelete(GQLDeletionPolicy.GRAPHICAL); + } else if (tool.id === 'expand') { + updateCollapsingState(GQLCollapsingState.EXPANDED); + } else if (tool.id === 'collapse') { + updateCollapsingState(GQLCollapsingState.COLLAPSED); + } else { + invokeTool(tool, toolSection); + } + }; + + const defaultToolId: string | undefined = defaultTools.find( + (ts) => ts.toolSectionId === toolSection.id + )?.defaultToolId; + + return ( +
+ +
+ ); + }); + const invokeVisibilityTool = (tool: GQLTool) => { if (tool.id === 'fade') { invokeFade(); @@ -453,14 +508,15 @@ export const ContextualPalette = ({ }; const paletteContent = - contextualPalette === 'loaded' && !toolSectionsLoading && toolSectionsData ? ( + contextualPalette === 'loaded' && !paletteLoading && paletteData ? (
{atLeastOneSingleClickOnTwoDiagramElementsTool ? (
- invokeConnectorTool(toolSections)} /> + invokeConnectorTool(palette)} />
) : null} + {toolElements} {toolSectionElements} {!isRoot ? (
diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.types.ts index 394897bb4fd..ceb460fa350 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPalette.types.ts @@ -22,7 +22,7 @@ export interface ContextualPaletteProps { renameable: boolean; defaultTools: ToolSectionWithDefaultTool[]; invokeTool: (tool: GQLTool, toolSection: GQLToolSection) => void; - invokeConnectorTool: (toolSections: GQLToolSection[]) => void; + invokeConnectorTool: (palette: GQLPalette) => void; invokeDelete: (deletionPolicy: GQLDeletionPolicy) => void | null; invokeClose: () => void; } @@ -31,12 +31,13 @@ export interface ContextualPaletteStyleProps { toolSectionsCount: number; } -export interface GQLGetToolSectionsVariables { +export interface GQLGetPaletteVariables { editingContextId: string; diagramId: string; diagramElementId: string; } -export interface GQLGetToolSectionsData { + +export interface GQLGetPaletteData { viewer: GQLViewer; } @@ -61,6 +62,12 @@ export interface GQLRepresentationDescription { } export interface GQLDiagramDescription extends GQLRepresentationDescription { + palette: GQLPalette; +} + +export interface GQLPalette { + id: string; + tools: GQLTool[]; toolSections: GQLToolSection[]; } @@ -96,6 +103,7 @@ export interface GQLSingleClickOnTwoDiagramElementsCandidate { export interface GQLDiagramElementDescription { id: string; } + export interface GQLNodeDescription { id: string; } @@ -115,6 +123,7 @@ export interface GQLHideDiagramElementVariables { export interface GQLHideDiagramElementPayload { __typename: string; } + export interface GQLHideDiagramElementData { hideDiagramElement: GQLHideDiagramElementPayload; } @@ -134,9 +143,11 @@ export interface GQLFadeDiagramElementVariables { export interface GQLFadeDiagramElementPayload { __typename: string; } + export interface GQLFadeDiagramElementData { fadeDiagramElement: GQLFadeDiagramElementPayload; } + export enum GQLCollapsingState { EXPANDED = 'EXPANDED', COLLAPSED = 'COLLAPSED', diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPaletteMachine.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPaletteMachine.ts index 8cc9eeb34e9..e7b8d217ab1 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPaletteMachine.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/palette/ContextualPaletteMachine.ts @@ -13,9 +13,9 @@ import { assign, Machine } from 'xstate'; import { GQLDiagramDescription, - GQLGetToolSectionsData, + GQLGetPaletteData, + GQLPalette, GQLRepresentationDescription, - GQLToolSection, } from './ContextualPalette.types'; export interface ContextualPaletteStateSchema { @@ -42,13 +42,13 @@ export type SchemaValue = { }; export interface ContextualPaletteContext { - toolSections: GQLToolSection[]; + palette: GQLPalette | null; message: string | null; } export type ShowToastEvent = { type: 'SHOW_TOAST'; message: string }; export type HideToastEvent = { type: 'HIDE_TOAST' }; -export type HandleToolSectionsResultEvent = { type: 'HANDLE_TOOL_SECTIONS_RESULT'; result: GQLGetToolSectionsData }; +export type HandleToolSectionsResultEvent = { type: 'HANDLE_PALETTE_RESULT'; result: GQLGetPaletteData }; export type ContextualPaletteEvent = ShowToastEvent | HideToastEvent | HandleToolSectionsResultEvent; const isDiagramDescription = ( @@ -63,7 +63,7 @@ export const contextualPaletteMachine = Machine< { type: 'parallel', context: { - toolSections: [], + palette: null, message: null, }, states: { @@ -93,16 +93,16 @@ export const contextualPaletteMachine = Machine< states: { loading: { on: { - HANDLE_TOOL_SECTIONS_RESULT: [ - { cond: 'isValidResult', target: 'loaded', actions: 'setToolSections' }, + HANDLE_PALETTE_RESULT: [ + { cond: 'isValidResult', target: 'loaded', actions: 'setPalette' }, { target: 'error' }, ], }, }, loaded: { on: { - HANDLE_TOOL_SECTIONS_RESULT: [ - { cond: 'isValidResult', target: 'loaded', actions: 'setToolSections' }, + HANDLE_PALETTE_RESULT: [ + { cond: 'isValidResult', target: 'loaded', actions: 'setPalette' }, { target: 'error' }, ], }, @@ -123,11 +123,11 @@ export const contextualPaletteMachine = Machine< }, }, actions: { - setToolSections: assign((_, event) => { + setPalette: assign((_, event) => { const { result } = event as HandleToolSectionsResultEvent; const description = result.viewer.editingContext.representation.description; - const toolSections = isDiagramDescription(description) ? description.toolSections : []; - return { toolSections }; + const palette = isDiagramDescription(description) ? description.palette : null; + return { palette }; }), setMessage: assign((_, event) => { const { message } = event as ShowToastEvent; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx index 8996f9d1e25..2fc58732ce5 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/representation/DiagramRepresentation.tsx @@ -31,6 +31,7 @@ import { DropArea } from '../droparea/DropArea'; import { ContextualMenu } from '../palette/ContextualMenu'; import { ContextualPalette } from '../palette/ContextualPalette'; import { + GQLPalette, GQLSingleClickOnDiagramElementTool, GQLSingleClickOnTwoDiagramElementsTool, GQLTool, @@ -1102,10 +1103,10 @@ export const DiagramRepresentation = ({ }; dispatch(setDefaultToolEvent); }; - const invokeConnectorToolFromContextualPalette = (toolSections: GQLToolSection[]) => { + const invokeConnectorToolFromContextualPalette = (palette: GQLPalette) => { resetTools(); const tools = []; - toolSections.forEach((toolSection) => { + palette?.toolSections.forEach((toolSection) => { const filteredTools = toolSection.tools .filter((tool) => tool.__typename === 'SingleClickOnTwoDiagramElementsTool') .map((tool) => tool as GQLSingleClickOnTwoDiagramElementsTool) @@ -1114,6 +1115,13 @@ export const DiagramRepresentation = ({ ); tools.push(...filteredTools); }); + palette?.tools + .filter((tool) => tool.__typename === 'SingleClickOnTwoDiagramElementsTool') + .map((tool) => tool as GQLSingleClickOnTwoDiagramElementsTool) + .filter((tool) => + tool.candidates.some((candidate) => candidate.sources.some((source) => source.id === element.descriptionId)) + ) + .map((tool) => tools.push(tool)); const setActiveConnectorToolsEvent: SetActiveConnectorToolsEvent = { type: 'SET_ACTIVE_CONNECTOR_TOOLS', tools, diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java index 71dbc16fe7c..13b64189f3b 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java @@ -67,6 +67,7 @@ @SuppressWarnings("checkstyle:MultipleStringLiterals") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ViewDiagramIntegrationTests extends AbstractIntegrationTests { + @Autowired private GraphQL graphQL; @@ -117,18 +118,19 @@ public void teardown() { private void createStudio() { var query = """ - mutation createProjectFromTemplate($input: CreateProjectFromTemplateInput!) { - createProjectFromTemplate(input: $input) { - __typename - } - } - """; + mutation createProjectFromTemplate($input: CreateProjectFromTemplateInput!) { + createProjectFromTemplate(input: $input) { + __typename + } + } + """; var input = new CreateProjectFromTemplateInput(UUID.randomUUID(), PapayaStudioTemplateProvider.STUDIO_TEMPLATE_ID); var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -144,23 +146,24 @@ mutation createProjectFromTemplate($input: CreateProjectFromTemplateInput!) { private void createProject() { var query = """ - mutation createProject($input: CreateProjectInput!) { - createProject(input: $input) { - __typename - ... on CreateProjectSuccessPayload { - project { - id + mutation createProject($input: CreateProjectInput!) { + createProject(input: $input) { + __typename + ... on CreateProjectSuccessPayload { + project { + id + } + } } } - } - } - """; + """; var input = new CreateProjectInput(UUID.randomUUID(), "Instance"); var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -181,17 +184,17 @@ mutation createProject($input: CreateProjectInput!) { private void createProjectContent() { var createDocumentQuery = """ - mutation createDocument($input: CreateDocumentInput!) { - createDocument(input: $input) { - __typename - ... on CreateDocumentSuccessPayload { - document { - id + mutation createDocument($input: CreateDocumentInput!) { + createDocument(input: $input) { + __typename + ... on CreateDocumentSuccessPayload { + document { + id + } + } } } - } - } - """; + """; assertThat(this.projectRepository.existsById(this.projectId)).isTrue(); @@ -199,7 +202,8 @@ mutation createDocument($input: CreateDocumentInput!) { var createDocumentExecutionInput = ExecutionInput.newExecutionInput() .query(createDocumentQuery) - .variables(Map.of("input", this.objectMapper.convertValue(createDocumentInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(createDocumentInput, new TypeReference>() { + }))) .build(); var createDocumentExecutionResult = this.graphQL.execute(createDocumentExecutionInput); assertThat(createDocumentExecutionResult.getErrors()).isEmpty(); @@ -217,23 +221,24 @@ mutation createDocument($input: CreateDocumentInput!) { } var createRootObjectQuery = """ - mutation createRootObject($input: CreateRootObjectInput!) { - createRootObject(input: $input) { - __typename - ... on CreateRootObjectSuccessPayload { - object { - id + mutation createRootObject($input: CreateRootObjectInput!) { + createRootObject(input: $input) { + __typename + ... on CreateRootObjectSuccessPayload { + object { + id + } + } } } - } - } - """; + """; var createRootObjectInput = new CreateRootObjectInput(UUID.randomUUID(), this.projectId.toString(), documentId, "domain://papaya_core", "Root"); var createRootObjectExecutionInput = ExecutionInput.newExecutionInput() .query(createRootObjectQuery) - .variables(Map.of("input", this.objectMapper.convertValue(createRootObjectInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(createRootObjectInput, new TypeReference>() { + }))) .build(); var createRootObjectExecutionResult = this.graphQL.execute(createRootObjectExecutionInput); assertThat(createRootObjectExecutionResult.getErrors()).isEmpty(); @@ -252,20 +257,20 @@ mutation createRootObject($input: CreateRootObjectInput!) { private void createDiagram() { var getRepresentationDescriptionsQuery = """ - query getRepresentationDescriptions($editingContextId: ID!, $objectId: ID!) { - viewer { - editingContext(editingContextId: $editingContextId) { - representationDescriptions(objectId: $objectId) { - edges { - node { - id + query getRepresentationDescriptions($editingContextId: ID!, $objectId: ID!) { + viewer { + editingContext(editingContextId: $editingContextId) { + representationDescriptions(objectId: $objectId) { + edges { + node { + id + } + } } } } } - } - } - """; + """; var getRepresentationDescriptionsExecutionInput = ExecutionInput.newExecutionInput() .query(getRepresentationDescriptionsQuery) @@ -283,22 +288,23 @@ query getRepresentationDescriptions($editingContextId: ID!, $objectId: ID!) { } var query = """ - mutation createRepresentation($input: CreateRepresentationInput!) { - createRepresentation(input: $input) { - __typename - ... on CreateRepresentationSuccessPayload { - representation { - id + mutation createRepresentation($input: CreateRepresentationInput!) { + createRepresentation(input: $input) { + __typename + ... on CreateRepresentationSuccessPayload { + representation { + id + } + } } } - } - } - """; + """; var input = new CreateRepresentationInput(UUID.randomUUID(), this.projectId.toString(), representationDescriptionId, this.rootObjectId.toString(), "Diagram"); var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -345,25 +351,26 @@ public void givenDomainAndViewWhenDocumentAndRepresentationAreCreatedThenWeCanSu private void initializeDiagram() { var query = """ - query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { - viewer { - editingContext(editingContextId: $editingContextId) { - representation(representationId: $diagramId) { - description { - ... on DiagramDescription { - toolSections(diagramElementId: $diagramElementId) { - tools { + query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId: ID!) { + viewer { + editingContext(editingContextId: $editingContextId) { + representation(representationId: $diagramId) { + description { + ... on DiagramDescription { + palette(diagramElementId: $diagramElementId) { id - label + tools { + id + label + } + } } } } } } } - } - } - """; + """; var variables = Map.of( "editingContextId", this.projectId.toString(), @@ -381,19 +388,19 @@ query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId String toolId = null; try { var jsonResult = this.objectMapper.writeValueAsString(executionResult.toSpecification()); - toolId = JsonPath.read(jsonResult, "$.data.viewer.editingContext.representation.description.toolSections[0].tools[0].id"); + toolId = JsonPath.read(jsonResult, "$.data.viewer.editingContext.representation.description.palette.tools[0].id"); } catch (JsonProcessingException exception) { fail(exception.getMessage()); } if (toolId != null) { var invokeToolQuery = """ - mutation invokeSingleClickOnDiagramElementTool($input: InvokeSingleClickOnDiagramElementToolInput!) { - invokeSingleClickOnDiagramElementTool(input: $input) { - __typename - } - } - """; + mutation invokeSingleClickOnDiagramElementTool($input: InvokeSingleClickOnDiagramElementToolInput!) { + invokeSingleClickOnDiagramElementTool(input: $input) { + __typename + } + } + """; var invokeToolInput = new InvokeSingleClickOnDiagramElementToolInput( UUID.randomUUID(), @@ -408,7 +415,8 @@ mutation invokeSingleClickOnDiagramElementTool($input: InvokeSingleClickOnDiagra var invokeToolExecutionInput = ExecutionInput.newExecutionInput() .query(invokeToolQuery) - .variables(Map.of("input", this.objectMapper.convertValue(invokeToolInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(invokeToolInput, new TypeReference>() { + }))) .build(); var invokeToolExecutionResult = this.graphQL.execute(invokeToolExecutionInput); assertThat(invokeToolExecutionResult.getErrors()).isEmpty(); diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java index f890b697f19..58ebfa7a25b 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java @@ -67,6 +67,7 @@ @SuppressWarnings("checkstyle:MultipleStringLiterals") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ViewInitialDirectEditElementLabelProviderIntegrationTests extends AbstractIntegrationTests { + @Autowired private GraphQL graphQL; @@ -163,7 +164,8 @@ mutation createProjectFromTemplate($input: CreateProjectFromTemplateInput!) { var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -195,7 +197,8 @@ mutation createProject($input: CreateProjectInput!) { var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -234,7 +237,8 @@ mutation createDocument($input: CreateDocumentInput!) { var createDocumentExecutionInput = ExecutionInput.newExecutionInput() .query(createDocumentQuery) - .variables(Map.of("input", this.objectMapper.convertValue(createDocumentInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(createDocumentInput, new TypeReference>() { + }))) .build(); var createDocumentExecutionResult = this.graphQL.execute(createDocumentExecutionInput); assertThat(createDocumentExecutionResult.getErrors()).isEmpty(); @@ -268,7 +272,8 @@ mutation createRootObject($input: CreateRootObjectInput!) { var createRootObjectExecutionInput = ExecutionInput.newExecutionInput() .query(createRootObjectQuery) - .variables(Map.of("input", this.objectMapper.convertValue(createRootObjectInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(createRootObjectInput, new TypeReference>() { + }))) .build(); var createRootObjectExecutionResult = this.graphQL.execute(createRootObjectExecutionInput); assertThat(createRootObjectExecutionResult.getErrors()).isEmpty(); @@ -333,7 +338,8 @@ mutation createRepresentation($input: CreateRepresentationInput!) { var input = new CreateRepresentationInput(UUID.randomUUID(), this.projectId.toString(), representationDescriptionId, this.rootObjectId.toString(), "Diagram"); var executionInput = ExecutionInput.newExecutionInput() .query(query) - .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(input, new TypeReference>() { + }))) .build(); var executionResult = this.graphQL.execute(executionInput); assertThat(executionResult.getErrors()).isEmpty(); @@ -355,7 +361,8 @@ query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId representation(representationId: $diagramId) { description { ... on DiagramDescription { - toolSections(diagramElementId: $diagramElementId) { + palette(diagramElementId: $diagramElementId) { + id tools { id label @@ -373,7 +380,7 @@ query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId "editingContextId", this.projectId.toString(), "diagramId", this.representationId.toString(), "diagramElementId", this.representationId.toString() - ); + ); var executionInput = ExecutionInput.newExecutionInput() .query(query) @@ -385,7 +392,7 @@ query getToolSections($editingContextId: ID!, $diagramId: ID!, $diagramElementId String toolId = null; try { var jsonResult = this.objectMapper.writeValueAsString(executionResult.toSpecification()); - toolId = JsonPath.read(jsonResult, "$.data.viewer.editingContext.representation.description.toolSections[0].tools[0].id"); + toolId = JsonPath.read(jsonResult, "$.data.viewer.editingContext.representation.description.palette.tools[0].id"); } catch (JsonProcessingException exception) { fail(exception.getMessage()); } @@ -408,11 +415,12 @@ mutation invokeSingleClickOnDiagramElementTool($input: InvokeSingleClickOnDiagra 0d, 0d, null - ); + ); var invokeToolExecutionInput = ExecutionInput.newExecutionInput() .query(invokeToolQuery) - .variables(Map.of("input", this.objectMapper.convertValue(invokeToolInput, new TypeReference>() { }))) + .variables(Map.of("input", this.objectMapper.convertValue(invokeToolInput, new TypeReference>() { + }))) .build(); var invokeToolExecutionResult = this.graphQL.execute(invokeToolExecutionInput); assertThat(invokeToolExecutionResult.getErrors()).isEmpty(); @@ -452,7 +460,7 @@ query initialDirectEditElementLabel($editingContextId: ID!, $diagramId: ID!, $la "editingContextId", this.projectId.toString(), "diagramId", this.representationId.toString(), "labelId", labelId - ); + ); var executionInput = ExecutionInput.newExecutionInput() .query(query) diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramBuilders.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramBuilders.java index c8fa2c89246..9ee5dcf04d6 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramBuilders.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramBuilders.java @@ -259,5 +259,35 @@ public SelectionDescriptionBuilder newSelectionDescription() { return new SelectionDescriptionBuilder(); } + /** + * Instantiate a DiagramToolSectionBuilder . + * + * @author BuilderGenerator + * @generated + */ + public DiagramToolSectionBuilder newDiagramToolSection() { + return new DiagramToolSectionBuilder(); + } + + /** + * Instantiate a NodeToolSectionBuilder . + * + * @author BuilderGenerator + * @generated + */ + public NodeToolSectionBuilder newNodeToolSection() { + return new NodeToolSectionBuilder(); + } + + /** + * Instantiate a EdgeToolSectionBuilder . + * + * @author BuilderGenerator + * @generated + */ + public EdgeToolSectionBuilder newEdgeToolSection() { + return new EdgeToolSectionBuilder(); + } + } diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramPaletteBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramPaletteBuilder.java index b83cde4f1e1..3811656a1b6 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramPaletteBuilder.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramPaletteBuilder.java @@ -63,6 +63,18 @@ public DiagramPaletteBuilder nodeTools(org.eclipse.sirius.components.view.diagra return this; } + /** + * Setter for ToolSections. + * + * @generated + */ + public DiagramPaletteBuilder toolSections(org.eclipse.sirius.components.view.diagram.DiagramToolSection ... values) { + for (org.eclipse.sirius.components.view.diagram.DiagramToolSection value : values) { + this.getDiagramPalette().getToolSections().add(value); + } + return this; + } + } diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramToolSectionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramToolSectionBuilder.java new file mode 100644 index 00000000000..e9760bd5bf3 --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramToolSectionBuilder.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2023 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; + +/** + * Builder for DiagramToolSectionBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class DiagramToolSectionBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.diagram.DiagramToolSection. + * @generated + */ + private org.eclipse.sirius.components.view.diagram.DiagramToolSection diagramToolSection = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createDiagramToolSection(); + + /** + * Return instance org.eclipse.sirius.components.view.diagram.DiagramToolSection. + * @generated + */ + protected org.eclipse.sirius.components.view.diagram.DiagramToolSection getDiagramToolSection() { + return this.diagramToolSection; + } + + /** + * Return instance org.eclipse.sirius.components.view.diagram.DiagramToolSection. + * @generated + */ + public org.eclipse.sirius.components.view.diagram.DiagramToolSection build() { + return this.getDiagramToolSection(); + } + + /** + * Setter for Name. + * + * @generated + */ + public DiagramToolSectionBuilder name(java.lang.String value) { + this.getDiagramToolSection().setName(value); + return this; + } + /** + * Setter for NodeTools. + * + * @generated + */ + public DiagramToolSectionBuilder nodeTools(org.eclipse.sirius.components.view.diagram.NodeTool ... values) { + for (org.eclipse.sirius.components.view.diagram.NodeTool value : values) { + this.getDiagramToolSection().getNodeTools().add(value); + } + return this; + } + + +} + diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgePaletteBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgePaletteBuilder.java index c3a52577387..242bc68155f 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgePaletteBuilder.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgePaletteBuilder.java @@ -102,6 +102,18 @@ public EdgePaletteBuilder edgeReconnectionTools(org.eclipse.sirius.components.vi return this; } + /** + * Setter for ToolSections. + * + * @generated + */ + public EdgePaletteBuilder toolSections(org.eclipse.sirius.components.view.diagram.EdgeToolSection ... values) { + for (org.eclipse.sirius.components.view.diagram.EdgeToolSection value : values) { + this.getEdgePalette().getToolSections().add(value); + } + return this; + } + } diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgeToolSectionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgeToolSectionBuilder.java new file mode 100644 index 00000000000..82189ef5d26 --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/EdgeToolSectionBuilder.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2023 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; + +/** + * Builder for EdgeToolSectionBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class EdgeToolSectionBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.diagram.EdgeToolSection. + * @generated + */ + private org.eclipse.sirius.components.view.diagram.EdgeToolSection edgeToolSection = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createEdgeToolSection(); + + /** + * Return instance org.eclipse.sirius.components.view.diagram.EdgeToolSection. + * @generated + */ + protected org.eclipse.sirius.components.view.diagram.EdgeToolSection getEdgeToolSection() { + return this.edgeToolSection; + } + + /** + * Return instance org.eclipse.sirius.components.view.diagram.EdgeToolSection. + * @generated + */ + public org.eclipse.sirius.components.view.diagram.EdgeToolSection build() { + return this.getEdgeToolSection(); + } + + /** + * Setter for Name. + * + * @generated + */ + public EdgeToolSectionBuilder name(java.lang.String value) { + this.getEdgeToolSection().setName(value); + return this; + } + + /** + * Setter for NodeTools. + * + * @generated + */ + public EdgeToolSectionBuilder nodeTools(org.eclipse.sirius.components.view.diagram.NodeTool ... values) { + for (org.eclipse.sirius.components.view.diagram.NodeTool value : values) { + this.getEdgeToolSection().getNodeTools().add(value); + } + return this; + } + + /** + * Setter for EdgeReconnectionTools. + * + * @generated + */ + public EdgeToolSectionBuilder edgeReconnectionTools(org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool ... values) { + for (org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool value : values) { + this.getEdgeToolSection().getEdgeReconnectionTools().add(value); + } + return this; + } + + +} + diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodePaletteBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodePaletteBuilder.java index 3a88f237f0a..8809c344ee0 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodePaletteBuilder.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodePaletteBuilder.java @@ -84,6 +84,18 @@ public NodePaletteBuilder edgeTools(org.eclipse.sirius.components.view.diagram.E return this; } + /** + * Setter for ToolSections. + * + * @generated + */ + public NodePaletteBuilder toolSections(org.eclipse.sirius.components.view.diagram.NodeToolSection ... values) { + for (org.eclipse.sirius.components.view.diagram.NodeToolSection value : values) { + this.getNodePalette().getToolSections().add(value); + } + return this; + } + } diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodeToolSectionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodeToolSectionBuilder.java new file mode 100644 index 00000000000..1df0e5d2a2f --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/NodeToolSectionBuilder.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2023 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; + +/** + * Builder for NodeToolSectionBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class NodeToolSectionBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.diagram.NodeToolSection. + * @generated + */ + private org.eclipse.sirius.components.view.diagram.NodeToolSection nodeToolSection = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createNodeToolSection(); + + /** + * Return instance org.eclipse.sirius.components.view.diagram.NodeToolSection. + * @generated + */ + protected org.eclipse.sirius.components.view.diagram.NodeToolSection getNodeToolSection() { + return this.nodeToolSection; + } + + /** + * Return instance org.eclipse.sirius.components.view.diagram.NodeToolSection. + * @generated + */ + public org.eclipse.sirius.components.view.diagram.NodeToolSection build() { + return this.getNodeToolSection(); + } + + /** + * Setter for Name. + * + * @generated + */ + public NodeToolSectionBuilder name(java.lang.String value) { + this.getNodeToolSection().setName(value); + return this; + } + /** + * Setter for NodeTools. + * + * @generated + */ + public NodeToolSectionBuilder nodeTools(org.eclipse.sirius.components.view.diagram.NodeTool ... values) { + for (org.eclipse.sirius.components.view.diagram.NodeTool value : values) { + this.getNodeToolSection().getNodeTools().add(value); + } + return this; + } + + /** + * Setter for EdgeTools. + * + * @generated + */ + public NodeToolSectionBuilder edgeTools(org.eclipse.sirius.components.view.diagram.EdgeTool ... values) { + for (org.eclipse.sirius.components.view.diagram.EdgeTool value : values) { + this.getNodeToolSection().getEdgeTools().add(value); + } + return this; + } + + +} + diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ToolSectionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ToolSectionBuilder.java new file mode 100644 index 00000000000..4c728bfaea8 --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ToolSectionBuilder.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2023 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; + +/** + * Builder for org.eclipse.sirius.components.view.diagram.ToolSection. + * + * @author BuilderGenerator + * @generated + */ +public abstract class ToolSectionBuilder { + + /** + * Builder for org.eclipse.sirius.components.view.diagram.ToolSection. + * @generated + */ + protected abstract org.eclipse.sirius.components.view.diagram.ToolSection getToolSection(); + + /** + * Setter for Name. + * + * @generated + */ + public ToolSectionBuilder name(java.lang.String value) { + this.getToolSection().setName(value); + return this; + } + +} + diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramEditPlugin.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramEditPlugin.java index 93b9308cfeb..46536f59de5 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramEditPlugin.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramEditPlugin.java @@ -90,15 +90,8 @@ protected static String extensionFor(String key) { int index = key.lastIndexOf('.'); if (index != -1) { String extension = key.substring(index + 1); - if ("png".equalsIgnoreCase(extension) || - "gif".equalsIgnoreCase(extension) || - "bmp".equalsIgnoreCase(extension) || - "ico".equalsIgnoreCase(extension) || - "jpg".equalsIgnoreCase(extension) || - "jpeg".equalsIgnoreCase(extension) || - "tif".equalsIgnoreCase(extension) || - "tiff".equalsIgnoreCase(extension) || - "svg".equalsIgnoreCase(extension)) { + if ("png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension) || "bmp".equalsIgnoreCase(extension) || "ico".equalsIgnoreCase(extension) || "jpg".equalsIgnoreCase(extension) + || "jpeg".equalsIgnoreCase(extension) || "tif".equalsIgnoreCase(extension) || "tiff".equalsIgnoreCase(extension) || "svg".equalsIgnoreCase(extension)) { result = ""; } } diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramItemProviderAdapterFactory.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramItemProviderAdapterFactory.java index 1604cca9b5b..53d02237a1c 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramItemProviderAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramItemProviderAdapterFactory.java @@ -656,6 +656,78 @@ public Adapter createSelectionDescriptionAdapter() { return this.selectionDescriptionItemProvider; } + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.diagram.DiagramToolSection} instances. + * + * @generated + */ + protected DiagramToolSectionItemProvider diagramToolSectionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.DiagramToolSection}. + * + * @generated + */ + @Override + public Adapter createDiagramToolSectionAdapter() { + if (this.diagramToolSectionItemProvider == null) { + this.diagramToolSectionItemProvider = new DiagramToolSectionItemProvider(this); + } + + return this.diagramToolSectionItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.diagram.NodeToolSection} instances. + * + * @generated + */ + protected NodeToolSectionItemProvider nodeToolSectionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.NodeToolSection}. + * + * @generated + */ + @Override + public Adapter createNodeToolSectionAdapter() { + if (this.nodeToolSectionItemProvider == null) { + this.nodeToolSectionItemProvider = new NodeToolSectionItemProvider(this); + } + + return this.nodeToolSectionItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection} instances. + * + * @generated + */ + protected EdgeToolSectionItemProvider edgeToolSectionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection}. + * + * @generated + */ + @Override + public Adapter createEdgeToolSectionAdapter() { + if (this.edgeToolSectionItemProvider == null) { + this.edgeToolSectionItemProvider = new EdgeToolSectionItemProvider(this); + } + + return this.edgeToolSectionItemProvider; + } + /** * This returns the root adapter factory that contains this factory. * @@ -804,6 +876,12 @@ public void dispose() { this.deleteViewItemProvider.dispose(); if (this.selectionDescriptionItemProvider != null) this.selectionDescriptionItemProvider.dispose(); + if (this.diagramToolSectionItemProvider != null) + this.diagramToolSectionItemProvider.dispose(); + if (this.nodeToolSectionItemProvider != null) + this.nodeToolSectionItemProvider.dispose(); + if (this.edgeToolSectionItemProvider != null) + this.edgeToolSectionItemProvider.dispose(); } /** diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramPaletteItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramPaletteItemProvider.java index 86b34659393..0d22f4558bc 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramPaletteItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramPaletteItemProvider.java @@ -76,6 +76,7 @@ public Collection getChildrenFeatures(Object objec super.getChildrenFeatures(object); this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_PALETTE__DROP_TOOL); this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_PALETTE__NODE_TOOLS); + this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_PALETTE__TOOL_SECTIONS); } return this.childrenFeatures; } @@ -137,6 +138,7 @@ public void notifyChanged(Notification notification) { switch (notification.getFeatureID(DiagramPalette.class)) { case DiagramPackage.DIAGRAM_PALETTE__DROP_TOOL: case DiagramPackage.DIAGRAM_PALETTE__NODE_TOOLS: + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } @@ -156,6 +158,8 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_PALETTE__DROP_TOOL, DiagramFactory.eINSTANCE.createDropTool())); newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_PALETTE__NODE_TOOLS, DiagramFactory.eINSTANCE.createNodeTool())); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_PALETTE__TOOL_SECTIONS, DiagramFactory.eINSTANCE.createDiagramToolSection())); } /** diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramToolSectionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramToolSectionItemProvider.java new file mode 100644 index 00000000000..ba3236543fa --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramToolSectionItemProvider.java @@ -0,0 +1,151 @@ +/******************************************************************************* + * Copyright (c) 2021, 2023 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.diagram.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.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.diagram.DiagramFactory; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.DiagramToolSection} object. + * + * + * @generated + */ +public class DiagramToolSectionItemProvider extends ToolSectionItemProvider { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public DiagramToolSectionItemProvider(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(DiagramPackage.Literals.DIAGRAM_TOOL_SECTION__NODE_TOOLS); + } + 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 DiagramToolSection.gif. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/DiagramToolSection.svg")); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((DiagramToolSection) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_DiagramToolSection_type") : this.getString("_UI_DiagramToolSection_type") + " " + label; + } + + /** + * 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(DiagramToolSection.class)) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + 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(DiagramPackage.Literals.DIAGRAM_TOOL_SECTION__NODE_TOOLS, DiagramFactory.eINSTANCE.createNodeTool())); + } + +} diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeDescriptionItemProvider.java index 0b570a1b473..e65ae910734 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeDescriptionItemProvider.java @@ -282,7 +282,7 @@ public String getCreateChildText(Object owner, Object feature, Object child, Col boolean qualify = childFeature == DiagramPackage.Literals.EDGE_DESCRIPTION__STYLE || childFeature == DiagramPackage.Literals.EDGE_DESCRIPTION__CONDITIONAL_STYLES; if (qualify) { - return this.getString("_UI_CreateChild_text2", new Object[]{this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner)}); + return this.getString("_UI_CreateChild_text2", new Object[] { this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner) }); } return super.getCreateChildText(owner, feature, child, selection); } diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgePaletteItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgePaletteItemProvider.java index 07df3ef1fee..1ab0a0bb5ca 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgePaletteItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgePaletteItemProvider.java @@ -39,6 +39,7 @@ */ public class EdgePaletteItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** * This constructs an instance from a factory and a notifier. * @@ -80,6 +81,7 @@ public Collection getChildrenFeatures(Object objec this.childrenFeatures.add(DiagramPackage.Literals.EDGE_PALETTE__END_LABEL_EDIT_TOOL); this.childrenFeatures.add(DiagramPackage.Literals.EDGE_PALETTE__NODE_TOOLS); this.childrenFeatures.add(DiagramPackage.Literals.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS); + this.childrenFeatures.add(DiagramPackage.Literals.EDGE_PALETTE__TOOL_SECTIONS); } return this.childrenFeatures; } @@ -145,6 +147,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.EDGE_PALETTE__END_LABEL_EDIT_TOOL: case DiagramPackage.EDGE_PALETTE__NODE_TOOLS: case DiagramPackage.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS: + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } @@ -174,6 +177,8 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS, DiagramFactory.eINSTANCE.createSourceEdgeEndReconnectionTool())); newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS, DiagramFactory.eINSTANCE.createTargetEdgeEndReconnectionTool())); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.EDGE_PALETTE__TOOL_SECTIONS, DiagramFactory.eINSTANCE.createEdgeToolSection())); } /** @@ -191,7 +196,7 @@ public String getCreateChildText(Object owner, Object feature, Object child, Col || childFeature == DiagramPackage.Literals.EDGE_PALETTE__END_LABEL_EDIT_TOOL; if (qualify) { - return this.getString("_UI_CreateChild_text2", new Object[] { this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner) }); + return this.getString("_UI_CreateChild_text2", new Object[]{this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner)}); } return super.getCreateChildText(owner, feature, child, selection); } diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeToolSectionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeToolSectionItemProvider.java new file mode 100644 index 00000000000..b281c4e11d7 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeToolSectionItemProvider.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2021, 2023 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.diagram.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.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.diagram.DiagramFactory; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection} object. + * + * + * @generated + */ +public class EdgeToolSectionItemProvider extends ToolSectionItemProvider { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public EdgeToolSectionItemProvider(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(DiagramPackage.Literals.EDGE_TOOL_SECTION__NODE_TOOLS); + this.childrenFeatures.add(DiagramPackage.Literals.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS); + } + 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 EdgeToolSection.gif. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/EdgeToolSection.svg")); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((EdgeToolSection) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_EdgeToolSection_type") : this.getString("_UI_EdgeToolSection_type") + " " + label; + } + + /** + * 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(EdgeToolSection.class)) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + 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(DiagramPackage.Literals.EDGE_TOOL_SECTION__NODE_TOOLS, DiagramFactory.eINSTANCE.createNodeTool())); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS, DiagramFactory.eINSTANCE.createSourceEdgeEndReconnectionTool())); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS, DiagramFactory.eINSTANCE.createTargetEdgeEndReconnectionTool())); + } + +} diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodePaletteItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodePaletteItemProvider.java index 3bcbd50d498..86972e1d24b 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodePaletteItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodePaletteItemProvider.java @@ -27,6 +27,7 @@ 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.diagram.DiagramFactory; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.NodePalette; @@ -38,6 +39,7 @@ */ public class NodePaletteItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** * This constructs an instance from a factory and a notifier. * @@ -77,6 +79,7 @@ public Collection getChildrenFeatures(Object objec this.childrenFeatures.add(DiagramPackage.Literals.NODE_PALETTE__LABEL_EDIT_TOOL); this.childrenFeatures.add(DiagramPackage.Literals.NODE_PALETTE__NODE_TOOLS); this.childrenFeatures.add(DiagramPackage.Literals.NODE_PALETTE__EDGE_TOOLS); + this.childrenFeatures.add(DiagramPackage.Literals.NODE_PALETTE__TOOL_SECTIONS); } return this.childrenFeatures; } @@ -140,6 +143,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.NODE_PALETTE__LABEL_EDIT_TOOL: case DiagramPackage.NODE_PALETTE__NODE_TOOLS: case DiagramPackage.NODE_PALETTE__EDGE_TOOLS: + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } @@ -161,6 +165,8 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.NODE_PALETTE__LABEL_EDIT_TOOL, defaultToolsFactory.createDefaultLabelEditTool())); newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.NODE_PALETTE__NODE_TOOLS, defaultToolsFactory.createDefaultNodeCreationTool())); newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.NODE_PALETTE__EDGE_TOOLS, defaultToolsFactory.createDefaultEdgeTool())); + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.NODE_PALETTE__TOOL_SECTIONS, DiagramFactory.eINSTANCE.createNodeToolSection())); + } /** diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodeToolSectionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodeToolSectionItemProvider.java new file mode 100644 index 00000000000..3b9a5c3fd5f --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/NodeToolSectionItemProvider.java @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2021, 2023 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.diagram.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.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.diagram.DiagramFactory; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.NodeToolSection} object. + * + * + * @generated + */ +public class NodeToolSectionItemProvider extends ToolSectionItemProvider { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public NodeToolSectionItemProvider(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(DiagramPackage.Literals.NODE_TOOL_SECTION__NODE_TOOLS); + this.childrenFeatures.add(DiagramPackage.Literals.NODE_TOOL_SECTION__EDGE_TOOLS); + } + 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 NodeToolSection.gif. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/NodeToolSection.svg")); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((NodeToolSection) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_NodeToolSection_type") : this.getString("_UI_NodeToolSection_type") + " " + label; + } + + /** + * 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(NodeToolSection.class)) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + 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(DiagramPackage.Literals.NODE_TOOL_SECTION__NODE_TOOLS, DiagramFactory.eINSTANCE.createNodeTool())); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.NODE_TOOL_SECTION__EDGE_TOOLS, DiagramFactory.eINSTANCE.createEdgeTool())); + } + +} diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ToolSectionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ToolSectionItemProvider.java new file mode 100644 index 00000000000..555317b5331 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ToolSectionItemProvider.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram.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.edit.provider.ComposeableAdapterFactory; +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.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.ToolSection; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.ToolSection} object. + * + * @generated + */ +public class ToolSectionItemProvider extends ItemProviderAdapter + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public ToolSectionItemProvider(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); + + this.addNamePropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Name feature. + * + * @generated + */ + protected void addNamePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_ToolSection_name_feature"), this.getString("_UI_PropertyDescriptor_description", "_UI_ToolSection_name_feature", "_UI_ToolSection_type"), + DiagramPackage.Literals.TOOL_SECTION__NAME, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((ToolSection) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_ToolSection_type") : this.getString("_UI_ToolSection_type") + " " + label; + } + + /** + * 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(ToolSection.class)) { + case DiagramPackage.TOOL_SECTION__NAME: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + 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); + } + + /** + * Return the resource locator for this item provider's resources. + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return DiagramEditPlugin.INSTANCE; + } + +} diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/DiagramToolSection.svg b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/DiagramToolSection.svg new file mode 100644 index 00000000000..995998b21b5 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/DiagramToolSection.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/EdgeToolSection.svg b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/EdgeToolSection.svg new file mode 100644 index 00000000000..995998b21b5 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/EdgeToolSection.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/NodeToolSection.svg b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/NodeToolSection.svg new file mode 100644 index 00000000000..995998b21b5 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/icons/full/obj16/NodeToolSection.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties index e4c2d522b25..289aa33f183 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/resources/plugin.properties @@ -1,26 +1,24 @@ +################################################################################ # Copyright (c) 2021, 2023 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 - +# Obeo - initial API and implementation +################################################################################# pluginName = Diagram Edit Support providerName = www.example.org - _UI_CreateChild_text = {0} _UI_CreateChild_text2 = {1} {0} _UI_CreateChild_text3 = {1} _UI_CreateChild_tooltip = Create New {0} Under {1} Feature _UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}. _UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent. - _UI_PropertyDescriptor_description = The {0} of the {1} - _UI_DiagramDescription_type = Diagram Description _UI_DiagramElementDescription_type = Diagram Element Description _UI_NodeDescription_type = Node Description @@ -52,10 +50,12 @@ _UI_TargetEdgeEndReconnectionTool_type = Target Edge End Reconnection Tool _UI_CreateView_type = Create View _UI_DeleteView_type = Delete View _UI_SelectionDescription_type = Selection Description +_UI_ToolSection_type = Tool Section +_UI_DiagramToolSection_type = Diagram Tool Section +_UI_NodeToolSection_type = Node Tool Section +_UI_EdgeToolSection_type = Edge Tool Section _UI_Unknown_type = Object - -_UI_Unknown_datatype= Value - +_UI_Unknown_datatype = Value _UI_DiagramDescription_autoLayout_feature = Auto Layout _UI_DiagramDescription_palette_feature = Palette _UI_DiagramDescription_nodeDescriptions_feature = Node Descriptions @@ -105,16 +105,19 @@ _UI_EdgeStyle_edgeWidth_feature = Edge Width _UI_EdgeStyle_showIcon_feature = Show Icon _UI_DiagramPalette_dropTool_feature = Drop Tool _UI_DiagramPalette_nodeTools_feature = Node Tools +_UI_DiagramPalette_toolSections_feature = Tool Sections _UI_NodePalette_deleteTool_feature = Delete Tool _UI_NodePalette_labelEditTool_feature = Label Edit Tool _UI_NodePalette_nodeTools_feature = Node Tools _UI_NodePalette_edgeTools_feature = Edge Tools +_UI_NodePalette_toolSections_feature = Tool Sections _UI_EdgePalette_deleteTool_feature = Delete Tool _UI_EdgePalette_centerLabelEditTool_feature = Center Label Edit Tool _UI_EdgePalette_beginLabelEditTool_feature = Begin Label Edit Tool _UI_EdgePalette_endLabelEditTool_feature = End Label Edit Tool _UI_EdgePalette_nodeTools_feature = Node Tools _UI_EdgePalette_edgeReconnectionTools_feature = Edge Reconnection Tools +_UI_EdgePalette_toolSections_feature = Tool Sections _UI_Tool_name_feature = Name _UI_Tool_body_feature = Body _UI_EdgeTool_targetElementDescriptions_feature = Target Element Descriptions @@ -128,8 +131,13 @@ _UI_CreateView_containmentKind_feature = Containment Kind _UI_DeleteView_viewExpression_feature = View Expression _UI_SelectionDescription_selectionCandidatesExpression_feature = Selection Candidates Expression _UI_SelectionDescription_selectionMessage_feature = Selection Message +_UI_ToolSection_name_feature = Name +_UI_DiagramToolSection_nodeTools_feature = Node Tools +_UI_NodeToolSection_nodeTools_feature = Node Tools +_UI_NodeToolSection_edgeTools_feature = Edge Tools +_UI_EdgeToolSection_nodeTools_feature = Node Tools +_UI_EdgeToolSection_edgeReconnectionTools_feature = Edge Reconnection Tools _UI_Unknown_feature = Unspecified - _UI_ArrowStyle_None_literal = None _UI_ArrowStyle_OutputArrow_literal = OutputArrow _UI_ArrowStyle_InputArrow_literal = InputArrow diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramFactory.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramFactory.java index 0d0bf972868..5b0c545daf3 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramFactory.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramFactory.java @@ -228,6 +228,30 @@ public interface DiagramFactory extends EFactory { */ SelectionDescription createSelectionDescription(); + /** + * Returns a new object of class 'Tool Section'. + * + * @return a new object of class 'Tool Section'. + * @generated + */ + DiagramToolSection createDiagramToolSection(); + + /** + * Returns a new object of class 'Node Tool Section'. + * + * @return a new object of class 'Node Tool Section'. + * @generated + */ + NodeToolSection createNodeToolSection(); + + /** + * Returns a new object of class 'Edge Tool Section'. + * + * @return a new object of class 'Edge Tool Section'. + * @generated + */ + EdgeToolSection createEdgeToolSection(); + /** * Returns the package supported by this factory. * diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java index e00c0d68319..1a751dd236d 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java @@ -1661,13 +1661,22 @@ public interface DiagramPackage extends EPackage { */ int DIAGRAM_PALETTE__NODE_TOOLS = 1; + /** + * The feature id for the 'Tool Sections' containment reference list. + * + * @generated + * @ordered + */ + int DIAGRAM_PALETTE__TOOL_SECTIONS = 2; + /** * The number of structural features of the 'Palette' class. * * @generated * @ordered */ - int DIAGRAM_PALETTE_FEATURE_COUNT = 2; + int DIAGRAM_PALETTE_FEATURE_COUNT = 3; /** * The number of operations of the 'Palette' class. @@ -1723,6 +1732,15 @@ public interface DiagramPackage extends EPackage { */ int NODE_PALETTE__EDGE_TOOLS = 3; + /** + * The feature id for the 'Tool Sections' containment reference list. + * + * @generated + * @ordered + */ + int NODE_PALETTE__TOOL_SECTIONS = 4; + /** * The number of structural features of the 'Node Palette' class. @@ -1730,7 +1748,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int NODE_PALETTE_FEATURE_COUNT = 4; + int NODE_PALETTE_FEATURE_COUNT = 5; /** * The number of operations of the 'Node Palette' class. @@ -1804,6 +1822,15 @@ public interface DiagramPackage extends EPackage { */ int EDGE_PALETTE__EDGE_RECONNECTION_TOOLS = 5; + /** + * The feature id for the 'Tool Sections' containment reference list. + * + * @generated + * @ordered + */ + int EDGE_PALETTE__TOOL_SECTIONS = 6; + /** * The number of structural features of the 'Edge Palette' class. @@ -1811,7 +1838,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int EDGE_PALETTE_FEATURE_COUNT = 6; + int EDGE_PALETTE_FEATURE_COUNT = 7; /** * The number of operations of the 'Edge Palette' class. @@ -2418,6 +2445,191 @@ public interface DiagramPackage extends EPackage { */ int SELECTION_DESCRIPTION_OPERATION_COUNT = 0; + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.ToolSectionImpl Tool + * Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.ToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getToolSection() + * @generated + */ + int TOOL_SECTION = 31; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int TOOL_SECTION__NAME = 0; + + /** + * The number of structural features of the 'Tool Section' class. + * + * @generated + * @ordered + */ + int TOOL_SECTION_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'Tool Section' class. + * + * @generated + * @ordered + */ + int TOOL_SECTION_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl + * Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramToolSection() + * @generated + */ + int DIAGRAM_TOOL_SECTION = 32; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int DIAGRAM_TOOL_SECTION__NAME = TOOL_SECTION__NAME; + + /** + * The feature id for the 'Node Tools' containment reference list. + * + * @generated + * @ordered + */ + int DIAGRAM_TOOL_SECTION__NODE_TOOLS = TOOL_SECTION_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Tool Section' class. + * + * @generated + * @ordered + */ + int DIAGRAM_TOOL_SECTION_FEATURE_COUNT = TOOL_SECTION_FEATURE_COUNT + 1; + + /** + * The number of operations of the 'Tool Section' class. + * + * @generated + * @ordered + */ + int DIAGRAM_TOOL_SECTION_OPERATION_COUNT = TOOL_SECTION_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl Node + * Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeToolSection() + * @generated + */ + int NODE_TOOL_SECTION = 33; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int NODE_TOOL_SECTION__NAME = TOOL_SECTION__NAME; + + /** + * The feature id for the 'Node Tools' containment reference list. + * + * @generated + * @ordered + */ + int NODE_TOOL_SECTION__NODE_TOOLS = TOOL_SECTION_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Edge Tools' containment reference list. + * + * @generated + * @ordered + */ + int NODE_TOOL_SECTION__EDGE_TOOLS = TOOL_SECTION_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Node Tool Section' class. + * + * @generated + * @ordered + */ + int NODE_TOOL_SECTION_FEATURE_COUNT = TOOL_SECTION_FEATURE_COUNT + 2; + + /** + * The number of operations of the 'Node Tool Section' class. + * + * @generated + * @ordered + */ + int NODE_TOOL_SECTION_OPERATION_COUNT = TOOL_SECTION_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl Edge + * Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeToolSection() + * @generated + */ + int EDGE_TOOL_SECTION = 34; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int EDGE_TOOL_SECTION__NAME = TOOL_SECTION__NAME; + + /** + * The feature id for the 'Node Tools' containment reference list. + * + * @generated + * @ordered + */ + int EDGE_TOOL_SECTION__NODE_TOOLS = TOOL_SECTION_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Edge Reconnection Tools' containment reference list. + * + * @generated + * @ordered + */ + int EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS = TOOL_SECTION_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Edge Tool Section' class. + * + * @generated + * @ordered + */ + int EDGE_TOOL_SECTION_FEATURE_COUNT = TOOL_SECTION_FEATURE_COUNT + 2; + + /** + * The number of operations of the 'Edge Tool Section' class. + * + * @generated + * @ordered + */ + int EDGE_TOOL_SECTION_OPERATION_COUNT = TOOL_SECTION_OPERATION_COUNT + 0; + /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.ArrowStyle Arrow Style}' * enum. @@ -2426,7 +2638,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getArrowStyle() * @generated */ - int ARROW_STYLE = 31; + int ARROW_STYLE = 35; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LayoutDirection Layout @@ -2436,7 +2648,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLayoutDirection() * @generated */ - int LAYOUT_DIRECTION = 32; + int LAYOUT_DIRECTION = 36; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LineStyle Line Style}' @@ -2446,7 +2658,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLineStyle() * @generated */ - int LINE_STYLE = 33; + int LINE_STYLE = 37; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.NodeContainmentKind Node @@ -2456,7 +2668,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeContainmentKind() * @generated */ - int NODE_CONTAINMENT_KIND = 34; + int NODE_CONTAINMENT_KIND = 38; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.SynchronizationPolicy @@ -2466,7 +2678,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getSynchronizationPolicy() * @generated */ - int SYNCHRONIZATION_POLICY = 35; + int SYNCHRONIZATION_POLICY = 39; /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.DiagramDescription @@ -3228,6 +3440,18 @@ public interface DiagramPackage extends EPackage { */ EReference getDiagramPalette_NodeTools(); + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.DiagramPalette#getToolSections Tool Sections}'. + * + * @return the meta object for the containment reference list 'Tool Sections'. + * @see org.eclipse.sirius.components.view.diagram.DiagramPalette#getToolSections() + * @see #getDiagramPalette() + * @generated + */ + EReference getDiagramPalette_ToolSections(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.NodePalette Node * Palette}'. @@ -3286,6 +3510,18 @@ public interface DiagramPackage extends EPackage { */ EReference getNodePalette_EdgeTools(); + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.NodePalette#getToolSections Tool Sections}'. + * + * @return the meta object for the containment reference list 'Tool Sections'. + * @see org.eclipse.sirius.components.view.diagram.NodePalette#getToolSections() + * @see #getNodePalette() + * @generated + */ + EReference getNodePalette_ToolSections(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.EdgePalette Edge * Palette}'. @@ -3368,6 +3604,18 @@ public interface DiagramPackage extends EPackage { */ EReference getEdgePalette_EdgeReconnectionTools(); + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.EdgePalette#getToolSections Tool Sections}'. + * + * @return the meta object for the containment reference list 'Tool Sections'. + * @see org.eclipse.sirius.components.view.diagram.EdgePalette#getToolSections() + * @see #getEdgePalette() + * @generated + */ + EReference getEdgePalette_ToolSections(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.Tool Tool}'. @@ -3645,6 +3893,117 @@ public interface DiagramPackage extends EPackage { */ EAttribute getSelectionDescription_SelectionMessage(); + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ToolSection Tool + * Section}'. + * + * @return the meta object for class 'Tool Section'. + * @see org.eclipse.sirius.components.view.diagram.ToolSection + * @generated + */ + EClass getToolSection(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.sirius.components.view.diagram.ToolSection#getName + * Name}'. + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.sirius.components.view.diagram.ToolSection#getName() + * @see #getToolSection() + * @generated + */ + EAttribute getToolSection_Name(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.DiagramToolSection Tool + * Section}'. + * + * @return the meta object for class 'Tool Section'. + * @see org.eclipse.sirius.components.view.diagram.DiagramToolSection + * @generated + */ + EClass getDiagramToolSection(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.DiagramToolSection#getNodeTools Node Tools}'. + * + * @return the meta object for the containment reference list 'Node Tools'. + * @see org.eclipse.sirius.components.view.diagram.DiagramToolSection#getNodeTools() + * @see #getDiagramToolSection() + * @generated + */ + EReference getDiagramToolSection_NodeTools(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.NodeToolSection Node + * Tool Section}'. + * + * @return the meta object for class 'Node Tool Section'. + * @see org.eclipse.sirius.components.view.diagram.NodeToolSection + * @generated + */ + EClass getNodeToolSection(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.NodeToolSection#getNodeTools Node Tools}'. + * + * @return the meta object for the containment reference list 'Node Tools'. + * @see org.eclipse.sirius.components.view.diagram.NodeToolSection#getNodeTools() + * @see #getNodeToolSection() + * @generated + */ + EReference getNodeToolSection_NodeTools(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.NodeToolSection#getEdgeTools Edge Tools}'. + * + * @return the meta object for the containment reference list 'Edge Tools'. + * @see org.eclipse.sirius.components.view.diagram.NodeToolSection#getEdgeTools() + * @see #getNodeToolSection() + * @generated + */ + EReference getNodeToolSection_EdgeTools(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.EdgeToolSection Edge + * Tool Section}'. + * + * @return the meta object for class 'Edge Tool Section'. + * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection + * @generated + */ + EClass getEdgeToolSection(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.EdgeToolSection#getNodeTools Node Tools}'. + * + * @return the meta object for the containment reference list 'Node Tools'. + * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection#getNodeTools() + * @see #getEdgeToolSection() + * @generated + */ + EReference getEdgeToolSection_NodeTools(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.EdgeToolSection#getEdgeReconnectionTools Edge Reconnection + * Tools}'. + * + * @return the meta object for the containment reference list 'Edge Reconnection Tools'. + * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection#getEdgeReconnectionTools() + * @see #getEdgeToolSection() + * @generated + */ + EReference getEdgeToolSection_EdgeReconnectionTools(); + /** * Returns the meta object for enum '{@link org.eclipse.sirius.components.view.diagram.ArrowStyle Arrow * Style}'. @@ -4288,6 +4647,14 @@ interface Literals { */ EReference DIAGRAM_PALETTE__NODE_TOOLS = eINSTANCE.getDiagramPalette_NodeTools(); + /** + * The meta object literal for the 'Tool Sections' containment reference list feature. + * + * @generated + */ + EReference DIAGRAM_PALETTE__TOOL_SECTIONS = eINSTANCE.getDiagramPalette_ToolSections(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.NodePaletteImpl * Node Palette}' class. @@ -4330,6 +4697,14 @@ interface Literals { */ EReference NODE_PALETTE__EDGE_TOOLS = eINSTANCE.getNodePalette_EdgeTools(); + /** + * The meta object literal for the 'Tool Sections' containment reference list feature. + * + * @generated + */ + EReference NODE_PALETTE__TOOL_SECTIONS = eINSTANCE.getNodePalette_ToolSections(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.EdgePaletteImpl * Edge Palette}' class. @@ -4388,6 +4763,14 @@ interface Literals { */ EReference EDGE_PALETTE__EDGE_RECONNECTION_TOOLS = eINSTANCE.getEdgePalette_EdgeReconnectionTools(); + /** + * The meta object literal for the 'Tool Sections' containment reference list feature. + * + * @generated + */ + EReference EDGE_PALETTE__TOOL_SECTIONS = eINSTANCE.getEdgePalette_ToolSections(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.ToolImpl * Tool}' class. @@ -4616,6 +4999,95 @@ interface Literals { */ EAttribute SELECTION_DESCRIPTION__SELECTION_MESSAGE = eINSTANCE.getSelectionDescription_SelectionMessage(); + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.ToolSectionImpl + * Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.ToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getToolSection() + * @generated + */ + EClass TOOL_SECTION = eINSTANCE.getToolSection(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * @generated + */ + EAttribute TOOL_SECTION__NAME = eINSTANCE.getToolSection_Name(); + + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl Tool Section}' class. + * + * + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramToolSection() + * @generated + */ + EClass DIAGRAM_TOOL_SECTION = eINSTANCE.getDiagramToolSection(); + + /** + * The meta object literal for the 'Node Tools' containment reference list feature. + * + * @generated + */ + EReference DIAGRAM_TOOL_SECTION__NODE_TOOLS = eINSTANCE.getDiagramToolSection_NodeTools(); + + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl + * Node Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeToolSection() + * @generated + */ + EClass NODE_TOOL_SECTION = eINSTANCE.getNodeToolSection(); + + /** + * The meta object literal for the 'Node Tools' containment reference list feature. + * + * @generated + */ + EReference NODE_TOOL_SECTION__NODE_TOOLS = eINSTANCE.getNodeToolSection_NodeTools(); + + /** + * The meta object literal for the 'Edge Tools' containment reference list feature. + * + * @generated + */ + EReference NODE_TOOL_SECTION__EDGE_TOOLS = eINSTANCE.getNodeToolSection_EdgeTools(); + + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl + * Edge Tool Section}' class. + * + * @see org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeToolSection() + * @generated + */ + EClass EDGE_TOOL_SECTION = eINSTANCE.getEdgeToolSection(); + + /** + * The meta object literal for the 'Node Tools' containment reference list feature. + * + * @generated + */ + EReference EDGE_TOOL_SECTION__NODE_TOOLS = eINSTANCE.getEdgeToolSection_NodeTools(); + + /** + * The meta object literal for the 'Edge Reconnection Tools' containment reference list feature. + * + * + * @generated + */ + EReference EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS = eINSTANCE.getEdgeToolSection_EdgeReconnectionTools(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.diagram.ArrowStyle Arrow * Style}' enum. diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPalette.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPalette.java index fd8226ef805..4a3ea6fd818 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPalette.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPalette.java @@ -24,6 +24,7 @@ *
    *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramPalette#getDropTool Drop Tool}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramPalette#getNodeTools Node Tools}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramPalette#getToolSections Tool Sections}
  • *
* * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramPalette() @@ -65,4 +66,16 @@ public interface DiagramPalette extends EObject { */ EList getNodeTools(); + /** + * Returns the value of the 'Tool Sections' containment reference list. The list contents are of + * type {@link org.eclipse.sirius.components.view.diagram.DiagramToolSection}. + * + * @return the value of the 'Tool Sections' containment reference list. + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramPalette_ToolSections() + * @model containment="true" + * @generated + */ + EList getToolSections(); + } // DiagramPalette diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramToolSection.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramToolSection.java new file mode 100644 index 00000000000..58784844e60 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramToolSection.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object 'Tool Section'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramToolSection#getNodeTools Node Tools}
  • + *
+ * + * @model + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramToolSection() + */ +public interface DiagramToolSection extends ToolSection { + + /** + * Returns the value of the 'Node Tools' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.diagram.NodeTool}. + * + * @return the value of the 'Node Tools' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramToolSection_NodeTools() + */ + EList getNodeTools(); + +} // DiagramToolSection diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgePalette.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgePalette.java index 9c0873bd304..6dc2d6fd3eb 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgePalette.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgePalette.java @@ -32,6 +32,7 @@ *
  • {@link org.eclipse.sirius.components.view.diagram.EdgePalette#getNodeTools Node Tools}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.EdgePalette#getEdgeReconnectionTools Edge Reconnection * Tools}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.EdgePalette#getToolSections Tool Sections}
  • * * * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgePalette() @@ -154,4 +155,16 @@ public interface EdgePalette extends EObject { */ EList getEdgeReconnectionTools(); + /** + * Returns the value of the 'Tool Sections' containment reference list. The list contents are of + * type {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection}. + * + * @return the value of the 'Tool Sections' containment reference list. + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgePalette_ToolSections() + * @model containment="true" + * @generated + */ + EList getToolSections(); + } // EdgePalette diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeToolSection.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeToolSection.java new file mode 100644 index 00000000000..3f612dbc5a2 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeToolSection.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object 'Edge Tool Section'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection#getNodeTools Node Tools}
    • + *
    • {@link org.eclipse.sirius.components.view.diagram.EdgeToolSection#getEdgeReconnectionTools Edge Reconnection + * Tools}
    • + *
    + * + * @model + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgeToolSection() + */ +public interface EdgeToolSection extends ToolSection { + + /** + * Returns the value of the 'Node Tools' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.diagram.NodeTool}. + * + * @return the value of the 'Node Tools' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgeToolSection_NodeTools() + */ + EList getNodeTools(); + + /** + * Returns the value of the 'Edge Reconnection Tools' containment reference list. The list contents + * are of type {@link org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool}. + * + * @return the value of the 'Edge Reconnection Tools' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgeToolSection_EdgeReconnectionTools() + */ + EList getEdgeReconnectionTools(); + +} // EdgeToolSection diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodePalette.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodePalette.java index 0e0f3cadda7..e5af088097b 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodePalette.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodePalette.java @@ -26,6 +26,7 @@ *
  • {@link org.eclipse.sirius.components.view.diagram.NodePalette#getLabelEditTool Label Edit Tool}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.NodePalette#getNodeTools Node Tools}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.NodePalette#getEdgeTools Edge Tools}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.NodePalette#getToolSections Tool Sections}
  • * * * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodePalette() @@ -101,4 +102,16 @@ public interface NodePalette extends EObject { */ EList getEdgeTools(); + /** + * Returns the value of the 'Tool Sections' containment reference list. The list contents are of + * type {@link org.eclipse.sirius.components.view.diagram.NodeToolSection}. + * + * @return the value of the 'Tool Sections' containment reference list. + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodePalette_ToolSections() + * @model containment="true" + * @generated + */ + EList getToolSections(); + } // NodePalette diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeToolSection.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeToolSection.java new file mode 100644 index 00000000000..6f1c5ba04d7 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeToolSection.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object 'Node Tool Section'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.NodeToolSection#getNodeTools Node Tools}
    • + *
    • {@link org.eclipse.sirius.components.view.diagram.NodeToolSection#getEdgeTools Edge Tools}
    • + *
    + * + * @model + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodeToolSection() + */ +public interface NodeToolSection extends ToolSection { + + /** + * Returns the value of the 'Node Tools' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.diagram.NodeTool}. + * + * @return the value of the 'Node Tools' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodeToolSection_NodeTools() + */ + EList getNodeTools(); + + /** + * Returns the value of the 'Edge Tools' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.diagram.EdgeTool}. + * + * @return the value of the 'Edge Tools' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodeToolSection_EdgeTools() + */ + EList getEdgeTools(); + +} // NodeToolSection diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ToolSection.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ToolSection.java new file mode 100644 index 00000000000..0ca488047a5 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ToolSection.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object 'Tool Section'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.ToolSection#getName Name}
    • + *
    + * + * @model abstract="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getToolSection() + */ +public interface ToolSection extends EObject { + + /** + * Returns the value of the 'Name' attribute. The default value is "Tool". + * + * @return the value of the 'Name' attribute. + * @model default="Tool" dataType="org.eclipse.sirius.components.view.Identifier" required="true" + * @generated + * @see #setName(String) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getToolSection_Name() + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.ToolSection#getName Name}' + * attribute. + * + * @param value the new value of the 'Name' attribute. + * @generated + * @see #getName() + */ + void setName(String value); + +} // ToolSection diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramFactoryImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramFactoryImpl.java index 87b863c266a..69b2c82e84f 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramFactoryImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramFactoryImpl.java @@ -28,11 +28,13 @@ import org.eclipse.sirius.components.view.diagram.DiagramFactory; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropTool; import org.eclipse.sirius.components.view.diagram.EdgeDescription; import org.eclipse.sirius.components.view.diagram.EdgePalette; import org.eclipse.sirius.components.view.diagram.EdgeStyle; import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription; import org.eclipse.sirius.components.view.diagram.IconLabelNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.ImageNodeStyleDescription; @@ -44,6 +46,7 @@ import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.NodePalette; import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.diagram.RectangularNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.SelectionDescription; import org.eclipse.sirius.components.view.diagram.SourceEdgeEndReconnectionTool; @@ -138,6 +141,12 @@ public EObject create(EClass eClass) { return this.createDeleteView(); case DiagramPackage.SELECTION_DESCRIPTION: return this.createSelectionDescription(); + case DiagramPackage.DIAGRAM_TOOL_SECTION: + return this.createDiagramToolSection(); + case DiagramPackage.NODE_TOOL_SECTION: + return this.createNodeToolSection(); + case DiagramPackage.EDGE_TOOL_SECTION: + return this.createEdgeToolSection(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -453,6 +462,39 @@ public SelectionDescription createSelectionDescription() { return selectionDescription; } + /** + * + * + * @generated + */ + @Override + public DiagramToolSection createDiagramToolSection() { + DiagramToolSectionImpl diagramToolSection = new DiagramToolSectionImpl(); + return diagramToolSection; + } + + /** + * + * + * @generated + */ + @Override + public NodeToolSection createNodeToolSection() { + NodeToolSectionImpl nodeToolSection = new NodeToolSectionImpl(); + return nodeToolSection; + } + + /** + * + * + * @generated + */ + @Override + public EdgeToolSection createEdgeToolSection() { + EdgeToolSectionImpl edgeToolSection = new EdgeToolSectionImpl(); + return edgeToolSection; + } + /** * * diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java index 568f315ba81..0bcab469af0 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java @@ -31,12 +31,14 @@ import org.eclipse.sirius.components.view.diagram.DiagramFactory; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropTool; import org.eclipse.sirius.components.view.diagram.EdgeDescription; import org.eclipse.sirius.components.view.diagram.EdgePalette; import org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool; import org.eclipse.sirius.components.view.diagram.EdgeStyle; import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription; import org.eclipse.sirius.components.view.diagram.IconLabelNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.ImageNodeStyleDescription; @@ -50,6 +52,7 @@ import org.eclipse.sirius.components.view.diagram.NodePalette; import org.eclipse.sirius.components.view.diagram.NodeStyleDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.diagram.RectangularNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.SelectionDescription; import org.eclipse.sirius.components.view.diagram.SourceEdgeEndReconnectionTool; @@ -57,6 +60,7 @@ import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.sirius.components.view.diagram.TargetEdgeEndReconnectionTool; import org.eclipse.sirius.components.view.diagram.Tool; +import org.eclipse.sirius.components.view.diagram.ToolSection; /** * An implementation of the model Package. @@ -281,6 +285,34 @@ public class DiagramPackageImpl extends EPackageImpl implements DiagramPackage { */ private EClass selectionDescriptionEClass = null; + /** + * + * + * @generated + */ + private EClass toolSectionEClass = null; + + /** + * + * + * @generated + */ + private EClass diagramToolSectionEClass = null; + + /** + * + * + * @generated + */ + private EClass nodeToolSectionEClass = null; + + /** + * + * + * @generated + */ + private EClass edgeToolSectionEClass = null; + /** * * @@ -1040,6 +1072,16 @@ public EReference getDiagramPalette_NodeTools() { return (EReference) this.diagramPaletteEClass.getEStructuralFeatures().get(1); } + /** + * + * + * @generated + */ + @Override + public EReference getDiagramPalette_ToolSections() { + return (EReference) this.diagramPaletteEClass.getEStructuralFeatures().get(2); + } + /** * * @@ -1090,6 +1132,16 @@ public EReference getNodePalette_EdgeTools() { return (EReference) this.nodePaletteEClass.getEStructuralFeatures().get(3); } + /** + * + * + * @generated + */ + @Override + public EReference getNodePalette_ToolSections() { + return (EReference) this.nodePaletteEClass.getEStructuralFeatures().get(4); + } + /** * * @@ -1160,6 +1212,16 @@ public EReference getEdgePalette_EdgeReconnectionTools() { return (EReference) this.edgePaletteEClass.getEStructuralFeatures().get(5); } + /** + * + * + * @generated + */ + @Override + public EReference getEdgePalette_ToolSections() { + return (EReference) this.edgePaletteEClass.getEStructuralFeatures().get(6); + } + /** * * @@ -1410,6 +1472,106 @@ public EAttribute getSelectionDescription_SelectionMessage() { return (EAttribute) this.selectionDescriptionEClass.getEStructuralFeatures().get(1); } + /** + * + * + * @generated + */ + @Override + public EClass getToolSection() { + return this.toolSectionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getToolSection_Name() { + return (EAttribute) this.toolSectionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getDiagramToolSection() { + return this.diagramToolSectionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getDiagramToolSection_NodeTools() { + return (EReference) this.diagramToolSectionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getNodeToolSection() { + return this.nodeToolSectionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getNodeToolSection_NodeTools() { + return (EReference) this.nodeToolSectionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getNodeToolSection_EdgeTools() { + return (EReference) this.nodeToolSectionEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EClass getEdgeToolSection() { + return this.edgeToolSectionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getEdgeToolSection_NodeTools() { + return (EReference) this.edgeToolSectionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getEdgeToolSection_EdgeReconnectionTools() { + return (EReference) this.edgeToolSectionEClass.getEStructuralFeatures().get(1); + } + /** * * @@ -1571,12 +1733,14 @@ public void createPackageContents() { this.diagramPaletteEClass = this.createEClass(DIAGRAM_PALETTE); this.createEReference(this.diagramPaletteEClass, DIAGRAM_PALETTE__DROP_TOOL); this.createEReference(this.diagramPaletteEClass, DIAGRAM_PALETTE__NODE_TOOLS); + this.createEReference(this.diagramPaletteEClass, DIAGRAM_PALETTE__TOOL_SECTIONS); this.nodePaletteEClass = this.createEClass(NODE_PALETTE); this.createEReference(this.nodePaletteEClass, NODE_PALETTE__DELETE_TOOL); this.createEReference(this.nodePaletteEClass, NODE_PALETTE__LABEL_EDIT_TOOL); this.createEReference(this.nodePaletteEClass, NODE_PALETTE__NODE_TOOLS); this.createEReference(this.nodePaletteEClass, NODE_PALETTE__EDGE_TOOLS); + this.createEReference(this.nodePaletteEClass, NODE_PALETTE__TOOL_SECTIONS); this.edgePaletteEClass = this.createEClass(EDGE_PALETTE); this.createEReference(this.edgePaletteEClass, EDGE_PALETTE__DELETE_TOOL); @@ -1585,6 +1749,7 @@ public void createPackageContents() { this.createEReference(this.edgePaletteEClass, EDGE_PALETTE__END_LABEL_EDIT_TOOL); this.createEReference(this.edgePaletteEClass, EDGE_PALETTE__NODE_TOOLS); this.createEReference(this.edgePaletteEClass, EDGE_PALETTE__EDGE_RECONNECTION_TOOLS); + this.createEReference(this.edgePaletteEClass, EDGE_PALETTE__TOOL_SECTIONS); this.toolEClass = this.createEClass(TOOL); this.createEAttribute(this.toolEClass, TOOL__NAME); @@ -1623,6 +1788,20 @@ public void createPackageContents() { this.createEAttribute(this.selectionDescriptionEClass, SELECTION_DESCRIPTION__SELECTION_CANDIDATES_EXPRESSION); this.createEAttribute(this.selectionDescriptionEClass, SELECTION_DESCRIPTION__SELECTION_MESSAGE); + this.toolSectionEClass = this.createEClass(TOOL_SECTION); + this.createEAttribute(this.toolSectionEClass, TOOL_SECTION__NAME); + + this.diagramToolSectionEClass = this.createEClass(DIAGRAM_TOOL_SECTION); + this.createEReference(this.diagramToolSectionEClass, DIAGRAM_TOOL_SECTION__NODE_TOOLS); + + this.nodeToolSectionEClass = this.createEClass(NODE_TOOL_SECTION); + this.createEReference(this.nodeToolSectionEClass, NODE_TOOL_SECTION__NODE_TOOLS); + this.createEReference(this.nodeToolSectionEClass, NODE_TOOL_SECTION__EDGE_TOOLS); + + this.edgeToolSectionEClass = this.createEClass(EDGE_TOOL_SECTION); + this.createEReference(this.edgeToolSectionEClass, EDGE_TOOL_SECTION__NODE_TOOLS); + this.createEReference(this.edgeToolSectionEClass, EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS); + // Create enums this.arrowStyleEEnum = this.createEEnum(ARROW_STYLE); this.layoutDirectionEEnum = this.createEEnum(LAYOUT_DIRECTION); @@ -1688,6 +1867,9 @@ public void initializePackageContents() { this.targetEdgeEndReconnectionToolEClass.getESuperTypes().add(this.getEdgeReconnectionTool()); this.createViewEClass.getESuperTypes().add(theViewPackage.getOperation()); this.deleteViewEClass.getESuperTypes().add(theViewPackage.getOperation()); + this.diagramToolSectionEClass.getESuperTypes().add(this.getToolSection()); + this.nodeToolSectionEClass.getESuperTypes().add(this.getToolSection()); + this.edgeToolSectionEClass.getESuperTypes().add(this.getToolSection()); // Initialize classes, features, and operations; add parameters this.initEClass(this.diagramDescriptionEClass, DiagramDescription.class, "DiagramDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -1822,6 +2004,8 @@ public void initializePackageContents() { !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEReference(this.getDiagramPalette_NodeTools(), this.getNodeTool(), null, "nodeTools", null, 0, -1, DiagramPalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getDiagramPalette_ToolSections(), this.getDiagramToolSection(), null, "toolSections", null, 0, -1, DiagramPalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.nodePaletteEClass, NodePalette.class, "NodePalette", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEReference(this.getNodePalette_DeleteTool(), this.getDeleteTool(), null, "deleteTool", null, 0, 1, NodePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, @@ -1832,6 +2016,8 @@ public void initializePackageContents() { !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEReference(this.getNodePalette_EdgeTools(), this.getEdgeTool(), null, "edgeTools", null, 0, -1, NodePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getNodePalette_ToolSections(), this.getNodeToolSection(), null, "toolSections", null, 0, -1, NodePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.edgePaletteEClass, EdgePalette.class, "EdgePalette", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEReference(this.getEdgePalette_DeleteTool(), this.getDeleteTool(), null, "deleteTool", null, 0, 1, EdgePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, @@ -1846,6 +2032,8 @@ public void initializePackageContents() { !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEReference(this.getEdgePalette_EdgeReconnectionTools(), this.getEdgeReconnectionTool(), null, "edgeReconnectionTools", null, 0, -1, EdgePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getEdgePalette_ToolSections(), this.getEdgeToolSection(), null, "toolSections", null, 0, -1, EdgePalette.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.toolEClass, Tool.class, "Tool", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEAttribute(this.getTool_Name(), theViewPackage.getIdentifier(), "name", "Tool", 1, 1, Tool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, @@ -1897,6 +2085,26 @@ public void initializePackageContents() { this.initEAttribute(this.getSelectionDescription_SelectionMessage(), this.ecorePackage.getEString(), "selectionMessage", null, 0, 1, SelectionDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.toolSectionEClass, ToolSection.class, "ToolSection", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEAttribute(this.getToolSection_Name(), theViewPackage.getIdentifier(), "name", "Tool Section", 1, 1, ToolSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, + !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.diagramToolSectionEClass, DiagramToolSection.class, "DiagramToolSection", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getDiagramToolSection_NodeTools(), this.getNodeTool(), null, "nodeTools", null, 0, -1, DiagramToolSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.nodeToolSectionEClass, NodeToolSection.class, "NodeToolSection", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getNodeToolSection_NodeTools(), this.getNodeTool(), null, "nodeTools", null, 0, -1, NodeToolSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getNodeToolSection_EdgeTools(), this.getEdgeTool(), null, "edgeTools", null, 0, -1, NodeToolSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.edgeToolSectionEClass, EdgeToolSection.class, "EdgeToolSection", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getEdgeToolSection_NodeTools(), this.getNodeTool(), null, "nodeTools", null, 0, -1, EdgeToolSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getEdgeToolSection_EdgeReconnectionTools(), this.getEdgeReconnectionTool(), null, "edgeReconnectionTools", null, 0, -1, EdgeToolSection.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + // Initialize enums and add enum literals this.initEEnum(this.arrowStyleEEnum, ArrowStyle.class, "ArrowStyle"); this.addEEnumLiteral(this.arrowStyleEEnum, ArrowStyle.NONE); diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPaletteImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPaletteImpl.java index f66b1da8e09..5fdc4400210 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPaletteImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPaletteImpl.java @@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropTool; import org.eclipse.sirius.components.view.diagram.NodeTool; @@ -36,6 +37,8 @@ *
      *
    • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramPaletteImpl#getDropTool Drop Tool}
    • *
    • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramPaletteImpl#getNodeTools Node Tools}
    • + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramPaletteImpl#getToolSections Tool + * Sections}
    • *
    * * @generated @@ -61,6 +64,16 @@ public class DiagramPaletteImpl extends MinimalEObjectImpl.Container implements */ protected EList nodeTools; + /** + * The cached value of the '{@link #getToolSections() Tool Sections}' containment reference list. + * + * @see #getToolSections() + * @generated + * @ordered + */ + protected EList toolSections; + /** * * @@ -141,6 +154,19 @@ public EList getNodeTools() { return this.nodeTools; } + /** + * + * + * @generated + */ + @Override + public EList getToolSections() { + if (this.toolSections == null) { + this.toolSections = new EObjectContainmentEList<>(DiagramToolSection.class, this, DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS); + } + return this.toolSections; + } + /** * * @@ -153,6 +179,8 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, return this.basicSetDropTool(null, msgs); case DiagramPackage.DIAGRAM_PALETTE__NODE_TOOLS: return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: + return ((InternalEList) this.getToolSections()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } @@ -169,6 +197,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getDropTool(); case DiagramPackage.DIAGRAM_PALETTE__NODE_TOOLS: return this.getNodeTools(); + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: + return this.getToolSections(); } return super.eGet(featureID, resolve, coreType); } @@ -189,6 +219,10 @@ public void eSet(int featureID, Object newValue) { this.getNodeTools().clear(); this.getNodeTools().addAll((Collection) newValue); return; + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + this.getToolSections().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -207,6 +241,9 @@ public void eUnset(int featureID) { case DiagramPackage.DIAGRAM_PALETTE__NODE_TOOLS: this.getNodeTools().clear(); return; + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + return; } super.eUnset(featureID); } @@ -223,6 +260,8 @@ public boolean eIsSet(int featureID) { return this.dropTool != null; case DiagramPackage.DIAGRAM_PALETTE__NODE_TOOLS: return this.nodeTools != null && !this.nodeTools.isEmpty(); + case DiagramPackage.DIAGRAM_PALETTE__TOOL_SECTIONS: + return this.toolSections != null && !this.toolSections.isEmpty(); } return super.eIsSet(featureID); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramToolSectionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramToolSectionImpl.java new file mode 100644 index 00000000000..50e31ca67c6 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramToolSectionImpl.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram.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.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; +import org.eclipse.sirius.components.view.diagram.NodeTool; + +/** + * An implementation of the model object 'Tool Section'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl#getNodeTools Node + * Tools}
    • + *
    + * + * @generated + */ +public class DiagramToolSectionImpl extends ToolSectionImpl implements DiagramToolSection { + + /** + * The cached value of the '{@link #getNodeTools() Node Tools}' containment reference list. + * + * @generated + * @ordered + * @see #getNodeTools() + */ + protected EList nodeTools; + + /** + * + * + * @generated + */ + protected DiagramToolSectionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.DIAGRAM_TOOL_SECTION; + } + + /** + * + * + * @generated + */ + @Override + public EList getNodeTools() { + if (this.nodeTools == null) { + this.nodeTools = new EObjectContainmentEList<>(NodeTool.class, this, DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS); + } + return this.nodeTools; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + return this.getNodeTools(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + this.getNodeTools().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.DIAGRAM_TOOL_SECTION__NODE_TOOLS: + return this.nodeTools != null && !this.nodeTools.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // DiagramToolSectionImpl diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgePaletteImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgePaletteImpl.java index 12ad8c0d22a..d42388bd8ad 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgePaletteImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgePaletteImpl.java @@ -27,6 +27,7 @@ import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.EdgePalette; import org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.LabelEditTool; import org.eclipse.sirius.components.view.diagram.NodeTool; @@ -46,6 +47,8 @@ *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgePaletteImpl#getNodeTools Node Tools}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgePaletteImpl#getEdgeReconnectionTools Edge * Reconnection Tools}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgePaletteImpl#getToolSections Tool + * Sections}
  • * * * @generated @@ -111,6 +114,16 @@ public class EdgePaletteImpl extends MinimalEObjectImpl.Container implements Edg */ protected EList edgeReconnectionTools; + /** + * The cached value of the '{@link #getToolSections() Tool Sections}' containment reference list. + * + * @see #getToolSections() + * @generated + * @ordered + */ + protected EList toolSections; + /** * * @@ -348,6 +361,19 @@ public EList getEdgeReconnectionTools() { return this.edgeReconnectionTools; } + /** + * + * + * @generated + */ + @Override + public EList getToolSections() { + if (this.toolSections == null) { + this.toolSections = new EObjectContainmentEList<>(EdgeToolSection.class, this, DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS); + } + return this.toolSections; + } + /** * * @@ -368,6 +394,8 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); case DiagramPackage.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS: return ((InternalEList) this.getEdgeReconnectionTools()).basicRemove(otherEnd, msgs); + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: + return ((InternalEList) this.getToolSections()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } @@ -392,6 +420,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getNodeTools(); case DiagramPackage.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS: return this.getEdgeReconnectionTools(); + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: + return this.getToolSections(); } return super.eGet(featureID, resolve, coreType); } @@ -425,6 +455,10 @@ public void eSet(int featureID, Object newValue) { this.getEdgeReconnectionTools().clear(); this.getEdgeReconnectionTools().addAll((Collection) newValue); return; + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + this.getToolSections().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -455,6 +489,9 @@ public void eUnset(int featureID) { case DiagramPackage.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS: this.getEdgeReconnectionTools().clear(); return; + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + return; } super.eUnset(featureID); } @@ -479,6 +516,8 @@ public boolean eIsSet(int featureID) { return this.nodeTools != null && !this.nodeTools.isEmpty(); case DiagramPackage.EDGE_PALETTE__EDGE_RECONNECTION_TOOLS: return this.edgeReconnectionTools != null && !this.edgeReconnectionTools.isEmpty(); + case DiagramPackage.EDGE_PALETTE__TOOL_SECTIONS: + return this.toolSections != null && !this.toolSections.isEmpty(); } return super.eIsSet(featureID); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeToolSectionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeToolSectionImpl.java new file mode 100644 index 00000000000..1b7521615b4 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeToolSectionImpl.java @@ -0,0 +1,196 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram.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.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; +import org.eclipse.sirius.components.view.diagram.NodeTool; + +/** + * An implementation of the model object 'Edge Tool Section'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl#getNodeTools Node Tools}
    • + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl#getEdgeReconnectionTools Edge + * Reconnection Tools}
    • + *
    + * + * @generated + */ +public class EdgeToolSectionImpl extends ToolSectionImpl implements EdgeToolSection { + + /** + * The cached value of the '{@link #getNodeTools() Node Tools}' containment reference list. + * + * @generated + * @ordered + * @see #getNodeTools() + */ + protected EList nodeTools; + + /** + * The cached value of the '{@link #getEdgeReconnectionTools() Edge Reconnection Tools}' containment + * reference list. + * + * @generated + * @ordered + * @see #getEdgeReconnectionTools() + */ + protected EList edgeReconnectionTools; + + /** + * + * + * @generated + */ + protected EdgeToolSectionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.EDGE_TOOL_SECTION; + } + + /** + * + * + * @generated + */ + @Override + public EList getNodeTools() { + if (this.nodeTools == null) { + this.nodeTools = new EObjectContainmentEList<>(NodeTool.class, this, DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS); + } + return this.nodeTools; + } + + /** + * + * + * @generated + */ + @Override + public EList getEdgeReconnectionTools() { + if (this.edgeReconnectionTools == null) { + this.edgeReconnectionTools = new EObjectContainmentEList<>(EdgeReconnectionTool.class, this, DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS); + } + return this.edgeReconnectionTools; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + return ((InternalEList) this.getEdgeReconnectionTools()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + return this.getNodeTools(); + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + return this.getEdgeReconnectionTools(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + this.getNodeTools().addAll((Collection) newValue); + return; + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + this.getEdgeReconnectionTools().clear(); + this.getEdgeReconnectionTools().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + return; + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + this.getEdgeReconnectionTools().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.EDGE_TOOL_SECTION__NODE_TOOLS: + return this.nodeTools != null && !this.nodeTools.isEmpty(); + case DiagramPackage.EDGE_TOOL_SECTION__EDGE_RECONNECTION_TOOLS: + return this.edgeReconnectionTools != null && !this.edgeReconnectionTools.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // EdgeToolSectionImpl diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodePaletteImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodePaletteImpl.java index 4ffd668fc5f..e267e7d675c 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodePaletteImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodePaletteImpl.java @@ -29,6 +29,7 @@ import org.eclipse.sirius.components.view.diagram.LabelEditTool; import org.eclipse.sirius.components.view.diagram.NodePalette; import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; /** * An implementation of the model object 'Node Palette'. @@ -41,6 +42,8 @@ * Tool
    } *
  • {@link org.eclipse.sirius.components.view.diagram.impl.NodePaletteImpl#getNodeTools Node Tools}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.impl.NodePaletteImpl#getEdgeTools Edge Tools}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.NodePaletteImpl#getToolSections Tool + * Sections}
  • * * * @generated @@ -86,6 +89,16 @@ public class NodePaletteImpl extends MinimalEObjectImpl.Container implements Nod */ protected EList edgeTools; + /** + * The cached value of the '{@link #getToolSections() Tool Sections}' containment reference list. + * + * @see #getToolSections() + * @generated + * @ordered + */ + protected EList toolSections; + /** * * @@ -227,6 +240,19 @@ public EList getEdgeTools() { return this.edgeTools; } + /** + * + * + * @generated + */ + @Override + public EList getToolSections() { + if (this.toolSections == null) { + this.toolSections = new EObjectContainmentEList<>(NodeToolSection.class, this, DiagramPackage.NODE_PALETTE__TOOL_SECTIONS); + } + return this.toolSections; + } + /** * * @@ -243,6 +269,8 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); case DiagramPackage.NODE_PALETTE__EDGE_TOOLS: return ((InternalEList) this.getEdgeTools()).basicRemove(otherEnd, msgs); + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: + return ((InternalEList) this.getToolSections()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } @@ -263,6 +291,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getNodeTools(); case DiagramPackage.NODE_PALETTE__EDGE_TOOLS: return this.getEdgeTools(); + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: + return this.getToolSections(); } return super.eGet(featureID, resolve, coreType); } @@ -290,6 +320,10 @@ public void eSet(int featureID, Object newValue) { this.getEdgeTools().clear(); this.getEdgeTools().addAll((Collection) newValue); return; + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + this.getToolSections().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -314,6 +348,9 @@ public void eUnset(int featureID) { case DiagramPackage.NODE_PALETTE__EDGE_TOOLS: this.getEdgeTools().clear(); return; + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: + this.getToolSections().clear(); + return; } super.eUnset(featureID); } @@ -334,6 +371,8 @@ public boolean eIsSet(int featureID) { return this.nodeTools != null && !this.nodeTools.isEmpty(); case DiagramPackage.NODE_PALETTE__EDGE_TOOLS: return this.edgeTools != null && !this.edgeTools.isEmpty(); + case DiagramPackage.NODE_PALETTE__TOOL_SECTIONS: + return this.toolSections != null && !this.toolSections.isEmpty(); } return super.eIsSet(featureID); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodeToolSectionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodeToolSectionImpl.java new file mode 100644 index 00000000000..3c6d06166e6 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/NodeToolSectionImpl.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram.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.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; + +/** + * An implementation of the model object 'Node Tool Section'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl#getNodeTools Node Tools}
    • + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl#getEdgeTools Edge Tools}
    • + *
    + * + * @generated + */ +public class NodeToolSectionImpl extends ToolSectionImpl implements NodeToolSection { + + /** + * The cached value of the '{@link #getNodeTools() Node Tools}' containment reference list. + * + * @generated + * @ordered + * @see #getNodeTools() + */ + protected EList nodeTools; + + /** + * The cached value of the '{@link #getEdgeTools() Edge Tools}' containment reference list. + * + * @generated + * @ordered + * @see #getEdgeTools() + */ + protected EList edgeTools; + + /** + * + * + * @generated + */ + protected NodeToolSectionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.NODE_TOOL_SECTION; + } + + /** + * + * + * @generated + */ + @Override + public EList getNodeTools() { + if (this.nodeTools == null) { + this.nodeTools = new EObjectContainmentEList<>(NodeTool.class, this, DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS); + } + return this.nodeTools; + } + + /** + * + * + * @generated + */ + @Override + public EList getEdgeTools() { + if (this.edgeTools == null) { + this.edgeTools = new EObjectContainmentEList<>(EdgeTool.class, this, DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS); + } + return this.edgeTools; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + return ((InternalEList) this.getNodeTools()).basicRemove(otherEnd, msgs); + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + return ((InternalEList) this.getEdgeTools()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + return this.getNodeTools(); + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + return this.getEdgeTools(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + this.getNodeTools().addAll((Collection) newValue); + return; + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + this.getEdgeTools().clear(); + this.getEdgeTools().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + this.getNodeTools().clear(); + return; + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + this.getEdgeTools().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.NODE_TOOL_SECTION__NODE_TOOLS: + return this.nodeTools != null && !this.nodeTools.isEmpty(); + case DiagramPackage.NODE_TOOL_SECTION__EDGE_TOOLS: + return this.edgeTools != null && !this.edgeTools.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // NodeToolSectionImpl diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ToolSectionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ToolSectionImpl.java new file mode 100644 index 00000000000..9340980a88a --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ToolSectionImpl.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2023 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.diagram.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.ToolSection; + +/** + * An implementation of the model object 'Tool Section'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.ToolSectionImpl#getName Name}
    • + *
    + * + * @generated + */ +public abstract class ToolSectionImpl extends MinimalEObjectImpl.Container implements ToolSection { + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * @generated + * @ordered + * @see #getName() + */ + protected static final String NAME_EDEFAULT = "Tool Section"; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * @generated + * @ordered + * @see #getName() + */ + protected String name = NAME_EDEFAULT; + + /** + * + * + * @generated + */ + protected ToolSectionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.TOOL_SECTION; + } + + /** + * + * + * @generated + */ + @Override + public String getName() { + return this.name; + } + + /** + * + * + * @generated + */ + @Override + public void setName(String newName) { + String oldName = this.name; + this.name = newName; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.TOOL_SECTION__NAME, oldName, this.name)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.TOOL_SECTION__NAME: + return this.getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.TOOL_SECTION__NAME: + this.setName((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.TOOL_SECTION__NAME: + this.setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.TOOL_SECTION__NAME: + return NAME_EDEFAULT == null ? this.name != null : !NAME_EDEFAULT.equals(this.name); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + String result = super.toString() + " (name: " + + this.name + + ')'; + return result; + } + +} // ToolSectionImpl diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramAdapterFactory.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramAdapterFactory.java index 455cc5aff6e..82002613cfa 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramAdapterFactory.java @@ -30,12 +30,14 @@ import org.eclipse.sirius.components.view.diagram.DiagramElementDescription; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropTool; import org.eclipse.sirius.components.view.diagram.EdgeDescription; import org.eclipse.sirius.components.view.diagram.EdgePalette; import org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool; import org.eclipse.sirius.components.view.diagram.EdgeStyle; import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription; import org.eclipse.sirius.components.view.diagram.IconLabelNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.ImageNodeStyleDescription; @@ -46,12 +48,14 @@ import org.eclipse.sirius.components.view.diagram.NodePalette; import org.eclipse.sirius.components.view.diagram.NodeStyleDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.diagram.RectangularNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.SelectionDescription; import org.eclipse.sirius.components.view.diagram.SourceEdgeEndReconnectionTool; import org.eclipse.sirius.components.view.diagram.Style; import org.eclipse.sirius.components.view.diagram.TargetEdgeEndReconnectionTool; import org.eclipse.sirius.components.view.diagram.Tool; +import org.eclipse.sirius.components.view.diagram.ToolSection; /** * The Adapter Factory for the model. It provides an adapter createXXX @@ -259,6 +263,26 @@ public Adapter caseSelectionDescription(SelectionDescription object) { return DiagramAdapterFactory.this.createSelectionDescriptionAdapter(); } + @Override + public Adapter caseToolSection(ToolSection object) { + return DiagramAdapterFactory.this.createToolSectionAdapter(); + } + + @Override + public Adapter caseDiagramToolSection(DiagramToolSection object) { + return DiagramAdapterFactory.this.createDiagramToolSectionAdapter(); + } + + @Override + public Adapter caseNodeToolSection(NodeToolSection object) { + return DiagramAdapterFactory.this.createNodeToolSectionAdapter(); + } + + @Override + public Adapter caseEdgeToolSection(EdgeToolSection object) { + return DiagramAdapterFactory.this.createEdgeToolSectionAdapter(); + } + @Override public Adapter caseRepresentationDescription(RepresentationDescription object) { return DiagramAdapterFactory.this.createRepresentationDescriptionAdapter(); @@ -727,6 +751,62 @@ public Adapter createSelectionDescriptionAdapter() { return null; } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.diagram.ToolSection + * Tool Section}'. 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. + * @see org.eclipse.sirius.components.view.diagram.ToolSection + * @generated + */ + public Adapter createToolSectionAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.diagram.DiagramToolSection Tool Section}'. 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. + * @see org.eclipse.sirius.components.view.diagram.DiagramToolSection + * @generated + */ + public Adapter createDiagramToolSectionAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.diagram.NodeToolSection + * Node Tool Section}'. 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. + * @see org.eclipse.sirius.components.view.diagram.NodeToolSection + * @generated + */ + public Adapter createNodeToolSectionAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.diagram.EdgeToolSection + * Edge Tool Section}'. 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. + * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection + * @generated + */ + public Adapter createEdgeToolSectionAdapter() { + 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-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramSwitch.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramSwitch.java index 0da375d1281..bf0a248ecd1 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramSwitch.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/util/DiagramSwitch.java @@ -29,12 +29,14 @@ import org.eclipse.sirius.components.view.diagram.DiagramElementDescription; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropTool; import org.eclipse.sirius.components.view.diagram.EdgeDescription; import org.eclipse.sirius.components.view.diagram.EdgePalette; import org.eclipse.sirius.components.view.diagram.EdgeReconnectionTool; import org.eclipse.sirius.components.view.diagram.EdgeStyle; import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription; import org.eclipse.sirius.components.view.diagram.IconLabelNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.ImageNodeStyleDescription; @@ -45,12 +47,14 @@ import org.eclipse.sirius.components.view.diagram.NodePalette; import org.eclipse.sirius.components.view.diagram.NodeStyleDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; +import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.diagram.RectangularNodeStyleDescription; import org.eclipse.sirius.components.view.diagram.SelectionDescription; import org.eclipse.sirius.components.view.diagram.SourceEdgeEndReconnectionTool; import org.eclipse.sirius.components.view.diagram.Style; import org.eclipse.sirius.components.view.diagram.TargetEdgeEndReconnectionTool; import org.eclipse.sirius.components.view.diagram.Tool; +import org.eclipse.sirius.components.view.diagram.ToolSection; /** * The Switch for the model's inheritance hierarchy. It supports the call @@ -398,6 +402,40 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case DiagramPackage.TOOL_SECTION: { + ToolSection toolSection = (ToolSection) theEObject; + T result = this.caseToolSection(toolSection); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case DiagramPackage.DIAGRAM_TOOL_SECTION: { + DiagramToolSection diagramToolSection = (DiagramToolSection) theEObject; + T result = this.caseDiagramToolSection(diagramToolSection); + if (result == null) + result = this.caseToolSection(diagramToolSection); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case DiagramPackage.NODE_TOOL_SECTION: { + NodeToolSection nodeToolSection = (NodeToolSection) theEObject; + T result = this.caseNodeToolSection(nodeToolSection); + if (result == null) + result = this.caseToolSection(nodeToolSection); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case DiagramPackage.EDGE_TOOL_SECTION: { + EdgeToolSection edgeToolSection = (EdgeToolSection) theEObject; + T result = this.caseEdgeToolSection(edgeToolSection); + if (result == null) + result = this.caseToolSection(edgeToolSection); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } default: return this.defaultCase(theEObject); } @@ -854,6 +892,64 @@ public T caseSelectionDescription(SelectionDescription object) { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Tool Section'. + * 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 'Tool Section'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseToolSection(ToolSection object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Tool Section'. + * 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 'Tool Section'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDiagramToolSection(DiagramToolSection object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Node Tool Section'. 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 'Node Tool Section'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseNodeToolSection(NodeToolSection object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Edge Tool Section'. 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 'Edge Tool Section'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseEdgeToolSection(EdgeToolSection 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.