diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index b91fd136fa..c22385db59 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -92,6 +92,7 @@ Introducing a generator of builders aimed to help creating view programmatically
- https://github.com/eclipse-sirius/sirius-components/issues/2004[#2004] [form] Add the possibility to show select options' icons.
+
image:doc/screenshots/ShowIconOptionSelectWidget.jpg[Icons on select widget option,70%,30%]
+- https://github.com/eclipse-sirius/sirius-components/issues/2044[#2044] [view] Add custom icons to edges and nodes label in view dsl
=== Improvements
diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java
index abb05b51f0..20a581a439 100644
--- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java
+++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.sirius.components.forms.graphql.datafetchers.form;
+import java.util.regex.Pattern;
+
import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher;
import org.eclipse.sirius.components.forms.SelectOption;
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates;
@@ -25,17 +27,26 @@
* If the SelectOption.iconURL
is of the form path/to/image.svg
, the rewritten value which will
* be seen by the frontend will be /api/images/path/to/image.svg
.
*
+ * If the SelectOption.iconURL
is of the form path/to/UUID.svg
, the rewritten value which will
+ * be seen by the frontend will be /api/images/custom/path/to/image.svg
.
+ *
* @author mcharfadi
*/
@QueryDataFetcher(type = "SelectOption", field = "iconURL")
public class SelectOptionIconURLDataFetcher implements IDataFetcherWithFieldCoordinates {
-
+ private static final Pattern UUID_REGEX =
+ Pattern.compile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
@Override
public String get(DataFetchingEnvironment environment) throws Exception {
SelectOption option = environment.getSource();
String result = option.getIconURL();
if (result != null && !result.isBlank()) {
- result = URLConstants.IMAGE_BASE_PATH + result;
+ if (UUID_REGEX.matcher(result).matches()) {
+ result = URLConstants.IMAGE_BASE_PATH + "/custom/" + result;
+ }
+ else {
+ result = URLConstants.IMAGE_BASE_PATH + result;
+ }
}
return result;
}
diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java
index 24fbff4282..24f009fa83 100644
--- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java
+++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java
@@ -61,6 +61,7 @@ public List getPropertyDescriptors(Object object) {
this.addTargetArrowStylePropertyDescriptor(object);
this.addEdgeWidthPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
+ this.addLabelIconPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
}
@@ -186,6 +187,17 @@ protected void addShowIconPropertyDescriptor(Object object) {
ViewPackage.Literals.EDGE_STYLE__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
+ /**
+ * This adds a property descriptor for the Label Icon feature.
+ *
+ * @generated
+ */
+ protected void addLabelIconPropertyDescriptor(Object object) {
+ this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
+ this.getString("_UI_EdgeStyle_labelIcon_feature"), this.getString("_UI_PropertyDescriptor_description", "_UI_EdgeStyle_labelIcon_feature", "_UI_EdgeStyle_type"),
+ ViewPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
/**
* This returns ConditionalEdgeStyle.gif.
*
@@ -240,6 +252,7 @@ public void notifyChanged(Notification notification) {
case ViewPackage.CONDITIONAL_EDGE_STYLE__TARGET_ARROW_STYLE:
case ViewPackage.CONDITIONAL_EDGE_STYLE__EDGE_WIDTH:
case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON:
+ case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java
index af409aadf6..9a83e60f3f 100644
--- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java
+++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java
@@ -60,6 +60,7 @@ public List getPropertyDescriptors(Object object) {
this.addTargetArrowStylePropertyDescriptor(object);
this.addEdgeWidthPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
+ this.addLabelIconPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
}
@@ -174,6 +175,17 @@ protected void addShowIconPropertyDescriptor(Object object) {
ViewPackage.Literals.EDGE_STYLE__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
+ /**
+ * This adds a property descriptor for the Label Icon feature.
+ *
+ * @generated
+ */
+ protected void addLabelIconPropertyDescriptor(Object object) {
+ this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
+ this.getString("_UI_EdgeStyle_labelIcon_feature"), this.getString("_UI_PropertyDescriptor_description", "_UI_EdgeStyle_labelIcon_feature", "_UI_EdgeStyle_type"),
+ ViewPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
/**
* This returns EdgeStyle.gif.
*
@@ -227,6 +239,7 @@ public void notifyChanged(Notification notification) {
case ViewPackage.EDGE_STYLE__TARGET_ARROW_STYLE:
case ViewPackage.EDGE_STYLE__EDGE_WIDTH:
case ViewPackage.EDGE_STYLE__SHOW_ICON:
+ case ViewPackage.EDGE_STYLE__LABEL_ICON:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java
index 2e54b949d2..baf3b8a79d 100644
--- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java
+++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java
@@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) {
this.addWidthComputationExpressionPropertyDescriptor(object);
this.addHeightComputationExpressionPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
+ this.addLabelIconPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
}
@@ -216,6 +217,18 @@ protected void addShowIconPropertyDescriptor(Object object) {
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
+ /**
+ * This adds a property descriptor for the Label Icon feature.
+ *
+ * @generated
+ */
+ protected void addLabelIconPropertyDescriptor(Object object) {
+ this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
+ this.getString("_UI_NodeStyleDescription_labelIcon_feature"),
+ this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"),
+ ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
/**
* This returns IconLabelNodeStyleDescription.gif.
*
@@ -272,6 +285,7 @@ public void notifyChanged(Notification notification) {
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON:
+ case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java
index 68890725d0..f80db20e4d 100644
--- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java
+++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java
@@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) {
this.addWidthComputationExpressionPropertyDescriptor(object);
this.addHeightComputationExpressionPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
+ this.addLabelIconPropertyDescriptor(object);
this.addShapePropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
@@ -217,6 +218,18 @@ protected void addShowIconPropertyDescriptor(Object object) {
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
+ /**
+ * This adds a property descriptor for the Label Icon feature.
+ *
+ * @generated
+ */
+ protected void addLabelIconPropertyDescriptor(Object object) {
+ this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
+ this.getString("_UI_NodeStyleDescription_labelIcon_feature"),
+ this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"),
+ ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
/**
* This adds a property descriptor for the Shape feature.
*
@@ -285,6 +298,7 @@ public void notifyChanged(Notification notification) {
case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION:
case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION:
case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON:
+ case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON:
case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java
index 044ffc1e06..ce12ec333b 100644
--- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java
+++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java
@@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) {
this.addWidthComputationExpressionPropertyDescriptor(object);
this.addHeightComputationExpressionPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
+ this.addLabelIconPropertyDescriptor(object);
this.addWithHeaderPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
@@ -217,6 +218,18 @@ protected void addShowIconPropertyDescriptor(Object object) {
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
+ /**
+ * This adds a property descriptor for the Label Icon feature.
+ *
+ * @generated
+ */
+ protected void addLabelIconPropertyDescriptor(Object object) {
+ this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
+ this.getString("_UI_NodeStyleDescription_labelIcon_feature"),
+ this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"),
+ ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
/**
* This adds a property descriptor for the With Header feature.
*
@@ -285,6 +298,7 @@ public void notifyChanged(Notification notification) {
case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION:
case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION:
case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON:
+ case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON:
case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java
index 9a3e4657b7..277124fac4 100644
--- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java
+++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java
@@ -77,7 +77,8 @@ public class ViewPropertiesDescriptionRegistryConfigurer implements IPropertiesD
private static final List TYPES_WITH_CUSTOM_PROPERTIES = List.of(
ViewPackage.Literals.IMAGE_NODE_STYLE_DESCRIPTION,
ViewPackage.Literals.ICON_LABEL_NODE_STYLE_DESCRIPTION,
- ViewPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION
+ ViewPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION,
+ ViewPackage.Literals.EDGE_STYLE
);
// @formatter:on
private final IObjectService objectService;
diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/EdgeStylePropertiesConfigurer.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/EdgeStylePropertiesConfigurer.java
new file mode 100644
index 0000000000..45c77db9b7
--- /dev/null
+++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/EdgeStylePropertiesConfigurer.java
@@ -0,0 +1,499 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.components.view.emf.diagram;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistry;
+import org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistryConfigurer;
+import org.eclipse.sirius.components.collaborative.validation.api.IValidationService;
+import org.eclipse.sirius.components.core.api.IEditingContext;
+import org.eclipse.sirius.components.core.api.IObjectService;
+import org.eclipse.sirius.components.emf.services.EditingContext;
+import org.eclipse.sirius.components.forms.SelectStyle;
+import org.eclipse.sirius.components.forms.components.SelectComponent;
+import org.eclipse.sirius.components.forms.description.AbstractControlDescription;
+import org.eclipse.sirius.components.forms.description.CheckboxDescription;
+import org.eclipse.sirius.components.forms.description.FormDescription;
+import org.eclipse.sirius.components.forms.description.GroupDescription;
+import org.eclipse.sirius.components.forms.description.PageDescription;
+import org.eclipse.sirius.components.forms.description.SelectDescription;
+import org.eclipse.sirius.components.representations.Failure;
+import org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider;
+import org.eclipse.sirius.components.representations.IStatus;
+import org.eclipse.sirius.components.representations.Success;
+import org.eclipse.sirius.components.representations.VariableManager;
+import org.eclipse.sirius.components.view.ArrowStyle;
+import org.eclipse.sirius.components.view.ColorPalette;
+import org.eclipse.sirius.components.view.EdgeStyle;
+import org.eclipse.sirius.components.view.FixedColor;
+import org.eclipse.sirius.components.view.LabelStyle;
+import org.eclipse.sirius.components.view.LineStyle;
+import org.eclipse.sirius.components.view.Style;
+import org.eclipse.sirius.components.view.UserColor;
+import org.eclipse.sirius.components.view.View;
+import org.eclipse.sirius.components.view.ViewPackage;
+import org.eclipse.sirius.components.view.emf.CustomImageMetadata;
+import org.eclipse.sirius.components.view.emf.ICustomImageMetadataSearchService;
+import org.eclipse.sirius.diagram.description.style.EdgeStyleDescription;
+import org.springframework.stereotype.Component;
+
+/**
+ * Customizes the properties view for some of the View DSL elements.
+ *
+ * @author mcharfadi
+ */
+@Component
+public class EdgeStylePropertiesConfigurer implements IPropertiesDescriptionRegistryConfigurer {
+
+ private static final String EMPTY = "";
+
+ private static final String UNNAMED = "";
+
+ private static final String INT_PATTERN = "\\d+";
+
+ private final Function> semanticElementsProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).stream().toList();
+
+ private final ICustomImageMetadataSearchService customImageSearchService;
+
+ private final IValidationService validationService;
+
+ private final IObjectService objectService;
+
+ public EdgeStylePropertiesConfigurer(ICustomImageMetadataSearchService customImageSearchService, IValidationService validationService,
+ IObjectService objectService) {
+ this.validationService = Objects.requireNonNull(validationService);
+ this.customImageSearchService = Objects.requireNonNull(customImageSearchService);
+ this.objectService = Objects.requireNonNull(objectService);
+ }
+
+ @Override
+ public void addPropertiesDescriptions(IPropertiesDescriptionRegistry registry) {
+
+ String formDescriptionId = UUID.nameUUIDFromBytes("edgestyle".getBytes()).toString();
+
+ List controls = new ArrayList<>();
+ controls.addAll(this.getGeneralControlDescription());
+
+ Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class)
+ .filter(self -> self instanceof List>)
+ .map(self -> (List>) self)
+ .flatMap(self -> self.stream().findFirst())
+ .filter(EdgeStyle.class::isInstance)
+ .isPresent();
+
+ GroupDescription groupDescription = this.createSimpleGroupDescription(controls);
+ // @formatter:off
+ FormDescription formDescription = FormDescription.newFormDescription(formDescriptionId)
+ .label("IconLabel Edge Style")
+ .labelProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyleDescription.class)
+ .map(EdgeStyleDescription::getStrokeColor)
+ .filter(FixedColor.class::isInstance)
+ .map(FixedColor.class::cast)
+ .map(FixedColor::getValue)
+ .orElse(UNNAMED))
+ .canCreatePredicate(variableManager -> true)
+ .idProvider(new GetOrCreateRandomIdProvider())
+ .targetObjectIdProvider(this.getTargetObjectIdProvider())
+ .pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate)))
+ .build();
+
+ registry.add(formDescription);
+ // @formatter:on
+ }
+
+ private PageDescription createSimplePageDescription(GroupDescription groupDescription, Predicate canCreatePredicate) {
+ // @formatter:off
+ return PageDescription.newPageDescription("page")
+ .idProvider(variableManager -> "page")
+ .labelProvider(variableManager -> "Properties")
+ .semanticElementsProvider(this.semanticElementsProvider)
+ .canCreatePredicate(canCreatePredicate)
+ .groupDescriptions(List.of(groupDescription))
+ .build();
+ // @formatter:on
+ }
+
+ private GroupDescription createSimpleGroupDescription(List controls) {
+ // @formatter:off
+ return GroupDescription.newGroupDescription("group")
+ .idProvider(variableManager -> "group")
+ .labelProvider(variableManager -> "General")
+ .semanticElementsProvider(this.semanticElementsProvider)
+ .controlDescriptions(controls)
+ .build();
+ // @formatter:on
+ }
+
+ private Function getTargetObjectIdProvider() {
+ // @formatter:off
+ return variableManager -> variableManager.get(VariableManager.SELF, Object.class)
+ .filter(self -> self instanceof List>)
+ .map(self -> (List>) self)
+ .flatMap(self -> self.stream().findFirst())
+ .filter(EObject.class::isInstance)
+ .map(EObject.class::cast)
+ .map(obj -> EcoreUtil.getURI(obj).toString())
+ .orElse(null);
+ // @formatter:on
+ }
+
+ private List getGeneralControlDescription() {
+ return List.of(
+ this.createUserColorSelectionField("edgestyle.Color", "Color", ViewPackage.Literals.STYLE__COLOR
+ , Style.class
+ , Style::getColor
+ , Style::setColor),
+ this.createCheckbox("edgestyle.italic", "Italic",
+ style -> ((LabelStyle) style).isItalic(),
+ (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic),
+ ViewPackage.Literals.LABEL_STYLE__ITALIC),
+ this.createCheckbox("edgestyle.bold", "Bold",
+ style -> ((LabelStyle) style).isBold(),
+ (style, newBold) -> ((LabelStyle) style).setBold(newBold),
+ ViewPackage.Literals.LABEL_STYLE__BOLD),
+ this.createCheckbox("edgestyle.underline", "Underline",
+ style -> ((LabelStyle) style).isUnderline(),
+ (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline),
+ ViewPackage.Literals.LABEL_STYLE__UNDERLINE),
+ this.createCheckbox("edgestyle.strikeThrough", "Strike Through",
+ style -> ((LabelStyle) style).isStrikeThrough(),
+ (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough),
+ ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH),
+ this.createCheckbox("edgestyle.showIcon", "Show Icon",
+ style -> ((EdgeStyle) style).isShowIcon(),
+ (style, newValue) -> ((EdgeStyle) style).setShowIcon(newValue),
+ ViewPackage.Literals.EDGE_STYLE__SHOW_ICON),
+ this.createIconSelectionField(
+ ViewPackage.Literals.EDGE_STYLE__LABEL_ICON),
+ this.createLineStyleSelectionField(
+ ViewPackage.Literals.LINE_STYLE),
+ this.createSourceArrowStyleSelectionField(
+ ViewPackage.Literals.EDGE_STYLE__SOURCE_ARROW_STYLE),
+ this.createTargetArrowStyleSelectionField(
+ ViewPackage.Literals.EDGE_STYLE__TARGET_ARROW_STYLE));
+ }
+
+ private SelectDescription createUserColorSelectionField(String id, String label, Object feature, Class styleType
+ , Function colorGetter, BiConsumer colorSetter) {
+ // @formatter:off
+ return SelectDescription.newSelectDescription(id)
+ .idProvider(variableManager -> id)
+ .labelProvider(variableManager -> label)
+ .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, styleType)
+ .map(colorGetter)
+ .map(UserColor::getName)
+ .orElse(EMPTY))
+ .optionsProvider(variableManager -> this.getColorsFromColorPalettesStream(variableManager).toList())
+ .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, UserColor.class)
+ .map(UserColor::getName)
+ .orElse(EMPTY))
+ .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, UserColor.class)
+ .map(UserColor::getName)
+ .orElse(EMPTY))
+ .optionIconURLProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, Object.class).map(this.objectService::getImagePath).orElse(""))
+ .newValueHandler((variableManager, newValue) ->
+ variableManager.get(VariableManager.SELF, styleType)
+ .map((style) -> {
+ if (newValue != null) {
+ this.getColorsFromColorPalettesStream(variableManager)
+ .filter(userColor -> newValue.equals(userColor.getName()))
+ .findFirst()
+ .ifPresent(userColor -> colorSetter.accept(style, userColor));
+ }
+ return new Success();
+ }).orElseGet(() -> new Failure(""))
+ )
+ .diagnosticsProvider(this.getDiagnosticsProvider(feature))
+ .kindProvider(this::kindProvider)
+ .messageProvider(this::messageProvider)
+ .build();
+ // @formatter:on
+ }
+
+ private Stream getColorsFromColorPalettesStream(VariableManager variableManager) {
+ return variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class)
+ .filter(EditingContext.class::isInstance)
+ .map(EditingContext.class::cast)
+ .map(EditingContext::getDomain)
+ .map(EditingDomain::getResourceSet)
+ .map(ResourceSet::getResources)
+ .stream()
+ .flatMap(EList::stream)
+ .map(Resource::getContents)
+ .flatMap(EList::stream)
+ .filter(View.class::isInstance)
+ .map(View.class::cast)
+ .map(View::getColorPalettes)
+ .flatMap(EList::stream)
+ .map(ColorPalette::getColors)
+ .flatMap(EList::stream);
+ }
+
+ private CheckboxDescription createCheckbox(String id, String title, Function