use of org.eclipse.sirius.diagram.description.style.NodeStyleDescription in project sirius-components by eclipse-sirius.
the class NodeMappingStyleProviderTests method testBorderLineStyleConversion.
@Test
public void testBorderLineStyleConversion() {
// @formatter:off
var conversions = Map.of(LineStyle.DASH_DOT_LITERAL, org.eclipse.sirius.components.diagrams.LineStyle.Dash_Dot, LineStyle.DASH_LITERAL, org.eclipse.sirius.components.diagrams.LineStyle.Dash, LineStyle.DOT_LITERAL, org.eclipse.sirius.components.diagrams.LineStyle.Dot, LineStyle.SOLID_LITERAL, org.eclipse.sirius.components.diagrams.LineStyle.Solid);
for (var entry : conversions.entrySet()) {
NodeMapping nodeMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
NodeStyleDescription style = this.createSquareStyle(0, 0, 0);
style.setBorderLineStyle(entry.getKey());
nodeMapping.setStyle(style);
VariableManager variableManager = new VariableManager();
AQLInterpreter interpreter = new AQLInterpreter(List.of(), List.of(EcorePackage.eINSTANCE));
INodeStyle nodeStyle = new AbstractNodeMappingStyleProvider(interpreter, nodeMapping).apply(variableManager);
assertThat(nodeStyle).isInstanceOf(RectangularNodeStyle.class);
RectangularNodeStyle rectangularNodeStyle = (RectangularNodeStyle) nodeStyle;
assertThat(rectangularNodeStyle.getBorderStyle()).isEqualTo(entry.getValue());
}
}
use of org.eclipse.sirius.diagram.description.style.NodeStyleDescription in project sirius-components by eclipse-sirius.
the class NodeMappingStyleProviderTests method createSquareStyle.
private NodeStyleDescription createSquareStyle(int red, int green, int blue) {
NodeStyleDescription nodeStyleDescription = StyleFactory.eINSTANCE.createSquareDescription();
FixedColor fixedColor = org.eclipse.sirius.viewpoint.description.DescriptionFactory.eINSTANCE.createFixedColor();
fixedColor.setRed(red);
fixedColor.setGreen(green);
fixedColor.setBlue(blue);
nodeStyleDescription.setBorderColor(fixedColor);
return nodeStyleDescription;
}
use of org.eclipse.sirius.diagram.description.style.NodeStyleDescription in project sirius-components by eclipse-sirius.
the class MappingConverterTests method testNodeStylePropertiesFromConditionalStyle.
@Test
public void testNodeStylePropertiesFromConditionalStyle() {
NodeMapping nodeMapping = DescriptionFactory.eINSTANCE.createNodeMapping();
// $NON-NLS-1$
String mappingName = "TestMapping";
nodeMapping.setName(mappingName);
// @formatter:off
NodeStyleDescription defaultStyle = StyleFactory.eINSTANCE.createSquareDescription();
new BasicLabelStyleDescriptionPopulator(defaultStyle).labelExpression(// $NON-NLS-1$
"aql:'defaultStyle'").labelSize(10).labelColor(this.getColor(1, 1, 1));
NodeStyleDescription firstConditionalStyle = StyleFactory.eINSTANCE.createSquareDescription();
new BasicLabelStyleDescriptionPopulator(firstConditionalStyle).labelExpression(// $NON-NLS-1$
"aql:'firstConditionalStyle'").labelSize(4).labelColor(this.getColor(3, 3, 3));
NodeStyleDescription secondConditionalStyle = StyleFactory.eINSTANCE.createSquareDescription();
new BasicLabelStyleDescriptionPopulator(secondConditionalStyle).labelExpression(// $NON-NLS-1$
"aql:'secondConditionalStyle'").labelSize(6).bold().italic().underline().strikeThrough().labelColor(this.getColor(2, 2, 2)).iconPath(PLUGIN_ID + ICON_PATH);
NodeStyleDescription thirdConditionalStyle = StyleFactory.eINSTANCE.createSquareDescription();
new BasicLabelStyleDescriptionPopulator(thirdConditionalStyle).labelExpression(// $NON-NLS-1$
"aql:'thirdConditionalStyle'").labelSize(8).labelColor(this.getColor(4, 4, 4));
// @formatter:on
nodeMapping.setStyle(defaultStyle);
nodeMapping.getConditionnalStyles().add(this.createConditionalNodeStyle(EXPRESSION_FALSE, firstConditionalStyle));
nodeMapping.getConditionnalStyles().add(this.createConditionalNodeStyle(EXPRESSION_TRUE, secondConditionalStyle));
nodeMapping.getConditionnalStyles().add(this.createConditionalNodeStyle(EXPRESSION_TRUE, thirdConditionalStyle));
IIdentifierProvider identifierProvider = new IIdentifierProvider() {
@Override
public String getIdentifier(Object element) {
return UUID.randomUUID().toString();
}
@Override
public Optional<String> findVsmElementId(UUID id) {
return Optional.empty();
}
};
ISemanticCandidatesProviderFactory semanticCandidatesProviderFactory = (interpreter, domainClass, semanticCandidatesExpression, preconditionExpression) -> variableManager -> List.of();
IModelOperationHandlerSwitchProvider modelOperationHandlerSwitchProvider = interpreter -> modelOperation -> Optional.empty();
VariableManager variableManager = new VariableManager();
AQLInterpreter interpreter = new AQLInterpreter(List.of(), List.of(EcorePackage.eINSTANCE));
var converter = new AbstractNodeMappingConverter(new IObjectService.NoOp(), new IEditService.NoOp(), identifierProvider, semanticCandidatesProviderFactory, modelOperationHandlerSwitchProvider);
NodeDescription convertedNodeDescription = converter.convert(nodeMapping, interpreter, new HashMap<UUID, NodeDescription>());
LabelDescription labelDescription = convertedNodeDescription.getLabelDescription();
String text = labelDescription.getTextProvider().apply(variableManager);
LabelStyleDescription labelStyleDescription = labelDescription.getStyleDescriptionProvider().apply(variableManager);
Integer fontSize = labelStyleDescription.getFontSizeProvider().apply(variableManager);
Boolean isBold = labelStyleDescription.getBoldProvider().apply(variableManager);
Boolean isItalic = labelStyleDescription.getItalicProvider().apply(variableManager);
Boolean isUnderline = labelStyleDescription.getUnderlineProvider().apply(variableManager);
Boolean isStrikeThrough = labelStyleDescription.getStrikeThroughProvider().apply(variableManager);
String color = labelStyleDescription.getColorProvider().apply(variableManager);
String iconURL = labelStyleDescription.getIconURLProvider().apply(variableManager);
// $NON-NLS-1$
assertThat(text).isEqualTo("secondConditionalStyle");
assertThat(fontSize).isEqualTo(6);
assertThat(isBold).isTrue();
assertThat(isItalic).isTrue();
assertThat(isUnderline).isTrue();
assertThat(isStrikeThrough).isTrue();
// $NON-NLS-1$
assertThat(color).isEqualTo("#020202");
assertThat(iconURL).isEqualTo(ICON_PATH);
}
Aggregations