From ca0968ba13e09f9853e06e8080eedd797ff4f76f 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 | 6 +- .../src/main/resources/schema/form.graphqls | 11 + .../eclipse/sirius/components/forms/Link.java | 32 +- .../sirius/components/forms/LinkStyle.java | 112 ++++ .../forms/components/LinkComponent.java | 21 +- .../forms/description/LinkDescription.java | 31 + .../forms/elements/LinkElementProps.java | 33 +- .../forms/renderer/FormElementFactory.java | 8 +- .../src/form/FormEventFragments.ts | 9 + .../src/form/FormEventFragments.types.ts | 11 + .../propertysections/LinkPropertySection.tsx | 37 +- .../LinkPropertySection.types.ts | 3 +- .../src/propertysections/PropertySection.tsx | 2 +- .../__tests__/LinkPropertySection.test.tsx | 76 +++ .../LinkPropertySection.test.tsx.snap | 57 ++ ...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/emf/form/LinkStyleProvider.java | 61 ++ .../ViewFormDescriptionConverterSwitch.java | 38 ++ .../view/emf/view/DynamicFormsTests.java | 78 ++- .../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 | 360 ++++++++++++ .../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 + 40 files changed, 3682 insertions(+), 25 deletions(-) create mode 100644 packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java create mode 100644 packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/LinkPropertySection.test.tsx create mode 100644 packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/LinkPropertySection.test.tsx.snap create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/LinkStyleProvider.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a2618e7b82..d715085f93 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,9 @@ https://github.com/eclipse-sirius/sirius-components/issues/1231[#1231] [workbenc https://github.com/eclipse-sirius/sirius-components/issues/1231[#1231] [workbench] Move the workbench related code to `@eclipse-sirius/sirius-components-core`. This move includes components such as `Workbench`, `RepresentationContext`, `WorkbenchViewContribution` for example https://github.com/eclipse-sirius/sirius-components/issues/1231[#1231] [diagram] Move the code of the diagram and the selection wizard in the packages `@eclipse-sirius/sirius-components-diagrams` and `@eclipse-sirius/sirius-components-selection` - https://github.com/eclipse-sirius/sirius-components/issues/1231[#1231] [core] Some code remain in the soon to be deprecated Sirius Component package `@eclipse-sirius/sirius-components`. Most of this code will either be moved to Sirius Web or be removed entirely (such as the old non MaterialUI widgets) +- https://github.com/eclipse-sirius/sirius-components/issues/1281[#1281] [form] The `LinkDescription` now requires a `displayProvider` and a `styleProvider`. The `displayProvider` is used to display the text of the hyperLink. +The GraphQL API has also been changed with two additional fields on the type `Link`: `display` and `style` (optional). The front-end use the `display` value instead of the `label` value to display the hyperlink text. +The `label` value is displayed before the widget to be consistent with other properties sections. === Dependency update @@ -44,7 +47,8 @@ https://github.com/eclipse-sirius/sirius-components/issues/1231[#1231] [diagram] - https://github.com/eclipse-sirius/sirius-components/issues/1272[#1272] [form] Add support for button widget on FormDescriptions - https://github.com/eclipse-sirius/sirius-components/issues/1273[#1273] [form] Add support for button widget on FormDescriptionEditors - 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.7.0 diff --git a/packages/forms/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls b/packages/forms/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls index 9a247fd61c..c75ea15b72 100644 --- a/packages/forms/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls +++ b/packages/forms/backend/sirius-components-collaborative-forms/src/main/resources/schema/form.graphqls @@ -250,6 +250,17 @@ type Link implements Widget { label: String! iconURL: String url: String! + display: String! + style: LinkStyle +} + +type LinkStyle { + color: String + fontSize: Int + italic: Boolean + bold: Boolean + underline: Boolean + strikeThrough: Boolean } type Button implements Widget { diff --git a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java index e8b6cf1d64..32b7c42b76 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java +++ b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/Link.java @@ -29,6 +29,10 @@ public final class Link extends AbstractWidget { private String url; + private String display; + + private LinkStyle style; + private Link() { // Prevent instantiation } @@ -37,14 +41,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); } /** @@ -62,6 +74,10 @@ public static final class Builder { private String url; + private String display; + + private LinkStyle style; + private List diagnostics; private Builder(String id) { @@ -83,6 +99,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; @@ -94,6 +120,8 @@ public Link build() { link.label = Objects.requireNonNull(this.label); link.iconURL = this.iconURL; 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/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/LinkStyle.java new file mode 100644 index 0000000000..2f5c64454e --- /dev/null +++ b/packages/forms/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/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java index d4150c2099..00448ae03d 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java +++ b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/LinkComponent.java @@ -15,9 +15,9 @@ 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.elements.LinkElementProps.Builder; import org.eclipse.sirius.components.forms.validation.DiagnosticComponent; import org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps; import org.eclipse.sirius.components.representations.Element; @@ -46,15 +46,28 @@ public Element render() { String label = linkDescription.getLabelProvider().apply(variableManager); String iconURL = linkDescription.getIconURLProvider().apply(variableManager); String url = linkDescription.getUrlProvider().apply(variableManager); + VariableManager displayVariableManager = variableManager.createChild(); + displayVariableManager.put(LinkDescription.VALUE, url); + String display = linkDescription.getDisplayProvider().apply(displayVariableManager); + LinkStyle style = linkDescription.getStyleProvider().apply(variableManager); List children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(linkDescription, variableManager))); - // @formatter:on - Builder linkElementPropsBuilder = LinkElementProps.newLinkElementProps(id).label(label).url(url).children(children); // @formatter:off + LinkElementProps.Builder linkElementPropsBuilder = LinkElementProps.newLinkElementProps(id) + .label(label) + .url(url) + .display(display) + .children(children); + // @formatter:on + if (style != null) { + linkElementPropsBuilder.style(style); + } if (iconURL != null) { linkElementPropsBuilder.iconURL(iconURL); } - return new Element(LinkElementProps.TYPE, linkElementPropsBuilder.build()); + + LinkElementProps linkElementProps = linkElementPropsBuilder.build(); + return new Element(LinkElementProps.TYPE, linkElementProps); } } diff --git a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java index df86d60e31..dbc0beefbf 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/description/LinkDescription.java +++ b/packages/forms/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,6 +28,8 @@ */ @Immutable public final class LinkDescription extends AbstractWidgetDescription { + public static final String VALUE = "value"; //$NON-NLS-1$ + private Function idProvider; private Function labelProvider; @@ -35,6 +38,10 @@ public final class LinkDescription extends AbstractWidgetDescription { private Function urlProvider; + private Function displayProvider; + + private Function styleProvider; + private LinkDescription() { // Prevent instantiation } @@ -55,6 +62,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); } @@ -82,6 +97,10 @@ public static final class Builder { private Function urlProvider; + private Function displayProvider; + + private Function styleProvider; + private Function> diagnosticsProvider; private Function kindProvider; @@ -112,6 +131,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; @@ -134,6 +163,8 @@ public LinkDescription build() { linkDescription.labelProvider = Objects.requireNonNull(this.labelProvider); linkDescription.iconURLProvider = Objects.requireNonNull(this.iconURLProvider); 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/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java index cd40149752..ecb9ace40f 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/elements/LinkElementProps.java +++ b/packages/forms/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; @@ -37,6 +38,10 @@ public final class LinkElementProps implements IProps { private String url; + private String display; + + private LinkStyle style; + private List children; private LinkElementProps() { @@ -59,6 +64,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; @@ -70,8 +83,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); } /** @@ -89,6 +102,10 @@ public static final class Builder { private String url; + private String display; + + private LinkStyle style; + private List children; private Builder(String id) { @@ -110,6 +127,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; @@ -121,6 +148,8 @@ public LinkElementProps build() { linkElementProps.label = Objects.requireNonNull(this.label); linkElementProps.iconURL = this.iconURL; 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/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java index 7349df5cba..233dad09ac 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java +++ b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java @@ -348,6 +348,7 @@ private Textfield instantiateTextfield(TextfieldElementProps props, List .value(props.getValue()) .newValueHandler(props.getNewValueHandler()) .diagnostics(diagnostics); + // @formatter:on if (props.getIconURL() != null) { textfieldBuilder.iconURL(props.getIconURL()); @@ -357,7 +358,6 @@ private Textfield instantiateTextfield(TextfieldElementProps props, List } return textfieldBuilder.build(); - // @formatter:on } private Object instantiateDiagnostic(DiagnosticElementProps props, List children) { @@ -376,9 +376,13 @@ private Link instantiateLink(LinkElementProps props, List children) { Link.Builder linkbuilder = Link.newLink(props.getId()) .label(props.getLabel()) .url(props.getUrl()) + .display(props.getDisplay()) .diagnostics(diagnostics); - // @formatter:on + // @formatter:on + if (props.getStyle() != null) { + linkbuilder.style(props.getStyle()); + } if (props.getIconURL() != null) { linkbuilder.iconURL(props.getIconURL()); } diff --git a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts index 3f01757c0a..437de5518e 100644 --- a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts +++ b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts @@ -219,6 +219,15 @@ export const formRefreshedEventPayloadFragment = ` label iconURL url + display + style { + color + fontSize + italic + bold + underline + strikeThrough + } } fragment buttonFields on Button { diff --git a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts index b4ce11aac4..250c1acff8 100644 --- a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts +++ b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts @@ -237,6 +237,17 @@ export interface GQLListItem { export interface GQLLink extends GQLWidget { url: string; + display: string; + style: GQLLinkStyle; +} + +export interface GQLLinkStyle { + color: string | null; + fontSize: number | null; + italic: boolean | null; + bold: boolean | null; + underline: boolean | null; + strikeThrough: boolean | null; } export interface GQLButton extends GQLWidget { diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.tsx index 6eb0dc73aa..bfda3be051 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.tsx @@ -11,16 +11,47 @@ * Obeo - initial API and implementation *******************************************************************************/ import Link from '@material-ui/core/Link'; +import { makeStyles, Theme } from '@material-ui/core/styles'; import { LinkPropertySectionProps } from './LinkPropertySection.types'; +import { PropertySectionLabel } from './PropertySectionLabel'; +import { getTextDecorationLineValue } from './getTextDecorationLineValue'; +interface StyleProps { + color: string | null; + fontSize: number | null; + italic: boolean | null; + bold: boolean | null; + underline: boolean | null; + strikeThrough: boolean | null; +} +const useStyle = makeStyles(() => ({ + style: { + color: ({ color }) => (color ? color : 'inherit'), + fontSize: ({ fontSize }) => (fontSize ? fontSize : 'inherit'), + fontStyle: ({ italic }) => (italic ? 'italic' : 'inherit'), + fontWeight: ({ bold }) => (bold ? 'bold' : 'inherit'), + textDecorationLine: ({ underline, strikeThrough }) => getTextDecorationLineValue(underline, strikeThrough), + }, +})); /** * Defines the content of a Link property section. */ -export const LinkPropertySection = ({ widget }: LinkPropertySectionProps) => { +export const LinkPropertySection = ({ widget, subscribers }: LinkPropertySectionProps) => { + const props: StyleProps = { + color: widget.style?.color ?? null, + fontSize: widget.style?.fontSize ?? null, + italic: widget.style?.italic ?? null, + bold: widget.style?.bold ?? null, + underline: widget.style?.underline ?? null, + strikeThrough: widget.style?.strikeThrough ?? null, + }; + + const classes = useStyle(props); return (
- - {widget.label} + + + {widget.display}
); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.types.ts b/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.types.ts index c47466d378..72a8530f60 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.types.ts +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/LinkPropertySection.types.ts @@ -10,8 +10,9 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { GQLLink } from '../form/FormEventFragments.types'; +import { GQLLink, GQLSubscriber } from '../form/FormEventFragments.types'; export interface LinkPropertySectionProps { widget: GQLLink; + subscribers: GQLSubscriber[]; } diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/PropertySection.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/PropertySection.tsx index f5a8a71ecd..4b1898e11c 100644 --- a/packages/forms/frontend/sirius-components-forms/src/propertysections/PropertySection.tsx +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/PropertySection.tsx @@ -138,7 +138,7 @@ export const PropertySection = ({ /> ); } else if (isLink(widget)) { - propertySection = ; + propertySection = ; } else if (isButton(widget)) { propertySection = ( ({ v4: () => '48be95fc-3422-45d3-b1f9-d590e847e9e1' })); + +afterEach(() => cleanup()); + +const defaultLink: GQLLink = { + label: 'myLabel', + url: 'the/url/value', + iconURL: null, + display: 'the displayed value', + style: { + color: null, + bold: null, + fontSize: null, + italic: null, + strikeThrough: null, + underline: null, + }, + __typename: 'Label', + diagnostics: [], + id: 'labelId', +}; + +const defaultLinkWithStyle: GQLLink = { + label: 'myLabel', + url: 'the/url/value', + iconURL: null, + display: 'the displayed value', + style: { + color: 'RebeccaPurple', + bold: true, + fontSize: 20, + italic: true, + strikeThrough: true, + underline: true, + }, + __typename: 'Label', + diagnostics: [], + id: 'labelId', +}; + +test('render label widget', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render label widget with style', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/LinkPropertySection.test.tsx.snap b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/LinkPropertySection.test.tsx.snap new file mode 100644 index 0000000000..8656e253bf --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/LinkPropertySection.test.tsx.snap @@ -0,0 +1,57 @@ +// Vitest Snapshot v1 + +exports[`render label widget 1`] = ` +
+
+
+
+ myLabel +
+
+
+ + the displayed value + +
+
+`; + +exports[`render label widget with style 1`] = ` +
+
+
+
+ myLabel +
+
+
+ + the displayed value + +
+
+`; diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalLinkDescriptionStyleItemProvider.java b/packages/view/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/packages/view/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/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java index 41f12a6605..08010332cd 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java @@ -28,6 +28,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; @@ -209,6 +210,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/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java index 1c029e11e3..ec9b69c35f 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java @@ -26,6 +26,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; @@ -188,6 +189,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/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionItemProvider.java b/packages/view/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/packages/view/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/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/LinkDescriptionStyleItemProvider.java b/packages/view/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/packages/view/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/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java index c6ec0c004c..4c5106846d 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java @@ -1200,6 +1200,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. @@ -1497,6 +1567,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/packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg b/packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/LinkDescription.svg new file mode 100644 index 0000000000..88d5f1bf3b --- /dev/null +++ b/packages/view/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/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties b/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties index 175287d0f4..27af9dcdb6 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties +++ b/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties @@ -83,6 +83,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 @@ -223,6 +226,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/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/LinkStyleProvider.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/LinkStyleProvider.java new file mode 100644 index 0000000000..97c355d8bd --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/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.view.emf.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/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java index 8f4c654008..4d42adae6f 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/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; @@ -51,6 +52,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; @@ -65,6 +67,7 @@ import org.eclipse.sirius.components.view.ButtonDescriptionStyle; 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; @@ -466,6 +469,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/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java b/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java index 4efe99e36d..1ff2df7d39 100644 --- a/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java +++ b/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java @@ -44,6 +44,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; @@ -71,6 +73,7 @@ import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; 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; @@ -82,6 +85,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; @@ -128,7 +133,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(11); + assertThat(group.getWidgets()).hasSize(12); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -140,6 +145,7 @@ void testRenderEcoreForm() throws Exception { FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); Button button = (Button) group.getWidgets().get(9); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(10); + Link link = (Link) group.getWidgets().get(11); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -168,6 +174,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$ @@ -297,7 +308,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(11); + assertThat(group.getWidgets()).hasSize(12); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -309,6 +320,7 @@ void testRenderEcoreFormWithStyle() throws Exception { FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); Button button = (Button) group.getWidgets().get(9); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(10); + Link link = (Link) group.getWidgets().get(11); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -353,6 +365,12 @@ void testRenderEcoreFormWithStyle() throws Exception { assertThat(button.getButtonLabel()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(button.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ this.testStyle(button); + + 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); @@ -388,7 +406,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(11); + assertThat(group.getWidgets()).hasSize(12); Textfield textfield = (Textfield) group.getWidgets().get(0); Textarea textarea = (Textarea) group.getWidgets().get(1); MultiSelect multiSelect = (MultiSelect) group.getWidgets().get(2); @@ -400,6 +418,7 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); Button button = (Button) group.getWidgets().get(9); LabelWidget labelWidget = (LabelWidget) group.getWidgets().get(10); + Link link = (Link) group.getWidgets().get(11); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(textfield.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ @@ -445,6 +464,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); @@ -473,7 +497,7 @@ 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(11); + assertThat(form.getPages()).flatExtracting(Page::getGroups).flatExtracting(Group::getWidgets).hasSize(12); this.checkValuesEditing(this.eClass1, form); } @@ -493,7 +517,7 @@ void testSetNullOnSelectEcoreForm() throws Exception { private void checkValuesEditing(EClass eClass, Form form) { Group group = form.getPages().get(0).getGroups().get(0); - assertThat(group.getWidgets()).hasSize(11); + assertThat(group.getWidgets()).hasSize(12); Textfield textfield = (Textfield) group.getWidgets().get(0); assertThat(textfield.getValue()).isEqualTo("Class1"); //$NON-NLS-1$ @@ -587,6 +611,8 @@ private FormDescription createClassFormDescription(boolean withStyle, boolean wi formDescription.getWidgets().add(buttonDescription); LabelDescription labelDescription = this.createLabel(withStyle, withConditionalStyle); formDescription.getWidgets().add(labelDescription); + LinkDescription linkDescription = this.createLink(withStyle, withConditionalStyle); + formDescription.getWidgets().add(linkDescription); return formDescription; } @@ -875,6 +901,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); @@ -952,6 +1001,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalLinkDescriptionStyle.java new file mode 100644 index 0000000000..87b8c79cf3 --- /dev/null +++ b/packages/view/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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescription.java new file mode 100644 index 0000000000..5f5470df4a --- /dev/null +++ b/packages/view/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#getValueExpression Value 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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/LinkDescriptionStyle.java new file mode 100644 index 0000000000..8a3fb2e2a0 --- /dev/null +++ b/packages/view/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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java index bfe935c321..7c93fe5007 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java @@ -429,6 +429,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java index 235e262893..cdeb47f867 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java @@ -4786,6 +4786,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 = 62; + + /** + * 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 = 63; + + /** + * 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 = 64; + + /** + * 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. * @@ -4794,7 +5034,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getArrowStyle() * @generated */ - int ARROW_STYLE = 62; + int ARROW_STYLE = 65; /** * 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}'. @@ -8656,6 +8986,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalLinkDescriptionStyleImpl.java b/packages/view/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/packages/view/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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java new file mode 100644 index 0000000000..78c6af70f8 --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionImpl.java @@ -0,0 +1,360 @@ +/** + * 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#getValueExpression Value + * 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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/LinkDescriptionStyleImpl.java b/packages/view/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/packages/view/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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java index 48a66f2707..5b5e8a26fe 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java @@ -31,6 +31,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; @@ -55,6 +56,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; @@ -221,6 +224,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$ } @@ -796,6 +805,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java index 6c13f3f12c..d1920ebf12 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java @@ -33,6 +33,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; @@ -59,6 +60,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; @@ -499,6 +502,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; + /** * * @@ -2396,6 +2420,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; + } + /** * * @@ -2925,6 +3029,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); @@ -3035,6 +3150,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$ @@ -3443,6 +3563,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java index 6ebb7aeabd..e72820cb6f 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.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; @@ -54,6 +55,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; @@ -441,6 +444,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(); @@ -1256,6 +1274,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/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java index 483df4f549..4fbf1b02b7 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java @@ -29,6 +29,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; @@ -53,6 +54,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; @@ -762,6 +765,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); } @@ -1626,6 +1664,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.