From ca22269db69909cd0543d41b1451ad0bb1d9fd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20ROU=C3=8BN=C3=89?= Date: Wed, 19 Jun 2024 14:35:04 +0200 Subject: [PATCH] [3647] Add support for diagram style with background customization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/3647 Signed-off-by: Florian ROUËNÉ --- CHANGELOG.adoc | 1 + .../CreateViewOperationHandlerTests.java | 1 + .../DeleteViewOperationHandlerTests.java | 1 + .../diagrams/DiagramDescriptionConverter.java | 3 +- .../main/resources/schema/diagram.graphqls | 5 + .../CreateDiagramEventHandlerTests.java | 1 + .../GetConnectorToolsEventHandlerTests.java | 1 + .../TestDiagramDescriptionBuilder.java | 1 + .../sirius/components/diagrams/Diagram.java | 33 +- .../components/diagrams/DiagramStyle.java | 63 ++++ .../diagrams/components/DiagramComponent.java | 17 +- .../description/DiagramDescription.java | 16 + .../elements/DiagramElementProps.java | 29 +- .../renderer/DiagramElementFactory.java | 10 +- .../DiagramElementChangeVisibilityTests.java | 1 + .../renderer/DiagramRendererEdgeTests.java | 1 + .../renderer/DiagramRendererNodeTests.java | 1 + .../renderer/UnsynchronizedDiagramTests.java | 57 ++-- .../src/converter/convertDiagram.ts | 3 + .../graphql/subscription/diagramFragment.ts | 3 + .../subscription/diagramFragment.types.ts | 5 + .../src/renderer/DiagramRenderer.tsx | 9 +- .../src/renderer/DiagramRenderer.types.ts | 1 + .../renderer/dropNode/useDropDiagramStyle.tsx | 14 +- .../dropNode/useDropDiagramStyle.types.ts | 3 +- .../diagrams/DiagramStyleControllerTests.java | 97 ++++++ .../sirius/web/data/StudioIdentifiers.java | 2 + .../src/test/resources/scripts/studio.sql | 9 +- .../ConditionalDiagramStyleBuilder.java | 65 ++++ .../builder/generated/DiagramBuilders.java | 20 ++ .../generated/DiagramDescriptionBuilder.java | 22 ++ .../DiagramStyleDescriptionBuilder.java | 56 ++++ .../ConditionalDiagramStyleItemProvider.java | 152 +++++++++ .../DiagramDescriptionItemProvider.java | 11 + .../DiagramItemProviderAdapterFactory.java | 52 +++ .../DiagramStyleDescriptionItemProvider.java | 141 ++++++++ .../src/main/resources/plugin.properties | 31 +- .../view/diagram/ConditionalDiagramStyle.java | 57 ++++ .../view/diagram/DiagramDescription.java | 38 +++ .../view/diagram/DiagramFactory.java | 18 +- .../view/diagram/DiagramPackage.java | 301 +++++++++++++++--- .../view/diagram/DiagramStyleDescription.java | 57 ++++ .../impl/ConditionalDiagramStyleImpl.java | 188 +++++++++++ .../diagram/impl/DiagramDescriptionImpl.java | 111 +++++++ .../view/diagram/impl/DiagramFactoryImpl.java | 28 ++ .../view/diagram/impl/DiagramPackageImpl.java | 97 ++++++ .../impl/DiagramStyleDescriptionImpl.java | 168 ++++++++++ .../diagram/util/DiagramAdapterFactory.java | 104 ++++-- .../view/diagram/util/DiagramSwitch.java | 48 +++ .../src/main/resources/model/diagram.ecore | 11 + .../src/main/resources/model/diagram.genmodel | 8 + .../view/emf/diagram/StylesFactory.java | 15 + .../ViewDiagramDescriptionConverter.java | 24 +- .../emf/diagram/ViewPaletteProviderTests.java | 1 + 54 files changed, 2044 insertions(+), 168 deletions(-) create mode 100644 packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/DiagramStyle.java create mode 100644 packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DiagramStyleControllerTests.java create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ConditionalDiagramStyleBuilder.java create mode 100644 packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramStyleDescriptionBuilder.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalDiagramStyleItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramStyleDescriptionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ConditionalDiagramStyle.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramStyleDescription.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalDiagramStyleImpl.java create mode 100644 packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramStyleDescriptionImpl.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 21d3b6d9e3f..e9fa87374fb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -76,6 +76,7 @@ This dialog presents diagram elements in a tree and allows to select them and up + image:doc/screenshots/diagramFilterView.png[Diagram Filter View, 70%] - https://github.com/eclipse-sirius/sirius-web/issues/3523[#3523] [gantt] Support rounding dates when changing dates from gantt +- https://github.com/eclipse-sirius/sirius-web/issues/3647[#3647] [diagram] Add support for diagram style with background customization === Improvements 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 1e0d8b84947..69fffddb5be 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 @@ -88,6 +88,7 @@ public void initialize() { .nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID().toString()))) .edgeDescriptions(List.of()) .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); Diagram diagram = Diagram.newDiagram(UUID.randomUUID().toString()) 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 80348439688..668714bcc48 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 @@ -91,6 +91,7 @@ public void initialize() { .nodeDescriptions(List.of(this.getNodeDescription(UUID.randomUUID().toString()))) .edgeDescriptions(List.of()) .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); Node node = Node.newNode(UUID.randomUUID().toString()) diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionConverter.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionConverter.java index f7d071b5ebc..937d4cc1bd2 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionConverter.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/DiagramDescriptionConverter.java @@ -67,7 +67,8 @@ public DiagramDescription convert(org.eclipse.sirius.diagram.description.Diagram .canCreatePredicate(canCreatePredicate) .labelProvider(labelProvider) .autoLayout(this.isAutoLayoutMode(siriusDiagramDescription)) - .arrangeLayoutDirection(ArrangeLayoutDirection.UNDEFINED); + .arrangeLayoutDirection(ArrangeLayoutDirection.UNDEFINED) + .styleProvider(variableManager -> null); for (IDiagramDescriptionPopulator diagramDescriptionPopulator : this.diagramDescriptionPopulators) { diagramDescriptionPopulator.populate(builder, siriusDiagramDescription, interpreter); 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 1ecbd9e3093..5a411feaeca 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 @@ -37,9 +37,14 @@ type Diagram implements Representation { position: Position! nodes: [Node!]! edges: [Edge!]! + style: DiagramStyle layoutData: DiagramLayoutData! } +type DiagramStyle { + background: String +} + type DiagramLayoutData { nodeLayoutData: [NodeLayoutData!]! } 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 4689ab3e471..f24165fdcf4 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 @@ -64,6 +64,7 @@ public Optional findById(IEditingContext editingCont .nodeDescriptions(new ArrayList<>()) .targetObjectIdProvider(variableManager -> "targetObjectId") .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); // @formatter:on 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 22c32067206..0917a726103 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 @@ -171,6 +171,7 @@ public void testGetConnectorTools() { .edgeDescriptions(new ArrayList<>()) .palettes(List.of(palette)) .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); Node sourceNode = this.getNode(SOURCE_NODE_ID, SOURCE_NODE_TARGET_ID); diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/TestDiagramDescriptionBuilder.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/TestDiagramDescriptionBuilder.java index 21d1e1a5357..11b1d3e86a3 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/TestDiagramDescriptionBuilder.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/TestDiagramDescriptionBuilder.java @@ -55,6 +55,7 @@ public DiagramDescription getDiagramDescription(String diagramDescriptionId, Lis .edgeDescriptions(edgeDescriptions) .palettes(palettes) .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); } diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/Diagram.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/Diagram.java index cad5ee29033..b623b3598c2 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/Diagram.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/Diagram.java @@ -28,6 +28,7 @@ */ @Immutable public final class Diagram implements IRepresentation { + public static final String KIND = IRepresentation.KIND_PREFIX + "?type=Diagram"; private String id; @@ -50,10 +51,20 @@ public final class Diagram implements IRepresentation { private DiagramLayoutData layoutData; + private DiagramStyle style; + private Diagram() { // Prevent instantiation } + public static Builder newDiagram(String id) { + return new Builder(id); + } + + public static Builder newDiagram(Diagram diagram) { + return new Builder(diagram); + } + @Override public String getId() { return this.id; @@ -99,12 +110,8 @@ public DiagramLayoutData getLayoutData() { return this.layoutData; } - public static Builder newDiagram(String id) { - return new Builder(id); - } - - public static Builder newDiagram(Diagram diagram) { - return new Builder(diagram); + public DiagramStyle getStyle() { + return this.style; } @Override @@ -120,9 +127,10 @@ public String toString() { */ @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private String id; - private String kind = KIND; + private final String id; + + private final String kind = KIND; private String targetObjectId; @@ -138,6 +146,8 @@ public static final class Builder { private List edges; + private DiagramStyle style; + private DiagramLayoutData layoutData = new DiagramLayoutData(Map.of(), Map.of(), Map.of()); private Builder(String id) { @@ -153,6 +163,7 @@ private Builder(Diagram diagram) { this.size = diagram.getSize(); this.nodes = diagram.getNodes(); this.edges = diagram.getEdges(); + this.style = diagram.getStyle(); this.layoutData = diagram.getLayoutData(); } @@ -191,6 +202,11 @@ public Builder edges(List edges) { return this; } + public Builder style(DiagramStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public Builder layoutData(DiagramLayoutData layoutData) { this.layoutData = Objects.requireNonNull(layoutData); return this; @@ -207,6 +223,7 @@ public Diagram build() { diagram.size = Objects.requireNonNull(this.size); diagram.nodes = Objects.requireNonNull(this.nodes); diagram.edges = Objects.requireNonNull(this.edges); + diagram.style = this.style; // Optional on purpose diagram.layoutData = Objects.requireNonNull(this.layoutData); return diagram; } diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/DiagramStyle.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/DiagramStyle.java new file mode 100644 index 00000000000..e8dccf8e06e --- /dev/null +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/DiagramStyle.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2024 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; + +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * A diagram style. + * + * @author frouene + */ +@Immutable +public final class DiagramStyle { + + private String background; + + private DiagramStyle() { + // prevent initialisation + } + + public static Builder newDiagramStyle() { + return new Builder(); + } + + public String getBackground() { + return this.background; + } + + /** + * The builder used to create the diagram style. + * + * @author frouene + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private String background; + + public Builder background(String background) { + this.background = Objects.requireNonNull(background); + return this; + } + + public DiagramStyle build() { + DiagramStyle diagramStyle = new DiagramStyle(); + diagramStyle.background = Objects.requireNonNull(this.background); + return diagramStyle; + } + + } +} diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/components/DiagramComponent.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/components/DiagramComponent.java index 97089244141..6787a79f312 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/components/DiagramComponent.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/components/DiagramComponent.java @@ -55,12 +55,12 @@ public Element render() { String diagramId = optionalPreviousDiagram.map(Diagram::getId).orElseGet(() -> UUID.randomUUID().toString()); String targetObjectId = diagramDescription.getTargetObjectIdProvider().apply(variableManager); + var style = diagramDescription.getStyleProvider().apply(variableManager); DiagramRenderingCache cache = new DiagramRenderingCache(); IDiagramElementRequestor diagramElementRequestor = new DiagramElementRequestor(); INodeDescriptionRequestor nodeDescriptionRequestor = new NodeDescriptionRequestor(allDiagramDescriptions); - // @formatter:off var nodes = diagramDescription.getNodeDescriptions().stream() .map(nodeDescription -> { var previousNodes = optionalPreviousDiagram.map(previousDiagram -> diagramElementRequestor.getRootNodes(previousDiagram, nodeDescription)) @@ -94,13 +94,11 @@ public Element render() { return new Element(EdgeComponent.class, edgeComponentProps); }) .toList(); - // @formatter:on List children = new ArrayList<>(); children.addAll(nodes); children.addAll(edges); - // @formatter:off Position position = optionalPreviousDiagram.map(Diagram::getPosition) .orElse(Position.UNDEFINED); @@ -108,16 +106,19 @@ public Element render() { Size size = optionalPreviousDiagram.map(Diagram::getSize) .orElse(Size.UNDEFINED); - DiagramElementProps diagramElementProps = DiagramElementProps.newDiagramElementProps(diagramId) + DiagramElementProps.Builder diagramElementPropsBuilder = DiagramElementProps.newDiagramElementProps(diagramId) .targetObjectId(targetObjectId) .descriptionId(diagramDescription.getId()) .label(label) .position(position) .size(size) - .children(children) - .build(); - // @formatter:on - return new Element(DiagramElementProps.TYPE, diagramElementProps); + .children(children); + + if (style != null) { + diagramElementPropsBuilder.style(style); + } + + return new Element(DiagramElementProps.TYPE, diagramElementPropsBuilder.build()); } } 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 67b50baa8a3..fbe17b19612 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 @@ -20,6 +20,7 @@ import org.eclipse.sirius.components.annotations.Immutable; import org.eclipse.sirius.components.diagrams.ArrangeLayoutDirection; +import org.eclipse.sirius.components.diagrams.DiagramStyle; import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.eclipse.sirius.components.representations.IStatus; @@ -66,6 +67,8 @@ public final class DiagramDescription implements IRepresentationDescription { private Function dropNodeHandler; + private Function styleProvider; + private DiagramDescription() { // Prevent instantiation } @@ -129,6 +132,10 @@ public Function getDropNodeHandler() { return this.dropNodeHandler; } + public Function getStyleProvider() { + return this.styleProvider; + } + @Override public String toString() { String pattern = "{0} '{'id: {1}, label: {2}, nodeDescriptionCount: {3}, edgeDescriptionCount: {4}'}'"; @@ -167,6 +174,8 @@ public static final class Builder { private Function dropNodeHandler; + private Function styleProvider; + private Builder(String id) { this.id = Objects.requireNonNull(id); } @@ -184,6 +193,7 @@ private Builder(DiagramDescription diagramDescription) { this.edgeDescriptions = diagramDescription.getEdgeDescriptions(); this.dropHandler = diagramDescription.getDropHandler(); this.dropNodeHandler = diagramDescription.getDropNodeHandler(); + this.styleProvider = diagramDescription.getStyleProvider(); } public Builder label(String label) { @@ -241,6 +251,11 @@ public Builder dropNodeHandler(Function dropNodeHandle return this; } + public Builder styleProvider(Function styleProvider) { + this.styleProvider = Objects.requireNonNull(styleProvider); + return this; + } + public DiagramDescription build() { DiagramDescription diagramDescription = new DiagramDescription(); diagramDescription.id = Objects.requireNonNull(this.id); @@ -255,6 +270,7 @@ public DiagramDescription build() { diagramDescription.edgeDescriptions = Objects.requireNonNull(this.edgeDescriptions); diagramDescription.dropHandler = Objects.requireNonNull(this.dropHandler); diagramDescription.dropNodeHandler = this.dropNodeHandler; // Optional on purpose. + diagramDescription.styleProvider = Objects.requireNonNull(this.styleProvider); return diagramDescription; } } diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/elements/DiagramElementProps.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/elements/DiagramElementProps.java index cc1f6aff73a..4ca377b4c46 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/elements/DiagramElementProps.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/elements/DiagramElementProps.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 Obeo. + * Copyright (c) 2019, 2024 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 @@ -17,6 +17,7 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.diagrams.DiagramStyle; import org.eclipse.sirius.components.diagrams.Position; import org.eclipse.sirius.components.diagrams.Size; import org.eclipse.sirius.components.representations.Element; @@ -29,6 +30,7 @@ */ @Immutable public final class DiagramElementProps implements IProps { + public static final String TYPE = "Diagram"; private String id; @@ -43,12 +45,18 @@ public final class DiagramElementProps implements IProps { private Size size; + private DiagramStyle style; + private List children; private DiagramElementProps() { // Prevent instantiation } + public static Builder newDiagramElementProps(String id) { + return new Builder(id); + } + public String getId() { return this.id; } @@ -73,15 +81,15 @@ public Size getSize() { return this.size; } + public DiagramStyle getStyle() { + return this.style; + } + @Override public List getChildren() { return this.children; } - public static Builder newDiagramElementProps(String id) { - return new Builder(id); - } - @Override public String toString() { String pattern = "{0} '{'id: {1}'}'"; @@ -95,7 +103,8 @@ public String toString() { */ @SuppressWarnings("checkstyle:HiddenField") public static final class Builder { - private String id; + + private final String id; private String targetObjectId; @@ -107,6 +116,8 @@ public static final class Builder { private Size size; + private DiagramStyle style; + private List children; private Builder(String id) { @@ -138,6 +149,11 @@ public Builder size(Size size) { return this; } + public Builder style(DiagramStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public Builder children(List children) { this.children = Objects.requireNonNull(children); return this; @@ -152,6 +168,7 @@ public DiagramElementProps build() { diagramElementProps.position = Objects.requireNonNull(this.position); diagramElementProps.size = Objects.requireNonNull(this.size); diagramElementProps.children = Objects.requireNonNull(this.children); + diagramElementProps.style = this.style; // Optional on purpose return diagramElementProps; } } diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementFactory.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementFactory.java index e79500a2fb6..085b63a7403 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementFactory.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/renderer/DiagramElementFactory.java @@ -71,15 +71,19 @@ private Diagram instantiateDiagram(IProps props, List children) { } }); - return Diagram.newDiagram(diagramElementProps.getId()) + var diagramBuilder = Diagram.newDiagram(diagramElementProps.getId()) .targetObjectId(diagramElementProps.getTargetObjectId()) .descriptionId(diagramElementProps.getDescriptionId()) .label(diagramElementProps.getLabel()) .position(diagramElementProps.getPosition()) .size(diagramElementProps.getSize()) .nodes(nodes) - .edges(edges) - .build(); + .edges(edges); + + if (diagramElementProps.getStyle() != null) { + diagramBuilder.style(diagramElementProps.getStyle()); + } + return diagramBuilder.build(); } return null; } 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 9140852d3b2..8d6583625f2 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 @@ -204,6 +204,7 @@ private Diagram createDiagram(Optional previousDiagram, List new Failure("")) + .styleProvider(variableManager -> null) .build(); VariableManager variableManager = new VariableManager(); 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 d8cdfc3cb19..0035296d588 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 @@ -148,6 +148,7 @@ private Diagram renderDiagram(List nodeDescriptions, List new Failure("")) + .styleProvider(variableManager -> null) .build(); VariableManager variableManager = new VariableManager(); 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 2d55f8b03d2..c53a97262cd 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 @@ -296,6 +296,7 @@ private Diagram createDiagram(Function styleProvide .edgeDescriptions(new ArrayList<>()) .palettes(List.of()) .dropHandler(variableManager -> new Failure("")) + .styleProvider(variableManager -> null) .build(); VariableManager variableManager = new VariableManager(); 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 d82117c2770..50923c54572 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 @@ -305,55 +305,22 @@ private DiagramDescription getDiagramDescription(Function childrenLayoutStrategyProvider = variableManager -> new FreeFormLayoutStrategy(); - NodeDescription subUnsynchronizedNodeDescription = NodeDescription.newNodeDescription("subUnsynchronized") + NodeDescription subUnsynchronizedNodeDescription = this.getCommonNodeDescriptionBuilder("subUnsynchronized", insideLabelDescription, styleProvider, childrenLayoutStrategyProvider) .synchronizationPolicy(SynchronizationPolicy.UNSYNCHRONIZED) - .typeProvider(variableManager -> NODE_TYPE) .semanticElementsProvider(semanticElementsProvider) - .targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID) - .targetObjectKindProvider(variableManager -> "") - .targetObjectLabelProvider(variableManager -> "") - .insideLabelDescription(insideLabelDescription) - .styleProvider(styleProvider) - .childrenLayoutStrategyProvider(childrenLayoutStrategyProvider) - .sizeProvider(variableManager -> Size.UNDEFINED) - .borderNodeDescriptions(new ArrayList<>()) .childNodeDescriptions(new ArrayList<>()) - .labelEditHandler((variableManager, newLabel) -> new Success()) - .deleteHandler(variableManager -> new Success()) .build(); - NodeDescription unsynchronizedNodeDescription = NodeDescription.newNodeDescription("unsynchronized") + NodeDescription unsynchronizedNodeDescription = this.getCommonNodeDescriptionBuilder("unsynchronized", insideLabelDescription, styleProvider, childrenLayoutStrategyProvider) .synchronizationPolicy(SynchronizationPolicy.UNSYNCHRONIZED) - .typeProvider(variableManager -> NODE_TYPE) .semanticElementsProvider(semanticElementsProvider) - .targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID) - .targetObjectKindProvider(variableManager -> "") - .targetObjectLabelProvider(variableManager -> "") - .insideLabelDescription(insideLabelDescription) - .styleProvider(styleProvider) - .childrenLayoutStrategyProvider(childrenLayoutStrategyProvider) - .sizeProvider(variableManager -> Size.UNDEFINED) - .borderNodeDescriptions(new ArrayList<>()) .childNodeDescriptions(List.of(subUnsynchronizedNodeDescription)) - .labelEditHandler((variableManager, newLabel) -> new Success()) - .deleteHandler(variableManager -> new Success()) .build(); - NodeDescription synchronizedNodeDescription = NodeDescription.newNodeDescription("synchronized") + NodeDescription synchronizedNodeDescription = this.getCommonNodeDescriptionBuilder("synchronized", insideLabelDescription, styleProvider, childrenLayoutStrategyProvider) .synchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED) - .typeProvider(variableManager -> NODE_TYPE) .semanticElementsProvider(variableManager -> List.of(new Object())) - .targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID) - .targetObjectKindProvider(variableManager -> "") - .targetObjectLabelProvider(variableManager -> "") - .insideLabelDescription(insideLabelDescription) - .styleProvider(styleProvider) - .childrenLayoutStrategyProvider(childrenLayoutStrategyProvider) - .sizeProvider(variableManager -> Size.UNDEFINED) - .borderNodeDescriptions(new ArrayList<>()) .childNodeDescriptions(new ArrayList<>()) - .labelEditHandler((variableManager, newLabel) -> new Success()) - .deleteHandler(variableManager -> new Success()) .build(); DiagramDescription diagramDescription = DiagramDescription.newDiagramDescription("diagram") @@ -365,8 +332,26 @@ private DiagramDescription getDiagramDescription(Function new Failure("")) + .styleProvider(variableManager -> null) .build(); return diagramDescription; } + + private NodeDescription.Builder getCommonNodeDescriptionBuilder(String id, + InsideLabelDescription insideLabelDescription, Function styleProvider, Function childrenLayoutStrategyProvider) { + + return NodeDescription.newNodeDescription(id) + .typeProvider(variableManager -> NODE_TYPE) + .targetObjectIdProvider(variableManager -> TARGET_OBJECT_ID) + .targetObjectKindProvider(variableManager -> "") + .targetObjectLabelProvider(variableManager -> "") + .insideLabelDescription(insideLabelDescription) + .styleProvider(styleProvider) + .childrenLayoutStrategyProvider(childrenLayoutStrategyProvider) + .sizeProvider(variableManager -> Size.UNDEFINED) + .borderNodeDescriptions(new ArrayList<>()) + .labelEditHandler((variableManager, newLabel) -> new Success()) + .deleteHandler(variableManager -> new Success()); + } } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/converter/convertDiagram.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/converter/convertDiagram.ts index 272e0e23bf4..afa35f3db3b 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/converter/convertDiagram.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/converter/convertDiagram.ts @@ -219,6 +219,9 @@ export const convertDiagram = ( kind: gqlDiagram.metadata.kind, targetObjectId: gqlDiagram.targetObjectId, }, + style: { + background: gqlDiagram.style?.background, + }, nodes: rawDiagram.nodes, edges: rawDiagram.edges, }; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.ts index 677c53529ea..ee5c87227c5 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.ts @@ -24,6 +24,9 @@ fragment diagramFragment on Diagram { kind label } + style { + background + } layoutData { nodeLayoutData { id diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.types.ts index 39a799b6c11..10b7a039a3b 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/graphql/subscription/diagramFragment.types.ts @@ -20,6 +20,7 @@ export interface GQLDiagram { metadata: GQLRepresentationMetadata; nodes: GQLNode[]; edges: GQLEdge[]; + style: GQLDiagramStyle; layoutData: GQLDiagramLayoutData; } @@ -38,3 +39,7 @@ export interface GQLRepresentationMetadata { kind: string; label: string; } + +export interface GQLDiagramStyle { + background: string; +} diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx index 9bebe9f0992..5d7ff44862e 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/DiagramRenderer.tsx @@ -114,7 +114,7 @@ export const DiagramRenderer = memo(({ diagramRefreshedEventPayload }: DiagramRe const { reconnectEdge } = useReconnectEdge(); const { onDrop, onDragOver } = useDrop(); const { onNodeDragStart, onNodeDrag, onNodeDragStop } = useDropNode(); - const { backgroundColor, largeGridColor, smallGridColor } = useDropDiagramStyle(); + const { background, setBackground, largeGridColor, smallGridColor } = useDropDiagramStyle(); const { nodeTypes } = useNodeType(); const { nodeConverters } = useContext(NodeTypeContext); @@ -151,6 +151,9 @@ export const DiagramRenderer = memo(({ diagramRefreshedEventPayload }: DiagramRe synchronizeLayoutData(diagramRefreshedEventPayload.id, laidOutDiagram); }); } + if (convertedDiagram.style?.background) { + setBackground(convertedDiagram.style.background); + } }, [diagramRefreshedEventPayload, diagramDescription]); useEffect(() => { @@ -329,7 +332,7 @@ export const DiagramRenderer = memo(({ diagramRefreshedEventPayload }: DiagramRe <> ) : ( - + )} []; edges: Edge[]; + style: React.CSSProperties; } export interface DiagramMetadata { diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.tsx index d7e15f53db9..29a9287f90c 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.tsx @@ -12,7 +12,7 @@ *******************************************************************************/ import { useTheme } from '@material-ui/core/styles'; -import { useContext, useMemo } from 'react'; +import { useContext, useMemo, useState } from 'react'; import { useStore } from '../../representation/useStore'; import { DropNodeContext } from './DropNodeContext'; import { DropNodeContextValue } from './DropNodeContext.types'; @@ -22,6 +22,7 @@ export const useDropDiagramStyle = (): useDropDiagramStyleValue => { const { droppableOnDiagram } = useContext(DropNodeContext); const { getNodes } = useStore(); const theme = useTheme(); + const [background, setBackground] = useState(theme.palette.background.default); const targetNode = getNodes().find((node) => node.data.isDropNodeTarget); const draggedNode = getNodes().find((node) => node.dragging); @@ -29,15 +30,16 @@ export const useDropDiagramStyle = (): useDropDiagramStyleValue => { const diagramTargeted: boolean = !!draggedNode && !targetNode && !!draggedNode?.parentNode && !draggedNode.data.isBorderNode; const diagramForbidden: boolean = diagramTargeted && !!draggedNode?.id !== null && !droppableOnDiagram; - const backgroundColor = diagramForbidden ? theme.palette.action.disabledBackground : theme.palette.background.default; + const backgroundColor = diagramForbidden ? theme.palette.action.disabledBackground : background; const memoizedStyle = useMemo(() => { return { - backgroundColor, - smallGridColor: diagramForbidden ? backgroundColor : '#f1f1f1', - largeGridColor: diagramForbidden ? backgroundColor : '#cccccc', + background: backgroundColor, + smallGridColor: diagramForbidden ? 'transparent' : '#f1f1f1', + largeGridColor: diagramForbidden ? 'transparent' : '#cccccc', + setBackground, }; - }, [diagramForbidden]); + }, [diagramForbidden, backgroundColor]); return memoizedStyle; }; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.types.ts index 1887a162bcb..5be4123a672 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/dropNode/useDropDiagramStyle.types.ts @@ -12,7 +12,8 @@ *******************************************************************************/ export interface useDropDiagramStyleValue { - backgroundColor: string; + background: string | number; smallGridColor: string; largeGridColor: string; + setBackground: (background: string | number) => void; } diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DiagramStyleControllerTests.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DiagramStyleControllerTests.java new file mode 100644 index 00000000000..4e0875ec4ef --- /dev/null +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/diagrams/DiagramStyleControllerTests.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2024 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.web.application.controllers.diagrams; + +import java.time.Duration; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Predicate; + +import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload; +import org.eclipse.sirius.components.collaborative.forms.dto.PropertiesEventInput; +import org.eclipse.sirius.components.forms.Form; +import org.eclipse.sirius.components.forms.tests.assertions.FormAssertions; +import org.eclipse.sirius.components.forms.tests.graphql.PropertiesEventSubscriptionRunner; +import org.eclipse.sirius.components.forms.tests.navigation.FormNavigator; +import org.eclipse.sirius.components.widget.reference.ReferenceWidget; +import org.eclipse.sirius.web.AbstractIntegrationTests; +import org.eclipse.sirius.web.data.StudioIdentifiers; +import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; +import org.springframework.transaction.annotation.Transactional; + +import graphql.execution.DataFetcherResult; +import reactor.test.StepVerifier; + +/** + * Integration tests of the "Diagram Style" view. + * + * @author frouene + */ +@Transactional +@SuppressWarnings("checkstyle:MultipleStringLiterals") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "sirius.web.test.enabled=studio" }) +public class DiagramStyleControllerTests extends AbstractIntegrationTests { + + @Autowired + private IGivenInitialServerState givenInitialServerState; + + @Autowired + private PropertiesEventSubscriptionRunner propertiesEventSubscriptionRunner; + + @BeforeEach + public void beforeEach() { + this.givenInitialServerState.initialize(); + } + + @Test + @DisplayName("Given a diagram style, when we subscribe to its properties events, then the form contains background property") + @Sql(scripts = { "/scripts/studio.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) + @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + public void givenDiagrmStyleObjectWhenWeSubscribeToItsPropertiesEventsThenTheFormContainsBackgroundProperty() { + var input = new PropertiesEventInput(UUID.randomUUID(), StudioIdentifiers.SAMPLE_STUDIO_PROJECT.toString(), List.of(StudioIdentifiers.DIAGRAM_STYLE_DESCRIPTION_OBJECT.toString())); + var flux = this.propertiesEventSubscriptionRunner.run(input); + + Predicate
formPredicate = form -> { + var groupNavigator = new FormNavigator(form).page("").group("Core Properties"); + + var borderSizeTextField = groupNavigator.findWidget("Background", ReferenceWidget.class); + FormAssertions.assertThat(borderSizeTextField).hasValueWithLabel("White"); + + return true; + }; + + Predicate formContentMatcher = object -> Optional.of(object) + .filter(DataFetcherResult.class::isInstance) + .map(DataFetcherResult.class::cast) + .map(DataFetcherResult::getData) + .filter(FormRefreshedEventPayload.class::isInstance) + .map(FormRefreshedEventPayload.class::cast) + .map(FormRefreshedEventPayload::form) + .filter(formPredicate) + .isPresent(); + + StepVerifier.create(flux) + .expectNextMatches(formContentMatcher) + .thenCancel() + .verify(Duration.ofSeconds(10)); + } + +} diff --git a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java index f000b5fdf09..0c08214a390 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java +++ b/packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/data/StudioIdentifiers.java @@ -51,6 +51,8 @@ public final class StudioIdentifiers { public static final UUID HUMAN_INSIDE_LABEL_STYLE_OBJECT = UUID.fromString("c8338087-e98e-43bd-ae1a-879b64308a7d"); + public static final UUID DIAGRAM_STYLE_DESCRIPTION_OBJECT = UUID.fromString("82dd8017-a782-4d48-8926-019c1a88db53"); + private StudioIdentifiers() { // Prevent instantiation } diff --git a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/studio.sql b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/studio.sql index fccc9fff9ec..e85fab38e4b 100644 --- a/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/studio.sql +++ b/packages/sirius-web/backend/sirius-web/src/test/resources/scripts/studio.sql @@ -389,7 +389,14 @@ INSERT INTO document ( "data":{ "name":"Root Diagram", "domainType":"buck::Root", - "nodeDescriptions":[ + "style": { + "data": { + "background": "//@colorPalettes.0/@colors.1" + }, + "eClass": "diagram:DiagramStyleDescription", + "id": "82dd8017-a782-4d48-8926-019c1a88db53" + }, + "nodeDescriptions":[ { "id":"e91e6e23-1440-4fbf-b31c-3a21bf25d85b", "eClass":"diagram:NodeDescription", diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ConditionalDiagramStyleBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ConditionalDiagramStyleBuilder.java new file mode 100644 index 00000000000..5754844cfd1 --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/ConditionalDiagramStyleBuilder.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2024 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 ConditionalDiagramStyleBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class ConditionalDiagramStyleBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle. + * @generated + */ + private org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle conditionalDiagramStyle = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createConditionalDiagramStyle(); + + /** + * Return instance org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle. + * @generated + */ + protected org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle getConditionalDiagramStyle() { + return this.conditionalDiagramStyle; + } + + /** + * Return instance org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle. + * @generated + */ + public org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle build() { + return this.getConditionalDiagramStyle(); + } + + /** + * Setter for Condition. + * + * @generated + */ + public ConditionalDiagramStyleBuilder condition(java.lang.String value) { + this.getConditionalDiagramStyle().setCondition(value); + return this; + } + /** + * Setter for Style. + * + * @generated + */ + public ConditionalDiagramStyleBuilder style(org.eclipse.sirius.components.view.diagram.DiagramStyleDescription value) { + this.getConditionalDiagramStyle().setStyle(value); + return this; + } + +} + 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 eec100cc5c6..0aaf791c00b 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 @@ -110,6 +110,16 @@ public OutsideLabelStyleBuilder newOutsideLabelStyle() { return new OutsideLabelStyleBuilder(); } + /** + * Instantiate a DiagramStyleDescriptionBuilder . + * + * @author BuilderGenerator + * @generated + */ + public DiagramStyleDescriptionBuilder newDiagramStyleDescription() { + return new DiagramStyleDescriptionBuilder(); + } + /** * Instantiate a ConditionalNodeStyleBuilder . * @@ -120,6 +130,16 @@ public ConditionalNodeStyleBuilder newConditionalNodeStyle() { return new ConditionalNodeStyleBuilder(); } + /** + * Instantiate a ConditionalDiagramStyleBuilder . + * + * @author BuilderGenerator + * @generated + */ + public ConditionalDiagramStyleBuilder newConditionalDiagramStyle() { + return new ConditionalDiagramStyleBuilder(); + } + /** * Instantiate a ConditionalInsideLabelStyleBuilder . * diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramDescriptionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramDescriptionBuilder.java index d9b2d3c1440..9515b3ef04c 100644 --- a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramDescriptionBuilder.java +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramDescriptionBuilder.java @@ -139,6 +139,28 @@ public DiagramDescriptionBuilder arrangeLayoutDirection(org.eclipse.sirius.compo return this; } + /** + * Setter for Style. + * + * @generated + */ + public DiagramDescriptionBuilder style(org.eclipse.sirius.components.view.diagram.DiagramStyleDescription value) { + this.getDiagramDescription().setStyle(value); + return this; + } + + /** + * Setter for ConditionalStyles. + * + * @generated + */ + public DiagramDescriptionBuilder conditionalStyles(org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle ... values) { + for (org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle value : values) { + this.getDiagramDescription().getConditionalStyles().add(value); + } + return this; + } + } diff --git a/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramStyleDescriptionBuilder.java b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramStyleDescriptionBuilder.java new file mode 100644 index 00000000000..6a7ba30713a --- /dev/null +++ b/packages/view/backend/sirius-components-view-builder/src/main/java/org/eclipse/sirius/components/view/builder/generated/DiagramStyleDescriptionBuilder.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2024 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 DiagramStyleDescriptionBuilder. + * + * @author BuilderGenerator + * @generated + */ +public class DiagramStyleDescriptionBuilder { + + /** + * Create instance org.eclipse.sirius.components.view.diagram.DiagramStyleDescription. + * @generated + */ + private org.eclipse.sirius.components.view.diagram.DiagramStyleDescription diagramStyleDescription = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createDiagramStyleDescription(); + + /** + * Return instance org.eclipse.sirius.components.view.diagram.DiagramStyleDescription. + * @generated + */ + protected org.eclipse.sirius.components.view.diagram.DiagramStyleDescription getDiagramStyleDescription() { + return this.diagramStyleDescription; + } + + /** + * Return instance org.eclipse.sirius.components.view.diagram.DiagramStyleDescription. + * @generated + */ + public org.eclipse.sirius.components.view.diagram.DiagramStyleDescription build() { + return this.getDiagramStyleDescription(); + } + + /** + * Setter for Background. + * + * @generated + */ + public DiagramStyleDescriptionBuilder background(org.eclipse.sirius.components.view.UserColor value) { + this.getDiagramStyleDescription().setBackground(value); + return this; + } + +} + diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalDiagramStyleItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalDiagramStyleItemProvider.java new file mode 100644 index 00000000000..3ec7c3653ba --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalDiagramStyleItemProvider.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2024 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.ConditionalDiagramStyle; +import org.eclipse.sirius.components.view.diagram.DiagramFactory; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.provider.ConditionalItemProvider; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle} + * object. + * + * @generated + */ +public class ConditionalDiagramStyleItemProvider extends ConditionalItemProvider { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public ConditionalDiagramStyleItemProvider(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.CONDITIONAL_DIAGRAM_STYLE__STYLE); + } + 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 ConditionalDiagramStyle.gif. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.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 = ((ConditionalDiagramStyle) object).getCondition(); + return label == null || label.length() == 0 ? this.getString("_UI_ConditionalDiagramStyle_type") : this.getString("_UI_ConditionalDiagramStyle_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(ConditionalDiagramStyle.class)) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + 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.CONDITIONAL_DIAGRAM_STYLE__STYLE, DiagramFactory.eINSTANCE.createDiagramStyleDescription())); + } + +} diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramDescriptionItemProvider.java index 472d92b5073..8084f86796f 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramDescriptionItemProvider.java @@ -22,6 +22,7 @@ import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.DiagramDescription; import org.eclipse.sirius.components.view.diagram.DiagramFactory; import org.eclipse.sirius.components.view.diagram.DiagramPackage; @@ -103,6 +104,8 @@ public Collection getChildrenFeatures(Object objec this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__PALETTE); this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__NODE_DESCRIPTIONS); this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS); + this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__STYLE); + this.childrenFeatures.add(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES); } return this.childrenFeatures; } @@ -170,6 +173,8 @@ public void notifyChanged(Notification notification) { case DiagramPackage.DIAGRAM_DESCRIPTION__PALETTE: case DiagramPackage.DIAGRAM_DESCRIPTION__NODE_DESCRIPTIONS: case DiagramPackage.DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS: + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } @@ -203,6 +208,12 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors edgeChild.setStyle(newEdgeStyle); edgeChild.setPalette(defaultToolsFactory.createDefaultEdgePalette()); newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS, edgeChild)); + + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__STYLE, DiagramFactory.eINSTANCE.createDiagramStyleDescription())); + + ConditionalDiagramStyle conditionalDiagramStyle = DiagramFactory.eINSTANCE.createConditionalDiagramStyle(); + conditionalDiagramStyle.setStyle(DiagramFactory.eINSTANCE.createDiagramStyleDescription()); + newChildDescriptors.add(this.createChildParameter(DiagramPackage.Literals.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES, conditionalDiagramStyle)); } } 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 fbb82d38a9c..79d5f22ed7c 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 @@ -530,6 +530,30 @@ public Adapter createOutsideLabelStyleAdapter() { return this.outsideLabelStyleItemProvider; } + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription} instances. + * + * + * @generated + */ + protected DiagramStyleDescriptionItemProvider diagramStyleDescriptionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription}. + * + * @generated + */ + @Override + public Adapter createDiagramStyleDescriptionAdapter() { + if (this.diagramStyleDescriptionItemProvider == null) { + this.diagramStyleDescriptionItemProvider = new DiagramStyleDescriptionItemProvider(this); + } + + return this.diagramStyleDescriptionItemProvider; + } + /** * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle}. @@ -545,6 +569,30 @@ public Adapter createConditionalNodeStyleAdapter() { return this.conditionalNodeStyleItemProvider; } + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle} instances. + * + * + * @generated + */ + protected ConditionalDiagramStyleItemProvider conditionalDiagramStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle}. + * + * @generated + */ + @Override + public Adapter createConditionalDiagramStyleAdapter() { + if (this.conditionalDiagramStyleItemProvider == null) { + this.conditionalDiagramStyleItemProvider = new ConditionalDiagramStyleItemProvider(this); + } + + return this.conditionalDiagramStyleItemProvider; + } + /** * This creates an adapter for a {@link org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle}. * @@ -1052,8 +1100,12 @@ public void dispose() { this.insideLabelStyleItemProvider.dispose(); if (this.outsideLabelStyleItemProvider != null) this.outsideLabelStyleItemProvider.dispose(); + if (this.diagramStyleDescriptionItemProvider != null) + this.diagramStyleDescriptionItemProvider.dispose(); if (this.conditionalNodeStyleItemProvider != null) this.conditionalNodeStyleItemProvider.dispose(); + if (this.conditionalDiagramStyleItemProvider != null) + this.conditionalDiagramStyleItemProvider.dispose(); if (this.conditionalInsideLabelStyleItemProvider != null) this.conditionalInsideLabelStyleItemProvider.dispose(); if (this.conditionalOutsideLabelStyleItemProvider != null) diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramStyleDescriptionItemProvider.java new file mode 100644 index 00000000000..90ae6af5f90 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/DiagramStyleDescriptionItemProvider.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2024 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.IChildCreationExtender; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription} + * object. + * + * @generated + */ +public class DiagramStyleDescriptionItemProvider extends ItemProviderAdapter + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public DiagramStyleDescriptionItemProvider(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.addBackgroundPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Background feature. + * + * @generated + */ + protected void addBackgroundPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_DiagramStyleDescription_background_feature"), + this.getString("_UI_PropertyDescriptor_description", "_UI_DiagramStyleDescription_background_feature", "_UI_DiagramStyleDescription_type"), + DiagramPackage.Literals.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND, true, false, true, null, null, null)); + } + + /** + * This returns DiagramStyleDescription.gif. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/Style.svg")); + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + return this.getString("_UI_DiagramStyleDescription_type"); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + 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 ((IChildCreationExtender) this.adapterFactory).getResourceLocator(); + } + +} 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 6c4c332a7fb..922fbfb7c6d 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 @@ -35,7 +35,9 @@ _UI_InsideLabelStyle_type=Inside Label Style _UI_OutsideLabelStyle_type=Outside Label Style _UI_NodeLabelStyle_type=Node Label Style _UI_NodeStyleDescription_type=Node Style Description +_UI_DiagramStyleDescription_type=Diagram Style Description _UI_ConditionalNodeStyle_type=Conditional Node Style +_UI_ConditionalDiagramStyle_type=Conditional Diagram Style _UI_ConditionalInsideLabelStyle_type=Conditional Inside Label Style _UI_ConditionalOutsideLabelStyle_type=Conditional Outside Label Style _UI_RectangularNodeStyleDescription_type=Rectangular Node Style Description @@ -70,6 +72,8 @@ _UI_DiagramDescription_palette_feature=Palette _UI_DiagramDescription_nodeDescriptions_feature=Node Descriptions _UI_DiagramDescription_edgeDescriptions_feature=Edge Descriptions _UI_DiagramDescription_arrangeLayoutDirection_feature=Arrange Layout Direction +_UI_DiagramDescription_style_feature=Style +_UI_DiagramDescription_conditionalStyles_feature=Conditional Styles _UI_DiagramElementDescription_name_feature=Name _UI_DiagramElementDescription_domainType_feature=Domain Type _UI_DiagramElementDescription_semanticCandidatesExpression_feature=Semantic Candidates Expression @@ -128,8 +132,9 @@ _UI_NodeLabelStyle_labelColor_feature=Label Color _UI_NodeLabelStyle_background_feature=Background _UI_NodeLabelStyle_showIcon_feature=Show Icon _UI_NodeLabelStyle_labelIcon_feature=Label Icon -_UI_NodeLabelStyle_background_feature=Background +_UI_DiagramStyleDescription_background_feature=Background _UI_ConditionalNodeStyle_style_feature=Style +_UI_ConditionalDiagramStyle_style_feature=Style _UI_ConditionalInsideLabelStyle_style_feature=Style _UI_ConditionalOutsideLabelStyle_style_feature=Style _UI_RectangularNodeStyleDescription_background_feature=Background @@ -209,14 +214,14 @@ _UI_NodeContainmentKind_BORDER_NODE_literal=BORDER_NODE _UI_SynchronizationPolicy_SYNCHRONIZED_literal=SYNCHRONIZED _UI_SynchronizationPolicy_UNSYNCHRONIZED_literal=UNSYNCHRONIZED _UI_InsideLabelPosition_TOP_CENTER_literal=TOP_CENTER -_UI_InsideLabelPosition_TOP_LEFT_literal = TOP_LEFT -_UI_InsideLabelPosition_TOP_RIGHT_literal = TOP_RIGHT -_UI_InsideLabelPosition_MIDDLE_LEFT_literal = MIDDLE_LEFT -_UI_InsideLabelPosition_MIDDLE_CENTER_literal = MIDDLE_CENTER -_UI_InsideLabelPosition_MIDDLE_RIGHT_literal = MIDDLE_RIGHT -_UI_InsideLabelPosition_BOTTOM_LEFT_literal = BOTTOM_LEFT -_UI_InsideLabelPosition_BOTTOM_CENTER_literal = BOTTOM_CENTER -_UI_InsideLabelPosition_BOTTOM_RIGHT_literal = BOTTOM_RIGHT +_UI_InsideLabelPosition_TOP_LEFT_literal=TOP_LEFT +_UI_InsideLabelPosition_TOP_RIGHT_literal=TOP_RIGHT +_UI_InsideLabelPosition_MIDDLE_LEFT_literal=MIDDLE_LEFT +_UI_InsideLabelPosition_MIDDLE_CENTER_literal=MIDDLE_CENTER +_UI_InsideLabelPosition_MIDDLE_RIGHT_literal=MIDDLE_RIGHT +_UI_InsideLabelPosition_BOTTOM_LEFT_literal=BOTTOM_LEFT +_UI_InsideLabelPosition_BOTTOM_CENTER_literal=BOTTOM_CENTER +_UI_InsideLabelPosition_BOTTOM_RIGHT_literal=BOTTOM_RIGHT _UI_OutsideLabelPosition_BOTTOM_CENTER_literal=BOTTOM_CENTER _UI_LabelOverflowStrategy_NONE_literal=NONE _UI_LabelOverflowStrategy_WRAP_literal=WRAP @@ -226,7 +231,7 @@ _UI_ArrangeLayoutDirection_RIGHT_literal=RIGHT _UI_ArrangeLayoutDirection_DOWN_literal=DOWN _UI_ArrangeLayoutDirection_LEFT_literal=LEFT _UI_ArrangeLayoutDirection_UP_literal=UP -_UI_LabelTextAlign_LEFT_literal = LEFT -_UI_LabelTextAlign_RIGHT_literal = RIGHT -_UI_LabelTextAlign_CENTER_literal = CENTER -_UI_LabelTextAlign_JUSTIFY_literal = JUSTIFY +_UI_LabelTextAlign_LEFT_literal=LEFT +_UI_LabelTextAlign_RIGHT_literal=RIGHT +_UI_LabelTextAlign_CENTER_literal=CENTER +_UI_LabelTextAlign_JUSTIFY_literal=JUSTIFY diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ConditionalDiagramStyle.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ConditionalDiagramStyle.java new file mode 100644 index 00000000000..8ccef112d65 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/ConditionalDiagramStyle.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2024 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.sirius.components.view.Conditional; + +/** + * A representation of the model object 'Conditional Diagram Style'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle#getStyle Style}
  • + *
+ * + * @model + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getConditionalDiagramStyle() + */ +public interface ConditionalDiagramStyle extends Conditional { + + /** + * Returns the value of the 'Style' containment reference. + * + * @return the value of the 'Style' containment reference. + * @model containment="true" + * @generated + * @see #setStyle(DiagramStyleDescription) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getConditionalDiagramStyle_Style() + */ + DiagramStyleDescription getStyle(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle#getStyle + * Style}' containment reference. + * + * @param value + * the new value of the 'Style' containment reference. + * @generated + * @see #getStyle() + */ + void setStyle(DiagramStyleDescription value); + +} // ConditionalDiagramStyle diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramDescription.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramDescription.java index c1ad91c8d56..6c2d6ec3deb 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramDescription.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramDescription.java @@ -30,6 +30,9 @@ * Descriptions} *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getArrangeLayoutDirection Arrange Layout * Direction}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getConditionalStyles Conditional + * Styles}
  • * * * @model @@ -135,4 +138,39 @@ public interface DiagramDescription extends RepresentationDescription { */ void setArrangeLayoutDirection(ArrangeLayoutDirection value); + /** + * Returns the value of the 'Style' containment reference. + * + * @return the value of the 'Style' containment reference. + * @model containment="true" + * @generated + * @see #setStyle(DiagramStyleDescription) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramDescription_Style() + */ + DiagramStyleDescription getStyle(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getStyle + * Style}' containment reference. + * + * @param value + * the new value of the 'Style' containment reference. + * @generated + * @see #getStyle() + */ + void setStyle(DiagramStyleDescription value); + + /** + * Returns the value of the 'Conditional Styles' containment reference list. The list contents are + * of type {@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle}. + * + * @return the value of the 'Conditional Styles' containment reference list. + * @model containment="true" + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramDescription_ConditionalStyles() + */ + EList getConditionalStyles(); + } // DiagramDescription 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 9376eaf7d18..2108c4ddb9b 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 @@ -18,8 +18,8 @@ * The Factory for the model. It provides a create method for each non-abstract class of * the model. * - * @see org.eclipse.sirius.components.view.diagram.DiagramPackage * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage */ public interface DiagramFactory extends EFactory { @@ -104,6 +104,14 @@ public interface DiagramFactory extends EFactory { */ OutsideLabelStyle createOutsideLabelStyle(); + /** + * Returns a new object of class 'Style Description'. + * + * @return a new object of class 'Style Description'. + * @generated + */ + DiagramStyleDescription createDiagramStyleDescription(); + /** * Returns a new object of class 'Conditional Node Style'. * @@ -112,6 +120,14 @@ public interface DiagramFactory extends EFactory { */ ConditionalNodeStyle createConditionalNodeStyle(); + /** + * Returns a new object of class 'Conditional Diagram Style'. + * + * @return a new object of class 'Conditional Diagram Style'. + * @generated + */ + ConditionalDiagramStyle createConditionalDiagramStyle(); + /** * Returns a new object of class 'Conditional Inside Label Style'. 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 7b0f3f83771..7164c3ca8d9 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 @@ -145,6 +145,24 @@ public interface DiagramPackage extends EPackage { */ int DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION = ViewPackage.REPRESENTATION_DESCRIPTION_FEATURE_COUNT + 4; + /** + * The feature id for the 'Style' containment reference. + * + * @generated + * @ordered + */ + int DIAGRAM_DESCRIPTION__STYLE = ViewPackage.REPRESENTATION_DESCRIPTION_FEATURE_COUNT + 5; + + /** + * The feature id for the 'Conditional Styles' containment reference list. + * + * + * @generated + * @ordered + */ + int DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES = ViewPackage.REPRESENTATION_DESCRIPTION_FEATURE_COUNT + 6; + /** * The number of structural features of the 'Description' class. @@ -152,7 +170,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int DIAGRAM_DESCRIPTION_FEATURE_COUNT = ViewPackage.REPRESENTATION_DESCRIPTION_FEATURE_COUNT + 5; + int DIAGRAM_DESCRIPTION_FEATURE_COUNT = ViewPackage.REPRESENTATION_DESCRIPTION_FEATURE_COUNT + 7; /** * The number of operations of the 'Description' class. @@ -1695,6 +1713,37 @@ public interface DiagramPackage extends EPackage { * @ordered */ int ICON_LABEL_NODE_STYLE_DESCRIPTION_OPERATION_COUNT = NODE_STYLE_DESCRIPTION_OPERATION_COUNT; + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.DiagramStyleDescriptionImpl + * Style Description}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramStyleDescriptionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramStyleDescription() + */ + int DIAGRAM_STYLE_DESCRIPTION = 16; + /** + * The feature id for the 'Background' reference. + * + * @generated + * @ordered + */ + int DIAGRAM_STYLE_DESCRIPTION__BACKGROUND = 0; + /** + * The number of structural features of the 'Style Description' class. + * + * @generated + * @ordered + */ + int DIAGRAM_STYLE_DESCRIPTION_FEATURE_COUNT = 1; + /** + * The number of operations of the 'Style Description' class. + * + * @generated + * @ordered + */ + int DIAGRAM_STYLE_DESCRIPTION_OPERATION_COUNT = 0; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalNodeStyleImpl * Conditional Node Style}' class. @@ -1703,7 +1752,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalNodeStyleImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalNodeStyle() */ - int CONDITIONAL_NODE_STYLE = 16; + int CONDITIONAL_NODE_STYLE = 17; /** * The feature id for the 'Condition' attribute. * @@ -1735,6 +1784,46 @@ public interface DiagramPackage extends EPackage { * @ordered */ int CONDITIONAL_NODE_STYLE_OPERATION_COUNT = ViewPackage.CONDITIONAL_OPERATION_COUNT; + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalDiagramStyleImpl + * Conditional Diagram Style}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalDiagramStyleImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalDiagramStyle() + */ + int CONDITIONAL_DIAGRAM_STYLE = 18; + /** + * The feature id for the 'Condition' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_DIAGRAM_STYLE__CONDITION = ViewPackage.CONDITIONAL__CONDITION; + /** + * The feature id for the 'Style' containment reference. + * + * @generated + * @ordered + */ + int CONDITIONAL_DIAGRAM_STYLE__STYLE = ViewPackage.CONDITIONAL_FEATURE_COUNT; + /** + * The number of structural features of the 'Conditional Diagram Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_DIAGRAM_STYLE_FEATURE_COUNT = ViewPackage.CONDITIONAL_FEATURE_COUNT + 1; + /** + * The number of operations of the 'Conditional Diagram Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_DIAGRAM_STYLE_OPERATION_COUNT = ViewPackage.CONDITIONAL_OPERATION_COUNT; /** * The meta object id for the * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalInsideLabelStyleImpl Conditional Inside @@ -1744,7 +1833,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalInsideLabelStyleImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalInsideLabelStyle() */ - int CONDITIONAL_INSIDE_LABEL_STYLE = 17; + int CONDITIONAL_INSIDE_LABEL_STYLE = 19; /** * The feature id for the 'Condition' attribute. * @@ -1785,7 +1874,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalOutsideLabelStyleImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalOutsideLabelStyle() */ - int CONDITIONAL_OUTSIDE_LABEL_STYLE = 18; + int CONDITIONAL_OUTSIDE_LABEL_STYLE = 20; /** * The feature id for the 'Condition' attribute. * @@ -1826,7 +1915,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.RectangularNodeStyleDescriptionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getRectangularNodeStyleDescription() */ - int RECTANGULAR_NODE_STYLE_DESCRIPTION = 19; + int RECTANGULAR_NODE_STYLE_DESCRIPTION = 21; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.ImageNodeStyleDescriptionImpl @@ -1836,7 +1925,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.ImageNodeStyleDescriptionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getImageNodeStyleDescription() */ - int IMAGE_NODE_STYLE_DESCRIPTION = 20; + int IMAGE_NODE_STYLE_DESCRIPTION = 22; /** * The meta object id for the @@ -1847,7 +1936,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.IconLabelNodeStyleDescriptionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getIconLabelNodeStyleDescription() */ - int ICON_LABEL_NODE_STYLE_DESCRIPTION = 21; + int ICON_LABEL_NODE_STYLE_DESCRIPTION = 23; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.EdgeStyleImpl Edge @@ -1857,7 +1946,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.EdgeStyleImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeStyle() */ - int EDGE_STYLE = 22; + int EDGE_STYLE = 24; /** * The feature id for the 'Color' reference. @@ -2023,7 +2112,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalEdgeStyleImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalEdgeStyle() */ - int CONDITIONAL_EDGE_STYLE = 23; + int CONDITIONAL_EDGE_STYLE = 25; /** * The feature id for the 'Condition' attribute. @@ -2198,7 +2287,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPaletteImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramPalette() */ - int DIAGRAM_PALETTE = 24; + int DIAGRAM_PALETTE = 26; /** * The feature id for the 'Drop Tool' containment reference. @@ -2483,7 +2572,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DeleteToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDeleteTool() */ - int DELETE_TOOL = 28; + int DELETE_TOOL = 30; /** * The feature id for the 'Name' attribute. @@ -2536,7 +2625,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DropToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDropTool() */ - int DROP_TOOL = 29; + int DROP_TOOL = 31; /** * The feature id for the 'Name' attribute. @@ -2589,7 +2678,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.EdgeToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeTool() */ - int EDGE_TOOL = 30; + int EDGE_TOOL = 32; /** * The feature id for the 'Name' attribute. @@ -2660,7 +2749,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.EdgeReconnectionToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeReconnectionTool() */ - int EDGE_RECONNECTION_TOOL = 31; + int EDGE_RECONNECTION_TOOL = 33; /** * The feature id for the 'Name' attribute. @@ -2787,7 +2876,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.LabelEditToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLabelEditTool() */ - int LABEL_EDIT_TOOL = 32; + int LABEL_EDIT_TOOL = 34; /** * The feature id for the 'Name' attribute. * @@ -2842,7 +2931,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.NodeToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeTool() */ - int NODE_TOOL = 33; + int NODE_TOOL = 35; /** * The feature id for the 'Name' attribute. * @@ -2906,7 +2995,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.SourceEdgeEndReconnectionToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getSourceEdgeEndReconnectionTool() */ - int SOURCE_EDGE_END_RECONNECTION_TOOL = 34; + int SOURCE_EDGE_END_RECONNECTION_TOOL = 36; /** * The meta object id for the @@ -2917,7 +3006,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.TargetEdgeEndReconnectionToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getTargetEdgeEndReconnectionTool() */ - int TARGET_EDGE_END_RECONNECTION_TOOL = 35; + int TARGET_EDGE_END_RECONNECTION_TOOL = 37; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.impl.CreateViewImpl Create @@ -2927,7 +3016,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.CreateViewImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getCreateView() */ - int CREATE_VIEW = 36; + int CREATE_VIEW = 38; /** * The feature id for the 'Children' containment reference list. @@ -3132,7 +3221,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DiagramToolSectionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramToolSection() */ - int DIAGRAM_TOOL_SECTION = 40; + int DIAGRAM_TOOL_SECTION = 42; /** * The feature id for the 'Name' attribute. @@ -3176,7 +3265,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.NodeToolSectionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeToolSection() */ - int NODE_TOOL_SECTION = 41; + int NODE_TOOL_SECTION = 43; /** * The feature id for the 'Name' attribute. @@ -3229,7 +3318,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.EdgeToolSectionImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getEdgeToolSection() */ - int EDGE_TOOL_SECTION = 42; + int EDGE_TOOL_SECTION = 44; /** * The feature id for the 'Name' attribute. @@ -3273,7 +3362,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.impl.DropNodeToolImpl * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDropNodeTool() */ - int DROP_NODE_TOOL = 43; + int DROP_NODE_TOOL = 45; /** * The feature id for the 'Name' attribute. @@ -3309,12 +3398,6 @@ public interface DiagramPackage extends EPackage { * @ordered */ int DROP_NODE_TOOL__ACCEPTED_NODE_TYPES = TOOL_FEATURE_COUNT; - /** - * The singleton instance of the package. - * - * @generated - */ - DiagramPackage eINSTANCE = org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl.init(); /** * The number of structural features of the 'Drop Node Tool' class. @@ -3338,7 +3421,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.ArrowStyle * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getArrowStyle() */ - int ARROW_STYLE = 44; + int ARROW_STYLE = 46; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LayoutDirection Layout * Direction}' enum. @@ -3347,7 +3430,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.LayoutDirection * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLayoutDirection() */ - int LAYOUT_DIRECTION = 45; + int LAYOUT_DIRECTION = 47; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LineStyle Line Style}' * enum. @@ -3356,7 +3439,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.LineStyle * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLineStyle() */ - int LINE_STYLE = 46; + int LINE_STYLE = 48; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.NodeContainmentKind Node * Containment Kind}' enum. @@ -3365,7 +3448,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.NodeContainmentKind * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getNodeContainmentKind() */ - int NODE_CONTAINMENT_KIND = 47; + int NODE_CONTAINMENT_KIND = 49; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.SynchronizationPolicy * Synchronization Policy}' enum. @@ -3374,7 +3457,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.SynchronizationPolicy * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getSynchronizationPolicy() */ - int SYNCHRONIZATION_POLICY = 48; + int SYNCHRONIZATION_POLICY = 50; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.InsideLabelPosition Inside * Label Position}' enum. @@ -3383,7 +3466,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.InsideLabelPosition * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getInsideLabelPosition() */ - int INSIDE_LABEL_POSITION = 49; + int INSIDE_LABEL_POSITION = 51; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.OutsideLabelPosition Outside * Label Position}' enum. @@ -3392,7 +3475,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.OutsideLabelPosition * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getOutsideLabelPosition() */ - int OUTSIDE_LABEL_POSITION = 50; + int OUTSIDE_LABEL_POSITION = 52; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LabelOverflowStrategy Label * Overflow Strategy}' enum. @@ -3401,7 +3484,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.LabelOverflowStrategy * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLabelOverflowStrategy() */ - int LABEL_OVERFLOW_STRATEGY = 51; + int LABEL_OVERFLOW_STRATEGY = 53; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.ArrangeLayoutDirection Arrange * Layout Direction}' enum. @@ -3410,7 +3493,7 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.ArrangeLayoutDirection * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getArrangeLayoutDirection() */ - int ARRANGE_LAYOUT_DIRECTION = 52; + int ARRANGE_LAYOUT_DIRECTION = 54; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.diagram.LabelTextAlign Label Text * Align}' enum. @@ -3419,7 +3502,13 @@ public interface DiagramPackage extends EPackage { * @see org.eclipse.sirius.components.view.diagram.LabelTextAlign * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getLabelTextAlign() */ - int LABEL_TEXT_ALIGN = 53; + int LABEL_TEXT_ALIGN = 55; + /** + * The singleton instance of the package. + * + * @generated + */ + DiagramPackage eINSTANCE = org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl.init(); /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.DiagramDescription @@ -3491,6 +3580,30 @@ public interface DiagramPackage extends EPackage { */ EAttribute getDiagramDescription_ArrangeLayoutDirection(); + /** + * Returns the meta object for the containment reference + * '{@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getStyle Style}'. + * + * @return the meta object for the containment reference 'Style'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramDescription#getStyle() + * @see #getDiagramDescription() + */ + EReference getDiagramDescription_Style(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.diagram.DiagramDescription#getConditionalStyles Conditional + * Styles}'. + * + * @return the meta object for the containment reference list 'Conditional Styles'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramDescription#getConditionalStyles() + * @see #getDiagramDescription() + */ + EReference getDiagramDescription_ConditionalStyles(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.DiagramElementDescription * Element Description}'. @@ -4338,6 +4451,28 @@ public interface DiagramPackage extends EPackage { */ EClass getNodeStyleDescription(); + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription + * Style Description}'. + * + * @return the meta object for class 'Style Description'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramStyleDescription + */ + EClass getDiagramStyleDescription(); + + /** + * Returns the meta object for the reference + * '{@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription#getBackground Background}'. + * + * + * @return the meta object for the reference 'Background'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramStyleDescription#getBackground() + * @see #getDiagramStyleDescription() + */ + EReference getDiagramStyleDescription_Background(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle * Conditional Node Style}'. @@ -4360,6 +4495,28 @@ public interface DiagramPackage extends EPackage { */ EReference getConditionalNodeStyle_Style(); + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle + * Conditional Diagram Style}'. + * + * @return the meta object for class 'Conditional Diagram Style'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle + */ + EClass getConditionalDiagramStyle(); + + /** + * Returns the meta object for the containment reference + * '{@link org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle#getStyle Style}'. + * + * @return the meta object for the containment reference 'Style'. + * @generated + * @see org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle#getStyle() + * @see #getConditionalDiagramStyle() + */ + EReference getConditionalDiagramStyle_Style(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle * Conditional Inside Label Style}'. @@ -5429,6 +5586,22 @@ interface Literals { */ EAttribute DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION = eINSTANCE.getDiagramDescription_ArrangeLayoutDirection(); + /** + * The meta object literal for the 'Style' containment reference feature. + * + * @generated + */ + EReference DIAGRAM_DESCRIPTION__STYLE = eINSTANCE.getDiagramDescription_Style(); + + /** + * The meta object literal for the 'Conditional Styles' containment reference list feature. + * + * @generated + */ + EReference DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES = eINSTANCE.getDiagramDescription_ConditionalStyles(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.diagram.impl.DiagramElementDescriptionImpl Element @@ -6048,6 +6221,25 @@ interface Literals { */ EClass NODE_STYLE_DESCRIPTION = eINSTANCE.getNodeStyleDescription(); + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.diagram.impl.DiagramStyleDescriptionImpl Style + * Description}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramStyleDescriptionImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getDiagramStyleDescription() + */ + EClass DIAGRAM_STYLE_DESCRIPTION = eINSTANCE.getDiagramStyleDescription(); + + /** + * The meta object literal for the 'Background' reference feature. + * + * @generated + */ + EReference DIAGRAM_STYLE_DESCRIPTION__BACKGROUND = eINSTANCE.getDiagramStyleDescription_Background(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalNodeStyleImpl Conditional Node @@ -6067,6 +6259,25 @@ interface Literals { */ EReference CONDITIONAL_NODE_STYLE__STYLE = eINSTANCE.getConditionalNodeStyle_Style(); + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalDiagramStyleImpl Conditional Diagram + * Style}' class. + * + * @generated + * @see org.eclipse.sirius.components.view.diagram.impl.ConditionalDiagramStyleImpl + * @see org.eclipse.sirius.components.view.diagram.impl.DiagramPackageImpl#getConditionalDiagramStyle() + */ + EClass CONDITIONAL_DIAGRAM_STYLE = eINSTANCE.getConditionalDiagramStyle(); + + /** + * The meta object literal for the 'Style' containment reference feature. + * + * @generated + */ + EReference CONDITIONAL_DIAGRAM_STYLE__STYLE = eINSTANCE.getConditionalDiagramStyle_Style(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalInsideLabelStyleImpl Conditional diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramStyleDescription.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramStyleDescription.java new file mode 100644 index 00000000000..01d3e4ccf5a --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramStyleDescription.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2024 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; +import org.eclipse.sirius.components.view.UserColor; + +/** + * A representation of the model object 'Style Description'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription#getBackground Background}
    • + *
    + * + * @model + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramStyleDescription() + */ +public interface DiagramStyleDescription extends EObject { + + /** + * Returns the value of the 'Background' reference. + * + * @return the value of the 'Background' reference. + * @model + * @generated + * @see #setBackground(UserColor) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getDiagramStyleDescription_Background() + */ + UserColor getBackground(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription#getBackground + * Background}' reference. + * + * @param value + * the new value of the 'Background' reference. + * @generated + * @see #getBackground() + */ + void setBackground(UserColor value); + +} // DiagramStyleDescription diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalDiagramStyleImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalDiagramStyleImpl.java new file mode 100644 index 00000000000..b62e7f87874 --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalDiagramStyleImpl.java @@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2024 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.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.DiagramStyleDescription; +import org.eclipse.sirius.components.view.impl.ConditionalImpl; + +/** + * An implementation of the model object 'Conditional Diagram Style'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.ConditionalDiagramStyleImpl#getStyle Style}
    • + *
    + * + * @generated + */ +public class ConditionalDiagramStyleImpl extends ConditionalImpl implements ConditionalDiagramStyle { + + /** + * The cached value of the '{@link #getStyle() Style}' containment reference. + * + * @generated + * @ordered + * @see #getStyle() + */ + protected DiagramStyleDescription style; + + /** + * + * + * @generated + */ + protected ConditionalDiagramStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.CONDITIONAL_DIAGRAM_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public DiagramStyleDescription getStyle() { + return this.style; + } + + /** + * + * + * @generated + */ + @Override + public void setStyle(DiagramStyleDescription newStyle) { + if (newStyle != this.style) { + NotificationChain msgs = null; + if (this.style != null) + msgs = ((InternalEObject) this.style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE, null, msgs); + if (newStyle != null) + msgs = ((InternalEObject) newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE, null, msgs); + msgs = this.basicSetStyle(newStyle, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE, newStyle, newStyle)); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetStyle(DiagramStyleDescription newStyle, NotificationChain msgs) { + DiagramStyleDescription oldStyle = this.style; + this.style = newStyle; + if (this.eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE, oldStyle, newStyle); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + return this.basicSetStyle(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + return this.getStyle(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + this.setStyle((DiagramStyleDescription) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + this.setStyle(null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE__STYLE: + return this.style != null; + } + return super.eIsSet(featureID); + } + +} // ConditionalDiagramStyleImpl diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramDescriptionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramDescriptionImpl.java index dba22598ced..9d40540c842 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramDescriptionImpl.java @@ -23,9 +23,11 @@ import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.sirius.components.view.diagram.ArrangeLayoutDirection; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.DiagramDescription; import org.eclipse.sirius.components.view.diagram.DiagramPackage; import org.eclipse.sirius.components.view.diagram.DiagramPalette; +import org.eclipse.sirius.components.view.diagram.DiagramStyleDescription; import org.eclipse.sirius.components.view.diagram.EdgeDescription; import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.impl.RepresentationDescriptionImpl; @@ -45,6 +47,9 @@ * Descriptions
    } *
  • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramDescriptionImpl#getArrangeLayoutDirection * Arrange Layout Direction}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramDescriptionImpl#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramDescriptionImpl#getConditionalStyles + * Conditional Styles}
  • * * * @generated @@ -115,6 +120,26 @@ public class DiagramDescriptionImpl extends RepresentationDescriptionImpl implem */ protected ArrangeLayoutDirection arrangeLayoutDirection = ARRANGE_LAYOUT_DIRECTION_EDEFAULT; + /** + * The cached value of the '{@link #getStyle() Style}' containment reference. + * + * @generated + * @ordered + * @see #getStyle() + */ + protected DiagramStyleDescription style; + + /** + * The cached value of the '{@link #getConditionalStyles() Conditional Styles}' containment reference list. + * + * + * @generated + * @ordered + * @see #getConditionalStyles() + */ + protected EList conditionalStyles; + /** * * @@ -254,6 +279,67 @@ public void setArrangeLayoutDirection(ArrangeLayoutDirection newArrangeLayoutDir this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION, oldArrangeLayoutDirection, this.arrangeLayoutDirection)); } + /** + * + * + * @generated + */ + @Override + public DiagramStyleDescription getStyle() { + return this.style; + } + + /** + * + * + * @generated + */ + @Override + public void setStyle(DiagramStyleDescription newStyle) { + if (newStyle != this.style) { + NotificationChain msgs = null; + if (this.style != null) + msgs = ((InternalEObject) this.style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiagramPackage.DIAGRAM_DESCRIPTION__STYLE, null, msgs); + if (newStyle != null) + msgs = ((InternalEObject) newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiagramPackage.DIAGRAM_DESCRIPTION__STYLE, null, msgs); + msgs = this.basicSetStyle(newStyle, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.DIAGRAM_DESCRIPTION__STYLE, newStyle, newStyle)); + } + + /** + * + * + * @generated + */ + @Override + public EList getConditionalStyles() { + if (this.conditionalStyles == null) { + this.conditionalStyles = new EObjectContainmentEList<>(ConditionalDiagramStyle.class, this, DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.conditionalStyles; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetStyle(DiagramStyleDescription newStyle, NotificationChain msgs) { + DiagramStyleDescription oldStyle = this.style; + this.style = newStyle; + if (this.eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiagramPackage.DIAGRAM_DESCRIPTION__STYLE, oldStyle, newStyle); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + /** * * @@ -268,6 +354,10 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, return ((InternalEList) this.getNodeDescriptions()).basicRemove(otherEnd, msgs); case DiagramPackage.DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS: return ((InternalEList) this.getEdgeDescriptions()).basicRemove(otherEnd, msgs); + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + return this.basicSetStyle(null, msgs); + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: + return ((InternalEList) this.getConditionalStyles()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } @@ -290,6 +380,10 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getEdgeDescriptions(); case DiagramPackage.DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION: return this.getArrangeLayoutDirection(); + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + return this.getStyle(); + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: + return this.getConditionalStyles(); } return super.eGet(featureID, resolve, coreType); } @@ -320,6 +414,13 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION: this.setArrangeLayoutDirection((ArrangeLayoutDirection) newValue); return; + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + this.setStyle((DiagramStyleDescription) newValue); + return; + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + this.getConditionalStyles().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -347,6 +448,12 @@ public void eUnset(int featureID) { case DiagramPackage.DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION: this.setArrangeLayoutDirection(ARRANGE_LAYOUT_DIRECTION_EDEFAULT); return; + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + this.setStyle(null); + return; + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + return; } super.eUnset(featureID); } @@ -369,6 +476,10 @@ public boolean eIsSet(int featureID) { return this.edgeDescriptions != null && !this.edgeDescriptions.isEmpty(); case DiagramPackage.DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION: return this.arrangeLayoutDirection != ARRANGE_LAYOUT_DIRECTION_EDEFAULT; + case DiagramPackage.DIAGRAM_DESCRIPTION__STYLE: + return this.style != null; + case DiagramPackage.DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES: + return this.conditionalStyles != null && !this.conditionalStyles.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/DiagramFactoryImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramFactoryImpl.java index bec03e5a343..09689ad8026 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 @@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.sirius.components.view.diagram.ArrangeLayoutDirection; import org.eclipse.sirius.components.view.diagram.ArrowStyle; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle; import org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle; @@ -31,6 +32,7 @@ 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.DiagramStyleDescription; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropNodeTool; import org.eclipse.sirius.components.view.diagram.DropTool; @@ -135,8 +137,12 @@ public EObject create(EClass eClass) { return this.createInsideLabelStyle(); case DiagramPackage.OUTSIDE_LABEL_STYLE: return this.createOutsideLabelStyle(); + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION: + return this.createDiagramStyleDescription(); case DiagramPackage.CONDITIONAL_NODE_STYLE: return this.createConditionalNodeStyle(); + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE: + return this.createConditionalDiagramStyle(); case DiagramPackage.CONDITIONAL_INSIDE_LABEL_STYLE: return this.createConditionalInsideLabelStyle(); case DiagramPackage.CONDITIONAL_OUTSIDE_LABEL_STYLE: @@ -355,6 +361,17 @@ public OutsideLabelStyle createOutsideLabelStyle() { return outsideLabelStyle; } + /** + * + * + * @generated + */ + @Override + public DiagramStyleDescription createDiagramStyleDescription() { + DiagramStyleDescriptionImpl diagramStyleDescription = new DiagramStyleDescriptionImpl(); + return diagramStyleDescription; + } + /** * * @@ -366,6 +383,17 @@ public ConditionalNodeStyle createConditionalNodeStyle() { return conditionalNodeStyle; } + /** + * + * + * @generated + */ + @Override + public ConditionalDiagramStyle createConditionalDiagramStyle() { + ConditionalDiagramStyleImpl conditionalDiagramStyle = new ConditionalDiagramStyleImpl(); + return conditionalDiagramStyle; + } + /** * * 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 9d20d776b8c..410d220ebb3 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 @@ -22,6 +22,7 @@ import org.eclipse.sirius.components.view.diagram.ArrangeLayoutDirection; import org.eclipse.sirius.components.view.diagram.ArrowStyle; import org.eclipse.sirius.components.view.diagram.BorderStyle; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle; import org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle; @@ -34,6 +35,7 @@ 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.DiagramStyleDescription; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropNodeTool; import org.eclipse.sirius.components.view.diagram.DropTool; @@ -202,6 +204,13 @@ public class DiagramPackageImpl extends EPackageImpl implements DiagramPackage { */ private EClass nodeStyleDescriptionEClass = null; + /** + * + * + * @generated + */ + private EClass diagramStyleDescriptionEClass = null; + /** * * @@ -209,6 +218,13 @@ public class DiagramPackageImpl extends EPackageImpl implements DiagramPackage { */ private EClass conditionalNodeStyleEClass = null; + /** + * + * + * @generated + */ + private EClass conditionalDiagramStyleEClass = null; + /** * * @@ -599,6 +615,26 @@ public EAttribute getDiagramDescription_ArrangeLayoutDirection() { return (EAttribute) this.diagramDescriptionEClass.getEStructuralFeatures().get(4); } + /** + * + * + * @generated + */ + @Override + public EReference getDiagramDescription_Style() { + return (EReference) this.diagramDescriptionEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + @Override + public EReference getDiagramDescription_ConditionalStyles() { + return (EReference) this.diagramDescriptionEClass.getEStructuralFeatures().get(6); + } + /** * * @@ -1329,6 +1365,26 @@ public EClass getNodeStyleDescription() { return this.nodeStyleDescriptionEClass; } + /** + * + * + * @generated + */ + @Override + public EClass getDiagramStyleDescription() { + return this.diagramStyleDescriptionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getDiagramStyleDescription_Background() { + return (EReference) this.diagramStyleDescriptionEClass.getEStructuralFeatures().get(0); + } + /** * * @@ -1349,6 +1405,26 @@ public EReference getConditionalNodeStyle_Style() { return (EReference) this.conditionalNodeStyleEClass.getEStructuralFeatures().get(0); } + /** + * + * + * @generated + */ + @Override + public EClass getConditionalDiagramStyle() { + return this.conditionalDiagramStyleEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getConditionalDiagramStyle_Style() { + return (EReference) this.conditionalDiagramStyleEClass.getEStructuralFeatures().get(0); + } + /** * * @@ -2267,6 +2343,8 @@ public void createPackageContents() { this.createEReference(this.diagramDescriptionEClass, DIAGRAM_DESCRIPTION__NODE_DESCRIPTIONS); this.createEReference(this.diagramDescriptionEClass, DIAGRAM_DESCRIPTION__EDGE_DESCRIPTIONS); this.createEAttribute(this.diagramDescriptionEClass, DIAGRAM_DESCRIPTION__ARRANGE_LAYOUT_DIRECTION); + this.createEReference(this.diagramDescriptionEClass, DIAGRAM_DESCRIPTION__STYLE); + this.createEReference(this.diagramDescriptionEClass, DIAGRAM_DESCRIPTION__CONDITIONAL_STYLES); this.diagramElementDescriptionEClass = this.createEClass(DIAGRAM_ELEMENT_DESCRIPTION); this.createEAttribute(this.diagramElementDescriptionEClass, DIAGRAM_ELEMENT_DESCRIPTION__NAME); @@ -2356,9 +2434,15 @@ public void createPackageContents() { this.nodeStyleDescriptionEClass = this.createEClass(NODE_STYLE_DESCRIPTION); + this.diagramStyleDescriptionEClass = this.createEClass(DIAGRAM_STYLE_DESCRIPTION); + this.createEReference(this.diagramStyleDescriptionEClass, DIAGRAM_STYLE_DESCRIPTION__BACKGROUND); + this.conditionalNodeStyleEClass = this.createEClass(CONDITIONAL_NODE_STYLE); this.createEReference(this.conditionalNodeStyleEClass, CONDITIONAL_NODE_STYLE__STYLE); + this.conditionalDiagramStyleEClass = this.createEClass(CONDITIONAL_DIAGRAM_STYLE); + this.createEReference(this.conditionalDiagramStyleEClass, CONDITIONAL_DIAGRAM_STYLE__STYLE); + this.conditionalInsideLabelStyleEClass = this.createEClass(CONDITIONAL_INSIDE_LABEL_STYLE); this.createEReference(this.conditionalInsideLabelStyleEClass, CONDITIONAL_INSIDE_LABEL_STYLE__STYLE); @@ -2515,6 +2599,7 @@ public void initializePackageContents() { this.nodeLabelStyleEClass.getESuperTypes().add(this.getBorderStyle()); this.nodeStyleDescriptionEClass.getESuperTypes().add(this.getBorderStyle()); this.conditionalNodeStyleEClass.getESuperTypes().add(theViewPackage.getConditional()); + this.conditionalDiagramStyleEClass.getESuperTypes().add(theViewPackage.getConditional()); this.conditionalInsideLabelStyleEClass.getESuperTypes().add(theViewPackage.getConditional()); this.conditionalOutsideLabelStyleEClass.getESuperTypes().add(theViewPackage.getConditional()); this.rectangularNodeStyleDescriptionEClass.getESuperTypes().add(this.getNodeStyleDescription()); @@ -2552,6 +2637,10 @@ public void initializePackageContents() { IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEAttribute(this.getDiagramDescription_ArrangeLayoutDirection(), this.getArrangeLayoutDirection(), "arrangeLayoutDirection", "UNDEFINED", 1, 1, DiagramDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getDiagramDescription_Style(), this.getDiagramStyleDescription(), null, "style", null, 0, 1, DiagramDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getDiagramDescription_ConditionalStyles(), this.getConditionalDiagramStyle(), null, "conditionalStyles", null, 0, -1, DiagramDescription.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.diagramElementDescriptionEClass, DiagramElementDescription.class, "DiagramElementDescription", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEAttribute(this.getDiagramElementDescription_Name(), theViewPackage.getIdentifier(), "name", "NewRepresentationDescription", 0, 1, DiagramElementDescription.class, !IS_TRANSIENT, @@ -2700,10 +2789,18 @@ public void initializePackageContents() { this.initEClass(this.nodeStyleDescriptionEClass, NodeStyleDescription.class, "NodeStyleDescription", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEClass(this.diagramStyleDescriptionEClass, DiagramStyleDescription.class, "DiagramStyleDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getDiagramStyleDescription_Background(), theViewPackage.getUserColor(), null, "background", null, 0, 1, DiagramStyleDescription.class, !IS_TRANSIENT, !IS_VOLATILE, + IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.conditionalNodeStyleEClass, ConditionalNodeStyle.class, "ConditionalNodeStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEReference(this.getConditionalNodeStyle_Style(), this.getNodeStyleDescription(), null, "style", null, 0, 1, ConditionalNodeStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.conditionalDiagramStyleEClass, ConditionalDiagramStyle.class, "ConditionalDiagramStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + this.initEReference(this.getConditionalDiagramStyle_Style(), this.getDiagramStyleDescription(), null, "style", null, 0, 1, ConditionalDiagramStyle.class, !IS_TRANSIENT, !IS_VOLATILE, + IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.conditionalInsideLabelStyleEClass, ConditionalInsideLabelStyle.class, "ConditionalInsideLabelStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEReference(this.getConditionalInsideLabelStyle_Style(), this.getInsideLabelStyle(), null, "style", null, 0, 1, ConditionalInsideLabelStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramStyleDescriptionImpl.java new file mode 100644 index 00000000000..ce0be88e2ff --- /dev/null +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramStyleDescriptionImpl.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2024 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.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; +import org.eclipse.sirius.components.view.UserColor; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.DiagramStyleDescription; + +/** + * An implementation of the model object 'Style Description'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.diagram.impl.DiagramStyleDescriptionImpl#getBackground + * Background}
    • + *
    + * + * @generated + */ +public class DiagramStyleDescriptionImpl extends MinimalEObjectImpl.Container implements DiagramStyleDescription { + + /** + * The cached value of the '{@link #getBackground() Background}' reference. + * + * @generated + * @ordered + * @see #getBackground() + */ + protected UserColor background; + + /** + * + * + * @generated + */ + protected DiagramStyleDescriptionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiagramPackage.Literals.DIAGRAM_STYLE_DESCRIPTION; + } + + /** + * + * + * @generated + */ + @Override + public UserColor getBackground() { + if (this.background != null && this.background.eIsProxy()) { + InternalEObject oldBackground = (InternalEObject) this.background; + this.background = (UserColor) this.eResolveProxy(oldBackground); + if (this.background != oldBackground) { + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND, oldBackground, this.background)); + } + } + return this.background; + } + + /** + * + * + * @generated + */ + @Override + public void setBackground(UserColor newBackground) { + UserColor oldBackground = this.background; + this.background = newBackground; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND, oldBackground, this.background)); + } + + /** + * + * + * @generated + */ + public UserColor basicGetBackground() { + return this.background; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND: + if (resolve) + return this.getBackground(); + return this.basicGetBackground(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND: + this.setBackground((UserColor) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND: + this.setBackground(null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION__BACKGROUND: + return this.background != null; + } + return super.eIsSet(featureID); + } + +} // DiagramStyleDescriptionImpl 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 848ac9360e8..fef7f1e66e3 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 @@ -21,6 +21,7 @@ import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.RepresentationDescription; import org.eclipse.sirius.components.view.diagram.BorderStyle; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle; import org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle; @@ -32,6 +33,7 @@ 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.DiagramStyleDescription; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropNodeTool; import org.eclipse.sirius.components.view.diagram.DropTool; @@ -70,8 +72,8 @@ * The Adapter Factory for the model. It provides an adapter createXXX * method for each class of the model. * - * @see org.eclipse.sirius.components.view.diagram.DiagramPackage * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage */ public class DiagramAdapterFactory extends AdapterFactoryImpl { @@ -168,11 +170,21 @@ public Adapter caseNodeStyleDescription(NodeStyleDescription object) { return DiagramAdapterFactory.this.createNodeStyleDescriptionAdapter(); } + @Override + public Adapter caseDiagramStyleDescription(DiagramStyleDescription object) { + return DiagramAdapterFactory.this.createDiagramStyleDescriptionAdapter(); + } + @Override public Adapter caseConditionalNodeStyle(ConditionalNodeStyle object) { return DiagramAdapterFactory.this.createConditionalNodeStyleAdapter(); } + @Override + public Adapter caseConditionalDiagramStyle(ConditionalDiagramStyle object) { + return DiagramAdapterFactory.this.createConditionalDiagramStyleAdapter(); + } + @Override public Adapter caseConditionalInsideLabelStyle(ConditionalInsideLabelStyle object) { return DiagramAdapterFactory.this.createConditionalInsideLabelStyleAdapter(); @@ -368,7 +380,7 @@ public boolean isFactoryForType(Object object) { * Creates an adapter for the target. * * @param target - * the object to adapt. + * the object to adapt. * @return the adapter for the target. * @generated */ @@ -384,8 +396,8 @@ public Adapter createAdapter(Notifier target) { * when inheritance will catch all the cases anyway. * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.DiagramDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramDescription */ public Adapter createDiagramDescriptionAdapter() { return null; @@ -412,8 +424,8 @@ public Adapter createDiagramElementDescriptionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.NodeDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.NodeDescription */ public Adapter createNodeDescriptionAdapter() { return null; @@ -426,8 +438,8 @@ public Adapter createNodeDescriptionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.EdgeDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.EdgeDescription */ public Adapter createEdgeDescriptionAdapter() { return null; @@ -440,8 +452,8 @@ public Adapter createEdgeDescriptionAdapter() { * 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.LayoutStrategyDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.LayoutStrategyDescription */ public Adapter createLayoutStrategyDescriptionAdapter() { return null; @@ -454,8 +466,8 @@ public Adapter createLayoutStrategyDescriptionAdapter() { * 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.ListLayoutStrategyDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.ListLayoutStrategyDescription */ public Adapter createListLayoutStrategyDescriptionAdapter() { return null; @@ -469,8 +481,8 @@ public Adapter createListLayoutStrategyDescriptionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.FreeFormLayoutStrategyDescription */ public Adapter createFreeFormLayoutStrategyDescriptionAdapter() { return null; @@ -483,8 +495,8 @@ public Adapter createFreeFormLayoutStrategyDescriptionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.LabelDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.LabelDescription */ public Adapter createLabelDescriptionAdapter() { return null; @@ -497,8 +509,8 @@ public Adapter createLabelDescriptionAdapter() { * to ignore a case when inheritance will catch all the cases anyway. * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.InsideLabelDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.InsideLabelDescription */ public Adapter createInsideLabelDescriptionAdapter() { return null; @@ -511,8 +523,8 @@ public Adapter createInsideLabelDescriptionAdapter() { * to ignore a case when inheritance will catch all the cases anyway. * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.OutsideLabelDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.OutsideLabelDescription */ public Adapter createOutsideLabelDescriptionAdapter() { return null; @@ -524,8 +536,8 @@ public Adapter createOutsideLabelDescriptionAdapter() { * 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.Style * @generated + * @see org.eclipse.sirius.components.view.diagram.Style */ public Adapter createStyleAdapter() { return null; @@ -552,8 +564,8 @@ public Adapter createBorderStyleAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.InsideLabelStyle * @generated + * @see org.eclipse.sirius.components.view.diagram.InsideLabelStyle */ public Adapter createInsideLabelStyleAdapter() { return null; @@ -566,8 +578,8 @@ public Adapter createInsideLabelStyleAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.OutsideLabelStyle * @generated + * @see org.eclipse.sirius.components.view.diagram.OutsideLabelStyle */ public Adapter createOutsideLabelStyleAdapter() { return null; @@ -580,8 +592,8 @@ public Adapter createOutsideLabelStyleAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.NodeLabelStyle * @generated + * @see org.eclipse.sirius.components.view.diagram.NodeLabelStyle */ public Adapter createNodeLabelStyleAdapter() { return null; @@ -601,6 +613,20 @@ public Adapter createNodeStyleDescriptionAdapter() { return null; } + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.diagram.DiagramStyleDescription Style Description}'. This default implementation returns null so that we can easily ignore cases; it's useful to + * ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramStyleDescription + */ + public Adapter createDiagramStyleDescriptionAdapter() { + return null; + } + /** * Creates a new adapter for an object of class * '{@link org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle Conditional Node Style}'. This default implementation returns null so that we can easily ignore cases; it's useful + * to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @generated + * @see org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle + */ + public Adapter createConditionalDiagramStyleAdapter() { + return null; + } + /** * Creates a new adapter for an object of class * '{@link org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle Conditional Inside Label @@ -622,8 +662,8 @@ public Adapter createConditionalNodeStyleAdapter() { * 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.ConditionalInsideLabelStyle * @generated + * @see org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle */ public Adapter createConditionalInsideLabelStyleAdapter() { return null; @@ -636,8 +676,8 @@ public Adapter createConditionalInsideLabelStyleAdapter() { * 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.ConditionalOutsideLabelStyle * @generated + * @see org.eclipse.sirius.components.view.diagram.ConditionalOutsideLabelStyle */ public Adapter createConditionalOutsideLabelStyleAdapter() { return null; @@ -650,8 +690,8 @@ public Adapter createConditionalOutsideLabelStyleAdapter() { * 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.RectangularNodeStyleDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.RectangularNodeStyleDescription */ public Adapter createRectangularNodeStyleDescriptionAdapter() { return null; @@ -664,8 +704,8 @@ public Adapter createRectangularNodeStyleDescriptionAdapter() { * 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.ImageNodeStyleDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.ImageNodeStyleDescription */ public Adapter createImageNodeStyleDescriptionAdapter() { return null; @@ -678,8 +718,8 @@ public Adapter createImageNodeStyleDescriptionAdapter() { * 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.IconLabelNodeStyleDescription * @generated + * @see org.eclipse.sirius.components.view.diagram.IconLabelNodeStyleDescription */ public Adapter createIconLabelNodeStyleDescriptionAdapter() { return null; @@ -719,8 +759,8 @@ public Adapter createConditionalEdgeStyleAdapter() { * 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.DiagramPalette * @generated + * @see org.eclipse.sirius.components.view.diagram.DiagramPalette */ public Adapter createDiagramPaletteAdapter() { return null; @@ -760,8 +800,8 @@ public Adapter createEdgePaletteAdapter() { * 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.Tool * @generated + * @see org.eclipse.sirius.components.view.diagram.Tool */ public Adapter createToolAdapter() { return null; @@ -787,8 +827,8 @@ public Adapter createDeleteToolAdapter() { * 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.DropTool * @generated + * @see org.eclipse.sirius.components.view.diagram.DropTool */ public Adapter createDropToolAdapter() { return null; @@ -800,8 +840,8 @@ public Adapter createDropToolAdapter() { * 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.EdgeTool * @generated + * @see org.eclipse.sirius.components.view.diagram.EdgeTool */ public Adapter createEdgeToolAdapter() { return null; @@ -828,8 +868,8 @@ public Adapter createEdgeReconnectionToolAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.LabelEditTool * @generated + * @see org.eclipse.sirius.components.view.diagram.LabelEditTool */ public Adapter createLabelEditToolAdapter() { return null; @@ -841,8 +881,8 @@ public Adapter createLabelEditToolAdapter() { * 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.NodeTool * @generated + * @see org.eclipse.sirius.components.view.diagram.NodeTool */ public Adapter createNodeToolAdapter() { return null; @@ -855,8 +895,8 @@ public Adapter createNodeToolAdapter() { * 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.SourceEdgeEndReconnectionTool * @generated + * @see org.eclipse.sirius.components.view.diagram.SourceEdgeEndReconnectionTool */ public Adapter createSourceEdgeEndReconnectionToolAdapter() { return null; @@ -869,8 +909,8 @@ public Adapter createSourceEdgeEndReconnectionToolAdapter() { * 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.TargetEdgeEndReconnectionTool * @generated + * @see org.eclipse.sirius.components.view.diagram.TargetEdgeEndReconnectionTool */ public Adapter createTargetEdgeEndReconnectionToolAdapter() { return null; @@ -953,8 +993,8 @@ public Adapter createDiagramToolSectionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.NodeToolSection * @generated + * @see org.eclipse.sirius.components.view.diagram.NodeToolSection */ public Adapter createNodeToolSectionAdapter() { return null; @@ -967,8 +1007,8 @@ public Adapter createNodeToolSectionAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection * @generated + * @see org.eclipse.sirius.components.view.diagram.EdgeToolSection */ public Adapter createEdgeToolSectionAdapter() { return null; @@ -995,8 +1035,8 @@ public Adapter createDropNodeToolAdapter() { * end-user-doc --> * * @return the new adapter. - * @see org.eclipse.sirius.components.view.RepresentationDescription * @generated + * @see org.eclipse.sirius.components.view.RepresentationDescription */ public Adapter createRepresentationDescriptionAdapter() { return null; @@ -1008,8 +1048,8 @@ public Adapter createRepresentationDescriptionAdapter() { * 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.LabelStyle * @generated + * @see org.eclipse.sirius.components.view.LabelStyle */ public Adapter createLabelStyleAdapter() { return null; 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 3d42764c908..c82833b2fdd 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 @@ -20,6 +20,7 @@ import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.RepresentationDescription; import org.eclipse.sirius.components.view.diagram.BorderStyle; +import org.eclipse.sirius.components.view.diagram.ConditionalDiagramStyle; import org.eclipse.sirius.components.view.diagram.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.diagram.ConditionalInsideLabelStyle; import org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle; @@ -31,6 +32,7 @@ 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.DiagramStyleDescription; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; import org.eclipse.sirius.components.view.diagram.DropNodeTool; import org.eclipse.sirius.components.view.diagram.DropTool; @@ -261,6 +263,13 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case DiagramPackage.DIAGRAM_STYLE_DESCRIPTION: { + DiagramStyleDescription diagramStyleDescription = (DiagramStyleDescription) theEObject; + T result = this.caseDiagramStyleDescription(diagramStyleDescription); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } case DiagramPackage.CONDITIONAL_NODE_STYLE: { ConditionalNodeStyle conditionalNodeStyle = (ConditionalNodeStyle) theEObject; T result = this.caseConditionalNodeStyle(conditionalNodeStyle); @@ -270,6 +279,15 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case DiagramPackage.CONDITIONAL_DIAGRAM_STYLE: { + ConditionalDiagramStyle conditionalDiagramStyle = (ConditionalDiagramStyle) theEObject; + T result = this.caseConditionalDiagramStyle(conditionalDiagramStyle); + if (result == null) + result = this.caseConditional(conditionalDiagramStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } case DiagramPackage.CONDITIONAL_INSIDE_LABEL_STYLE: { ConditionalInsideLabelStyle conditionalInsideLabelStyle = (ConditionalInsideLabelStyle) theEObject; T result = this.caseConditionalInsideLabelStyle(conditionalInsideLabelStyle); @@ -765,6 +783,21 @@ public T caseNodeStyleDescription(NodeStyleDescription object) { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Style Description'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Style Description'. + * @generated + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + */ + public T caseDiagramStyleDescription(DiagramStyleDescription object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Conditional Node Style'. This implementation returns null; returning a non-null result will terminate the switch. 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 'Conditional Diagram Style'. + * @generated + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + */ + public T caseConditionalDiagramStyle(ConditionalDiagramStyle object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Conditional Inside Label Style'. This implementation returns null; returning a non-null result will terminate the switch.