Search in sources :

Example 1 with ConditionalContainerStyleDescription

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;
}
Also used : NodeMapping(org.eclipse.sirius.diagram.description.NodeMapping) AbstractNodeMapping(org.eclipse.sirius.diagram.description.AbstractNodeMapping) ConditionalContainerStyleDescription(org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription) ConditionalNodeStyleDescription(org.eclipse.sirius.diagram.description.ConditionalNodeStyleDescription) List(java.util.List) LabelStyleDescription(org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription) ContainerMapping(org.eclipse.sirius.diagram.description.ContainerMapping) Result(org.eclipse.sirius.components.interpreter.Result)

Example 2 with ConditionalContainerStyleDescription

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;
}
Also used : ConditionalContainerStyleDescription(org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription)

Example 3 with ConditionalContainerStyleDescription

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;
}
Also used : ConditionalContainerStyleDescription(org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription)

Aggregations

ConditionalContainerStyleDescription (org.eclipse.sirius.diagram.description.ConditionalContainerStyleDescription)3 List (java.util.List)1 Result (org.eclipse.sirius.components.interpreter.Result)1 AbstractNodeMapping (org.eclipse.sirius.diagram.description.AbstractNodeMapping)1 ConditionalNodeStyleDescription (org.eclipse.sirius.diagram.description.ConditionalNodeStyleDescription)1 ContainerMapping (org.eclipse.sirius.diagram.description.ContainerMapping)1 NodeMapping (org.eclipse.sirius.diagram.description.NodeMapping)1 LabelStyleDescription (org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription)1