-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[315] Fix conditional style handling for containers and nodes
In Sirius-Web representations displayed to users, the label of elements with mapping 'MyMapping' should be the one of the conditional style. Some other properties (bold, italic, ...) of the conditional style were not also taking into account. Bug: #315 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr> Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
- Loading branch information
1 parent
e7b2a9f
commit a574cc6
Showing
20 changed files
with
544 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...c/main/java/org/eclipse/sirius/web/compat/diagrams/ContainerStyleDescriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 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.compat.diagrams; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription; | ||
import org.eclipse.sirius.diagram.description.ContainerMapping; | ||
import org.eclipse.sirius.diagram.description.style.ContainerStyleDescription; | ||
import org.eclipse.sirius.web.interpreter.AQLInterpreter; | ||
import org.eclipse.sirius.web.interpreter.Result; | ||
import org.eclipse.sirius.web.representations.VariableManager; | ||
|
||
/** | ||
* Compute the proper style description to use for a container mapping. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public class ContainerStyleDescriptionProvider { | ||
private final AQLInterpreter interpreter; | ||
|
||
private final ContainerMapping containerMapping; | ||
|
||
public ContainerStyleDescriptionProvider(AQLInterpreter interpreter, ContainerMapping containerMapping) { | ||
this.interpreter = Objects.requireNonNull(interpreter); | ||
this.containerMapping = Objects.requireNonNull(containerMapping); | ||
} | ||
|
||
public ContainerStyleDescription getContainerStyleDescription(VariableManager variableManager) { | ||
ContainerStyleDescription styleDescription = this.containerMapping.getStyle(); | ||
List<ConditionalContainerStyleDescription> conditionnalStyles = this.containerMapping.getConditionnalStyles(); | ||
for (ConditionalContainerStyleDescription conditionalStyle : conditionnalStyles) { | ||
String predicateExpression = conditionalStyle.getPredicateExpression(); | ||
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), predicateExpression); | ||
boolean shouldUseStyle = result.asBoolean().orElse(Boolean.FALSE).booleanValue(); | ||
if (shouldUseStyle) { | ||
styleDescription = conditionalStyle.getStyle(); | ||
break; | ||
} | ||
} | ||
return styleDescription; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ty/src/main/java/org/eclipse/sirius/web/compat/diagrams/EdgeStyleDescriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 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.compat.diagrams; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.diagram.description.ConditionalEdgeStyleDescription; | ||
import org.eclipse.sirius.diagram.description.EdgeMapping; | ||
import org.eclipse.sirius.diagram.description.style.EdgeStyleDescription; | ||
import org.eclipse.sirius.web.interpreter.AQLInterpreter; | ||
import org.eclipse.sirius.web.interpreter.Result; | ||
import org.eclipse.sirius.web.representations.VariableManager; | ||
|
||
/** | ||
* Compute the proper style description to use for a edge mapping. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public class EdgeStyleDescriptionProvider { | ||
private final AQLInterpreter interpreter; | ||
|
||
private final EdgeMapping edgeMapping; | ||
|
||
public EdgeStyleDescriptionProvider(AQLInterpreter interpreter, EdgeMapping edgeMapping) { | ||
this.interpreter = Objects.requireNonNull(interpreter); | ||
this.edgeMapping = Objects.requireNonNull(edgeMapping); | ||
} | ||
|
||
public EdgeStyleDescription getEdgeStyleDescription(VariableManager variableManager) { | ||
EdgeStyleDescription styleDescription = this.edgeMapping.getStyle(); | ||
List<ConditionalEdgeStyleDescription> conditionnalStyles = this.edgeMapping.getConditionnalStyles(); | ||
for (ConditionalEdgeStyleDescription conditionalStyle : conditionnalStyles) { | ||
String predicateExpression = conditionalStyle.getPredicateExpression(); | ||
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), predicateExpression); | ||
boolean shouldUseStyle = result.asBoolean().orElse(Boolean.FALSE).booleanValue(); | ||
if (shouldUseStyle) { | ||
styleDescription = conditionalStyle.getStyle(); | ||
break; | ||
} | ||
} | ||
return styleDescription; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.