Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3391] Accept gradient for node background #3394

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Accordingly, `IObjectSearchService` and `IIdentityService` now handle actual `IE
- https://github.com/eclipse-sirius/sirius-web/issues/3425[#3425] [diagram] In our GraphQL schema, `DiagramDescription` must now declare an `ArrangeLayoutDirection`.
- https://github.com/eclipse-sirius/sirius-web/issues/2655[#2655] [diagram] Add optional `calculateCustomNodeEdgeHandlePosition` method to `INodeLayoutHandler`.
- https://github.com/eclipse-sirius/sirius-web/issues/3456[#3456] [diagram] `ConnectionTargetHandle` now expects `isHovered` props for custom nodes
- https://github.com/eclipse-sirius/sirius-web/issues/3391[#3391] [diagram] Some changes have been made in the View DSL for diagram:
* super types `style` has been removed from `NodeStyleDescription`
frouene marked this conversation as resolved.
Show resolved Hide resolved
* attribute `background` has been added to `RectangularNodeStyleDescription` and `IconLabelNodeStyleDescription`

=== Dependency update

Expand Down Expand Up @@ -148,6 +151,7 @@ They still support returning an `java.time.Instant` object directly.
- https://github.com/eclipse-sirius/sirius-web/issues/3397[#3397] [diagram] Add helper lines when resizing nodes
- https://github.com/eclipse-sirius/sirius-web/issues/2655[#2655] [diagram] Add `calculateCustomNodeEdgeHandlePosition` method to position edge handles according to the real layout of the custom node
- https://github.com/eclipse-sirius/sirius-web/issues/3456[#3456] [diagram] Fix an issue that were causing a large delay when opening a diagram, creating an edge or reconnecting an edge
- https://github.com/eclipse-sirius/sirius-web/issues/3391[#3391] [diagram] Accept gradient for node background

== v2024.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('/projects/:projectId/edit - Color Palette', () => {
cy.get('[title="diagram::DiagramDescription"]').dblclick();
cy.getByTestId('Entity1 Node-toggle').click();
cy.get('[title="diagram::RectangularNodeStyleDescription"]').click();
cy.getByTestId('Color').click();
cy.getByTestId('Background').click();
cy.getByTestId('option-color_dark').should('exist').click();
cy.getByTestId('Border Color').click();
cy.getByTestId('option-border_green').should('exist').click();
Expand Down
599 changes: 309 additions & 290 deletions integration-tests/cypress/e2e/project/studio/studio.cy.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public RectangularNodeStyle getRectangularNodeStyle() {
.borderColor("#000000")
.borderSize(1)
.borderStyle(LineStyle.Solid)
.color("#FFFFFF")
.background("#FFFFFF")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,12 @@ private NodeDescription getNodeDescription(String nodeDescriptionId) {
.overflowStrategy(LabelOverflowStrategy.NONE)
.build();

Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> {
return RectangularNodeStyle.newRectangularNodeStyle()
.color("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();
};
Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> RectangularNodeStyle.newRectangularNodeStyle()
.background("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();

Function<VariableManager, String> targetObjectIdProvider = variableManager -> {
Object object = variableManager.getVariables().get(VariableManager.SELF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,12 @@ private NodeDescription getNodeDescription(String nodeDescriptionId) {
.overflowStrategy(LabelOverflowStrategy.NONE)
.build();

Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> {
return RectangularNodeStyle.newRectangularNodeStyle()
.color("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();
};
Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> RectangularNodeStyle.newRectangularNodeStyle()
.background("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();

Function<VariableManager, String> targetObjectIdProvider = variableManager -> {
Object object = variableManager.getVariables().get(VariableManager.SELF);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2023 Obeo and others.
* Copyright (c) 2019, 2024 Obeo and others.
* 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
Expand Down Expand Up @@ -60,27 +60,23 @@ private INodeStyle getNodeStyle(VariableManager variableManager, LabelStyleDescr

if (this.shouldBeConsideredAsListItemNodeStyle(variableManager, nodeStyleDescription)) {
style = this.createListItemNodeStyle(variableManager, nodeStyleDescription);
} else if (nodeStyleDescription instanceof SquareDescription) {
SquareDescription squareDescription = (SquareDescription) nodeStyleDescription;
} else if (nodeStyleDescription instanceof SquareDescription squareDescription) {
style = this.createRectangularNodeStyle(variableManager, squareDescription);
} else if (nodeStyleDescription instanceof DotDescription) {
DotDescription dotDescription = (DotDescription) nodeStyleDescription;
} else if (nodeStyleDescription instanceof DotDescription dotDescription) {
style = this.createRectangularNodeStyle(variableManager, dotDescription);
} else if (nodeStyleDescription instanceof FlatContainerStyleDescription) {
FlatContainerStyleDescription flatContainerStyleDescription = (FlatContainerStyleDescription) nodeStyleDescription;
} else if (nodeStyleDescription instanceof FlatContainerStyleDescription flatContainerStyleDescription) {
if (this.abstractNodeMapping instanceof ContainerMapping && new ContainerMappingQuery((ContainerMapping) this.abstractNodeMapping).isListContainer()) {
style = this.createListNodeStyle(variableManager, flatContainerStyleDescription);
} else {
style = this.createRectangularNodeStyle(variableManager, flatContainerStyleDescription);
}
} else if (nodeStyleDescription instanceof WorkspaceImageDescription) {
WorkspaceImageDescription workspaceImageDescription = (WorkspaceImageDescription) nodeStyleDescription;
} else if (nodeStyleDescription instanceof WorkspaceImageDescription workspaceImageDescription) {
WorkspaceImageDescriptionConverter workspaceImageDescriptionConverter = new WorkspaceImageDescriptionConverter(this.interpreter, variableManager, workspaceImageDescription);
style = workspaceImageDescriptionConverter.convert();
} else {
// Fallback on Rectangular node style for now, until other styles are supported
style = RectangularNodeStyle.newRectangularNodeStyle()
.color("rgb(200, 200, 200)")
.background("rgb(200, 200, 200)")
.borderColor("rgb(0, 0, 0)")
.borderSize(1)
.borderStyle(LineStyle.Solid)
Expand All @@ -95,22 +91,21 @@ private INodeStyle getNodeStyle(VariableManager variableManager, LabelStyleDescr
* lozenge) and the {@link #nodeMapping} container represents his children in a list, <code>false</code> otherwise.
*
* @param variableManager
* The variable manager
* The variable manager
* @param nodeStyleDescription
* the node style description that could be considered as a list item node style
* the node style description that could be considered as a list item node style
* @return <code>true</code> if the <em>nodeStyleDescription</em> should be considered as a list item node style
*/
private boolean shouldBeConsideredAsListItemNodeStyle(VariableManager variableManager, LabelStyleDescription nodeStyleDescription) {
if (this.abstractNodeMapping.eContainer() instanceof ContainerMapping) {
ContainerMapping parentMapping = (ContainerMapping) this.abstractNodeMapping.eContainer();
if (this.abstractNodeMapping.eContainer() instanceof ContainerMapping parentMapping) {
return new ContainerMappingQuery(parentMapping).isListContainer();
}
return false;
}

private INodeStyle createListItemNodeStyle(VariableManager variableManager, LabelStyleDescription nodeStyleDescription) {
return IconLabelNodeStyle.newIconLabelNodeStyle()
.backgroundColor("transparent")
.background("transparent")
.build();
}

Expand All @@ -128,7 +123,7 @@ private INodeStyle createListNodeStyle(VariableManager variableManager, FlatCont
int borderSize = result.asInt().getAsInt();

return RectangularNodeStyle.newRectangularNodeStyle()
.color(color)
.background(color)
.borderColor(borderColor)
.borderSize(borderSize)
.borderRadius(borderRadius)
Expand Down Expand Up @@ -161,7 +156,7 @@ private RectangularNodeStyle createRectangularNodeStyle(VariableManager variable
int borderSize = result.asInt().getAsInt();

return RectangularNodeStyle.newRectangularNodeStyle()
.color(color)
.background(color)
.borderColor(borderColor)
.borderSize(borderSize)
.borderStyle(borderStyle)
Expand All @@ -181,7 +176,7 @@ private RectangularNodeStyle createRectangularNodeStyle(VariableManager variable
int borderSize = result.asInt().getAsInt();

return RectangularNodeStyle.newRectangularNodeStyle()
.color(color)
.background(color)
.borderColor(borderColor)
.borderSize(borderSize)
.borderRadius(borderRadius)
Expand All @@ -202,7 +197,7 @@ private RectangularNodeStyle createRectangularNodeStyle(VariableManager variable
int borderSize = result.asInt().getAsInt();

return RectangularNodeStyle.newRectangularNodeStyle()
.color(color)
.background(color)
.borderColor(borderColor)
.borderSize(borderSize)
.borderRadius(borderRadius)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ type ImageNodeStyle {
}

type IconLabelNodeStyle {
backgroundColor: String!
background: String!
}

type RectangularNodeStyle {
borderColor: String!
borderRadius: Int!
borderSize: Int!
borderStyle: LineStyle!
color: String!
background: String!
}

enum LineStyle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public RectangularNodeStyle getRectangularNodeStyle() {
.borderColor("#000000")
.borderSize(1)
.borderStyle(LineStyle.Solid)
.color("#FFFFFF")
.background("#FFFFFF")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ public NodeDescription getNodeDescription(String nodeDescriptionId, Function<Var
.overflowStrategy(LabelOverflowStrategy.NONE)
.build();

Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> {
return RectangularNodeStyle.newRectangularNodeStyle()
.color("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();
};
Function<VariableManager, INodeStyle> nodeStyleProvider = variableManager -> RectangularNodeStyle.newRectangularNodeStyle()
.background("")
.borderColor("")
.borderSize(0)
.borderStyle(LineStyle.Solid)
.build();

Function<VariableManager, String> idProvider = variableManager -> {
Object object = variableManager.getVariables().get(VariableManager.SELF);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 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
Expand All @@ -23,14 +23,15 @@
* @author sbegaudeau
*/
public class RectangularNodeStyleAssert extends AbstractAssert<RectangularNodeStyleAssert, RectangularNodeStyle> {

public RectangularNodeStyleAssert(RectangularNodeStyle rectangularNodeStyle) {
super(rectangularNodeStyle, RectangularNodeStyleAssert.class);
}

public RectangularNodeStyleAssert matches(RectangularNodeStyle rectangularNodeStyle) {
this.isNotNull();

assertThat(this.actual.getColor()).isEqualTo(rectangularNodeStyle.getColor());
assertThat(this.actual.getBackground()).isEqualTo(rectangularNodeStyle.getBackground());
assertThat(this.actual.getBorderColor()).isEqualTo(rectangularNodeStyle.getBorderColor());
assertThat(this.actual.getBorderSize()).isEqualTo(rectangularNodeStyle.getBorderSize());
assertThat(this.actual.getBorderStyle()).isEqualTo(rectangularNodeStyle.getBorderStyle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public IconLabelNodeStyleAssert(IconLabelNodeStyle iconLabelNodeStyle) {
}

public IconLabelNodeStyleAssert hasBackgroundColor(String backgroundColor) {
assertThat(this.actual.getBackgroundColor()).isEqualTo(backgroundColor);
assertThat(this.actual.getBackground()).isEqualTo(backgroundColor);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public RectangularNodeStyleAssert(RectangularNodeStyle rectangularNodeStyle) {
super(rectangularNodeStyle, RectangularNodeStyleAssert.class);
}

public RectangularNodeStyleAssert hasColor(String color) {
assertThat(this.actual.getColor()).isEqualTo(color);
public RectangularNodeStyleAssert hasBackground(String color) {
assertThat(this.actual.getBackground()).isEqualTo(color);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 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
Expand Down Expand Up @@ -44,11 +44,11 @@
@SuppressWarnings("checkstyle:HiddenField")
public class IconlabelNodeBuilder<T> implements NodeBuilder<T> {

private NodesBuilder<T> nodesBuilder;
private final NodesBuilder<T> nodesBuilder;

private boolean isBorderNode;
private final boolean isBorderNode;

private InsideLabel insideLabel;
private final InsideLabel insideLabel;

private Position position;

Expand Down Expand Up @@ -100,11 +100,9 @@ public Node build(Map<String, String> targetObjectIdToNodeId) {
List<Node> borderNodes = Optional.ofNullable(this.borderNodesBuilder).map(nodesBuilder -> nodesBuilder.build(targetObjectIdToNodeId)).orElse(List.of());
List<Node> childNodes = Optional.ofNullable(this.childNodesBuilder).map(nodesBuilder -> nodesBuilder.build(targetObjectIdToNodeId)).orElse(List.of());

// @formatter:off
INodeStyle style = IconLabelNodeStyle.newIconLabelNodeStyle()
.backgroundColor("white")
.background("white")
.build();
// @formatter:on

String labelText = this.insideLabel.getText();
String nodeId = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 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
Expand Down Expand Up @@ -40,17 +40,17 @@
* Builder used to build a rectangle node.
*
* @param <T>
* The parent builder type
* The parent builder type
* @author gcoutable
*/
@SuppressWarnings("checkstyle:HiddenField")
public final class RectangleNodeBuilder<T> implements NodeBuilder<T> {

private NodesBuilder<T> nodesBuilder;
private final NodesBuilder<T> nodesBuilder;

private boolean isBorderNode;
private final boolean isBorderNode;

private InsideLabel insideLabel;
private final InsideLabel insideLabel;

private Position position;

Expand Down Expand Up @@ -124,7 +124,7 @@ public Node build(Map<String, String> targetObjectIdToNodeId) {
List<Node> childNodes = Optional.ofNullable(this.childNodesBuilder).map(nodesBuilder -> nodesBuilder.build(targetObjectIdToNodeId)).orElse(List.of());

INodeStyle style = RectangularNodeStyle.newRectangularNodeStyle()
.color("#E5F5F8")
.background("#E5F5F8")
.borderColor("#33B0C3")
.borderSize(1)
.borderRadius(3)
Expand Down