From d0106027a65be4500b045131f2a29e6b38d516b8 Mon Sep 17 00:00:00 2001 From: Michael Charfadi Date: Wed, 7 Jun 2023 16:39:10 +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 | 1 + .../e2e/project/edit/color-palette.cy.js | 7 +- .../form/SelectOptionIconURLDataFetcher.java | 1 - .../ConditionalEdgeStyleItemProvider.java | 13 + .../view/provider/EdgeStyleItemProvider.java | 13 + ...LabelNodeStyleDescriptionItemProvider.java | 14 + ...ImageNodeStyleDescriptionItemProvider.java | 14 + ...gularNodeStyleDescriptionItemProvider.java | 14 + ...opertiesDescriptionRegistryConfigurer.java | 3 +- .../IPropertiesConfigurerService.java | 34 ++ .../IPropertiesWidgetCreationService.java | 38 ++ .../PropertiesConfigurerService.java | 104 +++++ .../PropertiesWidgetCreationService.java | 98 +++++ .../EdgeStylePropertiesConfigurer.java | 390 ++++++++++++++++++ .../NodeStylePropertiesConfigurer.java | 239 +++++------ .../view/emf/diagram/StylesFactory.java | 10 +- .../sirius/components/view/EdgeStyle.java | 25 +- .../components/view/NodeStyleDescription.java | 28 +- .../sirius/components/view/ViewPackage.java | 93 ++++- .../view/impl/ConditionalEdgeStyleImpl.java | 60 +++ .../components/view/impl/EdgeStyleImpl.java | 56 +++ .../IconLabelNodeStyleDescriptionImpl.java | 57 +++ .../impl/ImageNodeStyleDescriptionImpl.java | 57 +++ .../RectangularNodeStyleDescriptionImpl.java | 57 +++ .../components/view/impl/ViewPackageImpl.java | 26 ++ .../src/main/resources/model/view.ecore | 2 + .../src/main/resources/model/view.genmodel | 2 + 27 files changed, 1295 insertions(+), 161 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 087943fab1..19276104ae 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,7 @@ - https://github.com/eclipse-sirius/sirius-components/issues/2004[#2004] [form] Add the possibility to show select options' icons. + image:doc/screenshots/ShowIconOptionSelectWidget.jpg[Icons on select widget option,70%,30%] +- https://github.com/eclipse-sirius/sirius-components/issues/2044[#2044] [view] Add custom icons to edges and nodes label in view dsl === Improvements diff --git a/integration-tests/cypress/e2e/project/edit/color-palette.cy.js b/integration-tests/cypress/e2e/project/edit/color-palette.cy.js index 2c5c489da1..824ac1d5a2 100644 --- a/integration-tests/cypress/e2e/project/edit/color-palette.cy.js +++ b/integration-tests/cypress/e2e/project/edit/color-palette.cy.js @@ -65,7 +65,7 @@ describe('/projects/:projectId/edit - Color Palette', () => { cy.getByTestId('Color').click().get('[data-value="color_dark"]').should('exist').click(); cy.getByTestId('Border Color').click().get('[data-value="border_blue"]').should('exist').click(); }); - + it('can select color from color palette in edge style properties', () => { cy.getByTestId('ViewNewModel-toggle').click(); cy.getByTestId('View-toggle').click(); @@ -73,7 +73,6 @@ describe('/projects/:projectId/edit - Color Palette', () => { cy.getByTestId('LinkedTo Edge-toggle').click(); cy.get('[title="view::EdgeStyle"]').click(); cy.getByTestId('Color').click(); - cy.contains('FixedColor color_blue').click(); + cy.contains('color_blue').click(); }); - -}); \ No newline at end of file +}); diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java index abb05b51f0..999be68630 100644 --- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java +++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/form/SelectOptionIconURLDataFetcher.java @@ -29,7 +29,6 @@ */ @QueryDataFetcher(type = "SelectOption", field = "iconURL") public class SelectOptionIconURLDataFetcher implements IDataFetcherWithFieldCoordinates { - @Override public String get(DataFetchingEnvironment environment) throws Exception { SelectOption option = environment.getSource(); diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java index 24fbff4282..24f009fa83 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalEdgeStyleItemProvider.java @@ -61,6 +61,7 @@ public List getPropertyDescriptors(Object object) { this.addTargetArrowStylePropertyDescriptor(object); this.addEdgeWidthPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); } return this.itemPropertyDescriptors; } @@ -186,6 +187,17 @@ protected void addShowIconPropertyDescriptor(Object object) { ViewPackage.Literals.EDGE_STYLE__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } + /** + * This adds a property descriptor for the Label Icon feature. + * + * @generated + */ + protected void addLabelIconPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_EdgeStyle_labelIcon_feature"), this.getString("_UI_PropertyDescriptor_description", "_UI_EdgeStyle_labelIcon_feature", "_UI_EdgeStyle_type"), + ViewPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns ConditionalEdgeStyle.gif. * @@ -240,6 +252,7 @@ public void notifyChanged(Notification notification) { case ViewPackage.CONDITIONAL_EDGE_STYLE__TARGET_ARROW_STYLE: case ViewPackage.CONDITIONAL_EDGE_STYLE__EDGE_WIDTH: case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java index af409aadf6..9a83e60f3f 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/EdgeStyleItemProvider.java @@ -60,6 +60,7 @@ public List getPropertyDescriptors(Object object) { this.addTargetArrowStylePropertyDescriptor(object); this.addEdgeWidthPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); } return this.itemPropertyDescriptors; } @@ -174,6 +175,17 @@ protected void addShowIconPropertyDescriptor(Object object) { ViewPackage.Literals.EDGE_STYLE__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } + /** + * This adds a property descriptor for the Label Icon feature. + * + * @generated + */ + protected void addLabelIconPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_EdgeStyle_labelIcon_feature"), this.getString("_UI_PropertyDescriptor_description", "_UI_EdgeStyle_labelIcon_feature", "_UI_EdgeStyle_type"), + ViewPackage.Literals.EDGE_STYLE__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns EdgeStyle.gif. * @@ -227,6 +239,7 @@ public void notifyChanged(Notification notification) { case ViewPackage.EDGE_STYLE__TARGET_ARROW_STYLE: case ViewPackage.EDGE_STYLE__EDGE_WIDTH: case ViewPackage.EDGE_STYLE__SHOW_ICON: + case ViewPackage.EDGE_STYLE__LABEL_ICON: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java index 2e54b949d2..baf3b8a79d 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/IconLabelNodeStyleDescriptionItemProvider.java @@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); } return this.itemPropertyDescriptors; } @@ -216,6 +217,18 @@ protected void addShowIconPropertyDescriptor(Object object) { ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } + /** + * This adds a property descriptor for the Label Icon feature. + * + * @generated + */ + protected void addLabelIconPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_NodeStyleDescription_labelIcon_feature"), + this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"), + ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This returns IconLabelNodeStyleDescription.gif. * @@ -272,6 +285,7 @@ public void notifyChanged(Notification notification) { case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java index 68890725d0..f80db20e4d 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ImageNodeStyleDescriptionItemProvider.java @@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); this.addShapePropertyDescriptor(object); } return this.itemPropertyDescriptors; @@ -217,6 +218,18 @@ protected void addShowIconPropertyDescriptor(Object object) { ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } + /** + * This adds a property descriptor for the Label Icon feature. + * + * @generated + */ + protected void addLabelIconPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_NodeStyleDescription_labelIcon_feature"), + this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"), + ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This adds a property descriptor for the Shape feature. * @@ -285,6 +298,7 @@ public void notifyChanged(Notification notification) { case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java index 044ffc1e06..ce12ec333b 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RectangularNodeStyleDescriptionItemProvider.java @@ -63,6 +63,7 @@ public List getPropertyDescriptors(Object object) { this.addWidthComputationExpressionPropertyDescriptor(object); this.addHeightComputationExpressionPropertyDescriptor(object); this.addShowIconPropertyDescriptor(object); + this.addLabelIconPropertyDescriptor(object); this.addWithHeaderPropertyDescriptor(object); } return this.itemPropertyDescriptors; @@ -217,6 +218,18 @@ protected void addShowIconPropertyDescriptor(Object object) { ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } + /** + * This adds a property descriptor for the Label Icon feature. + * + * @generated + */ + protected void addLabelIconPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_NodeStyleDescription_labelIcon_feature"), + this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelIcon_feature", "_UI_NodeStyleDescription_type"), + ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + /** * This adds a property descriptor for the With Header feature. * @@ -285,6 +298,7 @@ public void notifyChanged(Notification notification) { case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WIDTH_COMPUTATION_EXPRESSION: case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION: case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: + case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java index 9a3e4657b7..277124fac4 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/ViewPropertiesDescriptionRegistryConfigurer.java @@ -77,7 +77,8 @@ public class ViewPropertiesDescriptionRegistryConfigurer implements IPropertiesD private static final List TYPES_WITH_CUSTOM_PROPERTIES = List.of( ViewPackage.Literals.IMAGE_NODE_STYLE_DESCRIPTION, ViewPackage.Literals.ICON_LABEL_NODE_STYLE_DESCRIPTION, - ViewPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION + ViewPackage.Literals.RECTANGULAR_NODE_STYLE_DESCRIPTION, + ViewPackage.Literals.EDGE_STYLE ); // @formatter:on private final IObjectService objectService; diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/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..9eed763d34 --- /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(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..3ff28fec27 --- /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(GroupDescription groupDescription, Predicate canCreatePredicate) { + // @formatter:off + return PageDescription.newPageDescription("page") + .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..b762069cd7 --- /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,390 @@ +/******************************************************************************* + * 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.FormDescription; +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.GetOrCreateRandomIdProvider; +import org.eclipse.sirius.components.representations.IStatus; +import org.eclipse.sirius.components.representations.Success; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.view.ArrowStyle; +import org.eclipse.sirius.components.view.ColorPalette; +import org.eclipse.sirius.components.view.EdgeStyle; +import org.eclipse.sirius.components.view.FixedColor; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LineStyle; +import org.eclipse.sirius.components.view.Style; +import org.eclipse.sirius.components.view.UserColor; +import org.eclipse.sirius.components.view.View; +import org.eclipse.sirius.components.view.ViewPackage; +import org.eclipse.sirius.components.view.emf.CustomImageMetadata; +import org.eclipse.sirius.components.view.emf.ICustomImageMetadataSearchService; +import org.eclipse.sirius.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.eclipse.sirius.diagram.description.style.EdgeStyleDescription; +import org.springframework.stereotype.Component; + +/** + * Customizes the properties view for some of the View DSL elements. + * + * @author mcharfadi + */ +@Component +public class EdgeStylePropertiesConfigurer implements IPropertiesDescriptionRegistryConfigurer { + + private static final String EMPTY = ""; + + private static final String UNNAMED = ""; + + private static final String INT_PATTERN = "\\d+"; + + private final 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<>(); + controls.addAll(this.getGeneralControlDescription()); + + Predicate canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class) + .filter(self -> self instanceof List) + .map(self -> (List) self) + .flatMap(self -> self.stream().findFirst()) + .filter(EdgeStyle.class::isInstance) + .isPresent(); + + GroupDescription groupDescription = this.propertiesWidgetCreationService.createSimpleGroupDescription(controls); + // @formatter:off + FormDescription formDescription = FormDescription.newFormDescription(formDescriptionId) + .label("IconLabel Edge Style") + .labelProvider(variableManager -> variableManager.get(VariableManager.SELF, EdgeStyleDescription.class) + .map(EdgeStyleDescription::getStrokeColor) + .filter(FixedColor.class::isInstance) + .map(FixedColor.class::cast) + .map(FixedColor::getValue) + .orElse(UNNAMED)) + .canCreatePredicate(variableManager -> true) + .idProvider(new GetOrCreateRandomIdProvider()) + .targetObjectIdProvider(this.propertiesConfigurerService.getTargetObjectIdProvider()) + .pageDescriptions(List.of(this.propertiesWidgetCreationService.createSimplePageDescription(groupDescription, canCreatePagePredicate))) + .build(); + + registry.add(formDescription); + // @formatter:on + } + + private List getGeneralControlDescription() { + return List.of( + this.createUserColorSelectionField("edgestyle.Color", "Color", ViewPackage.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), + ViewPackage.Literals.EDGE_STYLE__SHOW_ICON), + this.createIconSelectionField( + ViewPackage.Literals.EDGE_STYLE__LABEL_ICON), + this.createLineStyleSelectionField( + ViewPackage.Literals.LINE_STYLE), + this.createSourceArrowStyleSelectionField( + ViewPackage.Literals.EDGE_STYLE__SOURCE_ARROW_STYLE), + this.createTargetArrowStyleSelectionField( + ViewPackage.Literals.EDGE_STYLE__TARGET_ARROW_STYLE)); + } + + private SelectDescription createUserColorSelectionField(String id, String label, Object feature, Class styleType + , Function colorGetter, BiConsumer colorSetter) { + // @formatter:off + return SelectDescription.newSelectDescription(id) + .idProvider(variableManager -> id) + .labelProvider(variableManager -> label) + .valueProvider(variableManager -> variableManager.get(VariableManager.SELF, styleType) + .map(colorGetter) + .map(UserColor::getName) + .orElse(EMPTY)) + .optionsProvider(variableManager -> this.getColorsFromColorPalettesStream(variableManager).toList()) + .optionIdProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, UserColor.class) + .map(UserColor::getName) + .orElse(EMPTY)) + .optionLabelProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, UserColor.class) + .map(UserColor::getName) + .orElse(EMPTY)) + .optionIconURLProvider(variableManager -> variableManager.get(SelectComponent.CANDIDATE_VARIABLE, Object.class).map(this.objectService::getImagePath).orElse("")) + .newValueHandler((variableManager, newValue) -> + variableManager.get(VariableManager.SELF, styleType) + .map((style) -> { + if (newValue != null) { + this.getColorsFromColorPalettesStream(variableManager) + .filter(userColor -> newValue.equals(userColor.getName())) + .findFirst() + .ifPresent(userColor -> colorSetter.accept(style, userColor)); + } + return new Success(); + }).orElseGet(() -> new Failure("")) + ) + .diagnosticsProvider(this.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 999cf66a56..f1443fd90a 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,12 +24,9 @@ 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.ecore.util.EcoreUtil; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.sirius.components.collaborative.diagrams.api.IParametricSVGImageRegistry; import org.eclipse.sirius.components.collaborative.forms.services.api.IPropertiesDescriptionRegistry; @@ -38,13 +35,12 @@ import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; import org.eclipse.sirius.components.emf.services.EditingContext; +import org.eclipse.sirius.components.forms.SelectStyle; import org.eclipse.sirius.components.forms.components.SelectComponent; import org.eclipse.sirius.components.forms.description.AbstractControlDescription; -import org.eclipse.sirius.components.forms.description.CheckboxDescription; import org.eclipse.sirius.components.forms.description.FormDescription; import org.eclipse.sirius.components.forms.description.GroupDescription; import org.eclipse.sirius.components.forms.description.ImageDescription; -import org.eclipse.sirius.components.forms.description.PageDescription; import org.eclipse.sirius.components.forms.description.SelectDescription; import org.eclipse.sirius.components.forms.description.TextareaDescription; import org.eclipse.sirius.components.forms.description.TextfieldDescription; @@ -68,6 +64,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; /** @@ -82,25 +81,29 @@ public class NodeStylePropertiesConfigurer implements IPropertiesDescriptionRegi private static final String UNNAMED = ""; - 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 IPropertiesConfigurerService propertiesConfigurerService; + + private 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 @@ -118,7 +121,7 @@ private FormDescription 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) @@ -133,8 +136,8 @@ private FormDescription getImageNodeStyleProperties() { .labelProvider(variableManager -> variableManager.get(VariableManager.SELF, ImageNodeStyleDescription.class).map(ImageNodeStyleDescription::getShape).orElse(UNNAMED)) .canCreatePredicate(variableManager -> true) .idProvider(new GetOrCreateRandomIdProvider()) - .targetObjectIdProvider(this.getTargetObjectIdProvider()) - .pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))) + .targetObjectIdProvider(this.propertiesConfigurerService.getTargetObjectIdProvider()) + .pageDescriptions(List.of(this.propertiesWidgetCreationService.createSimplePageDescription(groupDescription, canCreatePagePredicate))) .build(); // @formatter:on } @@ -145,7 +148,7 @@ private FormDescription getIconLabelNodeStyleProperties() { // @formatter:off 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(self -> self instanceof List) @@ -164,8 +167,8 @@ private FormDescription getIconLabelNodeStyleProperties() { .orElse(UNNAMED)) .canCreatePredicate(variableManager -> true) .idProvider(new GetOrCreateRandomIdProvider()) - .targetObjectIdProvider(this.getTargetObjectIdProvider()) - .pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))) + .targetObjectIdProvider(this.propertiesConfigurerService.getTargetObjectIdProvider()) + .pageDescriptions(List.of(this.propertiesWidgetCreationService.createSimplePageDescription(groupDescription, canCreatePagePredicate))) .build(); // @formatter:on } @@ -175,13 +178,13 @@ private FormDescription getRectangularNodeStyleProperties() { // @formatter:off List controls = new ArrayList<>(); - controls.add(this.createCheckbox("nodestyle.isWithHeader", "With Header", + controls.add(this.propertiesWidgetCreationService.createCheckbox("nodestyle.isWithHeader", "With Header", style -> ((RectangularNodeStyleDescription) style).isWithHeader(), (style, newWithHeaderValue) -> ((RectangularNodeStyleDescription) style).setWithHeader(newWithHeaderValue), ViewPackage.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(self -> self instanceof List) @@ -200,8 +203,8 @@ private FormDescription getRectangularNodeStyleProperties() { .orElse(UNNAMED)) .canCreatePredicate(variableManager -> true) .idProvider(new GetOrCreateRandomIdProvider()) - .targetObjectIdProvider(this.getTargetObjectIdProvider()) - .pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))) + .targetObjectIdProvider(this.propertiesConfigurerService.getTargetObjectIdProvider()) + .pageDescriptions(List.of(this.propertiesWidgetCreationService.createSimplePageDescription(groupDescription, canCreatePagePredicate))) .build(); // @formatter:on } @@ -216,10 +219,12 @@ private List getGeneralControlDescription() { style -> ((NodeStyleDescription) style).getHeightComputationExpression(), (style, newHeightExpression) -> ((NodeStyleDescription) style).setHeightComputationExpression(newHeightExpression), ViewPackage.Literals.NODE_STYLE_DESCRIPTION__HEIGHT_COMPUTATION_EXPRESSION), - this.createCheckbox("nodestyle.showIcon", "Show Icon", + this.propertiesWidgetCreationService.createCheckbox("nodestyle.showIcon", "Show Icon", style -> ((NodeStyleDescription) style).isShowIcon(), (style, newValue) -> ((NodeStyleDescription) style).setShowIcon(newValue), ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON), + this.createIconSelectionField( + ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_ICON), this.createUserColorSelectionField("nodestyle.labelColor", "Label Color", ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_COLOR , NodeStyleDescription.class , NodeStyleDescription::getLabelColor @@ -265,60 +270,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 Function getTargetObjectIdProvider() { - // @formatter:off - return variableManager -> variableManager.get(VariableManager.SELF, Object.class) - .filter(self -> self instanceof List) - .map(self -> (List) self) - .flatMap(self -> self.stream().findFirst()) - .filter(EObject.class::isInstance) - .map(EObject.class::cast) - .map(obj -> EcoreUtil.getURI(obj).toString()) - .orElse(null); - // @formatter:on - } - - private PageDescription createSimplePageDescription(GroupDescription groupDescription, Predicate canCreatePredicate) { - // @formatter:off - return PageDescription.newPageDescription("page") - .idProvider(variableManager -> "page") - .labelProvider(variableManager -> "Properties") - .semanticElementsProvider(this.semanticElementsProvider) - .canCreatePredicate(canCreatePredicate) - .groupDescriptions(List.of(groupDescription)) - .build(); - // @formatter:on - } - - private GroupDescription createSimpleGroupDescription(List controls) { - // @formatter:off - return GroupDescription.newGroupDescription("group") - .idProvider(variableManager -> "group") - .labelProvider(variableManager -> "General") - .semanticElementsProvider(this.semanticElementsProvider) - .controlDescriptions(controls) - .build(); - // @formatter:on - } - private 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) -> { @@ -337,9 +306,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 } @@ -362,35 +331,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 } @@ -417,9 +362,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 } @@ -453,9 +398,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(); } @@ -478,6 +423,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") @@ -506,9 +480,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 } @@ -521,18 +495,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); @@ -548,48 +537,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 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; - } - - private String messageProvider(Object 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/diagram/StylesFactory.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/StylesFactory.java index dc8acca6ef..9758c6980c 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(); diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/EdgeStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/EdgeStyle.java index 9cef90eb5b..b57a3dde22 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/EdgeStyle.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/EdgeStyle.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021, 2022 Obeo. + * Copyright (c) 2021, 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 @@ -24,6 +24,7 @@ *
  • {@link org.eclipse.sirius.components.view.EdgeStyle#getTargetArrowStyle Target Arrow Style}
  • *
  • {@link org.eclipse.sirius.components.view.EdgeStyle#getEdgeWidth Edge Width}
  • *
  • {@link org.eclipse.sirius.components.view.EdgeStyle#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.EdgeStyle#getLabelIcon Label Icon}
  • * * * @see org.eclipse.sirius.components.view.ViewPackage#getEdgeStyle() @@ -155,4 +156,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.ViewPackage#getEdgeStyle_LabelIcon() + * @model + * @generated + */ + String getLabelIcon(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.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/src/main/java/org/eclipse/sirius/components/view/NodeStyleDescription.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/NodeStyleDescription.java index 6714ea4414..98f228223f 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/NodeStyleDescription.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/NodeStyleDescription.java @@ -26,6 +26,7 @@ *
  • {@link org.eclipse.sirius.components.view.NodeStyleDescription#getHeightComputationExpression Height * Computation Expression}
  • *
  • {@link org.eclipse.sirius.components.view.NodeStyleDescription#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.NodeStyleDescription#getLabelIcon Label Icon}
  • * * * @see org.eclipse.sirius.components.view.ViewPackage#getNodeStyleDescription() @@ -49,9 +50,10 @@ public interface NodeStyleDescription extends Style, LabelStyle, BorderStyle { * Sets the value of the '{@link org.eclipse.sirius.components.view.NodeStyleDescription#getLabelColor Label * Color}' reference. * - * @param value the new value of the 'Label Color' reference. - * @generated + * @param value + * the new value of the 'Label Color' reference. * @see #getLabelColor() + * @generated */ void setLabelColor(UserColor value); @@ -125,4 +127,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.ViewPackage#getNodeStyleDescription_LabelIcon() + * @model + * @generated + */ + String getLabelIcon(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.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/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java index 8f6b8e5fe2..930714d241 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java @@ -1090,6 +1090,14 @@ public interface ViewPackage 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. @@ -1097,7 +1105,7 @@ public interface ViewPackage 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. * @@ -1384,6 +1400,14 @@ public interface ViewPackage 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. * @@ -1535,6 +1559,14 @@ public interface ViewPackage 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. @@ -1737,6 +1769,14 @@ public interface ViewPackage 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. @@ -1744,7 +1784,7 @@ public interface ViewPackage 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. @@ -2773,6 +2813,14 @@ public interface ViewPackage extends EPackage { */ int CONDITIONAL_EDGE_STYLE__SHOW_ICON = CONDITIONAL_FEATURE_COUNT + 10; + /** + * The feature id for the 'Label Icon' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_EDGE_STYLE__LABEL_ICON = CONDITIONAL_FEATURE_COUNT + 11; + /** * The number of structural features of the 'Conditional Edge Style' class. @@ -2780,7 +2828,7 @@ public interface ViewPackage extends EPackage { * @generated * @ordered */ - int CONDITIONAL_EDGE_STYLE_FEATURE_COUNT = CONDITIONAL_FEATURE_COUNT + 11; + int CONDITIONAL_EDGE_STYLE_FEATURE_COUNT = 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.NodeStyleDescription#getLabelIcon() + * @see #getNodeStyleDescription() + * @generated + */ + EAttribute getNodeStyleDescription_LabelIcon(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.RectangularNodeStyleDescription * Rectangular Node Style Description}'. @@ -7601,6 +7661,17 @@ public interface ViewPackage extends EPackage { */ EAttribute getEdgeStyle_ShowIcon(); + /** + * Returns the meta object for the attribute '{@link org.eclipse.sirius.components.view.EdgeStyle#getLabelIcon + * Label Icon}'. + * + * @return the meta object for the attribute 'Label Icon'. + * @see org.eclipse.sirius.components.view.EdgeStyle#getLabelIcon() + * @see #getEdgeStyle() + * @generated + */ + EAttribute getEdgeStyle_LabelIcon(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.Tool Tool}'. @@ -10596,6 +10667,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.impl.RectangularNodeStyleDescriptionImpl Rectangular Node @@ -10726,6 +10805,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.impl.ToolImpl Tool}' * class. diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalEdgeStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalEdgeStyleImpl.java index 88c835d89b..6675cc3b89 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalEdgeStyleImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalEdgeStyleImpl.java @@ -46,6 +46,7 @@ * Style} *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalEdgeStyleImpl#getEdgeWidth Edge Width}
  • *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalEdgeStyleImpl#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalEdgeStyleImpl#getLabelIcon Label Icon}
  • * * * @generated @@ -261,6 +262,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; + /** * * @@ -550,6 +571,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.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, ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -582,6 +626,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getEdgeWidth(); case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return this.isShowIcon(); + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -627,6 +673,9 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -672,6 +721,9 @@ public void eUnset(int featureID) { case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -706,6 +758,8 @@ public boolean eIsSet(int featureID) { return this.edgeWidth != EDGE_WIDTH_EDEFAULT; case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); } return super.eIsSet(featureID); } @@ -753,6 +807,8 @@ public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { return ViewPackage.EDGE_STYLE__EDGE_WIDTH; case ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON: return ViewPackage.EDGE_STYLE__SHOW_ICON; + case ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON: + return ViewPackage.EDGE_STYLE__LABEL_ICON; default: return -1; } @@ -803,6 +859,8 @@ public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { return ViewPackage.CONDITIONAL_EDGE_STYLE__EDGE_WIDTH; case ViewPackage.EDGE_STYLE__SHOW_ICON: return ViewPackage.CONDITIONAL_EDGE_STYLE__SHOW_ICON; + case ViewPackage.EDGE_STYLE__LABEL_ICON: + return ViewPackage.CONDITIONAL_EDGE_STYLE__LABEL_ICON; default: return -1; } @@ -841,6 +899,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/src/main/java/org/eclipse/sirius/components/view/impl/EdgeStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/EdgeStyleImpl.java index 12c34da06f..b4c9bec941 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/EdgeStyleImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/EdgeStyleImpl.java @@ -39,6 +39,7 @@ * Style} *
  • {@link org.eclipse.sirius.components.view.impl.EdgeStyleImpl#getEdgeWidth Edge Width}
  • *
  • {@link org.eclipse.sirius.components.view.impl.EdgeStyleImpl#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.EdgeStyleImpl#getLabelIcon Label Icon}
  • * * * @generated @@ -244,6 +245,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; + /** * * @@ -493,6 +514,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.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, ViewPackage.EDGE_STYLE__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -521,6 +565,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getEdgeWidth(); case ViewPackage.EDGE_STYLE__SHOW_ICON: return this.isShowIcon(); + case ViewPackage.EDGE_STYLE__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -563,6 +609,9 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.EDGE_STYLE__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case ViewPackage.EDGE_STYLE__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -605,6 +654,9 @@ public void eUnset(int featureID) { case ViewPackage.EDGE_STYLE__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case ViewPackage.EDGE_STYLE__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -637,6 +689,8 @@ public boolean eIsSet(int featureID) { return this.edgeWidth != EDGE_WIDTH_EDEFAULT; case ViewPackage.EDGE_STYLE__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case ViewPackage.EDGE_STYLE__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); } return super.eIsSet(featureID); } @@ -724,6 +778,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/src/main/java/org/eclipse/sirius/components/view/impl/IconLabelNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/IconLabelNodeStyleDescriptionImpl.java index 7ae0c575b4..131a177b23 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/IconLabelNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/IconLabelNodeStyleDescriptionImpl.java @@ -54,6 +54,8 @@ * Height Computation Expression} *
  • {@link org.eclipse.sirius.components.view.impl.IconLabelNodeStyleDescriptionImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.IconLabelNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • * * * @generated @@ -299,6 +301,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; + /** * * @@ -653,6 +675,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.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, ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -691,6 +736,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); } return super.eGet(featureID, resolve, coreType); } @@ -742,6 +789,9 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -793,6 +843,9 @@ public void eUnset(int featureID) { case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; } super.eUnset(featureID); } @@ -831,6 +884,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case ViewPackage.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); } @@ -948,6 +1003,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/src/main/java/org/eclipse/sirius/components/view/impl/ImageNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ImageNodeStyleDescriptionImpl.java index d7c39fbd9a..53e6463a35 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ImageNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ImageNodeStyleDescriptionImpl.java @@ -51,6 +51,8 @@ *
  • {@link org.eclipse.sirius.components.view.impl.ImageNodeStyleDescriptionImpl#getHeightComputationExpression * Height Computation Expression}
  • *
  • {@link org.eclipse.sirius.components.view.impl.ImageNodeStyleDescriptionImpl#isShowIcon Show Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ImageNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • *
  • {@link org.eclipse.sirius.components.view.impl.ImageNodeStyleDescriptionImpl#getShape Shape}
  • * * @@ -297,6 +299,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. @@ -671,6 +693,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.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, ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -732,6 +777,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: return this.getShape(); } @@ -785,6 +832,9 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.setShape((String) newValue); return; @@ -839,6 +889,9 @@ public void eUnset(int featureID) { case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: this.setShape(SHAPE_EDEFAULT); return; @@ -880,6 +933,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); case ViewPackage.IMAGE_NODE_STYLE_DESCRIPTION__SHAPE: return SHAPE_EDEFAULT == null ? this.shape != null : !SHAPE_EDEFAULT.equals(this.shape); } @@ -999,6 +1054,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/src/main/java/org/eclipse/sirius/components/view/impl/RectangularNodeStyleDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RectangularNodeStyleDescriptionImpl.java index b262f9c831..95f0986f8f 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RectangularNodeStyleDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RectangularNodeStyleDescriptionImpl.java @@ -54,6 +54,8 @@ * Height Computation Expression} *
  • {@link org.eclipse.sirius.components.view.impl.RectangularNodeStyleDescriptionImpl#isShowIcon Show * Icon}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.RectangularNodeStyleDescriptionImpl#getLabelIcon Label + * Icon}
  • *
  • {@link org.eclipse.sirius.components.view.impl.RectangularNodeStyleDescriptionImpl#isWithHeader With * Header}
  • * @@ -301,6 +303,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. @@ -675,6 +697,29 @@ public void setShowIcon(boolean newShowIcon) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.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, ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON, oldLabelIcon, this.labelIcon)); + } + /** * * @@ -736,6 +781,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getHeightComputationExpression(); case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.isShowIcon(); + case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return this.getLabelIcon(); case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: return this.isWithHeader(); } @@ -789,6 +836,9 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon((Boolean) newValue); return; + case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon((String) newValue); + return; case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: this.setWithHeader((Boolean) newValue); return; @@ -843,6 +893,9 @@ public void eUnset(int featureID) { case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: this.setShowIcon(SHOW_ICON_EDEFAULT); return; + case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + this.setLabelIcon(LABEL_ICON_EDEFAULT); + return; case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: this.setWithHeader(WITH_HEADER_EDEFAULT); return; @@ -884,6 +937,8 @@ public boolean eIsSet(int featureID) { return HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT == null ? this.heightComputationExpression != null : !HEIGHT_COMPUTATION_EXPRESSION_EDEFAULT.equals(this.heightComputationExpression); case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__SHOW_ICON: return this.showIcon != SHOW_ICON_EDEFAULT; + case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__LABEL_ICON: + return LABEL_ICON_EDEFAULT == null ? this.labelIcon != null : !LABEL_ICON_EDEFAULT.equals(this.labelIcon); case ViewPackage.RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER: return this.withHeader != WITH_HEADER_EDEFAULT; } @@ -1003,6 +1058,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/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java index 99840a24bc..14421d368a 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java @@ -1554,6 +1554,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); + } + /** * * @@ -1694,6 +1704,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); + } + /** * * @@ -3952,6 +3972,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.rectangularNodeStyleDescriptionEClass = this.createEClass(RECTANGULAR_NODE_STYLE_DESCRIPTION); this.createEAttribute(this.rectangularNodeStyleDescriptionEClass, RECTANGULAR_NODE_STYLE_DESCRIPTION__WITH_HEADER); @@ -3973,6 +3994,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.toolEClass = this.createEClass(TOOL); this.createEAttribute(this.toolEClass, TOOL__NAME); @@ -4520,6 +4542,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.rectangularNodeStyleDescriptionEClass, RectangularNodeStyleDescription.class, "RectangularNodeStyleDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEAttribute(this.getRectangularNodeStyleDescription_WithHeader(), this.ecorePackage.getEBoolean(), "withHeader", null, 0, 1, RectangularNodeStyleDescription.class, !IS_TRANSIENT, @@ -4549,6 +4573,8 @@ public void initializePackageContents() { !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.toolEClass, Tool.class, "Tool", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); this.initEAttribute(this.getTool_Name(), this.getIdentifier(), "name", "Tool", 1, 1, Tool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, diff --git a/packages/view/backend/sirius-components-view/src/main/resources/model/view.ecore b/packages/view/backend/sirius-components-view/src/main/resources/model/view.ecore index 10c0b2011a..5d32b274c7 100644 --- a/packages/view/backend/sirius-components-view/src/main/resources/model/view.ecore +++ b/packages/view/backend/sirius-components-view/src/main/resources/model/view.ecore @@ -130,6 +130,7 @@ + @@ -156,6 +157,7 @@ eType="#//Length" defaultValueLiteral="1"/> + diff --git a/packages/view/backend/sirius-components-view/src/main/resources/model/view.genmodel b/packages/view/backend/sirius-components-view/src/main/resources/model/view.genmodel index e543aba740..9de6d1750e 100644 --- a/packages/view/backend/sirius-components-view/src/main/resources/model/view.genmodel +++ b/packages/view/backend/sirius-components-view/src/main/resources/model/view.genmodel @@ -140,6 +140,7 @@ + @@ -157,6 +158,7 @@ +