use of org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription in project sirius-components by eclipse-sirius.
the class LabelStyleDescriptionProvider method apply.
@Override
public LabelStyleDescription apply(VariableManager variableManager) {
LabelStyleDescription labelStyleDescription = null;
if (this.abstractNodeMapping instanceof NodeMapping) {
NodeMapping nodeMapping = (NodeMapping) this.abstractNodeMapping;
labelStyleDescription = nodeMapping.getStyle();
List<ConditionalNodeStyleDescription> conditionnalStyles = nodeMapping.getConditionnalStyles();
for (ConditionalNodeStyleDescription conditionalStyle : conditionnalStyles) {
String predicateExpression = conditionalStyle.getPredicateExpression();
Result result = this.interpreter.evaluateExpression(variableManager.getVariables(), predicateExpression);
boolean shouldUseStyle = result.asBoolean().orElse(Boolean.FALSE).booleanValue();
if (shouldUseStyle) {
labelStyleDescription = conditionalStyle.getStyle();
break;
}
}
} else if (this.abstractNodeMapping instanceof ContainerMapping) {
ContainerMapping containerMapping = (ContainerMapping) this.abstractNodeMapping;
labelStyleDescription = containerMapping.getStyle();
List<ConditionalContainerStyleDescription> conditionnalStyles = 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) {
labelStyleDescription = conditionalStyle.getStyle();
break;
}
}
}
return labelStyleDescription;
}
use of org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription in project sirius-components by eclipse-sirius.
the class ContainerMappingStyleProviderTests method createConditionalStyle.
private ConditionalContainerStyleDescription createConditionalStyle(String predicateExpression, ContainerStyleDescription containerStyleDescription) {
ConditionalContainerStyleDescription conditionalContainerStyle = DescriptionFactory.eINSTANCE.createConditionalContainerStyleDescription();
conditionalContainerStyle.setPredicateExpression(predicateExpression);
conditionalContainerStyle.setStyle(containerStyleDescription);
return conditionalContainerStyle;
}
use of org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription in project sirius-components by eclipse-sirius.
the class MappingConverterTests method createConditionalContainerStyle.
private ConditionalContainerStyleDescription createConditionalContainerStyle(String predicateExpression, ContainerStyleDescription containerStyleDescription) {
ConditionalContainerStyleDescription conditionalContainerStyle = DescriptionFactory.eINSTANCE.createConditionalContainerStyleDescription();
conditionalContainerStyle.setPredicateExpression(predicateExpression);
conditionalContainerStyle.setStyle(containerStyleDescription);
return conditionalContainerStyle;
}
Aggregations