From 12b8e965b83fa8737c6694a4b3352ab698b6aee7 Mon Sep 17 00:00:00 2001 From: Florian Barbin Date: Wed, 22 Jun 2022 11:17:18 +0200 Subject: [PATCH] [1281] Add support for Link widget in Form representation Bug: https://github.com/eclipse-sirius/sirius-components/issues/1281 Signed-off-by: Florian Barbin --- CHANGELOG.adoc | 4 +- .../src/main/resources/schema/form.graphqls | 11 + .../emf/view/form/LinkStyleProvider.java | 61 ++ .../ViewFormDescriptionConverterSwitch.java | 38 ++ .../emf/view/DynamicFormsTests.java | 77 ++- .../eclipse/sirius/components/forms/Link.java | 32 +- .../sirius/components/forms/LinkStyle.java | 112 ++++ .../forms/components/LinkComponent.java | 18 +- .../forms/description/LinkDescription.java | 31 + .../forms/elements/LinkElementProps.java | 33 +- .../forms/renderer/FormElementFactory.java | 15 +- ...ionalLinkDescriptionStyleItemProvider.java | 202 +++++++ ...exboxContainerDescriptionItemProvider.java | 5 + .../provider/FormDescriptionItemProvider.java | 5 + .../provider/LinkDescriptionItemProvider.java | 209 +++++++ .../LinkDescriptionStyleItemProvider.java | 201 +++++++ .../ViewItemProviderAdapterFactory.java | 76 +++ .../icons/full/obj16/LinkDescription.svg | 1 + .../src/main/resources/plugin.properties | 8 + .../view/ConditionalLinkDescriptionStyle.java | 25 + .../components/view/LinkDescription.java | 117 ++++ .../components/view/LinkDescriptionStyle.java | 53 ++ .../sirius/components/view/ViewFactory.java | 25 + .../sirius/components/view/ViewPackage.java | 409 ++++++++++++- .../ConditionalLinkDescriptionStyleImpl.java | 537 ++++++++++++++++++ .../view/impl/LinkDescriptionImpl.java | 359 ++++++++++++ .../view/impl/LinkDescriptionStyleImpl.java | 505 ++++++++++++++++ .../components/view/impl/ViewFactoryImpl.java | 42 ++ .../components/view/impl/ViewPackageImpl.java | 136 +++++ .../view/util/ViewAdapterFactory.java | 59 ++ .../components/view/util/ViewSwitch.java | 83 +++ .../src/main/resources/model/view.ecore | 13 + .../src/main/resources/model/view.genmodel | 10 + frontend/src/form/Form.types.ts | 11 + frontend/src/form/FormEventFragments.ts | 9 + frontend/src/form/FormEventFragments.types.ts | 11 + .../properties/PropertySectionOperations.tsx | 2 +- .../propertysections/LinkPropertySection.tsx | 38 +- .../LinkPropertySection.types.ts | 3 +- .../__tests__/LinkPropertySection.test.tsx | 64 +++ .../LinkPropertySection.test.tsx.snap | 57 ++ 41 files changed, 3679 insertions(+), 28 deletions(-) create mode 100644 backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/LinkStyleProvider.java create mode 100644 backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java create mode 100644 backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java create mode 100644 backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java create mode 100644 backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java create mode 100644 backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java create mode 100644 backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java create mode 100644 frontend/src/properties/propertysections/__tests__/LinkPropertySection.test.tsx create mode 100644 frontend/src/properties/propertysections/__tests__/__snapshots__/LinkPropertySection.test.tsx.snap diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4717b6ab73..7b14b17e34 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -36,7 +36,9 @@ - https://github.com/eclipse-sirius/sirius-components/issues/1255[#1255] [form] Add support for charts in form descriptions editor - https://github.com/eclipse-sirius/sirius-components/issues/1244[#1244] [form] Add support for flexbox containers on FormDescriptions - https://github.com/eclipse-sirius/sirius-components/issues/1266[#1266] [form] Add styling support on bar-chart and pie-chart Widgets in View DSL -- https://github.com/eclipse-sirius/sirius-components/issues/1275[#1275] [form] Add support for label widget in forms +- https://github.com/eclipse-sirius/sirius-components/issues/1275[#1275] [form] Add support for Label widget in Form representation +- https://github.com/eclipse-sirius/sirius-components/issues/1281[#1281] [form] Add support for Link widget in Form representation + == v2022.5.0 diff --git a/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls b/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls index df9e2140c0..5fcd32bbd4 100644 --- a/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls +++ b/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls @@ -219,6 +219,17 @@ type Link implements Widget { diagnostics: [Diagnostic!]! label: String! url: String! + display: String! + style: LinkStyle +} + +type LinkStyle { + color: String + fontSize: Int + italic: Boolean + bold: Boolean + underline: Boolean + strikeThrough: Boolean } union Chart = BarChart | PieChart diff --git a/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/LinkStyleProvider.java b/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/LinkStyleProvider.java new file mode 100644 index 0000000000..53fbf9c01c --- /dev/null +++ b/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/LinkStyleProvider.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2022 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.emf.view.form; + +import java.util.Objects; +import java.util.function.Function; + +import org.eclipse.sirius.components.forms.LinkStyle; +import org.eclipse.sirius.components.forms.LinkStyle.Builder; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; + +/** + * The style provider for the Link Description widget of the View DSL. + * + * @author fbarbin + */ +public class LinkStyleProvider implements Function { + + private final LinkDescriptionStyle viewStyle; + + public LinkStyleProvider(LinkDescriptionStyle viewStyle) { + this.viewStyle = Objects.requireNonNull(viewStyle); + } + + @Override + public LinkStyle apply(VariableManager variableManager) { + Builder linkStyleBuilder = LinkStyle.newLinkStyle(); + + String color = this.viewStyle.getColor(); + if (color != null && !color.isBlank()) { + linkStyleBuilder.color(color); + } + int fontSize = this.viewStyle.getFontSize(); + boolean italic = this.viewStyle.isItalic(); + boolean bold = this.viewStyle.isBold(); + boolean underline = this.viewStyle.isUnderline(); + boolean strikeThrough = this.viewStyle.isStrikeThrough(); + + // @formatter:off + return linkStyleBuilder + .fontSize(fontSize) + .italic(italic) + .bold(bold) + .underline(underline) + .strikeThrough(strikeThrough) + .build(); + // @formatter:on + } + +} diff --git a/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/ViewFormDescriptionConverterSwitch.java b/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/ViewFormDescriptionConverterSwitch.java index 7a776e02db..6efb2b1440 100644 --- a/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/ViewFormDescriptionConverterSwitch.java +++ b/backend/sirius-components-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/ViewFormDescriptionConverterSwitch.java @@ -38,6 +38,7 @@ import org.eclipse.sirius.components.forms.CheckboxStyle; import org.eclipse.sirius.components.forms.FlexDirection; import org.eclipse.sirius.components.forms.LabelWidgetStyle; +import org.eclipse.sirius.components.forms.LinkStyle; import org.eclipse.sirius.components.forms.MultiSelectStyle; import org.eclipse.sirius.components.forms.RadioStyle; import org.eclipse.sirius.components.forms.SelectStyle; @@ -50,6 +51,7 @@ import org.eclipse.sirius.components.forms.description.CheckboxDescription; import org.eclipse.sirius.components.forms.description.FlexboxContainerDescription; import org.eclipse.sirius.components.forms.description.LabelDescription; +import org.eclipse.sirius.components.forms.description.LinkDescription; import org.eclipse.sirius.components.forms.description.MultiSelectDescription; import org.eclipse.sirius.components.forms.description.RadioDescription; import org.eclipse.sirius.components.forms.description.SelectDescription; @@ -63,6 +65,7 @@ import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; import org.eclipse.sirius.components.view.LabelDescriptionStyle; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.RadioDescriptionStyle; @@ -426,6 +429,41 @@ public AbstractWidgetDescription caseLabelDescription(org.eclipse.sirius.compone // @formatter:on } + @Override + public AbstractWidgetDescription caseLinkDescription(org.eclipse.sirius.components.view.LinkDescription viewLinkDescription) { + String descriptionId = this.getDescriptionId(viewLinkDescription); + WidgetIdProvider idProvider = new WidgetIdProvider(); + StringValueProvider labelProvider = this.getStringValueProvider(viewLinkDescription.getLabelExpression()); + StringValueProvider valueProvider = this.getStringValueProvider(viewLinkDescription.getValueExpression()); + StringValueProvider displayProvider = this.getStringValueProvider(viewLinkDescription.getDisplayExpression()); + Function styleProvider = variableManager -> { + // @formatter:off + var effectiveStyle = viewLinkDescription.getConditionalStyles().stream() + .filter(style -> this.matches(style.getCondition(), variableManager)) + .map(LinkDescriptionStyle.class::cast) + .findFirst() + .orElseGet(viewLinkDescription::getStyle); + // @formatter:on + if (effectiveStyle == null) { + return null; + } + return new LinkStyleProvider(effectiveStyle).apply(variableManager); + }; + + // @formatter:off + return LinkDescription.newLinkDescription(descriptionId) + .idProvider(idProvider) + .labelProvider(labelProvider) + .urlProvider(valueProvider) + .displayProvider(displayProvider) + .styleProvider(styleProvider) + .diagnosticsProvider(variableManager -> List.of()) + .kindProvider(diagnostic -> "") //$NON-NLS-1$ + .messageProvider(diagnostic -> "") //$NON-NLS-1$ + .build(); + // @formatter:on + } + private Function> getMultiValueProvider(String expression) { String safeExpression = Optional.ofNullable(expression).orElse(""); //$NON-NLS-1$ return variableManager -> { diff --git a/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/view/DynamicFormsTests.java b/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/view/DynamicFormsTests.java index d5d0f9eaa5..2b30184b0d 100644 --- a/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/view/DynamicFormsTests.java +++ b/backend/sirius-components-emf/src/test/java/org/eclipse/sirius/components/emf/view/DynamicFormsTests.java @@ -43,6 +43,8 @@ import org.eclipse.sirius.components.forms.Group; import org.eclipse.sirius.components.forms.LabelWidget; import org.eclipse.sirius.components.forms.LabelWidgetStyle; +import org.eclipse.sirius.components.forms.Link; +import org.eclipse.sirius.components.forms.LinkStyle; import org.eclipse.sirius.components.forms.MultiSelect; import org.eclipse.sirius.components.forms.MultiSelectStyle; import org.eclipse.sirius.components.forms.Page; @@ -67,6 +69,7 @@ import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalLabelDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; @@ -78,6 +81,8 @@ import org.eclipse.sirius.components.view.LabelDescription; import org.eclipse.sirius.components.view.LabelDescriptionStyle; import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.PieChartDescription; @@ -122,7 +127,7 @@ void testRenderEcoreForm() throws Exception { assertThat(result.getPages()).extracting(Page::getGroups).hasSize(1); Group group = result.getPages().get(0).getGroups().get(0); - assertThat(group.getWidgets()).hasSize(10); + assertThat(group.getWidgets()).hasSize(11); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -133,6 +138,7 @@ void testRenderEcoreForm() throws Exception { ChartWidget chartWidgetWithPieChart = (ChartWidget) group.getWidgets().get(7); FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(9); + Link link = (Link) group.getWidgets().get(10); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -161,6 +167,11 @@ void testRenderEcoreForm() throws Exception { assertThat(labelWidget.getLabel()).isEqualTo("Label EClass name"); //$NON-NLS-1$ this.testNoStyle(labelWidget); + assertThat(link.getLabel()).isEqualTo("Label EClass link"); //$NON-NLS-1$ + assertThat(link.getUrl()).isEqualTo("myHyperLink"); //$NON-NLS-1$ + assertThat(link.getDisplay()).isEqualTo("myHyperLinkDisplayed"); //$NON-NLS-1$ + this.testNoStyle(link); + assertThat(radio.getOptions()).hasSize(3); assertThat(radio.getOptions()).allSatisfy(option -> { if (option.getLabel().equals("Class2")) { //$NON-NLS-1$ @@ -283,7 +294,7 @@ void testRenderEcoreFormWithStyle() throws Exception { assertThat(result.getPages()).extracting(Page::getGroups).hasSize(1); Group group = result.getPages().get(0).getGroups().get(0); - assertThat(group.getWidgets()).hasSize(10); + assertThat(group.getWidgets()).hasSize(11); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -294,6 +305,7 @@ void testRenderEcoreFormWithStyle() throws Exception { ChartWidget chartWidgetWithPieChart = (ChartWidget) group.getWidgets().get(7); FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(9); + Link link = (Link) group.getWidgets().get(10); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -333,6 +345,11 @@ void testRenderEcoreFormWithStyle() throws Exception { assertThat(labelWidget.getLabel()).isEqualTo("Label EClass name"); //$NON-NLS-1$ this.testStyle(labelWidget); + assertThat(link.getLabel()).isEqualTo("Label EClass link"); //$NON-NLS-1$ + assertThat(link.getUrl()).isEqualTo("myHyperLink"); //$NON-NLS-1$ + assertThat(link.getDisplay()).isEqualTo("myHyperLinkDisplayed"); //$NON-NLS-1$ + this.testStyle(link); + this.checkBarChart(chartWidgetWithBarChart, true, false); this.checkPieChart(chartWidgetWithPieChart, true, false); @@ -370,7 +387,7 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { assertThat(result.getPages()).extracting(Page::getGroups).hasSize(1); Group group = result.getPages().get(0).getGroups().get(0); - assertThat(group.getWidgets()).hasSize(10); + assertThat(group.getWidgets()).hasSize(11); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -381,6 +398,7 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { ChartWidget chartWidgetWithPieChart = (ChartWidget) group.getWidgets().get(7); FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(9); + Link link = (Link) group.getWidgets().get(10); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -420,6 +438,11 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { assertThat(labelWidget.getLabel()).isEqualTo("Label EClass name"); //$NON-NLS-1$ this.testConditionalStyle(labelWidget); + assertThat(link.getLabel()).isEqualTo("Label EClass link"); //$NON-NLS-1$ + assertThat(link.getUrl()).isEqualTo("myHyperLink"); //$NON-NLS-1$ + assertThat(link.getDisplay()).isEqualTo("myHyperLinkDisplayed"); //$NON-NLS-1$ + this.testConditionalStyle(link); + this.checkBarChart(chartWidgetWithBarChart, false, true); this.checkPieChart(chartWidgetWithPieChart, false, true); @@ -449,14 +472,14 @@ void testEditingEcoreForm() throws Exception { this.buildFixture(); FormDescription eClassFormDescription = this.createClassFormDescription(false, false); Form form = this.render(eClassFormDescription, this.eClass1); - assertThat(form.getPages()).flatExtracting(Page::getGroups).flatExtracting(Group::getWidgets).hasSize(10); + assertThat(form.getPages()).flatExtracting(Page::getGroups).flatExtracting(Group::getWidgets).hasSize(11); this.checkValuesEditing(this.eClass1, form); } private void checkValuesEditing(EClass eClass, Form form) { Group group = form.getPages().get(0).getGroups().get(0); - assertThat(group.getWidgets()).hasSize(10); + assertThat(group.getWidgets()).hasSize(11); Textfield textfield = (Textfield) group.getWidgets().get(0); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ @@ -541,6 +564,8 @@ private FormDescription createClassFormDescription(boolean withStyle, boolean wi formDescription.getWidgets().add(flexboxContainerDescription); LabelDescription labelDescription = this.createLabel(withStyle, withConditionalStyle); formDescription.getWidgets().add(labelDescription); + LinkDescription linkDescription = this.createLink(withStyle, withConditionalStyle); + formDescription.getWidgets().add(linkDescription); return formDescription; } @@ -801,6 +826,29 @@ private LabelDescription createLabel(boolean withStyle, boolean withConditionalS return labelDescription; } + private LinkDescription createLink(boolean withStyle, boolean withConditionalStyle) { + LinkDescription linkDescription = ViewFactory.eINSTANCE.createLinkDescription(); + linkDescription.setLabelExpression("aql:'Label EClass link'"); //$NON-NLS-1$ + linkDescription.setValueExpression("myHyperLink"); //$NON-NLS-1$ + linkDescription.setDisplayExpression("aql:value+'Displayed'"); //$NON-NLS-1$ + linkDescription.setName("Class Name"); //$NON-NLS-1$ + if (withStyle) { + LinkDescriptionStyle style = ViewFactory.eINSTANCE.createLinkDescriptionStyle(); + style.setColor("#de1000"); //$NON-NLS-1$ + this.setFontStyle(style); + linkDescription.setStyle(style); + } + if (withConditionalStyle) { + ConditionalLinkDescriptionStyle conditionalStyle = ViewFactory.eINSTANCE.createConditionalLinkDescriptionStyle(); + conditionalStyle.setCondition("aql:true"); //$NON-NLS-1$ + conditionalStyle.setColor("#fbb800"); //$NON-NLS-1$ + this.setConditionalFontStyle(conditionalStyle); + linkDescription.getConditionalStyles().add(conditionalStyle); + } + + return linkDescription; + } + private void setFontStyle(LabelStyle labelStyle) { labelStyle.setFontSize(20); labelStyle.setItalic(true); @@ -878,6 +926,25 @@ private void testConditionalStyle(LabelWidget labelWidget) { this.testConditionalFontStyle(labelWidgetStyle); } + private void testNoStyle(Link link) { + LinkStyle linkStyle = link.getStyle(); + assertThat(linkStyle).isNull(); + } + + private void testStyle(Link link) { + LinkStyle linkStyle = link.getStyle(); + assertThat(linkStyle).isNotNull(); + assertThat(linkStyle.getColor()).isEqualTo("#de1000"); //$NON-NLS-1$ + this.testFontStyle(linkStyle); + } + + private void testConditionalStyle(Link link) { + LinkStyle linkStyle = link.getStyle(); + assertThat(linkStyle).isNotNull(); + assertThat(linkStyle.getColor()).isEqualTo("#fbb800"); //$NON-NLS-1$ + this.testConditionalFontStyle(linkStyle); + } + private void testStyle(Radio radio) { RadioStyle radioStyle = radio.getStyle(); assertThat(radioStyle).isNotNull(); diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java index 75ee46dc89..3b377df6ff 100644 --- a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java @@ -30,6 +30,10 @@ public final class Link extends AbstractWidget { private String url; + private String display; + + private LinkStyle style; + private Link() { // Prevent instantiation } @@ -42,14 +46,22 @@ public String getUrl() { return this.url; } + public String getDisplay() { + return this.display; + } + + public LinkStyle getStyle() { + return this.style; + } + public static Builder newLink(String id) { return new Builder(id); } @Override public String toString() { - String pattern = "{0} '{'id: {1}, label: {2}, url: {3}'}'"; //$NON-NLS-1$ - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.label, this.url); + String pattern = "{0} '{'id: {1}, label: {2}, url: {3}, display: {4}'}'"; //$NON-NLS-1$ + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.label, this.url, this.display); } /** @@ -65,6 +77,10 @@ public static final class Builder { private String url; + private String display; + + private LinkStyle style; + private List diagnostics; private Builder(String id) { @@ -81,6 +97,16 @@ public Builder url(String value) { return this; } + public Builder display(String display) { + this.display = Objects.requireNonNull(display); + return this; + } + + public Builder style(LinkStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public Builder diagnostics(List diagnostics) { this.diagnostics = Objects.requireNonNull(diagnostics); return this; @@ -91,6 +117,8 @@ public Link build() { link.id = Objects.requireNonNull(this.id); link.label = Objects.requireNonNull(this.label); link.url = Objects.requireNonNull(this.url); + link.display = Objects.requireNonNull(this.display); + link.style = this.style; // Optional on purpose link.diagnostics = Objects.requireNonNull(this.diagnostics); return link; } diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java new file mode 100644 index 0000000000..2f5c64454e --- /dev/null +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2022 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.forms; + +import java.text.MessageFormat; +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * The style of a Link Widget. + * + * @author fbarbin + */ +@Immutable +public final class LinkStyle extends AbstractFontStyle { + + private String color; + + private LinkStyle() { + // Prevent instantiation + } + + public String getColor() { + return this.color; + } + + public static Builder newLinkStyle() { + return new Builder(); + } + + @Override + public String toString() { + String pattern = "{0} '{'color: {1}, fontSize: {2}, italic: {3}, bold: {4}, underline: {5}, strikeThrough: {6},'}'"; //$NON-NLS-1$ + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.color, this.fontSize, this.italic, this.bold, this.underline, this.strikeThrough); + } + + /** + * Builder used to create the Link style. + * + * @author fbarbin + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + private String color; + + private int fontSize; + + private boolean italic; + + private boolean bold; + + private boolean underline; + + private boolean strikeThrough; + + private Builder() { + } + + public Builder color(String color) { + this.color = Objects.requireNonNull(color); + return this; + } + + public Builder fontSize(int fontSize) { + this.fontSize = fontSize; + return this; + } + + public Builder italic(boolean italic) { + this.italic = italic; + return this; + } + + public Builder bold(boolean bold) { + this.bold = bold; + return this; + } + + public Builder underline(boolean underline) { + this.underline = underline; + return this; + } + + public Builder strikeThrough(boolean strikeThrough) { + this.strikeThrough = strikeThrough; + return this; + } + + public LinkStyle build() { + LinkStyle linkStyle = new LinkStyle(); + linkStyle.color = this.color; + linkStyle.fontSize = this.fontSize; + linkStyle.italic = this.italic; + linkStyle.bold = this.bold; + linkStyle.underline = this.underline; + linkStyle.strikeThrough = this.strikeThrough; + return linkStyle; + } + + } +} diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java index e8e6107ec1..12222c5500 100644 --- a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Objects; +import org.eclipse.sirius.components.forms.LinkStyle; import org.eclipse.sirius.components.forms.description.LinkDescription; import org.eclipse.sirius.components.forms.elements.LinkElementProps; import org.eclipse.sirius.components.forms.validation.DiagnosticComponent; @@ -44,15 +45,24 @@ public Element render() { String id = linkDescription.getIdProvider().apply(variableManager); String label = linkDescription.getLabelProvider().apply(variableManager); String url = linkDescription.getUrlProvider().apply(variableManager); + variableManager.put(LinkDescription.VALUE, url); + String display = linkDescription.getDisplayProvider().apply(variableManager); + LinkStyle style = linkDescription.getStyleProvider().apply(variableManager); List children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(linkDescription, variableManager))); // @formatter:off - LinkElementProps linkElementProps = LinkElementProps.newLinkElementProps(id) + LinkElementProps.Builder builder = LinkElementProps.newLinkElementProps(id) .label(label) .url(url) - .children(children) - .build(); - return new Element(LinkElementProps.TYPE, linkElementProps); + .display(display) + .children(children); // @formatter:on + + if (style != null) { + builder.style(style); + } + + LinkElementProps linkElementProps = builder.build(); + return new Element(LinkElementProps.TYPE, linkElementProps); } } diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java index 4cb148b7d8..d2e6b12ec4 100644 --- a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java @@ -18,6 +18,7 @@ import java.util.function.Function; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.forms.LinkStyle; import org.eclipse.sirius.components.representations.VariableManager; /** @@ -27,12 +28,18 @@ */ @Immutable public final class LinkDescription extends AbstractWidgetDescription { + public static final String VALUE = "value"; //$NON-NLS-1$ + private Function idProvider; private Function labelProvider; private Function urlProvider; + private Function displayProvider; + + private Function styleProvider; + private LinkDescription() { // Prevent instantiation } @@ -49,6 +56,14 @@ public Function getUrlProvider() { return this.urlProvider; } + public Function getDisplayProvider() { + return this.displayProvider; + } + + public Function getStyleProvider() { + return this.styleProvider; + } + public static Builder newLinkDescription(String id) { return new Builder(id); } @@ -74,6 +89,10 @@ public static final class Builder { private Function urlProvider; + private Function displayProvider; + + private Function styleProvider; + private Function> diagnosticsProvider; private Function kindProvider; @@ -99,6 +118,16 @@ public Builder urlProvider(Function valueProvider) { return this; } + public Builder displayProvider(Function displayProvider) { + this.displayProvider = Objects.requireNonNull(displayProvider); + return this; + } + + public Builder styleProvider(Function styleProvider) { + this.styleProvider = Objects.requireNonNull(styleProvider); + return this; + } + public Builder diagnosticsProvider(Function> diagnosticsProvider) { this.diagnosticsProvider = Objects.requireNonNull(diagnosticsProvider); return this; @@ -120,6 +149,8 @@ public LinkDescription build() { linkDescription.idProvider = Objects.requireNonNull(this.idProvider); linkDescription.labelProvider = Objects.requireNonNull(this.labelProvider); linkDescription.urlProvider = Objects.requireNonNull(this.urlProvider); + linkDescription.displayProvider = Objects.requireNonNull(this.displayProvider); + linkDescription.styleProvider = Objects.requireNonNull(this.styleProvider); linkDescription.diagnosticsProvider = Objects.requireNonNull(this.diagnosticsProvider); linkDescription.kindProvider = Objects.requireNonNull(this.kindProvider); linkDescription.messageProvider = Objects.requireNonNull(this.messageProvider); diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java index e9e9cfa05d..8559ebd083 100644 --- a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java @@ -17,6 +17,7 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.forms.LinkStyle; import org.eclipse.sirius.components.representations.Element; import org.eclipse.sirius.components.representations.IProps; @@ -35,6 +36,10 @@ public final class LinkElementProps implements IProps { private String url; + private String display; + + private LinkStyle style; + private List children; private LinkElementProps() { @@ -53,6 +58,14 @@ public String getUrl() { return this.url; } + public String getDisplay() { + return this.display; + } + + public LinkStyle getStyle() { + return this.style; + } + @Override public List getChildren() { return this.children; @@ -64,8 +77,8 @@ public static Builder newLinkElementProps(String id) { @Override public String toString() { - String pattern = "{0} '{'id: {1}, label: {2}, url: {3}'}'"; //$NON-NLS-1$ - return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.label, this.url); + String pattern = "{0} '{'id: {1}, label: {2}, url: {3}, display: {4}'}'"; //$NON-NLS-1$ + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.label, this.url, this.display); } /** @@ -81,6 +94,10 @@ public static final class Builder { private String url; + private String display; + + private LinkStyle style; + private List children; private Builder(String id) { @@ -97,6 +114,16 @@ public Builder url(String value) { return this; } + public Builder display(String display) { + this.display = Objects.requireNonNull(display); + return this; + } + + public Builder style(LinkStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public Builder children(List children) { this.children = Objects.requireNonNull(children); return this; @@ -107,6 +134,8 @@ public LinkElementProps build() { linkElementProps.id = Objects.requireNonNull(this.id); linkElementProps.label = Objects.requireNonNull(this.label); linkElementProps.url = Objects.requireNonNull(this.url); + linkElementProps.display = Objects.requireNonNull(this.display); + linkElementProps.style = this.style; // Optional on purpose linkElementProps.children = Objects.requireNonNull(this.children); return linkElementProps; } diff --git a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java index 4a03f093bd..7b2b221685 100644 --- a/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java +++ b/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java @@ -321,13 +321,13 @@ private Textfield instantiateTextfield(TextfieldElementProps props, List .value(props.getValue()) .newValueHandler(props.getNewValueHandler()) .diagnostics(diagnostics); + // @formatter:on if (props.getStyle() != null) { textfieldBuilder.style(props.getStyle()); } return textfieldBuilder.build(); - // @formatter:on } private Object instantiateDiagnostic(DiagnosticElementProps props, List children) { @@ -343,12 +343,17 @@ private Link instantiateLink(LinkElementProps props, List children) { List diagnostics = this.getDiagnosticsFromChildren(children); // @formatter:off - return Link.newLink(props.getId()) + Link.Builder builder = Link.newLink(props.getId()) .label(props.getLabel()) .url(props.getUrl()) - .diagnostics(diagnostics) - .build(); - // @formatter:on + .display(props.getDisplay()) + .diagnostics(diagnostics); + // @formatter:on + + if (props.getStyle() != null) { + builder.style(props.getStyle()); + } + return builder.build(); } private LabelWidget instantiateLabel(LabelWidgetElementProps props, List children) { diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..9a3c72b452 --- /dev/null +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2021, 2022 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.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle} + * object. + * + * @generated + */ +public class ConditionalLinkDescriptionStyleItemProvider extends ConditionalItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public ConditionalLinkDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Color feature. + * + * @generated + */ + protected void addColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LinkDescriptionStyle_color_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LinkDescriptionStyle_color_feature", "_UI_LinkDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LINK_DESCRIPTION_STYLE__COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns ConditionalStyle.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((ConditionalLinkDescriptionStyle) object).getCondition(); + return label == null || label.length() == 0 ? this.getString("_UI_ConditionalLinkDescriptionStyle_type") : //$NON-NLS-1$ + this.getString("_UI_ConditionalLinkDescriptionStyle_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(ConditionalLinkDescriptionStyle.class)) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java index e3213f66b8..657f5f1e56 100644 --- a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java @@ -27,6 +27,7 @@ import org.eclipse.sirius.components.view.FlexDirection; import org.eclipse.sirius.components.view.FlexboxContainerDescription; import org.eclipse.sirius.components.view.LabelDescription; +import org.eclipse.sirius.components.view.LinkDescription; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.PieChartDescription; import org.eclipse.sirius.components.view.RadioDescription; @@ -204,6 +205,10 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors labelDescription.setStyle(ViewFactory.eINSTANCE.createLabelDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, labelDescription)); + LinkDescription linkDescription = ViewFactory.eINSTANCE.createLinkDescription(); + linkDescription.setStyle(ViewFactory.eINSTANCE.createLinkDescriptionStyle()); + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, linkDescription)); + BarChartDescription barChartDescription = ViewFactory.eINSTANCE.createBarChartDescription(); barChartDescription.setStyle(ViewFactory.eINSTANCE.createBarChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, barChartDescription)); diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java index ef57ccc47d..865b5003ba 100644 --- a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java @@ -25,6 +25,7 @@ import org.eclipse.sirius.components.view.FlexboxContainerDescription; import org.eclipse.sirius.components.view.FormDescription; import org.eclipse.sirius.components.view.LabelDescription; +import org.eclipse.sirius.components.view.LinkDescription; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.PieChartDescription; import org.eclipse.sirius.components.view.RadioDescription; @@ -183,6 +184,10 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors labelDescription.setStyle(ViewFactory.eINSTANCE.createLabelDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, labelDescription)); + LinkDescription linkDescription = ViewFactory.eINSTANCE.createLinkDescription(); + linkDescription.setStyle(ViewFactory.eINSTANCE.createLinkDescriptionStyle()); + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, linkDescription)); + BarChartDescription barChartDescription = ViewFactory.eINSTANCE.createBarChartDescription(); barChartDescription.setStyle(ViewFactory.eINSTANCE.createBarChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, barChartDescription)); diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java new file mode 100644 index 0000000000..154174b6a8 --- /dev/null +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java @@ -0,0 +1,209 @@ +/** + * Copyright (c) 2021, 2022 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.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.ViewFactory; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.LinkDescription} object. + * + * @generated + */ +public class LinkDescriptionItemProvider extends WidgetDescriptionItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public LinkDescriptionItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addValueExpressionPropertyDescriptor(object); + this.addDisplayExpressionPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Value Expression feature. + * + * @generated + */ + protected void addValueExpressionPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LinkDescription_valueExpression_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LinkDescription_valueExpression_feature", "_UI_LinkDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LINK_DESCRIPTION__VALUE_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Display Expression feature. + * + * @generated + */ + protected void addDisplayExpressionPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LinkDescription_displayExpression_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LinkDescription_displayExpression_feature", "_UI_LinkDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LINK_DESCRIPTION__DISPLAY_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (this.childrenFeatures == null) { + super.getChildrenFeatures(object); + this.childrenFeatures.add(ViewPackage.Literals.LINK_DESCRIPTION__STYLE); + this.childrenFeatures.add(ViewPackage.Literals.LINK_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns LinkDescription.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/LinkDescription.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((LinkDescription) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_LinkDescription_type") : //$NON-NLS-1$ + this.getString("_UI_LinkDescription_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(LinkDescription.class)) { + case ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION: + case ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + case ViewPackage.LINK_DESCRIPTION__STYLE: + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.LINK_DESCRIPTION__STYLE, ViewFactory.eINSTANCE.createLinkDescriptionStyle())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.LINK_DESCRIPTION__STYLE, ViewFactory.eINSTANCE.createConditionalLinkDescriptionStyle())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.LINK_DESCRIPTION__CONDITIONAL_STYLES, ViewFactory.eINSTANCE.createConditionalLinkDescriptionStyle())); + } + + /** + * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. + * + * + * @generated + */ + @Override + public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) { + Object childFeature = feature; + Object childObject = child; + + boolean qualify = childFeature == ViewPackage.Literals.LINK_DESCRIPTION__STYLE || childFeature == ViewPackage.Literals.LINK_DESCRIPTION__CONDITIONAL_STYLES; + + if (qualify) { + return this.getString("_UI_CreateChild_text2", //$NON-NLS-1$ + new Object[] { this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner) }); + } + return super.getCreateChildText(owner, feature, child, selection); + } + +} diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..98df553547 --- /dev/null +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java @@ -0,0 +1,201 @@ +/** + * Copyright (c) 2021, 2022 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.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.LinkDescriptionStyle} object. + * + * @generated + */ +public class LinkDescriptionStyleItemProvider extends WidgetDescriptionStyleItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public LinkDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Color feature. + * + * @generated + */ + protected void addColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LinkDescriptionStyle_color_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LinkDescriptionStyle_color_feature", "_UI_LinkDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LINK_DESCRIPTION_STYLE__COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns Style.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/Style.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + LinkDescriptionStyle linkDescriptionStyle = (LinkDescriptionStyle) object; + return this.getString("_UI_LinkDescriptionStyle_type") + " " + linkDescriptionStyle.getFontSize(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(LinkDescriptionStyle.class)) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java index 70e26b02fd..4984f1b184 100644 --- a/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java +++ b/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java @@ -1152,6 +1152,76 @@ public Adapter createConditionalLabelDescriptionStyleAdapter() { return this.conditionalLabelDescriptionStyleItemProvider; } + /** + * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.LinkDescription} + * instances. + * + * @generated + */ + protected LinkDescriptionItemProvider linkDescriptionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.LinkDescription}. + * + * + * @generated + */ + @Override + public Adapter createLinkDescriptionAdapter() { + if (this.linkDescriptionItemProvider == null) { + this.linkDescriptionItemProvider = new LinkDescriptionItemProvider(this); + } + + return this.linkDescriptionItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.LinkDescriptionStyle} + * instances. + * + * @generated + */ + protected LinkDescriptionStyleItemProvider linkDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.LinkDescriptionStyle}. + * + * @generated + */ + @Override + public Adapter createLinkDescriptionStyleAdapter() { + if (this.linkDescriptionStyleItemProvider == null) { + this.linkDescriptionStyleItemProvider = new LinkDescriptionStyleItemProvider(this); + } + + return this.linkDescriptionStyleItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle} instances. + * + * + * @generated + */ + protected ConditionalLinkDescriptionStyleItemProvider conditionalLinkDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle}. + * + * @generated + */ + @Override + public Adapter createConditionalLinkDescriptionStyleAdapter() { + if (this.conditionalLinkDescriptionStyleItemProvider == null) { + this.conditionalLinkDescriptionStyleItemProvider = new ConditionalLinkDescriptionStyleItemProvider(this); + } + + return this.conditionalLinkDescriptionStyleItemProvider; + } + /** * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.BarChartDescription} * instances. @@ -1420,6 +1490,12 @@ public void dispose() { this.labelDescriptionStyleItemProvider.dispose(); if (this.conditionalLabelDescriptionStyleItemProvider != null) this.conditionalLabelDescriptionStyleItemProvider.dispose(); + if (this.linkDescriptionItemProvider != null) + this.linkDescriptionItemProvider.dispose(); + if (this.linkDescriptionStyleItemProvider != null) + this.linkDescriptionStyleItemProvider.dispose(); + if (this.conditionalLinkDescriptionStyleItemProvider != null) + this.conditionalLinkDescriptionStyleItemProvider.dispose(); } } diff --git a/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg b/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg new file mode 100644 index 0000000000..88d5f1bf3b --- /dev/null +++ b/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/backend/sirius-components-view-edit/src/main/resources/plugin.properties b/backend/sirius-components-view-edit/src/main/resources/plugin.properties index 3487d10a99..58baf9713e 100644 --- a/backend/sirius-components-view-edit/src/main/resources/plugin.properties +++ b/backend/sirius-components-view-edit/src/main/resources/plugin.properties @@ -80,6 +80,9 @@ _UI_ConditionalPieChartDescriptionStyle_type = Conditional Pie Chart Description _UI_LabelDescription_type = Label Description _UI_LabelDescriptionStyle_type = Label Description Style _UI_ConditionalLabelDescriptionStyle_type = Conditional Label Description Style +_UI_LinkDescription_type = Link Description +_UI_LinkDescriptionStyle_type = Link Description Style +_UI_ConditionalLinkDescriptionStyle_type = Conditional Link Description Style _UI_Unknown_type = Object _UI_Unknown_datatype= Value @@ -213,6 +216,11 @@ _UI_LabelDescription_displayExpression_feature = Display Expression _UI_LabelDescription_style_feature = Style _UI_LabelDescription_conditionalStyles_feature = Conditional Styles _UI_LabelDescriptionStyle_color_feature = Color +_UI_LinkDescription_valueExpression_feature = Value Expression +_UI_LinkDescription_displayExpression_feature = Display Expression +_UI_LinkDescription_style_feature = Style +_UI_LinkDescription_conditionalStyles_feature = Conditional Styles +_UI_LinkDescriptionStyle_color_feature = Color _UI_Unknown_feature = Unspecified _UI_ArrowStyle_None_literal = None diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java new file mode 100644 index 0000000000..87b8c79cf3 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2021, 2022 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; + +/** + * A representation of the model object 'Conditional Link Description Style'. + * + * + * + * @see org.eclipse.sirius.components.view.ViewPackage#getConditionalLinkDescriptionStyle() + * @model + * @generated + */ +public interface ConditionalLinkDescriptionStyle extends Conditional, LinkDescriptionStyle { +} // ConditionalLinkDescriptionStyle diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java new file mode 100644 index 0000000000..233a209877 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2021, 2022 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; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object 'Link Description'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.LinkDescription#getUrlExpression Url Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.LinkDescription#getDisplayExpression Display Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.LinkDescription#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.LinkDescription#getConditionalStyles Conditional Styles}
  • + *
+ * + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescription() + * @model + * @generated + */ +public interface LinkDescription extends WidgetDescription { + /** + * Returns the value of the 'Value Expression' attribute. + * + * @return the value of the 'Value Expression' attribute. + * @see #setValueExpression(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescription_ValueExpression() + * @model + * @generated + */ + String getValueExpression(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.LinkDescription#getValueExpression Value + * Expression}' attribute. + * + * @param value + * the new value of the 'Value Expression' attribute. + * @see #getValueExpression() + * @generated + */ + void setValueExpression(String value); + + /** + * Returns the value of the 'Display Expression' attribute. The default value is + * "aql:value". + * + * @return the value of the 'Display Expression' attribute. + * @see #setDisplayExpression(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescription_DisplayExpression() + * @model default="aql:value" + * @generated + */ + String getDisplayExpression(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.LinkDescription#getDisplayExpression Display + * Expression}' attribute. + * + * @param value + * the new value of the 'Display Expression' attribute. + * @see #getDisplayExpression() + * @generated + */ + void setDisplayExpression(String value); + + /** + * Returns the value of the 'Style' containment reference. + * + * @return the value of the 'Style' containment reference. + * @see #setStyle(LinkDescriptionStyle) + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescription_Style() + * @model containment="true" + * @generated + */ + LinkDescriptionStyle getStyle(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.LinkDescription#getStyle Style}' + * containment reference. + * + * @param value + * the new value of the 'Style' containment reference. + * @see #getStyle() + * @generated + */ + void setStyle(LinkDescriptionStyle value); + + /** + * Returns the value of the 'Conditional Styles' containment reference list. The list contents are + * of type {@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle}. + * + * @return the value of the 'Conditional Styles' containment reference list. + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescription_ConditionalStyles() + * @model containment="true" + * @generated + */ + EList getConditionalStyles(); + +} // LinkDescription diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java new file mode 100644 index 0000000000..8a3fb2e2a0 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2021, 2022 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; + +/** + * A representation of the model object 'Link Description Style'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.LinkDescriptionStyle#getColor Color}
  • + *
+ * + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescriptionStyle() + * @model + * @generated + */ +public interface LinkDescriptionStyle extends WidgetDescriptionStyle, LabelStyle { + /** + * Returns the value of the 'Color' attribute. + * + * @return the value of the 'Color' attribute. + * @see #setColor(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getLinkDescriptionStyle_Color() + * @model + * @generated + */ + String getColor(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.LinkDescriptionStyle#getColor Color}' + * attribute. + * + * @param value + * the new value of the 'Color' attribute. + * @see #getColor() + * @generated + */ + void setColor(String value); + +} // LinkDescriptionStyle diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java index 9e9e74f855..216457abd0 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java @@ -412,6 +412,31 @@ public interface ViewFactory extends EFactory { */ ConditionalLabelDescriptionStyle createConditionalLabelDescriptionStyle(); + /** + * Returns a new object of class 'Link Description'. + * + * @return a new object of class 'Link Description'. + * @generated + */ + LinkDescription createLinkDescription(); + + /** + * Returns a new object of class 'Link Description Style'. + * + * @return a new object of class 'Link Description Style'. + * @generated + */ + LinkDescriptionStyle createLinkDescriptionStyle(); + + /** + * Returns a new object of class 'Conditional Link Description Style'. + * + * @return a new object of class 'Conditional Link Description Style'. + * @generated + */ + ConditionalLinkDescriptionStyle createConditionalLinkDescriptionStyle(); + /** * Returns a new object of class 'Bar Chart Description'. * diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java index d1afcf02b1..fc7b867afc 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java @@ -4516,6 +4516,246 @@ public interface ViewPackage extends EPackage { */ int CONDITIONAL_LABEL_DESCRIPTION_STYLE_OPERATION_COUNT = CONDITIONAL_OPERATION_COUNT + 0; + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl Link + * Description}' class. + * + * @see org.eclipse.sirius.components.view.impl.LinkDescriptionImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescription() + * @generated + */ + int LINK_DESCRIPTION = 59; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__NAME = WIDGET_DESCRIPTION__NAME; + + /** + * The feature id for the 'Label Expression' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__LABEL_EXPRESSION = WIDGET_DESCRIPTION__LABEL_EXPRESSION; + + /** + * The feature id for the 'Value Expression' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__VALUE_EXPRESSION = WIDGET_DESCRIPTION_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Display Expression' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__DISPLAY_EXPRESSION = WIDGET_DESCRIPTION_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Style' containment reference. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__STYLE = WIDGET_DESCRIPTION_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Conditional Styles' containment reference list. + * + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION__CONDITIONAL_STYLES = WIDGET_DESCRIPTION_FEATURE_COUNT + 3; + + /** + * The number of structural features of the 'Link Description' class. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 4; + + /** + * The number of operations of the 'Link Description' class. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_OPERATION_COUNT = WIDGET_DESCRIPTION_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl Link + * Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescriptionStyle() + * @generated + */ + int LINK_DESCRIPTION_STYLE = 60; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__FONT_SIZE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__ITALIC = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__BOLD = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__UNDERLINE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__STRIKE_THROUGH = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Color' attribute. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE__COLOR = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 5; + + /** + * The number of structural features of the 'Link Description Style' class. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE_FEATURE_COUNT = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 6; + + /** + * The number of operations of the 'Link Description Style' class. + * + * @generated + * @ordered + */ + int LINK_DESCRIPTION_STYLE_OPERATION_COUNT = WIDGET_DESCRIPTION_STYLE_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl + * Conditional Link Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalLinkDescriptionStyle() + * @generated + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE = 61; + + /** + * The feature id for the 'Condition' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__CONDITION = CONDITIONAL__CONDITION; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE = CONDITIONAL_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC = CONDITIONAL_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD = CONDITIONAL_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE = CONDITIONAL_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH = CONDITIONAL_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Color' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR = CONDITIONAL_FEATURE_COUNT + 5; + + /** + * The number of structural features of the 'Conditional Link Description Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE_FEATURE_COUNT = CONDITIONAL_FEATURE_COUNT + 6; + + /** + * The number of operations of the 'Conditional Link Description Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_LINK_DESCRIPTION_STYLE_OPERATION_COUNT = CONDITIONAL_OPERATION_COUNT + 0; + /** * The meta object id for the '{@link org.eclipse.sirius.components.view.ArrowStyle Arrow Style}' enum. * @@ -4524,7 +4764,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getArrowStyle() * @generated */ - int ARROW_STYLE = 59; + int ARROW_STYLE = 62; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.LineStyle Line Style}' enum. + * + * @return the meta object for class 'Link Description'. + * @see org.eclipse.sirius.components.view.LinkDescription + * @generated + */ + EClass getLinkDescription(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.LinkDescription#getValueExpression Value Expression}'. + * + * @return the meta object for the attribute 'Value Expression'. + * @see org.eclipse.sirius.components.view.LinkDescription#getValueExpression() + * @see #getLinkDescription() + * @generated + */ + EAttribute getLinkDescription_ValueExpression(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.LinkDescription#getDisplayExpression Display Expression}'. + * + * + * @return the meta object for the attribute 'Display Expression'. + * @see org.eclipse.sirius.components.view.LinkDescription#getDisplayExpression() + * @see #getLinkDescription() + * @generated + */ + EAttribute getLinkDescription_DisplayExpression(); + + /** + * Returns the meta object for the containment reference + * '{@link org.eclipse.sirius.components.view.LinkDescription#getStyle Style}'. + * + * + * @return the meta object for the containment reference 'Style'. + * @see org.eclipse.sirius.components.view.LinkDescription#getStyle() + * @see #getLinkDescription() + * @generated + */ + EReference getLinkDescription_Style(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.LinkDescription#getConditionalStyles Conditional Styles}'. + * + * + * @return the meta object for the containment reference list 'Conditional Styles'. + * @see org.eclipse.sirius.components.view.LinkDescription#getConditionalStyles() + * @see #getLinkDescription() + * @generated + */ + EReference getLinkDescription_ConditionalStyles(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.LinkDescriptionStyle Link + * Description Style}'. + * + * @return the meta object for class 'Link Description Style'. + * @see org.eclipse.sirius.components.view.LinkDescriptionStyle + * @generated + */ + EClass getLinkDescriptionStyle(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.LinkDescriptionStyle#getColor Color}'. + * + * @return the meta object for the attribute 'Color'. + * @see org.eclipse.sirius.components.view.LinkDescriptionStyle#getColor() + * @see #getLinkDescriptionStyle() + * @generated + */ + EAttribute getLinkDescriptionStyle_Color(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle + * Conditional Link Description Style}'. + * + * @return the meta object for class 'Conditional Link Description Style'. + * @see org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle + * @generated + */ + EClass getConditionalLinkDescriptionStyle(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.BarChartDescription Bar Chart * Description}'. @@ -8235,6 +8565,77 @@ interface Literals { */ EClass CONDITIONAL_LABEL_DESCRIPTION_STYLE = eINSTANCE.getConditionalLabelDescriptionStyle(); + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl Link + * Description}' class. + * + * @see org.eclipse.sirius.components.view.impl.LinkDescriptionImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescription() + * @generated + */ + EClass LINK_DESCRIPTION = eINSTANCE.getLinkDescription(); + + /** + * The meta object literal for the 'Value Expression' attribute feature. + * + * + * @generated + */ + EAttribute LINK_DESCRIPTION__VALUE_EXPRESSION = eINSTANCE.getLinkDescription_ValueExpression(); + + /** + * The meta object literal for the 'Display Expression' attribute feature. + * + * @generated + */ + EAttribute LINK_DESCRIPTION__DISPLAY_EXPRESSION = eINSTANCE.getLinkDescription_DisplayExpression(); + + /** + * The meta object literal for the 'Style' containment reference feature. + * + * @generated + */ + EReference LINK_DESCRIPTION__STYLE = eINSTANCE.getLinkDescription_Style(); + + /** + * The meta object literal for the 'Conditional Styles' containment reference list feature. + * + * @generated + */ + EReference LINK_DESCRIPTION__CONDITIONAL_STYLES = eINSTANCE.getLinkDescription_ConditionalStyles(); + + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl + * Link Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescriptionStyle() + * @generated + */ + EClass LINK_DESCRIPTION_STYLE = eINSTANCE.getLinkDescriptionStyle(); + + /** + * The meta object literal for the 'Color' attribute feature. + * + * @generated + */ + EAttribute LINK_DESCRIPTION_STYLE__COLOR = eINSTANCE.getLinkDescriptionStyle_Color(); + + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl Conditional Link + * Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalLinkDescriptionStyle() + * @generated + */ + EClass CONDITIONAL_LINK_DESCRIPTION_STYLE = eINSTANCE.getConditionalLinkDescriptionStyle(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl * Bar Chart Description}' class. diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java new file mode 100644 index 0000000000..525532db27 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java @@ -0,0 +1,537 @@ +/** + * Copyright (c) 2021, 2022 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.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; +import org.eclipse.sirius.components.view.WidgetDescriptionStyle; + +/** + * An implementation of the model object 'Conditional Link Description Style'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#getFontSize Font + * Size}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#isItalic Italic}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#isBold Bold}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#isUnderline + * Underline}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#isStrikeThrough Strike + * Through}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.ConditionalLinkDescriptionStyleImpl#getColor Color}
  • + *
+ * + * @generated + */ +public class ConditionalLinkDescriptionStyleImpl extends ConditionalImpl implements ConditionalLinkDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getColor() Color}' attribute. + * + * @see #getColor() + * @generated + * @ordered + */ + protected static final String COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getColor() Color}' attribute. + * + * @see #getColor() + * @generated + * @ordered + */ + protected String color = COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected ConditionalLinkDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.CONDITIONAL_LINK_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getColor() { + return this.color; + } + + /** + * + * + * @generated + */ + @Override + public void setColor(String newColor) { + String oldColor = this.color; + this.color = newColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR, oldColor, this.color)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + return this.getColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + this.setColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + this.setColor(COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + return COLOR_EDEFAULT == null ? this.color != null : !COLOR_EDEFAULT.equals(this.color); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (derivedFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == LinkDescriptionStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR: + return ViewPackage.LINK_DESCRIPTION_STYLE__COLOR; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (baseFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == LinkDescriptionStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + return ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE__COLOR; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", color: "); //$NON-NLS-1$ + result.append(this.color); + result.append(')'); + return result.toString(); + } + +} // ConditionalLinkDescriptionStyleImpl diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java new file mode 100644 index 0000000000..bcccea7b84 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java @@ -0,0 +1,359 @@ +/** + * Copyright (c) 2021, 2022 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.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * An implementation of the model object 'Link Description'. + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl#getUrlExpression Url Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl#getDisplayExpression Display + * Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionImpl#getConditionalStyles Conditional + * Styles}
  • + *
+ * + * @generated + */ +public class LinkDescriptionImpl extends WidgetDescriptionImpl implements LinkDescription { + /** + * The default value of the '{@link #getValueExpression() Value Expression}' attribute. + * + * @see #getValueExpression() + * @generated + * @ordered + */ + protected static final String VALUE_EXPRESSION_EDEFAULT = null; + + /** + * The cached value of the '{@link #getValueExpression() Value Expression}' attribute. + * + * @see #getValueExpression() + * @generated + * @ordered + */ + protected String valueExpression = VALUE_EXPRESSION_EDEFAULT; + + /** + * The default value of the '{@link #getDisplayExpression() Display Expression}' attribute. + * + * @see #getDisplayExpression() + * @generated + * @ordered + */ + protected static final String DISPLAY_EXPRESSION_EDEFAULT = "aql:value"; //$NON-NLS-1$ + + /** + * The cached value of the '{@link #getDisplayExpression() Display Expression}' attribute. + * + * @see #getDisplayExpression() + * @generated + * @ordered + */ + protected String displayExpression = DISPLAY_EXPRESSION_EDEFAULT; + + /** + * The cached value of the '{@link #getStyle() Style}' containment reference. + * + * @see #getStyle() + * @generated + * @ordered + */ + protected LinkDescriptionStyle style; + + /** + * The cached value of the '{@link #getConditionalStyles() Conditional Styles}' containment reference list. + * + * + * @see #getConditionalStyles() + * @generated + * @ordered + */ + protected EList conditionalStyles; + + /** + * + * + * @generated + */ + protected LinkDescriptionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.LINK_DESCRIPTION; + } + + /** + * + * + * @generated + */ + @Override + public String getValueExpression() { + return this.valueExpression; + } + + /** + * + * + * @generated + */ + @Override + public void setValueExpression(String newValueExpression) { + String oldValueExpression = this.valueExpression; + this.valueExpression = newValueExpression; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION, oldValueExpression, this.valueExpression)); + } + + /** + * + * + * @generated + */ + @Override + public String getDisplayExpression() { + return this.displayExpression; + } + + /** + * + * + * @generated + */ + @Override + public void setDisplayExpression(String newDisplayExpression) { + String oldDisplayExpression = this.displayExpression; + this.displayExpression = newDisplayExpression; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION, oldDisplayExpression, this.displayExpression)); + } + + /** + * + * + * @generated + */ + @Override + public LinkDescriptionStyle getStyle() { + return this.style; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetStyle(LinkDescriptionStyle newStyle, NotificationChain msgs) { + LinkDescriptionStyle oldStyle = this.style; + this.style = newStyle; + if (this.eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION__STYLE, oldStyle, newStyle); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setStyle(LinkDescriptionStyle newStyle) { + if (newStyle != this.style) { + NotificationChain msgs = null; + if (this.style != null) + msgs = ((InternalEObject) this.style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ViewPackage.LINK_DESCRIPTION__STYLE, null, msgs); + if (newStyle != null) + msgs = ((InternalEObject) newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ViewPackage.LINK_DESCRIPTION__STYLE, null, msgs); + msgs = this.basicSetStyle(newStyle, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION__STYLE, newStyle, newStyle)); + } + + /** + * + * + * @generated + */ + @Override + public EList getConditionalStyles() { + if (this.conditionalStyles == null) { + this.conditionalStyles = new EObjectContainmentEList<>(ConditionalLinkDescriptionStyle.class, this, ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.conditionalStyles; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION__STYLE: + return this.basicSetStyle(null, msgs); + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + return ((InternalEList) this.getConditionalStyles()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION: + return this.getValueExpression(); + case ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION: + return this.getDisplayExpression(); + case ViewPackage.LINK_DESCRIPTION__STYLE: + return this.getStyle(); + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + return this.getConditionalStyles(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION: + this.setValueExpression((String) newValue); + return; + case ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION: + this.setDisplayExpression((String) newValue); + return; + case ViewPackage.LINK_DESCRIPTION__STYLE: + this.setStyle((LinkDescriptionStyle) newValue); + return; + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + this.getConditionalStyles().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION: + this.setValueExpression(VALUE_EXPRESSION_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION: + this.setDisplayExpression(DISPLAY_EXPRESSION_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION__STYLE: + this.setStyle((LinkDescriptionStyle) null); + return; + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION__VALUE_EXPRESSION: + return VALUE_EXPRESSION_EDEFAULT == null ? this.valueExpression != null : !VALUE_EXPRESSION_EDEFAULT.equals(this.valueExpression); + case ViewPackage.LINK_DESCRIPTION__DISPLAY_EXPRESSION: + return DISPLAY_EXPRESSION_EDEFAULT == null ? this.displayExpression != null : !DISPLAY_EXPRESSION_EDEFAULT.equals(this.displayExpression); + case ViewPackage.LINK_DESCRIPTION__STYLE: + return this.style != null; + case ViewPackage.LINK_DESCRIPTION__CONDITIONAL_STYLES: + return this.conditionalStyles != null && !this.conditionalStyles.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (valueExpression: "); //$NON-NLS-1$ + result.append(this.valueExpression); + result.append(", displayExpression: "); //$NON-NLS-1$ + result.append(this.displayExpression); + result.append(')'); + return result.toString(); + } + +} // LinkDescriptionImpl diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java new file mode 100644 index 0000000000..5d2926d724 --- /dev/null +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java @@ -0,0 +1,505 @@ +/** + * Copyright (c) 2021, 2022 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.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * An implementation of the model object 'Link Description Style'. + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#getFontSize Font Size}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#isItalic Italic}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#isBold Bold}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#isUnderline Underline}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#isStrikeThrough Strike + * Through}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.LinkDescriptionStyleImpl#getColor Color}
  • + *
+ * + * @generated + */ +public class LinkDescriptionStyleImpl extends WidgetDescriptionStyleImpl implements LinkDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getColor() Color}' attribute. + * + * @see #getColor() + * @generated + * @ordered + */ + protected static final String COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getColor() Color}' attribute. + * + * @see #getColor() + * @generated + * @ordered + */ + protected String color = COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected LinkDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.LINK_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getColor() { + return this.color; + } + + /** + * + * + * @generated + */ + @Override + public void setColor(String newColor) { + String oldColor = this.color; + this.color = newColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.LINK_DESCRIPTION_STYLE__COLOR, oldColor, this.color)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + return this.getColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + this.setColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + this.setColor(COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.LINK_DESCRIPTION_STYLE__COLOR: + return COLOR_EDEFAULT == null ? this.color != null : !COLOR_EDEFAULT.equals(this.color); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.LINK_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.LINK_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.LINK_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.LINK_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.LINK_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.LINK_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", color: "); //$NON-NLS-1$ + result.append(this.color); + result.append(')'); + return result.toString(); + } + +} // LinkDescriptionStyleImpl diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java index b46acaf72e..64a4831a07 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java @@ -28,6 +28,7 @@ import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalLabelDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; @@ -52,6 +53,8 @@ import org.eclipse.sirius.components.view.LabelDescriptionStyle; import org.eclipse.sirius.components.view.LabelEditTool; import org.eclipse.sirius.components.view.LineStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.NodeDescription; @@ -212,6 +215,12 @@ public EObject create(EClass eClass) { return this.createLabelDescriptionStyle(); case ViewPackage.CONDITIONAL_LABEL_DESCRIPTION_STYLE: return this.createConditionalLabelDescriptionStyle(); + case ViewPackage.LINK_DESCRIPTION: + return this.createLinkDescription(); + case ViewPackage.LINK_DESCRIPTION_STYLE: + return this.createLinkDescriptionStyle(); + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE: + return this.createConditionalLinkDescriptionStyle(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -765,6 +774,39 @@ public ConditionalLabelDescriptionStyle createConditionalLabelDescriptionStyle() return conditionalLabelDescriptionStyle; } + /** + * + * + * @generated + */ + @Override + public LinkDescription createLinkDescription() { + LinkDescriptionImpl linkDescription = new LinkDescriptionImpl(); + return linkDescription; + } + + /** + * + * + * @generated + */ + @Override + public LinkDescriptionStyle createLinkDescriptionStyle() { + LinkDescriptionStyleImpl linkDescriptionStyle = new LinkDescriptionStyleImpl(); + return linkDescriptionStyle; + } + + /** + * + * + * @generated + */ + @Override + public ConditionalLinkDescriptionStyle createConditionalLinkDescriptionStyle() { + ConditionalLinkDescriptionStyleImpl conditionalLinkDescriptionStyle = new ConditionalLinkDescriptionStyleImpl(); + return conditionalLinkDescriptionStyle; + } + /** * * diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java index c0d8840616..ddbe7630db 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java @@ -30,6 +30,7 @@ import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalLabelDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; @@ -56,6 +57,8 @@ import org.eclipse.sirius.components.view.LabelEditTool; import org.eclipse.sirius.components.view.LabelStyle; import org.eclipse.sirius.components.view.LineStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.NodeDescription; @@ -482,6 +485,27 @@ public class ViewPackageImpl extends EPackageImpl implements ViewPackage { */ private EClass conditionalLabelDescriptionStyleEClass = null; + /** + * + * + * @generated + */ + private EClass linkDescriptionEClass = null; + + /** + * + * + * @generated + */ + private EClass linkDescriptionStyleEClass = null; + + /** + * + * + * @generated + */ + private EClass conditionalLinkDescriptionStyleEClass = null; + /** * * @@ -2332,6 +2356,86 @@ public EClass getConditionalLabelDescriptionStyle() { return this.conditionalLabelDescriptionStyleEClass; } + /** + * + * + * @generated + */ + @Override + public EClass getLinkDescription() { + return this.linkDescriptionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getLinkDescription_ValueExpression() { + return (EAttribute) this.linkDescriptionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getLinkDescription_DisplayExpression() { + return (EAttribute) this.linkDescriptionEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getLinkDescription_Style() { + return (EReference) this.linkDescriptionEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getLinkDescription_ConditionalStyles() { + return (EReference) this.linkDescriptionEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EClass getLinkDescriptionStyle() { + return this.linkDescriptionStyleEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getLinkDescriptionStyle_Color() { + return (EAttribute) this.linkDescriptionStyleEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getConditionalLinkDescriptionStyle() { + return this.conditionalLinkDescriptionStyleEClass; + } + /** * * @@ -2788,6 +2892,17 @@ public void createPackageContents() { this.conditionalLabelDescriptionStyleEClass = this.createEClass(CONDITIONAL_LABEL_DESCRIPTION_STYLE); + this.linkDescriptionEClass = this.createEClass(LINK_DESCRIPTION); + this.createEAttribute(this.linkDescriptionEClass, LINK_DESCRIPTION__VALUE_EXPRESSION); + this.createEAttribute(this.linkDescriptionEClass, LINK_DESCRIPTION__DISPLAY_EXPRESSION); + this.createEReference(this.linkDescriptionEClass, LINK_DESCRIPTION__STYLE); + this.createEReference(this.linkDescriptionEClass, LINK_DESCRIPTION__CONDITIONAL_STYLES); + + this.linkDescriptionStyleEClass = this.createEClass(LINK_DESCRIPTION_STYLE); + this.createEAttribute(this.linkDescriptionStyleEClass, LINK_DESCRIPTION_STYLE__COLOR); + + this.conditionalLinkDescriptionStyleEClass = this.createEClass(CONDITIONAL_LINK_DESCRIPTION_STYLE); + // Create enums this.arrowStyleEEnum = this.createEEnum(ARROW_STYLE); this.lineStyleEEnum = this.createEEnum(LINE_STYLE); @@ -2893,6 +3008,11 @@ public void initializePackageContents() { this.labelDescriptionStyleEClass.getESuperTypes().add(this.getLabelStyle()); this.conditionalLabelDescriptionStyleEClass.getESuperTypes().add(this.getConditional()); this.conditionalLabelDescriptionStyleEClass.getESuperTypes().add(this.getLabelDescriptionStyle()); + this.linkDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); + this.linkDescriptionStyleEClass.getESuperTypes().add(this.getWidgetDescriptionStyle()); + this.linkDescriptionStyleEClass.getESuperTypes().add(this.getLabelStyle()); + this.conditionalLinkDescriptionStyleEClass.getESuperTypes().add(this.getConditional()); + this.conditionalLinkDescriptionStyleEClass.getESuperTypes().add(this.getLinkDescriptionStyle()); // Initialize classes, features, and operations; add parameters this.initEClass(this.viewEClass, View.class, "View", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -3280,6 +3400,22 @@ public void initializePackageContents() { this.initEClass(this.conditionalLabelDescriptionStyleEClass, ConditionalLabelDescriptionStyle.class, "ConditionalLabelDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, //$NON-NLS-1$ IS_GENERATED_INSTANCE_CLASS); + this.initEClass(this.linkDescriptionEClass, LinkDescription.class, "LinkDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + this.initEAttribute(this.getLinkDescription_ValueExpression(), this.ecorePackage.getEString(), "valueExpression", null, 0, 1, LinkDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, //$NON-NLS-1$ + !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEAttribute(this.getLinkDescription_DisplayExpression(), this.ecorePackage.getEString(), "displayExpression", "aql:value", 0, 1, LinkDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ //$NON-NLS-2$ + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getLinkDescription_Style(), this.getLinkDescriptionStyle(), null, "style", null, 0, 1, LinkDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, //$NON-NLS-1$ + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getLinkDescription_ConditionalStyles(), this.getConditionalLinkDescriptionStyle(), null, "conditionalStyles", null, 0, -1, LinkDescription.class, !IS_TRANSIENT, //$NON-NLS-1$ + !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.linkDescriptionStyleEClass, LinkDescriptionStyle.class, "LinkDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + this.initEAttribute(this.getLinkDescriptionStyle_Color(), this.ecorePackage.getEString(), "color", null, 0, 1, LinkDescriptionStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, //$NON-NLS-1$ + !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.conditionalLinkDescriptionStyleEClass, ConditionalLinkDescriptionStyle.class, "ConditionalLinkDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + // Initialize enums and add enum literals this.initEEnum(this.arrowStyleEEnum, ArrowStyle.class, "ArrowStyle"); //$NON-NLS-1$ this.addEEnumLiteral(this.arrowStyleEEnum, ArrowStyle.NONE); diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java index 813b605884..36e86670f0 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java @@ -27,6 +27,7 @@ import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalLabelDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; @@ -51,6 +52,8 @@ import org.eclipse.sirius.components.view.LabelDescriptionStyle; import org.eclipse.sirius.components.view.LabelEditTool; import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.NodeDescription; @@ -423,6 +426,21 @@ public Adapter caseConditionalLabelDescriptionStyle(ConditionalLabelDescriptionS return ViewAdapterFactory.this.createConditionalLabelDescriptionStyleAdapter(); } + @Override + public Adapter caseLinkDescription(LinkDescription object) { + return ViewAdapterFactory.this.createLinkDescriptionAdapter(); + } + + @Override + public Adapter caseLinkDescriptionStyle(LinkDescriptionStyle object) { + return ViewAdapterFactory.this.createLinkDescriptionStyleAdapter(); + } + + @Override + public Adapter caseConditionalLinkDescriptionStyle(ConditionalLinkDescriptionStyle object) { + return ViewAdapterFactory.this.createConditionalLinkDescriptionStyleAdapter(); + } + @Override public Adapter defaultCase(EObject object) { return ViewAdapterFactory.this.createEObjectAdapter(); @@ -1210,6 +1228,47 @@ public Adapter createConditionalLabelDescriptionStyleAdapter() { return null; } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.LinkDescription Link + * Description}'. This default implementation returns null so that we can easily ignore + * cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.LinkDescription + * @generated + */ + public Adapter createLinkDescriptionAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.LinkDescriptionStyle + * Link Description Style}'. This default implementation returns null so that we + * can easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.LinkDescriptionStyle + * @generated + */ + public Adapter createLinkDescriptionStyleAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle Conditional Link Description + * Style}'. This default implementation returns null so that we can easily ignore + * cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle + * @generated + */ + public Adapter createConditionalLinkDescriptionStyleAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.BarChartDescription * Bar Chart Description}'. This default implementation returns null so that we can diff --git a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java index 5f909cfb8b..c2a260ccbb 100644 --- a/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java +++ b/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java @@ -26,6 +26,7 @@ import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalLabelDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalLinkDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; @@ -50,6 +51,8 @@ import org.eclipse.sirius.components.view.LabelDescriptionStyle; import org.eclipse.sirius.components.view.LabelEditTool; import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.LinkDescription; +import org.eclipse.sirius.components.view.LinkDescriptionStyle; import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.NodeDescription; @@ -724,6 +727,41 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case ViewPackage.LINK_DESCRIPTION: { + LinkDescription linkDescription = (LinkDescription) theEObject; + T result = this.caseLinkDescription(linkDescription); + if (result == null) + result = this.caseWidgetDescription(linkDescription); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case ViewPackage.LINK_DESCRIPTION_STYLE: { + LinkDescriptionStyle linkDescriptionStyle = (LinkDescriptionStyle) theEObject; + T result = this.caseLinkDescriptionStyle(linkDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(linkDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(linkDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case ViewPackage.CONDITIONAL_LINK_DESCRIPTION_STYLE: { + ConditionalLinkDescriptionStyle conditionalLinkDescriptionStyle = (ConditionalLinkDescriptionStyle) theEObject; + T result = this.caseConditionalLinkDescriptionStyle(conditionalLinkDescriptionStyle); + if (result == null) + result = this.caseConditional(conditionalLinkDescriptionStyle); + if (result == null) + result = this.caseLinkDescriptionStyle(conditionalLinkDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(conditionalLinkDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(conditionalLinkDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } default: return this.defaultCase(theEObject); } @@ -1558,6 +1596,51 @@ public T caseConditionalLabelDescriptionStyle(ConditionalLabelDescriptionStyle o return null; } + /** + * Returns the result of interpreting the object as an instance of 'Link Description'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Link Description'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseLinkDescription(LinkDescription object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Link Description Style'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Link Description Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseLinkDescriptionStyle(LinkDescriptionStyle object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Conditional Link Description Style'. + * This implementation returns null; returning a non-null result will terminate the switch. + * + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Conditional Link Description Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseConditionalLinkDescriptionStyle(ConditionalLinkDescriptionStyle object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Bar Chart Description'. This implementation returns null; returning a non-null result will terminate the switch.