From 31bedefac8f914465f603f39977db523c86c8a1f Mon Sep 17 00:00:00 2001 From: Michael Charfadi Date: Tue, 30 May 2023 10:52:46 +0200 Subject: [PATCH] [2044] Custom icons to edges and nodes label in view dsl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-components/issues/2044 Signed-off-by: Michaƫl Charfadi --- CHANGELOG.adoc | 2 + .../e2e/project/edit/color-palette.cy.js | 3 +- .../ConditionalEdgeStyleItemProvider.java | 13 + .../provider/EdgeStyleItemProvider.java | 13 + ...LabelNodeStyleDescriptionItemProvider.java | 14 + ...ImageNodeStyleDescriptionItemProvider.java | 14 + ...gularNodeStyleDescriptionItemProvider.java | 14 + .../view/diagram/DiagramPackage.java | 94 ++++- .../components/view/diagram/EdgeStyle.java | 23 ++ .../view/diagram/NodeStyleDescription.java | 23 ++ .../impl/ConditionalEdgeStyleImpl.java | 61 +++ .../view/diagram/impl/DiagramPackageImpl.java | 26 ++ .../view/diagram/impl/EdgeStyleImpl.java | 56 +++ .../IconLabelNodeStyleDescriptionImpl.java | 57 +++ .../impl/ImageNodeStyleDescriptionImpl.java | 57 +++ .../RectangularNodeStyleDescriptionImpl.java | 57 +++ .../src/main/resources/model/diagram.ecore | 2 + .../src/main/resources/model/diagram.genmodel | 2 + ...opertiesDescriptionRegistryConfigurer.java | 3 +- .../IPropertiesConfigurerService.java | 34 ++ .../IPropertiesWidgetCreationService.java | 38 ++ .../PropertiesConfigurerService.java | 104 +++++ .../PropertiesWidgetCreationService.java | 98 +++++ .../EdgeStylePropertiesConfigurer.java | 367 ++++++++++++++++++ .../NodeStylePropertiesConfigurer.java | 224 +++++------ .../view/emf/diagram/StylesFactory.java | 10 +- 26 files changed, 1270 insertions(+), 139 deletions(-) create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesConfigurerService.java create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesWidgetCreationService.java create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesConfigurerService.java create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesWidgetCreationService.java create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/EdgeStylePropertiesConfigurer.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index da16051848..014d8229c7 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -23,6 +23,8 @@ Without the dependency to notistack in `sirius-components-core`, it will be easi === New Features +- 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/integration-tests/cypress/e2e/project/edit/color-palette.cy.js b/integration-tests/cypress/e2e/project/edit/color-palette.cy.js index fefd9e9608..4776b06109 100644 --- a/integration-tests/cypress/e2e/project/edit/color-palette.cy.js +++ b/integration-tests/cypress/e2e/project/edit/color-palette.cy.js @@ -75,7 +75,6 @@ describe('/projects/:projectId/edit - Color Palette', () => { cy.getByTestId('LinkedTo Edge-toggle').click(); cy.get('[title="diagram::EdgeStyle"]').click(); cy.getByTestId('Color').click(); - cy.contains('FixedColor color_blue').click(); + cy.contains('color_blue').click(); }); }); - diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalEdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalEdgeStyleItemProvider.java index 87cd31e655..775014f519 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalEdgeStyleItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ConditionalEdgeStyleItemProvider.java @@ -64,6 +64,7 @@ public List getPropertyDescriptors(Object object) { this.addTargetArrowStylePropertyDescriptor(object); this.addEdgeWidthPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); } return this.itemPropertyDescriptors; } @@ -189,6 +190,17 @@ protected void addShowIconPropertyDescriptor(Object object) { DiagramPackage.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"), + DiagramPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns ConditionalEdgeStyle.gif. * @@ -243,6 +255,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.CONDITIONAL_EDGE_STYLE__TARGET_ARROW_STYLE: case DiagramPackage.CONDITIONAL_EDGE_STYLE__EDGE_WIDTH: case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeStyleItemProvider.java index 824d278f82..8e6b2f7f27 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeStyleItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/EdgeStyleItemProvider.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; } @@ -175,6 +176,17 @@ protected void addShowIconPropertyDescriptor(Object object) { DiagramPackage.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"), + DiagramPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns EdgeStyle.gif. * @@ -228,6 +240,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.EDGE_STYLE__TARGET_ARROW_STYLE: case DiagramPackage.EDGE_STYLE__EDGE_WIDTH: case DiagramPackage.EDGE_STYLE__SHOW_ICON: + case DiagramPackage.EDGE_STYLE__LABEL_ICON: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/IconLabelNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/IconLabelNodeStyleDescriptionItemProvider.java index 78dca5b5d7..1a6adcd53c 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/IconLabelNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/IconLabelNodeStyleDescriptionItemProvider.java @@ -65,6 +65,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); } return this.itemPropertyDescriptors; } @@ -218,6 +219,18 @@ protected void addShowIconPropertyDescriptor(Object object) { DiagramPackage.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"), + DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns IconLabelNodeStyleDescription.gif. * @@ -274,6 +287,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case DiagramPackage.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-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ImageNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ImageNodeStyleDescriptionItemProvider.java index 8e519e037f..4949f48d80 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ImageNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/ImageNodeStyleDescriptionItemProvider.java @@ -64,6 +64,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); this.addShapePropertyDescriptor(object); } return this.itemPropertyDescriptors; @@ -218,6 +219,18 @@ protected void addShowIconPropertyDescriptor(Object object) { DiagramPackage.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"), + DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This adds a property descriptor for the Shape feature. * @@ -286,6 +299,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; diff --git a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/RectangularNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/RectangularNodeStyleDescriptionItemProvider.java index 796e2d2bf1..25309bcf02 100644 --- a/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/RectangularNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-diagram-edit/src/main/java/org/eclipse/sirius/components/view/diagram/provider/RectangularNodeStyleDescriptionItemProvider.java @@ -65,6 +65,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); this.addWithHeaderPropertyDescriptor(object); } return this.itemPropertyDescriptors; @@ -219,6 +220,18 @@ protected void addShowIconPropertyDescriptor(Object object) { DiagramPackage.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"), + DiagramPackage.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. * @@ -287,6 +300,7 @@ public void notifyChanged(Notification notification) { case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: case DiagramPackage.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-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java index e00c0d6831..1bcc093ebe 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/DiagramPackage.java @@ -880,6 +880,14 @@ public interface DiagramPackage extends EPackage { */ int NODE_STYLE_DESCRIPTION__SHOW_ICON = STYLE_FEATURE_COUNT + 12; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int NODE_STYLE_DESCRIPTION__LABEL_ICON = STYLE_FEATURE_COUNT + 13; + /** * The number of structural features of the 'Node Style Description' class. @@ -887,7 +895,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int NODE_STYLE_DESCRIPTION_FEATURE_COUNT = STYLE_FEATURE_COUNT + 13; + int NODE_STYLE_DESCRIPTION_FEATURE_COUNT = STYLE_FEATURE_COUNT + 14; /** * The number of operations of the 'Node Style Description' class. + * + * @generated + * @ordered + */ + int RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON = NODE_STYLE_DESCRIPTION__LABEL_ICON; + /** * The feature id for the 'With Header' attribute. * @@ -1220,6 +1236,14 @@ public interface DiagramPackage extends EPackage { */ int IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON = NODE_STYLE_DESCRIPTION__SHOW_ICON; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON = NODE_STYLE_DESCRIPTION__LABEL_ICON; + /** * The feature id for the 'Shape' attribute. * @@ -1372,6 +1396,14 @@ public interface DiagramPackage extends EPackage { */ int ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON = NODE_STYLE_DESCRIPTION__SHOW_ICON; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON = NODE_STYLE_DESCRIPTION__LABEL_ICON; + /** * The number of structural features of the 'Icon Label Node Style Description' class. @@ -1490,6 +1522,14 @@ public interface DiagramPackage extends EPackage { */ int EDGE_STYLE__SHOW_ICON = STYLE_FEATURE_COUNT + 9; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int EDGE_STYLE__LABEL_ICON = STYLE_FEATURE_COUNT + 10; + /** * The number of structural features of the 'Edge Style' class. @@ -1497,7 +1537,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int EDGE_STYLE_FEATURE_COUNT = STYLE_FEATURE_COUNT + 10; + int EDGE_STYLE_FEATURE_COUNT = STYLE_FEATURE_COUNT + 11; /** * The number of operations of the 'Edge Style' class. @@ -1615,6 +1655,14 @@ public interface DiagramPackage extends EPackage { */ int CONDITIONAL_EDGE_STYLE__SHOW_ICON = ViewPackage.CONDITIONAL_FEATURE_COUNT + 10; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_EDGE_STYLE__LABEL_ICON = ViewPackage.CONDITIONAL_FEATURE_COUNT + 11; + /** * The number of structural features of the 'Conditional Edge Style' class. @@ -1622,7 +1670,7 @@ public interface DiagramPackage extends EPackage { * @generated * @ordered */ - int CONDITIONAL_EDGE_STYLE_FEATURE_COUNT = ViewPackage.CONDITIONAL_FEATURE_COUNT + 11; + int CONDITIONAL_EDGE_STYLE_FEATURE_COUNT = ViewPackage.CONDITIONAL_FEATURE_COUNT + 12; /** * The number of operations of the 'Conditional Edge Style' class. + * + * @return the meta object for the attribute 'Label Icon'. + * @see org.eclipse.sirius.components.view.diagram.NodeStyleDescription#getLabelIcon() + * @see #getNodeStyleDescription() + * @generated + */ + EAttribute getNodeStyleDescription_LabelIcon(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ConditionalNodeStyle * Conditional Node Style}'. @@ -3184,6 +3244,18 @@ public interface DiagramPackage extends EPackage { */ EAttribute getEdgeStyle_ShowIcon(); + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.diagram.EdgeStyle#getLabelIcon Label Icon}'. + * + * @return the meta object for the attribute 'Label Icon'. + * @see org.eclipse.sirius.components.view.diagram.EdgeStyle#getLabelIcon() + * @see #getEdgeStyle() + * @generated + */ + EAttribute getEdgeStyle_LabelIcon(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.diagram.ConditionalEdgeStyle * Conditional Edge Style}'. @@ -4133,6 +4205,14 @@ interface Literals { */ EAttribute NODE_STYLE_DESCRIPTION__SHOW_ICON = eINSTANCE.getNodeStyleDescription_ShowIcon(); + /** + * The meta object literal for the 'Label Icon' attribute feature. + * + * @generated + */ + EAttribute NODE_STYLE_DESCRIPTION__LABEL_ICON = eINSTANCE.getNodeStyleDescription_LabelIcon(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalNodeStyleImpl Conditional Node @@ -4251,6 +4331,14 @@ interface Literals { */ EAttribute EDGE_STYLE__SHOW_ICON = eINSTANCE.getEdgeStyle_ShowIcon(); + /** + * The meta object literal for the 'Label Icon' attribute feature. + * + * @generated + */ + EAttribute EDGE_STYLE__LABEL_ICON = eINSTANCE.getEdgeStyle_LabelIcon(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.diagram.impl.ConditionalEdgeStyleImpl Conditional Edge diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeStyle.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeStyle.java index 5904b9c0c8..e92f76f0c4 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeStyle.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/EdgeStyle.java @@ -26,6 +26,7 @@ *
  • {@link org.eclipse.sirius.components.view.diagram.EdgeStyle#getTargetArrowStyle Target Arrow Style}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.EdgeStyle#getEdgeWidth Edge Width}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.EdgeStyle#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.EdgeStyle#getLabelIcon Label Icon}
  • * * * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgeStyle() @@ -157,4 +158,26 @@ public interface EdgeStyle extends Style, LabelStyle { */ void setShowIcon(boolean value); + /** + * Returns the value of the 'Label Icon' attribute. + * + * @return the value of the 'Label Icon' attribute. + * @see #setLabelIcon(String) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getEdgeStyle_LabelIcon() + * @model + * @generated + */ + String getLabelIcon(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.EdgeStyle#getLabelIcon Label + * Icon}' attribute. + * + * @param value + * the new value of the 'Label Icon' attribute. + * @see #getLabelIcon() + * @generated + */ + void setLabelIcon(String value); + } // EdgeStyle diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeStyleDescription.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeStyleDescription.java index 1e89969249..fb547c8e58 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeStyleDescription.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/NodeStyleDescription.java @@ -29,6 +29,7 @@ *
  • {@link org.eclipse.sirius.components.view.diagram.NodeStyleDescription#getHeightComputationExpression Height * Computation Expression}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.NodeStyleDescription#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.NodeStyleDescription#getLabelIcon Label Icon}
  • * * * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodeStyleDescription() @@ -128,4 +129,26 @@ public interface NodeStyleDescription extends Style, LabelStyle, BorderStyle { */ void setShowIcon(boolean value); + /** + * Returns the value of the 'Label Icon' attribute. + * + * @return the value of the 'Label Icon' attribute. + * @see #setLabelIcon(String) + * @see org.eclipse.sirius.components.view.diagram.DiagramPackage#getNodeStyleDescription_LabelIcon() + * @model + * @generated + */ + String getLabelIcon(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.diagram.NodeStyleDescription#getLabelIcon + * Label Icon}' attribute. + * + * @param value + * the new value of the 'Label Icon' attribute. + * @see #getLabelIcon() + * @generated + */ + void setLabelIcon(String value); + } // NodeStyleDescription diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalEdgeStyleImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalEdgeStyleImpl.java index 61c92cd135..0c443c728f 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalEdgeStyleImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ConditionalEdgeStyleImpl.java @@ -53,6 +53,8 @@ * Width
    } *
  • {@link org.eclipse.sirius.components.view.diagram.impl.ConditionalEdgeStyleImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.ConditionalEdgeStyleImpl#getLabelIcon Label + * Icon}
  • * * * @generated @@ -268,6 +270,26 @@ public class ConditionalEdgeStyleImpl extends ConditionalImpl implements Conditi */ protected boolean showIcon = SHOW_ICON_EDEFAULT; + /** + * The default value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected static final String LABEL_ICON_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected String labelIcon = LABEL_ICON_EDEFAULT; + /** * * @@ -557,6 +579,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON, oldShowIcon, this.showIcon)); } + /** + * + * + * @generated + */ + @Override + public String getLabelIcon() { + return this.labelIcon; + } + + /** + * + * + * @generated + */ + @Override + public void setLabelIcon(String newLabelIcon) { + String oldLabelIcon = this.labelIcon; + this.labelIcon = newLabelIcon; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -589,6 +634,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getEdgeWidth(); case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return this.isShowIcon(); + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -634,6 +681,9 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -679,6 +729,9 @@ public void eUnset(int featureID) { case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -713,6 +766,8 @@ public boolean eIsSet(int featureID) { return this.edgeWidth != EDGE_WIDTH_EDEFAULT; case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); } return super.eIsSet(featureID); } @@ -760,6 +815,8 @@ public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { return DiagramPackage.EDGE_STYLE__EDGE_WIDTH; case DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return DiagramPackage.EDGE_STYLE__SHOW_ICON; + case DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return DiagramPackage.EDGE_STYLE__LABEL_ICON; default: return -1; } @@ -810,6 +867,8 @@ public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { return DiagramPackage.CONDITIONAL_EDGE_STYLE__EDGE_WIDTH; case DiagramPackage.EDGE_STYLE__SHOW_ICON: return DiagramPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON; + case DiagramPackage.EDGE_STYLE__LABEL_ICON: + return DiagramPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON; default: return -1; } @@ -848,6 +907,8 @@ public String toString() { result.append(this.edgeWidth); result.append(", showIcon: "); result.append(this.showIcon); + result.append(", labelIcon: "); + result.append(this.labelIcon); result.append(')'); return result.toString(); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java index 568f315ba8..8e73fcdd2b 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/DiagramPackageImpl.java @@ -870,6 +870,16 @@ public EAttribute getNodeStyleDescription_ShowIcon() { return (EAttribute) this.nodeStyleDescriptionEClass.getEStructuralFeatures().get(3); } + /** + * + * + * @generated + */ + @Override + public EAttribute getNodeStyleDescription_LabelIcon() { + return (EAttribute) this.nodeStyleDescriptionEClass.getEStructuralFeatures().get(4); + } + /** * * @@ -1000,6 +1010,16 @@ public EAttribute getEdgeStyle_ShowIcon() { return (EAttribute) this.edgeStyleEClass.getEStructuralFeatures().get(4); } + /** + * + * + * @generated + */ + @Override + public EAttribute getEdgeStyle_LabelIcon() { + return (EAttribute) this.edgeStyleEClass.getEStructuralFeatures().get(5); + } + /** * * @@ -1547,6 +1567,7 @@ public void createPackageContents() { this.createEAttribute(this.nodeStyleDescriptionEClass, NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION); this.createEAttribute(this.nodeStyleDescriptionEClass, NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION); this.createEAttribute(this.nodeStyleDescriptionEClass, NODE_STYLE_DESCRIPTION__SHOW_ICON); + this.createEAttribute(this.nodeStyleDescriptionEClass, NODE_STYLE_DESCRIPTION__LABEL_ICON); this.conditionalNodeStyleEClass = this.createEClass(CONDITIONAL_NODE_STYLE); this.createEReference(this.conditionalNodeStyleEClass, CONDITIONAL_NODE_STYLE__STYLE); @@ -1565,6 +1586,7 @@ public void createPackageContents() { this.createEAttribute(this.edgeStyleEClass, EDGE_STYLE__TARGET_ARROW_STYLE); this.createEAttribute(this.edgeStyleEClass, EDGE_STYLE__EDGE_WIDTH); this.createEAttribute(this.edgeStyleEClass, EDGE_STYLE__SHOW_ICON); + this.createEAttribute(this.edgeStyleEClass, EDGE_STYLE__LABEL_ICON); this.conditionalEdgeStyleEClass = this.createEClass(CONDITIONAL_EDGE_STYLE); @@ -1788,6 +1810,8 @@ public void initializePackageContents() { !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEAttribute(this.getNodeStyleDescription_ShowIcon(), this.ecorePackage.getEBoolean(), "showIcon", null, 0, 1, NodeStyleDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEAttribute(this.getNodeStyleDescription_LabelIcon(), this.ecorePackage.getEString(), "labelIcon", null, 0, 1, NodeStyleDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.conditionalNodeStyleEClass, ConditionalNodeStyle.class, "ConditionalNodeStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEReference(this.getConditionalNodeStyle_Style(), this.getNodeStyleDescription(), null, "style", null, 0, 1, ConditionalNodeStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, @@ -1814,6 +1838,8 @@ public void initializePackageContents() { IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEAttribute(this.getEdgeStyle_ShowIcon(), this.ecorePackage.getEBoolean(), "showIcon", "false", 0, 1, EdgeStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEAttribute(this.getEdgeStyle_LabelIcon(), this.ecorePackage.getEString(), "labelIcon", null, 0, 1, EdgeStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.conditionalEdgeStyleEClass, ConditionalEdgeStyle.class, "ConditionalEdgeStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeStyleImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeStyleImpl.java index 51bc7411d8..1511227c01 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeStyleImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/EdgeStyleImpl.java @@ -41,6 +41,7 @@ * Style
    } *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgeStyleImpl#getEdgeWidth Edge Width}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgeStyleImpl#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.EdgeStyleImpl#getLabelIcon Label Icon}
  • * * * @generated @@ -246,6 +247,26 @@ public class EdgeStyleImpl extends StyleImpl implements EdgeStyle { */ protected boolean showIcon = SHOW_ICON_EDEFAULT; + /** + * The default value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected static final String LABEL_ICON_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected String labelIcon = LABEL_ICON_EDEFAULT; + /** * * @@ -495,6 +516,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.EDGE_STYLE__SHOW_ICON, oldShowIcon, this.showIcon)); } + /** + * + * + * @generated + */ + @Override + public String getLabelIcon() { + return this.labelIcon; + } + + /** + * + * + * @generated + */ + @Override + public void setLabelIcon(String newLabelIcon) { + String oldLabelIcon = this.labelIcon; + this.labelIcon = newLabelIcon; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.EDGE_STYLE__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -523,6 +567,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getEdgeWidth(); case DiagramPackage.EDGE_STYLE__SHOW_ICON: return this.isShowIcon(); + case DiagramPackage.EDGE_STYLE__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -565,6 +611,9 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.EDGE_STYLE__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case DiagramPackage.EDGE_STYLE__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -607,6 +656,9 @@ public void eUnset(int featureID) { case DiagramPackage.EDGE_STYLE__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case DiagramPackage.EDGE_STYLE__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -639,6 +691,8 @@ public boolean eIsSet(int featureID) { return this.edgeWidth != EDGE_WIDTH_EDEFAULT; case DiagramPackage.EDGE_STYLE__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case DiagramPackage.EDGE_STYLE__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); } return super.eIsSet(featureID); } @@ -726,6 +780,8 @@ public String toString() { result.append(this.edgeWidth); result.append(", showIcon: "); result.append(this.showIcon); + result.append(", labelIcon: "); + result.append(this.labelIcon); result.append(')'); return result.toString(); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/IconLabelNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/IconLabelNodeStyleDescriptionImpl.java index e1e64380bb..c067b3a9dc 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/IconLabelNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/IconLabelNodeStyleDescriptionImpl.java @@ -57,6 +57,8 @@ * Height Computation Expression} *
  • {@link org.eclipse.sirius.components.view.diagram.impl.IconLabelNodeStyleDescriptionImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.IconLabelNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • * * * @generated @@ -302,6 +304,26 @@ public class IconLabelNodeStyleDescriptionImpl extends StyleImpl implements Icon */ protected boolean showIcon = SHOW_ICON_EDEFAULT; + /** + * The default value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected static final String LABEL_ICON_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected String labelIcon = LABEL_ICON_EDEFAULT; + /** * * @@ -656,6 +678,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON, oldShowIcon, this.showIcon)); } + /** + * + * + * @generated + */ + @Override + public String getLabelIcon() { + return this.labelIcon; + } + + /** + * + * + * @generated + */ + @Override + public void setLabelIcon(String newLabelIcon) { + String oldLabelIcon = this.labelIcon; + this.labelIcon = newLabelIcon; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -694,6 +739,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -745,6 +792,9 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -796,6 +846,9 @@ public void eUnset(int featureID) { case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -834,6 +887,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case DiagramPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); } return super.eIsSet(featureID); } @@ -951,6 +1006,8 @@ public String toString() { result.append(this.heightComputationExpression); result.append(", showIcon: "); result.append(this.showIcon); + result.append(", labelIcon: "); + result.append(this.labelIcon); result.append(')'); return result.toString(); } diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ImageNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ImageNodeStyleDescriptionImpl.java index ea5a265cbc..1f458e96bd 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ImageNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/ImageNodeStyleDescriptionImpl.java @@ -56,6 +56,8 @@ * Height Computation Expression} *
  • {@link org.eclipse.sirius.components.view.diagram.impl.ImageNodeStyleDescriptionImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.ImageNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.impl.ImageNodeStyleDescriptionImpl#getShape * Shape}
  • * @@ -303,6 +305,26 @@ public class ImageNodeStyleDescriptionImpl extends StyleImpl implements ImageNod */ protected boolean showIcon = SHOW_ICON_EDEFAULT; + /** + * The default value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected static final String LABEL_ICON_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected String labelIcon = LABEL_ICON_EDEFAULT; + /** * The default value of the '{@link #getShape() Shape}' attribute. @@ -677,6 +699,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON, oldShowIcon, this.showIcon)); } + /** + * + * + * @generated + */ + @Override + public String getLabelIcon() { + return this.labelIcon; + } + + /** + * + * + * @generated + */ + @Override + public void setLabelIcon(String newLabelIcon) { + String oldLabelIcon = this.labelIcon; + this.labelIcon = newLabelIcon; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -738,6 +783,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: return this.getShape(); } @@ -791,6 +838,9 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.setShape((String) newValue); return; @@ -845,6 +895,9 @@ public void eUnset(int featureID) { case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.setShape(SHAPE_EDEFAULT); return; @@ -886,6 +939,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); case DiagramPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: return SHAPE_EDEFAULT == null ? this.shape != null : !SHAPE_EDEFAULT.equals(this.shape); } @@ -1005,6 +1060,8 @@ public String toString() { result.append(this.heightComputationExpression); result.append(", showIcon: "); result.append(this.showIcon); + result.append(", labelIcon: "); + result.append(this.labelIcon); result.append(", shape: "); result.append(this.shape); result.append(')'); diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/RectangularNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/RectangularNodeStyleDescriptionImpl.java index 4e76f516c3..5771f467fa 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/RectangularNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view-diagram/src/main/java/org/eclipse/sirius/components/view/diagram/impl/RectangularNodeStyleDescriptionImpl.java @@ -57,6 +57,8 @@ * Height Computation Expression} *
  • {@link org.eclipse.sirius.components.view.diagram.impl.RectangularNodeStyleDescriptionImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.diagram.impl.RectangularNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • *
  • {@link org.eclipse.sirius.components.view.diagram.impl.RectangularNodeStyleDescriptionImpl#isWithHeader With * Header}
  • * @@ -304,6 +306,26 @@ public class RectangularNodeStyleDescriptionImpl extends StyleImpl implements Re */ protected boolean showIcon = SHOW_ICON_EDEFAULT; + /** + * The default value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected static final String LABEL_ICON_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabelIcon() Label Icon}' attribute. + * + * @see #getLabelIcon() + * @generated + * @ordered + */ + protected String labelIcon = LABEL_ICON_EDEFAULT; + /** * The default value of the '{@link #isWithHeader() With Header}' attribute. @@ -678,6 +700,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON, oldShowIcon, this.showIcon)); } + /** + * + * + * @generated + */ + @Override + public String getLabelIcon() { + return this.labelIcon; + } + + /** + * + * + * @generated + */ + @Override + public void setLabelIcon(String newLabelIcon) { + String oldLabelIcon = this.labelIcon; + this.labelIcon = newLabelIcon; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -739,6 +784,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: return this.isWithHeader(); } @@ -792,6 +839,9 @@ public void eSet(int featureID, Object newValue) { case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: this.setWithHeader((Boolean) newValue); return; @@ -846,6 +896,9 @@ public void eUnset(int featureID) { case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: this.setWithHeader(WITH_HEADER_EDEFAULT); return; @@ -887,6 +940,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); case DiagramPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: return this.withHeader != WITH_HEADER_EDEFAULT; } @@ -1006,6 +1061,8 @@ public String toString() { result.append(this.heightComputationExpression); result.append(", showIcon: "); result.append(this.showIcon); + result.append(", labelIcon: "); + result.append(this.labelIcon); result.append(", withHeader: "); result.append(this.withHeader); result.append(')'); diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.ecore b/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.ecore index ab65f32ffb..d06e83c107 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.ecore +++ b/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.ecore @@ -131,6 +131,7 @@ eType="ecore:EDataType ../../../../../sirius-components-view/src/main/resources/model/view.ecore#//InterpretedExpression" defaultValueLiteral="1"/> + + diff --git a/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.genmodel b/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.genmodel index af7f7b9d9f..080cd1201c 100644 --- a/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.genmodel +++ b/packages/view/backend/sirius-components-view-diagram/src/main/resources/model/diagram.genmodel @@ -104,6 +104,7 @@ + @@ -121,6 +122,7 @@ + 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 7e79e7446e..b38a75572e 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 @@ -76,7 +76,8 @@ public class ViewPropertiesDescriptionRegistryConfigurer implements IPropertiesD private static final List TYPES_WITH_CUSTOM_PROPERTIES = List.of( DiagramPackage.Literals.IMAGE_NODE_STYLE_DESCRIPTION, DiagramPackage.Literals.ICON_LABEL_NODE_STYLE_DESCRIPTION, - DiagramPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION + DiagramPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION, + DiagramPackage.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/compatibility/IPropertiesConfigurerService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesConfigurerService.java new file mode 100644 index 0000000000..bc4d0992e9 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesConfigurerService.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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.compatibility; + +import java.util.List; +import java.util.function.Function; + +import org.eclipse.sirius.components.representations.VariableManager; + +/** + * Configuration for the properties view for some of the View DSL elements. + * + * @author mcharfadi + */ +public interface IPropertiesConfigurerService { + + Function> getDiagnosticsProvider(Object feature); + + Function getKindProvider(); + + Function getMessageProvider(); + + Function getTargetObjectIdProvider(); +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesWidgetCreationService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesWidgetCreationService.java new file mode 100644 index 0000000000..87c99e4358 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesWidgetCreationService.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.compatibility; + +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.eclipse.sirius.components.forms.description.AbstractControlDescription; +import org.eclipse.sirius.components.forms.description.CheckboxDescription; +import org.eclipse.sirius.components.forms.description.GroupDescription; +import org.eclipse.sirius.components.forms.description.PageDescription; +import org.eclipse.sirius.components.representations.VariableManager; + +/** + * Customizes the properties view for some of the View DSL elements. + * + * @author mcharfadi + */ +public interface IPropertiesWidgetCreationService { + + PageDescription createSimplePageDescription(String id, GroupDescription groupDescription, Predicate canCreatePredicate); + + GroupDescription createSimpleGroupDescription(List controls); + + CheckboxDescription createCheckbox(String id, String title, Function reader, BiConsumer writer, Object feature); +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesConfigurerService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesConfigurerService.java new file mode 100644 index 0000000000..5818c6a183 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesConfigurerService.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * 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.compatibility; + +import java.util.List; +import java.util.Objects; +import java.util.function.Function; + +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.sirius.components.collaborative.validation.api.IValidationService; +import org.eclipse.sirius.components.representations.VariableManager; +import org.springframework.stereotype.Service; + +/** + * Configuration for the properties view for some of the View DSL elements. + * + * @author mcharfadi + */ +@Service +public class PropertiesConfigurerService implements IPropertiesConfigurerService { + + private final IValidationService validationService; + + public PropertiesConfigurerService(IValidationService validationService) { + this.validationService = Objects.requireNonNull(validationService); + } + + @Override + public 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 + } + + @Override + public Function> getDiagnosticsProvider(Object feature) { + return variableManager -> { + var optionalSelf = variableManager.get(VariableManager.SELF, EObject.class); + + if (optionalSelf.isPresent()) { + EObject self = optionalSelf.get(); + List diagnostics = this.validationService.validate(self, feature); + return diagnostics; + } + + return List.of(); + }; + } + + @Override + public Function getKindProvider() { + return object -> { + String kind = "Unknown"; + if (object instanceof Diagnostic) { + Diagnostic diagnostic = (Diagnostic) object; + switch (diagnostic.getSeverity()) { + case org.eclipse.emf.common.util.Diagnostic.ERROR: + kind = "Error"; + break; + case org.eclipse.emf.common.util.Diagnostic.WARNING: + kind = "Warning"; + break; + case org.eclipse.emf.common.util.Diagnostic.INFO: + kind = "Info"; + break; + default: + kind = "Unknown"; + break; + } + } + return kind; + }; + } + + @Override + public Function getMessageProvider() { + return object -> { + if (object instanceof Diagnostic) { + Diagnostic diagnostic = (Diagnostic) object; + return diagnostic.getMessage(); + } + return ""; + }; + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesWidgetCreationService.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesWidgetCreationService.java new file mode 100644 index 0000000000..6040075815 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/compatibility/PropertiesWidgetCreationService.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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.compatibility; + +import java.util.List; +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.eclipse.sirius.components.forms.description.AbstractControlDescription; +import org.eclipse.sirius.components.forms.description.CheckboxDescription; +import org.eclipse.sirius.components.forms.description.GroupDescription; +import org.eclipse.sirius.components.forms.description.PageDescription; +import org.eclipse.sirius.components.representations.Failure; +import org.eclipse.sirius.components.representations.IStatus; +import org.eclipse.sirius.components.representations.Success; +import org.eclipse.sirius.components.representations.VariableManager; +import org.springframework.stereotype.Service; + +/** + * Customizes the properties view for some of the View DSL elements. + * + * @author mcharfadi + */ +@Service +public class PropertiesWidgetCreationService implements IPropertiesWidgetCreationService { + + private static final Function> SEMANTIC_ELEMENT_PROVIDER = variableManager -> variableManager.get(VariableManager.SELF, Object.class).stream().toList(); + + private IPropertiesConfigurerService propertiesConfigurerService; + + public PropertiesWidgetCreationService(IPropertiesConfigurerService propertiesConfigurerService) { + this.propertiesConfigurerService = Objects.requireNonNull(propertiesConfigurerService); + } + + @Override + public PageDescription createSimplePageDescription(String id, GroupDescription groupDescription, Predicate canCreatePredicate) { + // @formatter:off + return PageDescription.newPageDescription(id) + .idProvider(variableManager -> "page") + .labelProvider(variableManager -> "Properties") + .semanticElementsProvider(SEMANTIC_ELEMENT_PROVIDER) + .canCreatePredicate(canCreatePredicate) + .groupDescriptions(List.of(groupDescription)) + .build(); + // @formatter:on + } + + @Override + public GroupDescription createSimpleGroupDescription(List controls) { + // @formatter:off + return GroupDescription.newGroupDescription("group") + .idProvider(variableManager -> "group") + .labelProvider(variableManager -> "General") + .semanticElementsProvider(SEMANTIC_ELEMENT_PROVIDER) + .controlDescriptions(controls) + .build(); + // @formatter:on + } + + @Override + public CheckboxDescription createCheckbox(String id, String title, Function reader, BiConsumer writer, Object feature) { + Function valueProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(reader).orElse(Boolean.FALSE); + BiFunction newValueHandler = (variableManager, newValue) -> { + var optionalDiagramMapping = variableManager.get(VariableManager.SELF, Object.class); + if (optionalDiagramMapping.isPresent()) { + writer.accept(optionalDiagramMapping.get(), newValue); + return new Success(); + } else { + return new Failure(""); + } + }; + // @formatter:off + return CheckboxDescription.newCheckboxDescription(id) + .idProvider(variableManager -> id) + .labelProvider(variableManager -> title) + .valueProvider(valueProvider) + .newValueHandler(newValueHandler) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + +} 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..967fb08622 --- /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,367 @@ +/******************************************************************************* + * 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.EList; +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +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.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.GroupDescription; +import org.eclipse.sirius.components.forms.description.SelectDescription; +import org.eclipse.sirius.components.representations.Failure; +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.ColorPalette; +import org.eclipse.sirius.components.view.LabelStyle; +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.diagram.ArrowStyle; +import org.eclipse.sirius.components.view.diagram.DiagramPackage; +import org.eclipse.sirius.components.view.diagram.EdgeStyle; +import org.eclipse.sirius.components.view.diagram.LineStyle; +import org.eclipse.sirius.components.view.diagram.Style; +import org.eclipse.sirius.components.view.emf.CustomImageMetadata; +import org.eclipse.sirius.components.view.emf.ICustomImageMetadataSearchService; +import org.eclipse.sirius.components.view.emf.compatibility.IPropertiesConfigurerService; +import org.eclipse.sirius.components.view.emf.compatibility.IPropertiesWidgetCreationService; +import org.eclipse.sirius.components.view.emf.compatibility.PropertiesConfigurerService; +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 INT_PATTERN = "\\d+"; + + private final ICustomImageMetadataSearchService customImageSearchService; + + private final IObjectService objectService; + + private IPropertiesConfigurerService propertiesConfigurerService; + + private IPropertiesWidgetCreationService propertiesWidgetCreationService; + + public EdgeStylePropertiesConfigurer(ICustomImageMetadataSearchService customImageSearchService, + IObjectService objectService, PropertiesConfigurerService propertiesConfigurerService, IPropertiesWidgetCreationService propertiesWidgetCreationService) { + this.customImageSearchService = Objects.requireNonNull(customImageSearchService); + this.objectService = Objects.requireNonNull(objectService); + this.propertiesConfigurerService = Objects.requireNonNull(propertiesConfigurerService); + this.propertiesWidgetCreationService = Objects.requireNonNull(propertiesWidgetCreationService); + } + + @Override + public void addPropertiesDescriptions(IPropertiesDescriptionRegistry registry) { + + String formDescriptionId = UUID.nameUUIDFromBytes("edgestyle".getBytes()).toString(); + + List controls = new ArrayList<>(this.getGeneralControlDescription()); + + Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class) + .filter(EdgeStyle.class::isInstance) + .isPresent(); + + GroupDescription groupDescription = this.propertiesWidgetCreationService.createSimpleGroupDescription(controls); + + registry.add(this.propertiesWidgetCreationService.createSimplePageDescription(formDescriptionId, groupDescription, canCreatePagePredicate)); + + } + + private List getGeneralControlDescription() { + return List.of( + this.createUserColorSelectionField("edgestyle.Color", "Color", DiagramPackage.Literals.STYLE__COLOR + , Style.class + , Style::getColor + , Style::setColor), + this.propertiesWidgetCreationService.createCheckbox("edgestyle.italic", "Italic", + style -> ((LabelStyle) style).isItalic(), + (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic), + ViewPackage.Literals.LABEL_STYLE__ITALIC), + this.propertiesWidgetCreationService.createCheckbox("edgestyle.bold", "Bold", + style -> ((LabelStyle) style).isBold(), + (style, newBold) -> ((LabelStyle) style).setBold(newBold), + ViewPackage.Literals.LABEL_STYLE__BOLD), + this.propertiesWidgetCreationService.createCheckbox("edgestyle.underline", "Underline", + style -> ((LabelStyle) style).isUnderline(), + (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline), + ViewPackage.Literals.LABEL_STYLE__UNDERLINE), + this.propertiesWidgetCreationService.createCheckbox("edgestyle.strikeThrough", "Strike Through", + style -> ((LabelStyle) style).isStrikeThrough(), + (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough), + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH), + this.propertiesWidgetCreationService.createCheckbox("edgestyle.showIcon", "Show Icon", + style -> ((EdgeStyle) style).isShowIcon(), + (style, newValue) -> ((EdgeStyle) style).setShowIcon(newValue), + DiagramPackage.Literals.EDGE_STYLE__SHOW_ICON), + this.createIconSelectionField( + DiagramPackage.Literals.EDGE_STYLE__LABEL_ICON), + this.createLineStyleSelectionField( + DiagramPackage.Literals.LINE_STYLE), + this.createSourceArrowStyleSelectionField( + DiagramPackage.Literals.EDGE_STYLE__SOURCE_ARROW_STYLE), + this.createTargetArrowStyleSelectionField( + DiagramPackage.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.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .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 SelectDescription createSourceArrowStyleSelectionField(Object feature) { + // @formatter:off + return SelectDescription.newSelectDescription("edgestyle.sourceArrowStyleSelector") + .idProvider(variableManager -> "edgestyle.sourceArrowStyleSelector") + .labelProvider(variableManager -> "Source Arrow Syle") + .styleProvider(vm -> SelectStyle.newSelectStyle().showIcon(true).build()) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyle.class).map(EdgeStyle::getSourceArrowStyle) + .map(ArrowStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionsProvider(variableManager -> ArrowStyle.VALUES) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, ArrowStyle.class) + .map(ArrowStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, ArrowStyle.class) + .map(Enumerator::getName) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> "") + .newValueHandler(this.getSourceArrowValueHandler()) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + + private BiFunction getSourceArrowValueHandler() { + return (variableManager, newValue) -> { + var optionalEdgeStyle = variableManager.get(VariableManager.SELF, EdgeStyle.class); + if (optionalEdgeStyle.isPresent() && newValue != null && newValue.matches(INT_PATTERN)) { + int newArrowStyle = Integer.parseInt(newValue); + ArrowStyle arrowStyle = ArrowStyle.get(newArrowStyle); + if (arrowStyle != null) { + optionalEdgeStyle.get().setSourceArrowStyle(arrowStyle); + return new Success(); + } + } + return new Failure(""); + }; + } + + private SelectDescription createTargetArrowStyleSelectionField(Object feature) { + // @formatter:off + return SelectDescription.newSelectDescription("edgestyle.targetArrowStyleSelector") + .idProvider(variableManager -> "edgestyle.targetArrowStyleSelector") + .labelProvider(variableManager -> "Target Arrow Syle") + .styleProvider(vm -> SelectStyle.newSelectStyle().showIcon(true).build()) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyle.class).map(EdgeStyle::getTargetArrowStyle) + .map(ArrowStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionsProvider(variableManager -> ArrowStyle.VALUES) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, ArrowStyle.class) + .map(ArrowStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, ArrowStyle.class) + .map(Enumerator::getName) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> "") + .newValueHandler(this.getTargetArrowValueHandler()) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + + private BiFunction getTargetArrowValueHandler() { + return (variableManager, newValue) -> { + var optionalEdgeStyle = variableManager.get(VariableManager.SELF, EdgeStyle.class); + if (optionalEdgeStyle.isPresent() && newValue != null && newValue.matches(INT_PATTERN)) { + int newArrowStyle = Integer.parseInt(newValue); + ArrowStyle arrowStyle = ArrowStyle.get(newArrowStyle); + if (arrowStyle != null) { + optionalEdgeStyle.get().setTargetArrowStyle(arrowStyle); + return new Success(); + } + } + return new Failure(""); + }; + } + + private SelectDescription createLineStyleSelectionField(Object feature) { + // @formatter:off + return SelectDescription.newSelectDescription("edgestyle.lineStyleSelector") + .idProvider(variableManager -> "edgestyle.lineStyleSelector") + .labelProvider(variableManager -> "Line Syle") + .styleProvider(vm -> SelectStyle.newSelectStyle().showIcon(true).build()) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyle.class).map(EdgeStyle::getLineStyle) + .map(LineStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionsProvider(variableManager -> LineStyle.VALUES) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, LineStyle.class) + .map(LineStyle::getValue) + .map(value -> String.valueOf(value)) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, LineStyle.class) + .map(Enumerator::getName) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> "") + .newValueHandler(this.getLineStyleValueHandler()) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + + private BiFunction getLineStyleValueHandler() { + return (variableManager, newValue) -> { + var optionalEdgeStyle = variableManager.get(VariableManager.SELF, EdgeStyle.class); + if (optionalEdgeStyle.isPresent() && newValue != null && newValue.matches(INT_PATTERN)) { + int newLineStyle = Integer.parseInt(newValue); + LineStyle lineStyle = LineStyle.get(newLineStyle); + if (lineStyle != null) { + optionalEdgeStyle.get().setLineStyle(lineStyle); + return new Success(); + } + } + return new Failure(""); + }; + } + + private SelectDescription createIconSelectionField(Object feature) { + // @formatter:off + return SelectDescription.newSelectDescription("edgestyle.iconLabelSelector") + .idProvider(variableManager -> "edgestyle.iconLabelSelector") + .labelProvider(variableManager -> "Custom Icon") + .styleProvider(vm -> SelectStyle.newSelectStyle().showIcon(true).build()) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyle.class).map(EdgeStyle::getLabelIcon).orElse(EMPTY)) + .optionsProvider(variableManager -> variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class) + .map(IEditingContext::getId) + .map(this.customImageSearchService::getAvailableImages) + .orElse(List.of()) + ) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(customImageMetadataEntity -> String.format("/custom/%s", customImageMetadataEntity.getId().toString())) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(CustomImageMetadata::getLabel) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(customImageMetadataEntity -> String.format("/custom/%s", customImageMetadataEntity.getId().toString())) + .orElse(EMPTY)) + .newValueHandler(this.getIconLabelValueHandler()) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + + private BiFunction getIconLabelValueHandler() { + return (variableManager, newValue) -> { + var optionalEdgeStyle = variableManager.get(VariableManager.SELF, EdgeStyle.class); + if (optionalEdgeStyle.isPresent()) { + String newIcon = newValue; + if (newValue != null && newValue.isBlank()) { + newIcon = null; + } + optionalEdgeStyle.get().setLabelIcon(newIcon); + return new Success(); + } + return new Failure(""); + }; + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/NodeStylePropertiesConfigurer.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/NodeStylePropertiesConfigurer.java index 6bf22043e8..2cb755f6a0 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/NodeStylePropertiesConfigurer.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/NodeStylePropertiesConfigurer.java @@ -24,9 +24,7 @@ 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.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.edit.domain.EditingDomain; @@ -37,9 +35,9 @@ 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.GroupDescription; import org.eclipse.sirius.components.forms.description.ImageDescription; import org.eclipse.sirius.components.forms.description.PageDescription; @@ -65,6 +63,9 @@ import org.eclipse.sirius.components.view.emf.AQLTextfieldCustomizer; import org.eclipse.sirius.components.view.emf.CustomImageMetadata; import org.eclipse.sirius.components.view.emf.ICustomImageMetadataSearchService; +import org.eclipse.sirius.components.view.emf.compatibility.IPropertiesConfigurerService; +import org.eclipse.sirius.components.view.emf.compatibility.IPropertiesWidgetCreationService; +import org.eclipse.sirius.components.view.emf.compatibility.PropertiesConfigurerService; import org.springframework.stereotype.Component; /** @@ -77,25 +78,29 @@ public class NodeStylePropertiesConfigurer implements IPropertiesDescriptionRegi private static final String EMPTY = ""; - private final Function> semanticElementsProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).stream().toList(); + private static final String CUSTOM = "/custom/%s"; private final List parametricSVGImageRegistries; private final ICustomImageMetadataSearchService customImageSearchService; - private final IValidationService validationService; - private final AQLTextfieldCustomizer aqlTextfieldCustomizer; private final IObjectService objectService; + private final IPropertiesConfigurerService propertiesConfigurerService; + + private final IPropertiesWidgetCreationService propertiesWidgetCreationService; + public NodeStylePropertiesConfigurer(ICustomImageMetadataSearchService customImageSearchService, IValidationService validationService, - List parametricSVGImageRegistries, AQLTextfieldCustomizer aqlTextfieldCustomizer, IObjectService objectService) { - this.validationService = Objects.requireNonNull(validationService); + List parametricSVGImageRegistries, AQLTextfieldCustomizer aqlTextfieldCustomizer, IObjectService objectService, + PropertiesConfigurerService propertiesConfigurerService, IPropertiesWidgetCreationService propertiesWidgetCreationService) { this.customImageSearchService = Objects.requireNonNull(customImageSearchService); this.parametricSVGImageRegistries = parametricSVGImageRegistries; this.aqlTextfieldCustomizer = Objects.requireNonNull(aqlTextfieldCustomizer); this.objectService = Objects.requireNonNull(objectService); + this.propertiesConfigurerService = Objects.requireNonNull(propertiesConfigurerService); + this.propertiesWidgetCreationService = Objects.requireNonNull(propertiesWidgetCreationService); } @Override @@ -113,14 +118,14 @@ private PageDescription getImageNodeStyleProperties() { controls.add(this.createShapePreviewField()); controls.addAll(this.getGeneralControlDescription()); - GroupDescription groupDescription = this.createSimpleGroupDescription(controls); + GroupDescription groupDescription = this.propertiesWidgetCreationService.createSimpleGroupDescription(controls); // @formatter:off Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class) .filter(ImageNodeStyleDescription.class::isInstance) .isPresent(); - return this.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); + return this.propertiesWidgetCreationService.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); } private PageDescription getIconLabelNodeStyleProperties() { @@ -128,13 +133,13 @@ private PageDescription getIconLabelNodeStyleProperties() { List controls = this.getGeneralControlDescription(); - GroupDescription groupDescription = this.createSimpleGroupDescription(controls); + GroupDescription groupDescription = this.propertiesWidgetCreationService.createSimpleGroupDescription(controls); Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class) .filter(IconLabelNodeStyleDescription.class::isInstance) .isPresent(); - return this.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); + return this.propertiesWidgetCreationService.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); } private PageDescription getRectangularNodeStyleProperties() { @@ -142,19 +147,19 @@ private PageDescription getRectangularNodeStyleProperties() { String id = UUID.nameUUIDFromBytes("rectangularnodestyle".getBytes()).toString(); List controls = new ArrayList<>(); - controls.add(this.createCheckbox("nodestyle.isWithHeader", "With Header", - style -> ((RectangularNodeStyleDescription) style).isWithHeader(), - (style, newWithHeaderValue) -> ((RectangularNodeStyleDescription) style).setWithHeader(newWithHeaderValue), + controls.add(this.propertiesWidgetCreationService.createCheckbox("nodestyle.isWithHeader", "With Header", + style -> ((RectangularNodeStyleDescription) style).isWithHeader(), + (style, newWithHeaderValue) -> ((RectangularNodeStyleDescription) style).setWithHeader(newWithHeaderValue), DiagramPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER)); controls.addAll(this.getGeneralControlDescription()); - GroupDescription groupDescription = this.createSimpleGroupDescription(controls); + GroupDescription groupDescription = this.propertiesWidgetCreationService.createSimpleGroupDescription(controls); Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class) .filter(RectangularNodeStyleDescription.class::isInstance) .isPresent(); - return this.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); + return this.propertiesWidgetCreationService.createSimplePageDescription(id, groupDescription, canCreatePagePredicate); } private List getGeneralControlDescription() { @@ -166,11 +171,13 @@ private List getGeneralControlDescription() { this.createExpressionField("nodestyle.heightExpression", "Height Expression", style -> ((NodeStyleDescription) style).getHeightComputationExpression(), (style, newHeightExpression) -> ((NodeStyleDescription) style).setHeightComputationExpression(newHeightExpression), - DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION), - this.createCheckbox("nodestyle.showIcon", "Show Icon", + DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION), + this.propertiesWidgetCreationService.createCheckbox("nodestyle.showIcon", "Show Icon", style -> ((NodeStyleDescription) style).isShowIcon(), (style, newValue) -> ((NodeStyleDescription) style).setShowIcon(newValue), - DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON), + DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON), + this.createIconSelectionField( + DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON), this.createUserColorSelectionField("nodestyle.labelColor", "Label Color", DiagramPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_COLOR , NodeStyleDescription.class , NodeStyleDescription::getLabelColor @@ -216,47 +223,24 @@ private List getGeneralControlDescription() { } }, ViewPackage.Literals.LABEL_STYLE__FONT_SIZE), - this.createCheckbox("nodestyle.italic", "Italic", + this.propertiesWidgetCreationService.createCheckbox("nodestyle.italic", "Italic", style -> ((LabelStyle) style).isItalic(), (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic), ViewPackage.Literals.LABEL_STYLE__ITALIC), - this.createCheckbox("nodestyle.bold", "Bold", + this.propertiesWidgetCreationService.createCheckbox("nodestyle.bold", "Bold", style -> ((LabelStyle) style).isBold(), (style, newBold) -> ((LabelStyle) style).setBold(newBold), ViewPackage.Literals.LABEL_STYLE__BOLD), - this.createCheckbox("nodestyle.underline", "Underline", + this.propertiesWidgetCreationService.createCheckbox("nodestyle.underline", "Underline", style -> ((LabelStyle) style).isUnderline(), (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline), ViewPackage.Literals.LABEL_STYLE__UNDERLINE), - this.createCheckbox("nodestyle.strikeThrough", "Strike Through", + this.propertiesWidgetCreationService.createCheckbox("nodestyle.strikeThrough", "Strike Through", style -> ((LabelStyle) style).isStrikeThrough(), (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough), ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH)); } - private PageDescription createSimplePageDescription(String id, GroupDescription groupDescription, Predicate canCreatePredicate) { - // @formatter:off - return PageDescription.newPageDescription(id) - .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 TextfieldDescription createTextField(String id, String title, Function reader, BiConsumer writer, Object feature) { Function valueProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(reader).orElse(EMPTY); BiFunction newValueHandler = (variableManager, newValue) -> { @@ -275,9 +259,9 @@ private TextfieldDescription createTextField(String id, String title, Function title) .valueProvider(valueProvider) .newValueHandler(newValueHandler) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); // @formatter:on } @@ -300,35 +284,11 @@ private TextareaDescription createExpressionField(String id, String title, Funct .labelProvider(variableManager -> title) .valueProvider(valueProvider) .newValueHandler(newValueHandler) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) .completionProposalsProvider(this.aqlTextfieldCustomizer.getCompletionProposalsProvider()) .styleProvider(this.aqlTextfieldCustomizer.getStyleProvider()) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) - .build(); - // @formatter:on - } - - private CheckboxDescription createCheckbox(String id, String title, Function reader, BiConsumer writer, Object feature) { - Function valueProvider = variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(reader).orElse(Boolean.FALSE); - BiFunction newValueHandler = (variableManager, newValue) -> { - var optionalDiagramMapping = variableManager.get(VariableManager.SELF, Object.class); - if (optionalDiagramMapping.isPresent()) { - writer.accept(optionalDiagramMapping.get(), newValue); - return new Success(); - } else { - return new Failure(""); - } - }; - // @formatter:off - return CheckboxDescription.newCheckboxDescription(id) - .idProvider(variableManager -> id) - .labelProvider(variableManager -> title) - .valueProvider(valueProvider) - .newValueHandler(newValueHandler) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); // @formatter:on } @@ -355,9 +315,9 @@ private SelectDescription createBorderLineStyleSelectionField(String id, Object } return new Failure(""); }) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); // @formatter:on } @@ -391,9 +351,9 @@ private SelectDescription createUserColorSelectionField(String id, String la return new Success(); }).orElseGet(() -> new Failure("")) ) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); } @@ -416,6 +376,35 @@ private Stream getColorsFromColorPalettesStream(VariableManager varia .flatMap(EList::stream); } + private SelectDescription createIconSelectionField(Object feature) { + // @formatter:off + return SelectDescription.newSelectDescription("nodestyle.iconLabelSelector") + .idProvider(variableManager -> "nodestyle.iconLabelSelector") + .labelProvider(variableManager -> "Custom Icon") + .styleProvider(vm -> SelectStyle.newSelectStyle().showIcon(true).build()) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, NodeStyleDescription.class).map(NodeStyleDescription::getLabelIcon).orElse(EMPTY)) + .optionsProvider(variableManager -> variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class) + .map(IEditingContext::getId) + .map(this.customImageSearchService::getAvailableImages) + .orElse(List.of()) + ) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(customImageMetadataEntity -> String.format(CUSTOM, customImageMetadataEntity.getId().toString())) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(CustomImageMetadata::getLabel) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, CustomImageMetadata.class) + .map(customImageMetadataEntity -> String.format(CUSTOM, customImageMetadataEntity.getId().toString())) + .orElse(EMPTY)) + .newValueHandler(this.getIconLabelValueHandler()) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) + .build(); + // @formatter:on + } + private SelectDescription createShapeSelectionField(Object feature) { // @formatter:off return SelectDescription.newSelectDescription("nodestyle.shapeSelector") @@ -444,9 +433,9 @@ private SelectDescription createShapeSelectionField(Object feature) { .orElse(EMPTY)) .optionIconURLProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, Object.class).map(this.objectService::getImagePath).orElse("")) .newValueHandler(this.getNewShapeValueHandler()) - .diagnosticsProvider(this.getDiagnosticsProvider(feature)) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .diagnosticsProvider(this.propertiesConfigurerService.getDiagnosticsProvider(feature)) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); // @formatter:on } @@ -459,18 +448,33 @@ private ImageDescription createShapePreviewField() { .urlProvider(variableManager -> { var optionalShape = variableManager.get(VariableManager.SELF, ImageNodeStyleDescription.class).map(ImageNodeStyleDescription::getShape); if (optionalShape.isPresent()) { - return String.format("/custom/%s", optionalShape.get()); + return String.format(CUSTOM, optionalShape.get()); } return ""; }) .maxWidthProvider(variableManager -> "300px") .diagnosticsProvider(variableManager -> List.of()) - .kindProvider(this::kindProvider) - .messageProvider(this::messageProvider) + .kindProvider(this.propertiesConfigurerService.getKindProvider()) + .messageProvider(this.propertiesConfigurerService.getMessageProvider()) .build(); // @formatter:on } + private BiFunction getIconLabelValueHandler() { + return (variableManager, newValue) -> { + var optionalNodeStyle = variableManager.get(VariableManager.SELF, NodeStyleDescription.class); + if (optionalNodeStyle.isPresent()) { + String newIcon = newValue; + if (newValue != null && newValue.isBlank()) { + newIcon = null; + } + optionalNodeStyle.get().setLabelIcon(newIcon); + return new Success(); + } + return new Failure(""); + }; + } + private BiFunction getNewShapeValueHandler() { return (variableManager, newValue) -> { var optionalNodeStyle = variableManager.get(VariableManager.SELF, ImageNodeStyleDescription.class); @@ -486,46 +490,4 @@ private BiFunction getNewShapeValueHandler() { }; } - private Function> getDiagnosticsProvider(Object feature) { - return variableManager -> { - var optionalSelf = variableManager.get(VariableManager.SELF, EObject.class); - - if (optionalSelf.isPresent()) { - EObject self = optionalSelf.get(); - List diagnostics = this.validationService.validate(self, feature); - return diagnostics; - } - - return List.of(); - }; - } - - private String kindProvider(Object object) { - String kind = "Unknown"; - if (object instanceof Diagnostic diagnostic) { - switch (diagnostic.getSeverity()) { - case org.eclipse.emf.common.util.Diagnostic.ERROR: - kind = "Error"; - break; - case org.eclipse.emf.common.util.Diagnostic.WARNING: - kind = "Warning"; - break; - case org.eclipse.emf.common.util.Diagnostic.INFO: - kind = "Info"; - break; - default: - kind = "Unknown"; - break; - } - } - return kind; - } - - private String messageProvider(Object object) { - if (object instanceof Diagnostic diagnostic) { - return diagnostic.getMessage(); - } - return ""; - } - } diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/StylesFactory.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/StylesFactory.java index 4a3820454c..cf62e84765 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/StylesFactory.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/StylesFactory.java @@ -66,9 +66,12 @@ public LabelStyleDescription createLabelStyleDescription(NodeStyleDescription no .strikeThroughProvider(variableManager -> nodeStyle.isStrikeThrough()) .iconURLProvider(variableManager -> { String iconURL = ""; - if (nodeStyle.isShowIcon()) { + if (nodeStyle.isShowIcon() && nodeStyle.getLabelIcon() == null) { iconURL = variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getImagePath).orElse(""); } + if (nodeStyle.isShowIcon() && !(nodeStyle.getLabelIcon() == null)) { + iconURL = nodeStyle.getLabelIcon(); + } return iconURL; }) .build(); @@ -90,9 +93,12 @@ public LabelStyleDescription createEdgeLabelStyleDescription(org.eclipse.sirius. .strikeThroughProvider(variableManager -> edgeStyle.isStrikeThrough()) .iconURLProvider(variableManager -> { String iconURL = ""; - if (edgeStyle.isShowIcon()) { + if (edgeStyle.isShowIcon() && edgeStyle.getLabelIcon() == null) { iconURL = variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getImagePath).orElse(""); } + if (edgeStyle.isShowIcon() && !(edgeStyle.getLabelIcon() == null)) { + iconURL = edgeStyle.getLabelIcon(); + } return iconURL; }) .build();