From b74bbec265bc2b834641192b7efb0a03e7d9fdd5 Mon Sep 17 00:00:00 2001 From: Pierre-Charles David Date: Wed, 14 Sep 2022 15:30:17 +0200 Subject: [PATCH] [DRAFT 1346] Add richtext in view-based forms and form description editors Bug: https://github.com/eclipse-sirius/sirius-components/issues/1346 Signed-off-by: Pierre-Charles David --- .../FormDescriptionEditorRepresentation.tsx | 12 + ...rmDescriptionEditorRepresentation.types.ts | 3 +- .../src/RichTextWidget.tsx | 61 ++++ .../src/WidgetEntry.tsx | 11 + .../src/WidgetOperations.tsx | 3 +- .../plugin.properties | 267 ++++++++++++++++++ .../RichTextDescriptionItemProvider.java | 181 ++++++++++++ .../ViewItemProviderAdapterFactory.java | 25 ++ .../icons/full/obj16/RichTextDescription.gif | Bin 0 -> 129 bytes .../src/main/resources/plugin.properties | 5 +- .../ViewFormDescriptionConverterSwitch.java | 22 ++ .../components/view/RichTextDescription.java | 68 +++++ .../sirius/components/view/ViewFactory.java | 8 + .../sirius/components/view/ViewPackage.java | 197 ++++++++++--- .../view/impl/RichTextDescriptionImpl.java | 230 +++++++++++++++ .../components/view/impl/ViewFactoryImpl.java | 14 + .../components/view/impl/ViewPackageImpl.java | 49 ++++ .../view/util/ViewAdapterFactory.java | 20 ++ .../components/view/util/ViewSwitch.java | 25 ++ .../src/main/resources/model/view.ecore | 5 + .../src/main/resources/model/view.genmodel | 4 + 21 files changed, 1169 insertions(+), 41 deletions(-) create mode 100644 packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/RichTextWidget.tsx create mode 100644 packages/view/backend/sirius-components-view-edit/plugin.properties create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RichTextDescriptionItemProvider.java create mode 100644 packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/RichTextDescription.gif create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/RichTextDescription.java create mode 100644 packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RichTextDescriptionImpl.java diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx index 2eaa500777..dbfe826d01 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/FormDescriptionEditorRepresentation.tsx @@ -25,6 +25,7 @@ import CloseIcon from '@material-ui/icons/Close'; import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; import LabelOutlinedIcon from '@material-ui/icons/LabelOutlined'; import LinkIcon from '@material-ui/icons/Link'; +import NotesIcon from '@material-ui/icons/Notes'; import PieChartIcon from '@material-ui/icons/PieChart'; import RadioButtonCheckedIcon from '@material-ui/icons/RadioButtonChecked'; import TextFieldsIcon from '@material-ui/icons/TextFields'; @@ -322,6 +323,17 @@ export const FormDescriptionEditorRepresentation = ({ Textarea +
+ + + Rich Text + +
{' '}
({ + selected: { + color: theme.palette.primary.main, + }, +})); + +export const RichTextWidget = ({ widget, selection }: WidgetProps) => { + const classes = useStyles(); + + const [selected, setSelected] = useState(false); + + const ref = useRef(null); + + useEffect(() => { + if (ref.current && selection.entries.find((entry) => entry.id === widget.id)) { + ref.current.focus(); + setSelected(true); + } else { + setSelected(false); + } + }, [selection, widget]); + + return ( +
+ + {widget.label} + + setSelected(true)} + onBlur={() => setSelected(false)} + InputProps={{ + readOnly: true, + }} + value="Rich text in mardown format" + /> +
+ ); +}; diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx index de015e7049..586f0afabe 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/WidgetEntry.tsx @@ -46,6 +46,7 @@ import { ListWidget } from './ListWidget'; import { MultiSelectWidget } from './MultiSelectWidget'; import { PieChartWidget } from './PieChartWidget'; import { RadioWidget } from './RadioWidget'; +import { RichTextWidget } from './RichTextWidget'; import { SelectWidget } from './SelectWidget'; import { TextAreaWidget } from './TextAreaWidget'; import { TextfieldWidget } from './TextfieldWidget'; @@ -268,6 +269,16 @@ export const WidgetEntry = ({ onDropBefore={onDropBefore} /> ); + } else if (widget.kind === 'RichText') { + widgetElement = ( + + ); } else if (widget.kind === 'Checkbox') { widgetElement = ( { value === 'List' || value === 'BarChart' || value === 'PieChart' || - value === 'FlexboxContainer' + value === 'FlexboxContainer' || + value === 'RichText' ); }; diff --git a/packages/view/backend/sirius-components-view-edit/plugin.properties b/packages/view/backend/sirius-components-view-edit/plugin.properties new file mode 100644 index 0000000000..5e582e9061 --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/plugin.properties @@ -0,0 +1,267 @@ +# 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 + +pluginName = View Edit Support +providerName = www.example.org + +_UI_CreateChild_text = {0} +_UI_CreateChild_text2 = {1} {0} +_UI_CreateChild_text3 = {1} +_UI_CreateChild_tooltip = Create New {0} Under {1} Feature +_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}. +_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent. + +_UI_PropertyDescriptor_description = The {0} of the {1} + +_UI_View_type = View +_UI_RepresentationDescription_type = Representation Description +_UI_DiagramDescription_type = Diagram Description +_UI_DiagramElementDescription_type = Diagram Element Description +_UI_NodeDescription_type = Node Description +_UI_EdgeDescription_type = Edge Description +_UI_LabelStyle_type = Label Style +_UI_BorderStyle_type = Border Style +_UI_Style_type = Style +_UI_NodeStyle_type = Node Style +_UI_EdgeStyle_type = Edge Style +_UI_Tool_type = Tool +_UI_LabelEditTool_type = Label Edit Tool +_UI_DeleteTool_type = Delete Tool +_UI_NodeTool_type = Node Tool +_UI_EdgeTool_type = Edge Tool +_UI_DropTool_type = Drop Tool +_UI_Operation_type = Operation +_UI_ChangeContext_type = Change Context +_UI_CreateInstance_type = Create Instance +_UI_SetValue_type = Set Value +_UI_UnsetValue_type = Unset Value +_UI_DeleteElement_type = Delete Element +_UI_CreateView_type = Create View +_UI_DeleteView_type = Delete View +_UI_Conditional_type = Conditional +_UI_ConditionalNodeStyle_type = Conditional Node Style +_UI_ConditionalEdgeStyle_type = Conditional Edge Style +_UI_FormDescription_type = Form Description +_UI_WidgetDescription_type = Widget Description +_UI_TextfieldDescription_type = Textfield Description +_UI_CheckboxDescription_type = Checkbox Description +_UI_SelectDescription_type = Select Description +_UI_MultiSelectDescription_type = Multi Select Description +_UI_TextAreaDescription_type = Text Area Description +_UI_RichTextDescription_type = Rich Text Description +_UI_RadioDescription_type = Radio Description +_UI_BarChartDescription_type = Bar Chart Description +_UI_PieChartDescription_type = Pie Chart Description +_UI_FlexboxContainerDescription_type = Flexbox Container Description +_UI_ButtonDescription_type = Button Description +_UI_WidgetDescriptionStyle_type = Widget Description Style +_UI_TextfieldDescriptionStyle_type = Textfield Description Style +_UI_ConditionalTextfieldDescriptionStyle_type = Conditional Textfield Description Style +_UI_CheckboxDescriptionStyle_type = Checkbox Description Style +_UI_ConditionalCheckboxDescriptionStyle_type = Conditional Checkbox Description Style +_UI_SelectDescriptionStyle_type = Select Description Style +_UI_ConditionalSelectDescriptionStyle_type = Conditional Select Description Style +_UI_MultiSelectDescriptionStyle_type = Multi Select Description Style +_UI_ConditionalMultiSelectDescriptionStyle_type = Conditional Multi Select Description Style +_UI_TextareaDescriptionStyle_type = Textarea Description Style +_UI_ConditionalTextareaDescriptionStyle_type = Conditional Textarea Description Style +_UI_RadioDescriptionStyle_type = Radio Description Style +_UI_ConditionalRadioDescriptionStyle_type = Conditional Radio Description Style +_UI_ButtonDescriptionStyle_type = Button Description Style +_UI_ConditionalButtonDescriptionStyle_type = Conditional Button Description Style +_UI_BarChartDescriptionStyle_type = Bar Chart Description Style +_UI_ConditionalBarChartDescriptionStyle_type = Conditional Bar Chart Description Style +_UI_PieChartDescriptionStyle_type = Pie Chart Description Style +_UI_ConditionalPieChartDescriptionStyle_type = Conditional Pie Chart Description Style +_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_ListDescription_type = List Description +_UI_ListDescriptionStyle_type = List Description Style +_UI_ConditionalListDescriptionStyle_type = Conditional List Description Style +_UI_Unknown_type = Object + +_UI_Unknown_datatype= Value + +_UI_View_descriptions_feature = Descriptions +_UI_RepresentationDescription_name_feature = Name +_UI_RepresentationDescription_domainType_feature = Domain Type +_UI_RepresentationDescription_preconditionExpression_feature = Precondition Expression +_UI_RepresentationDescription_titleExpression_feature = Title Expression +_UI_DiagramDescription_autoLayout_feature = Auto Layout +_UI_DiagramDescription_nodeDescriptions_feature = Node Descriptions +_UI_DiagramDescription_edgeDescriptions_feature = Edge Descriptions +_UI_DiagramDescription_onDrop_feature = On Drop +_UI_DiagramElementDescription_name_feature = Name +_UI_DiagramElementDescription_domainType_feature = Domain Type +_UI_DiagramElementDescription_semanticCandidatesExpression_feature = Semantic Candidates Expression +_UI_DiagramElementDescription_labelExpression_feature = Label Expression +_UI_DiagramElementDescription_deleteTool_feature = Delete Tool +_UI_DiagramElementDescription_labelEditTool_feature = Label Edit Tool +_UI_DiagramElementDescription_synchronizationPolicy_feature = Synchronization Policy +_UI_NodeDescription_childrenDescriptions_feature = Children Descriptions +_UI_NodeDescription_borderNodesDescriptions_feature = Border Nodes Descriptions +_UI_NodeDescription_style_feature = Style +_UI_NodeDescription_nodeTools_feature = Node Tools +_UI_NodeDescription_conditionalStyles_feature = Conditional Styles +_UI_EdgeDescription_beginLabelExpression_feature = Begin Label Expression +_UI_EdgeDescription_endLabelExpression_feature = End Label Expression +_UI_EdgeDescription_isDomainBasedEdge_feature = Is Domain Based Edge +_UI_EdgeDescription_sourceNodeDescriptions_feature = Source Node Descriptions +_UI_EdgeDescription_targetNodeDescriptions_feature = Target Node Descriptions +_UI_EdgeDescription_sourceNodesExpression_feature = Source Nodes Expression +_UI_EdgeDescription_targetNodesExpression_feature = Target Nodes Expression +_UI_EdgeDescription_style_feature = Style +_UI_EdgeDescription_edgeTools_feature = Edge Tools +_UI_EdgeDescription_conditionalStyles_feature = Conditional Styles +_UI_LabelStyle_fontSize_feature = Font Size +_UI_LabelStyle_italic_feature = Italic +_UI_LabelStyle_bold_feature = Bold +_UI_LabelStyle_underline_feature = Underline +_UI_LabelStyle_strikeThrough_feature = Strike Through +_UI_BorderStyle_borderColor_feature = Border Color +_UI_BorderStyle_borderRadius_feature = Border Radius +_UI_BorderStyle_borderSize_feature = Border Size +_UI_BorderStyle_borderLineStyle_feature = Border Line Style +_UI_Style_color_feature = Color +_UI_NodeStyle_listMode_feature = List Mode +_UI_NodeStyle_shape_feature = Shape +_UI_NodeStyle_labelColor_feature = Label Color +_UI_NodeStyle_sizeComputationExpression_feature = Size Computation Expression +_UI_EdgeStyle_lineStyle_feature = Line Style +_UI_EdgeStyle_sourceArrowStyle_feature = Source Arrow Style +_UI_EdgeStyle_targetArrowStyle_feature = Target Arrow Style +_UI_EdgeStyle_edgeWidth_feature = Edge Width +_UI_Tool_name_feature = Name +_UI_Tool_body_feature = Body +_UI_Operation_children_feature = Children +_UI_ChangeContext_expression_feature = Expression +_UI_CreateInstance_typeName_feature = Type Name +_UI_CreateInstance_referenceName_feature = Reference Name +_UI_CreateInstance_variableName_feature = Variable Name +_UI_SetValue_featureName_feature = Feature Name +_UI_SetValue_valueExpression_feature = Value Expression +_UI_UnsetValue_featureName_feature = Feature Name +_UI_UnsetValue_elementExpression_feature = Element Expression +_UI_CreateView_parentViewExpression_feature = Parent View Expression +_UI_CreateView_elementDescription_feature = Element Description +_UI_CreateView_semanticElementExpression_feature = Semantic Element Expression +_UI_CreateView_variableName_feature = Variable Name +_UI_DeleteView_viewExpression_feature = View Expression +_UI_Conditional_condition_feature = Condition +_UI_FormDescription_widgets_feature = Widgets +_UI_WidgetDescription_name_feature = Name +_UI_WidgetDescription_labelExpression_feature = Label Expression +_UI_TextfieldDescription_valueExpression_feature = Value Expression +_UI_TextfieldDescription_body_feature = Body +_UI_TextfieldDescription_style_feature = Style +_UI_TextfieldDescription_conditionalStyles_feature = Conditional Styles +_UI_CheckboxDescription_valueExpression_feature = Value Expression +_UI_CheckboxDescription_body_feature = Body +_UI_CheckboxDescription_style_feature = Style +_UI_CheckboxDescription_conditionalStyles_feature = Conditional Styles +_UI_SelectDescription_valueExpression_feature = Value Expression +_UI_SelectDescription_candidatesExpression_feature = Candidates Expression +_UI_SelectDescription_candidateLabelExpression_feature = Candidate Label Expression +_UI_SelectDescription_body_feature = Body +_UI_SelectDescription_style_feature = Style +_UI_SelectDescription_conditionalStyles_feature = Conditional Styles +_UI_MultiSelectDescription_valueExpression_feature = Value Expression +_UI_MultiSelectDescription_candidatesExpression_feature = Candidates Expression +_UI_MultiSelectDescription_candidateLabelExpression_feature = Candidate Label Expression +_UI_MultiSelectDescription_body_feature = Body +_UI_MultiSelectDescription_style_feature = Style +_UI_MultiSelectDescription_conditionalStyles_feature = Conditional Styles +_UI_TextAreaDescription_valueExpression_feature = Value Expression +_UI_TextAreaDescription_body_feature = Body +_UI_TextAreaDescription_style_feature = Style +_UI_TextAreaDescription_conditionalStyles_feature = Conditional Styles +_UI_RichTextDescription_valueExpression_feature = Value Expression +_UI_RichTextDescription_body_feature = Body +_UI_RadioDescription_valueExpression_feature = Value Expression +_UI_RadioDescription_candidatesExpression_feature = Candidates Expression +_UI_RadioDescription_candidateLabelExpression_feature = Candidate Label Expression +_UI_RadioDescription_body_feature = Body +_UI_RadioDescription_style_feature = Style +_UI_RadioDescription_conditionalStyles_feature = Conditional Styles +_UI_BarChartDescription_valuesExpression_feature = Values Expression +_UI_BarChartDescription_keysExpression_feature = Keys Expression +_UI_BarChartDescription_yAxisLabelExpression_feature = YAxis Label Expression +_UI_BarChartDescription_style_feature = Style +_UI_BarChartDescription_conditionalStyles_feature = Conditional Styles +_UI_PieChartDescription_valuesExpression_feature = Values Expression +_UI_PieChartDescription_keysExpression_feature = Keys Expression +_UI_PieChartDescription_style_feature = Style +_UI_PieChartDescription_conditionalStyles_feature = Conditional Styles +_UI_FlexboxContainerDescription_children_feature = Children +_UI_FlexboxContainerDescription_flexDirection_feature = Flex Direction +_UI_ButtonDescription_buttonLabelExpression_feature = Button Label Expression +_UI_ButtonDescription_body_feature = Body +_UI_ButtonDescription_imageExpression_feature = Image Expression +_UI_ButtonDescription_style_feature = Style +_UI_ButtonDescription_conditionalStyles_feature = Conditional Styles +_UI_TextfieldDescriptionStyle_backgroundColor_feature = Background Color +_UI_TextfieldDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_CheckboxDescriptionStyle_color_feature = Color +_UI_SelectDescriptionStyle_backgroundColor_feature = Background Color +_UI_SelectDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_MultiSelectDescriptionStyle_backgroundColor_feature = Background Color +_UI_MultiSelectDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_TextareaDescriptionStyle_backgroundColor_feature = Background Color +_UI_TextareaDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_RadioDescriptionStyle_color_feature = Color +_UI_ButtonDescriptionStyle_backgroundColor_feature = Background Color +_UI_ButtonDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_BarChartDescriptionStyle_barsColor_feature = Bars Color +_UI_PieChartDescriptionStyle_colors_feature = Colors +_UI_PieChartDescriptionStyle_strokeWidth_feature = Stroke Width +_UI_PieChartDescriptionStyle_strokeColor_feature = Stroke Color +_UI_LabelDescription_valueExpression_feature = Value 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_style_feature = Style +_UI_LinkDescription_conditionalStyles_feature = Conditional Styles +_UI_LinkDescriptionStyle_color_feature = Color +_UI_ListDescription_valueExpression_feature = Value Expression +_UI_ListDescription_displayExpression_feature = Display Expression +_UI_ListDescription_isDeletableExpression_feature = Is Deletable Expression +_UI_ListDescription_body_feature = Body +_UI_ListDescription_style_feature = Style +_UI_ListDescription_conditionalStyles_feature = Conditional Styles +_UI_ListDescriptionStyle_color_feature = Color +_UI_Unknown_feature = Unspecified + +_UI_ArrowStyle_None_literal = None +_UI_ArrowStyle_OutputArrow_literal = OutputArrow +_UI_ArrowStyle_InputArrow_literal = InputArrow +_UI_ArrowStyle_OutputClosedArrow_literal = OutputClosedArrow +_UI_ArrowStyle_InputClosedArrow_literal = InputClosedArrow +_UI_ArrowStyle_OutputFillClosedArrow_literal = OutputFillClosedArrow +_UI_ArrowStyle_InputFillClosedArrow_literal = InputFillClosedArrow +_UI_ArrowStyle_Diamond_literal = Diamond +_UI_ArrowStyle_FillDiamond_literal = FillDiamond +_UI_ArrowStyle_InputArrowWithDiamond_literal = InputArrowWithDiamond +_UI_ArrowStyle_InputArrowWithFillDiamond_literal = InputArrowWithFillDiamond +_UI_LineStyle_Solid_literal = Solid +_UI_LineStyle_Dash_literal = Dash +_UI_LineStyle_Dot_literal = Dot +_UI_LineStyle_Dash_Dot_literal = Dash_Dot +_UI_SynchronizationPolicy_SYNCHRONIZED_literal = SYNCHRONIZED +_UI_SynchronizationPolicy_UNSYNCHRONIZED_literal = UNSYNCHRONIZED +_UI_FlexDirection_row_literal = row +_UI_FlexDirection_rowReverse_literal = row-reverse +_UI_FlexDirection_column_literal = column +_UI_FlexDirection_columnReverse_literal = column-reverse diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RichTextDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RichTextDescriptionItemProvider.java new file mode 100644 index 0000000000..16b816cbe6 --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/RichTextDescriptionItemProvider.java @@ -0,0 +1,181 @@ +/** + * 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.RichTextDescription; +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.RichTextDescription} object. + * + * @generated + */ +public class RichTextDescriptionItemProvider extends WidgetDescriptionItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public RichTextDescriptionItemProvider(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); + } + 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_RichTextDescription_valueExpression_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_RichTextDescription_valueExpression_feature", "_UI_RichTextDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.RICH_TEXT_DESCRIPTION__VALUE_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.RICH_TEXT_DESCRIPTION__BODY); + } + 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 RichTextDescription.gif. + * + * @generated + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/RichTextDescription")); //$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 = ((RichTextDescription) object).getName(); + return label == null || label.length() == 0 ? this.getString("_UI_RichTextDescription_type") : //$NON-NLS-1$ + this.getString("_UI_RichTextDescription_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(RichTextDescription.class)) { + case ViewPackage.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + 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.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createChangeContext())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createCreateInstance())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createSetValue())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createUnsetValue())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createDeleteElement())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createCreateView())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.RICH_TEXT_DESCRIPTION__BODY, ViewFactory.eINSTANCE.createDeleteView())); + } + +} 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 c4556e6df7..667fc6cb39 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 @@ -676,6 +676,29 @@ public Adapter createTextAreaDescriptionAdapter() { return this.textAreaDescriptionItemProvider; } + /** + * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.RichTextDescription} + * instances. + * + * @generated + */ + protected RichTextDescriptionItemProvider richTextDescriptionItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.RichTextDescription}. + * + * @generated + */ + @Override + public Adapter createRichTextDescriptionAdapter() { + if (this.richTextDescriptionItemProvider == null) { + this.richTextDescriptionItemProvider = new RichTextDescriptionItemProvider(this); + } + + return this.richTextDescriptionItemProvider; + } + /** * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.RadioDescription} * instances. @@ -1585,6 +1608,8 @@ public void dispose() { this.multiSelectDescriptionItemProvider.dispose(); if (this.textAreaDescriptionItemProvider != null) this.textAreaDescriptionItemProvider.dispose(); + if (this.richTextDescriptionItemProvider != null) + this.richTextDescriptionItemProvider.dispose(); if (this.radioDescriptionItemProvider != null) this.radioDescriptionItemProvider.dispose(); if (this.barChartDescriptionItemProvider != null) diff --git a/packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/RichTextDescription.gif b/packages/view/backend/sirius-components-view-edit/src/main/resources/icons/full/obj16/RichTextDescription.gif new file mode 100644 index 0000000000000000000000000000000000000000..33854e98c25a13543eb9477dc67b0baf87fc81aa GIT binary patch literal 129 zcmZ?wbhEHb6krfw*vtS14M4Jip`qcxfddT<4GjN*-2XuK|Nmgt|Nnblyy&@kGwsY7 zhXV%`f3h$#FmN*HfOLY)U|`WRIO(~1uf^*x-&FV?7P@XXWxbV>;I&}kR~x;L)6}k- WmG`XF newValueHandler = this.getNewValueHandler(richTextDescription.getBody()); + + // @formatter:off + return org.eclipse.sirius.components.forms.description.RichTextDescription.newRichTextDescription(descriptionId) + .idProvider(idProvider) + .labelProvider(labelProvider) + .valueProvider(valueProvider) + .newValueHandler(newValueHandler) + .diagnosticsProvider(variableManager -> List.of()) + .kindProvider(diagnostic -> "") //$NON-NLS-1$ + .messageProvider(diagnostic -> "") //$NON-NLS-1$ + .build(); + // @formatter:on + } + @Override public AbstractWidgetDescription caseMultiSelectDescription(org.eclipse.sirius.components.view.MultiSelectDescription multiSelectDescription) { String descriptionId = this.getDescriptionId(multiSelectDescription); diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/RichTextDescription.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/RichTextDescription.java new file mode 100644 index 0000000000..7c2a11609b --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/RichTextDescription.java @@ -0,0 +1,68 @@ +/** + * 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 'Rich Text Description'. + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.RichTextDescription#getValueExpression Value Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.RichTextDescription#getBody Body}
  • + *
+ * + * @see org.eclipse.sirius.components.view.ViewPackage#getRichTextDescription() + * @model + * @generated + */ +public interface RichTextDescription 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#getRichTextDescription_ValueExpression() + * @model + * @generated + */ + String getValueExpression(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.RichTextDescription#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 'Body' containment reference list. The list contents are of type + * {@link org.eclipse.sirius.components.view.Operation}. + * + * @return the value of the 'Body' containment reference list. + * @see org.eclipse.sirius.components.view.ViewPackage#getRichTextDescription_Body() + * @model containment="true" + * @generated + */ + EList getBody(); + +} // RichTextDescription 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 ee10f2125f..60c5a84d64 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 @@ -237,6 +237,14 @@ public interface ViewFactory extends EFactory { */ TextAreaDescription createTextAreaDescription(); + /** + * Returns a new object of class 'Rich Text Description'. + * + * @return a new object of class 'Rich Text Description'. + * @generated + */ + RichTextDescription createRichTextDescription(); + /** * Returns a new object of class 'Radio 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 947be1a58c..bb303eda05 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 @@ -2601,6 +2601,69 @@ public interface ViewPackage extends EPackage { */ int TEXT_AREA_DESCRIPTION_OPERATION_COUNT = WIDGET_DESCRIPTION_OPERATION_COUNT + 0; + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl Rich Text + * Description}' class. + * + * @see org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getRichTextDescription() + * @generated + */ + int RICH_TEXT_DESCRIPTION = 35; + + /** + * The feature id for the 'Name' attribute. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION__NAME = WIDGET_DESCRIPTION__NAME; + + /** + * The feature id for the 'Label Expression' attribute. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION__LABEL_EXPRESSION = WIDGET_DESCRIPTION__LABEL_EXPRESSION; + + /** + * The feature id for the 'Value Expression' attribute. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION = WIDGET_DESCRIPTION_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Body' containment reference list. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION__BODY = WIDGET_DESCRIPTION_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Rich Text Description' class. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 2; + + /** + * The number of operations of the 'Rich Text Description' class. + * + * @generated + * @ordered + */ + int RICH_TEXT_DESCRIPTION_OPERATION_COUNT = WIDGET_DESCRIPTION_OPERATION_COUNT + 0; + /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.RadioDescriptionImpl Radio * Description}' class. @@ -2609,7 +2672,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getRadioDescription() * @generated */ - int RADIO_DESCRIPTION = 35; + int RADIO_DESCRIPTION = 36; /** * The feature id for the 'Name' attribute. @@ -2707,7 +2770,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getWidgetDescriptionStyle() * @generated */ - int WIDGET_DESCRIPTION_STYLE = 40; + int WIDGET_DESCRIPTION_STYLE = 41; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.TextfieldDescriptionStyleImpl @@ -2717,7 +2780,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getTextfieldDescriptionStyle() * @generated */ - int TEXTFIELD_DESCRIPTION_STYLE = 41; + int TEXTFIELD_DESCRIPTION_STYLE = 42; /** * The meta object id for the @@ -2728,7 +2791,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalTextfieldDescriptionStyle() * @generated */ - int CONDITIONAL_TEXTFIELD_DESCRIPTION_STYLE = 42; + int CONDITIONAL_TEXTFIELD_DESCRIPTION_STYLE = 43; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.CheckboxDescriptionStyleImpl @@ -2738,7 +2801,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getCheckboxDescriptionStyle() * @generated */ - int CHECKBOX_DESCRIPTION_STYLE = 43; + int CHECKBOX_DESCRIPTION_STYLE = 44; /** * The meta object id for the @@ -2749,7 +2812,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalCheckboxDescriptionStyle() * @generated */ - int CONDITIONAL_CHECKBOX_DESCRIPTION_STYLE = 44; + int CONDITIONAL_CHECKBOX_DESCRIPTION_STYLE = 45; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.SelectDescriptionStyleImpl Select @@ -2759,7 +2822,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getSelectDescriptionStyle() * @generated */ - int SELECT_DESCRIPTION_STYLE = 45; + int SELECT_DESCRIPTION_STYLE = 46; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.ConditionalSelectDescriptionStyleImpl @@ -2769,7 +2832,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalSelectDescriptionStyle() * @generated */ - int CONDITIONAL_SELECT_DESCRIPTION_STYLE = 46; + int CONDITIONAL_SELECT_DESCRIPTION_STYLE = 47; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.MultiSelectDescriptionStyleImpl @@ -2779,7 +2842,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getMultiSelectDescriptionStyle() * @generated */ - int MULTI_SELECT_DESCRIPTION_STYLE = 47; + int MULTI_SELECT_DESCRIPTION_STYLE = 48; /** * The meta object id for the @@ -2790,7 +2853,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalMultiSelectDescriptionStyle() * @generated */ - int CONDITIONAL_MULTI_SELECT_DESCRIPTION_STYLE = 48; + int CONDITIONAL_MULTI_SELECT_DESCRIPTION_STYLE = 49; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.TextareaDescriptionStyleImpl @@ -2800,7 +2863,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getTextareaDescriptionStyle() * @generated */ - int TEXTAREA_DESCRIPTION_STYLE = 49; + int TEXTAREA_DESCRIPTION_STYLE = 50; /** * The meta object id for the @@ -2811,7 +2874,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalTextareaDescriptionStyle() * @generated */ - int CONDITIONAL_TEXTAREA_DESCRIPTION_STYLE = 50; + int CONDITIONAL_TEXTAREA_DESCRIPTION_STYLE = 51; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.RadioDescriptionStyleImpl Radio @@ -2821,7 +2884,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getRadioDescriptionStyle() * @generated */ - int RADIO_DESCRIPTION_STYLE = 51; + int RADIO_DESCRIPTION_STYLE = 52; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.ConditionalRadioDescriptionStyleImpl @@ -2831,7 +2894,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalRadioDescriptionStyle() * @generated */ - int CONDITIONAL_RADIO_DESCRIPTION_STYLE = 52; + int CONDITIONAL_RADIO_DESCRIPTION_STYLE = 53; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl Bar Chart @@ -2841,7 +2904,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getBarChartDescription() * @generated */ - int BAR_CHART_DESCRIPTION = 36; + int BAR_CHART_DESCRIPTION = 37; /** * The feature id for the 'Name' attribute. @@ -2930,7 +2993,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getPieChartDescription() * @generated */ - int PIE_CHART_DESCRIPTION = 37; + int PIE_CHART_DESCRIPTION = 38; /** * The feature id for the 'Name' attribute. @@ -3010,7 +3073,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getFlexboxContainerDescription() * @generated */ - int FLEXBOX_CONTAINER_DESCRIPTION = 38; + int FLEXBOX_CONTAINER_DESCRIPTION = 39; /** * The feature id for the 'Name' attribute. @@ -3072,7 +3135,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getButtonDescription() * @generated */ - int BUTTON_DESCRIPTION = 39; + int BUTTON_DESCRIPTION = 40; /** * The feature id for the 'Name' attribute. @@ -4020,7 +4083,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getButtonDescriptionStyle() * @generated */ - int BUTTON_DESCRIPTION_STYLE = 53; + int BUTTON_DESCRIPTION_STYLE = 54; /** * The feature id for the 'Font Size' attribute. @@ -4106,7 +4169,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalButtonDescriptionStyle() * @generated */ - int CONDITIONAL_BUTTON_DESCRIPTION_STYLE = 54; + int CONDITIONAL_BUTTON_DESCRIPTION_STYLE = 55; /** * The feature id for the 'Condition' attribute. @@ -4200,7 +4263,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getBarChartDescriptionStyle() * @generated */ - int BAR_CHART_DESCRIPTION_STYLE = 55; + int BAR_CHART_DESCRIPTION_STYLE = 56; /** * The feature id for the 'Font Size' attribute. @@ -4277,7 +4340,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalBarChartDescriptionStyle() * @generated */ - int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE = 56; + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE = 57; /** * The feature id for the 'Condition' attribute. @@ -4361,7 +4424,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getPieChartDescriptionStyle() * @generated */ - int PIE_CHART_DESCRIPTION_STYLE = 57; + int PIE_CHART_DESCRIPTION_STYLE = 58; /** * The feature id for the 'Font Size' attribute. @@ -4454,7 +4517,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalPieChartDescriptionStyle() * @generated */ - int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE = 58; + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE = 59; /** * The feature id for the 'Condition' attribute. @@ -4554,7 +4617,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLabelDescription() * @generated */ - int LABEL_DESCRIPTION = 59; + int LABEL_DESCRIPTION = 60; /** * The feature id for the 'Name' attribute. @@ -4625,7 +4688,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLabelDescriptionStyle() * @generated */ - int LABEL_DESCRIPTION_STYLE = 60; + int LABEL_DESCRIPTION_STYLE = 61; /** * The feature id for the 'Font Size' attribute. @@ -4701,7 +4764,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalLabelDescriptionStyle() * @generated */ - int CONDITIONAL_LABEL_DESCRIPTION_STYLE = 61; + int CONDITIONAL_LABEL_DESCRIPTION_STYLE = 62; /** * The feature id for the 'Condition' attribute. @@ -4785,7 +4848,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescription() * @generated */ - int LINK_DESCRIPTION = 62; + int LINK_DESCRIPTION = 63; /** * The feature id for the 'Name' attribute. @@ -4856,7 +4919,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getLinkDescriptionStyle() * @generated */ - int LINK_DESCRIPTION_STYLE = 63; + int LINK_DESCRIPTION_STYLE = 64; /** * The feature id for the 'Font Size' attribute. @@ -4932,7 +4995,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalLinkDescriptionStyle() * @generated */ - int CONDITIONAL_LINK_DESCRIPTION_STYLE = 64; + int CONDITIONAL_LINK_DESCRIPTION_STYLE = 65; /** * The feature id for the 'Condition' attribute. @@ -5016,7 +5079,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getListDescription() * @generated */ - int LIST_DESCRIPTION = 65; + int LIST_DESCRIPTION = 66; /** * The feature id for the 'Name' attribute. @@ -5114,7 +5177,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getListDescriptionStyle() * @generated */ - int LIST_DESCRIPTION_STYLE = 66; + int LIST_DESCRIPTION_STYLE = 67; /** * The feature id for the 'Font Size' attribute. @@ -5190,7 +5253,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalListDescriptionStyle() * @generated */ - int CONDITIONAL_LIST_DESCRIPTION_STYLE = 67; + int CONDITIONAL_LIST_DESCRIPTION_STYLE = 68; /** * The feature id for the 'Condition' attribute. @@ -5274,7 +5337,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getArrowStyle() * @generated */ - int ARROW_STYLE = 68; + int ARROW_STYLE = 69; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.LineStyle Line Style}' enum. + * + * @return the meta object for class 'Rich Text Description'. + * @see org.eclipse.sirius.components.view.RichTextDescription + * @generated + */ + EClass getRichTextDescription(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.RichTextDescription#getValueExpression Value Expression}'. + * + * + * @return the meta object for the attribute 'Value Expression'. + * @see org.eclipse.sirius.components.view.RichTextDescription#getValueExpression() + * @see #getRichTextDescription() + * @generated + */ + EAttribute getRichTextDescription_ValueExpression(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.RichTextDescription#getBody Body}'. + * + * + * @return the meta object for the containment reference list 'Body'. + * @see org.eclipse.sirius.components.view.RichTextDescription#getBody() + * @see #getRichTextDescription() + * @generated + */ + EReference getRichTextDescription_Body(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.RadioDescription Radio * Description}'. @@ -8859,6 +8956,32 @@ interface Literals { */ EReference TEXT_AREA_DESCRIPTION__CONDITIONAL_STYLES = eINSTANCE.getTextAreaDescription_ConditionalStyles(); + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl + * Rich Text Description}' class. + * + * @see org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getRichTextDescription() + * @generated + */ + EClass RICH_TEXT_DESCRIPTION = eINSTANCE.getRichTextDescription(); + + /** + * The meta object literal for the 'Value Expression' attribute feature. + * + * + * @generated + */ + EAttribute RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION = eINSTANCE.getRichTextDescription_ValueExpression(); + + /** + * The meta object literal for the 'Body' containment reference list feature. + * + * @generated + */ + EReference RICH_TEXT_DESCRIPTION__BODY = eINSTANCE.getRichTextDescription_Body(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.RadioDescriptionImpl * Radio Description}' class. diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RichTextDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RichTextDescriptionImpl.java new file mode 100644 index 0000000000..0b8db932fa --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/RichTextDescriptionImpl.java @@ -0,0 +1,230 @@ +/** + * 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.Operation; +import org.eclipse.sirius.components.view.RichTextDescription; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * An implementation of the model object 'Rich Text Description'. + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl#getValueExpression Value + * Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.RichTextDescriptionImpl#getBody Body}
  • + *
+ * + * @generated + */ +public class RichTextDescriptionImpl extends WidgetDescriptionImpl implements RichTextDescription { + /** + * 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 cached value of the '{@link #getBody() Body}' containment reference list. + * + * + * @see #getBody() + * @generated + * @ordered + */ + protected EList body; + + /** + * + * + * @generated + */ + protected RichTextDescriptionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.RICH_TEXT_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.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION, oldValueExpression, this.valueExpression)); + } + + /** + * + * + * @generated + */ + @Override + public EList getBody() { + if (this.body == null) { + this.body = new EObjectContainmentEList<>(Operation.class, this, ViewPackage.RICH_TEXT_DESCRIPTION__BODY); + } + return this.body; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + return ((InternalEList) this.getBody()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION: + return this.getValueExpression(); + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + return this.getBody(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION: + this.setValueExpression((String) newValue); + return; + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + this.getBody().clear(); + this.getBody().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION: + this.setValueExpression(VALUE_EXPRESSION_EDEFAULT); + return; + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + this.getBody().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION: + return VALUE_EXPRESSION_EDEFAULT == null ? this.valueExpression != null : !VALUE_EXPRESSION_EDEFAULT.equals(this.valueExpression); + case ViewPackage.RICH_TEXT_DESCRIPTION__BODY: + return this.body != null && !this.body.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(')'); + return result.toString(); + } + +} // RichTextDescriptionImpl 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 696298db64..2e998ff7b3 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 @@ -70,6 +70,7 @@ import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; +import org.eclipse.sirius.components.view.RichTextDescription; import org.eclipse.sirius.components.view.SelectDescription; import org.eclipse.sirius.components.view.SelectDescriptionStyle; import org.eclipse.sirius.components.view.SetValue; @@ -175,6 +176,8 @@ public EObject create(EClass eClass) { return this.createMultiSelectDescription(); case ViewPackage.TEXT_AREA_DESCRIPTION: return this.createTextAreaDescription(); + case ViewPackage.RICH_TEXT_DESCRIPTION: + return this.createRichTextDescription(); case ViewPackage.RADIO_DESCRIPTION: return this.createRadioDescription(); case ViewPackage.BAR_CHART_DESCRIPTION: @@ -572,6 +575,17 @@ public TextAreaDescription createTextAreaDescription() { return textAreaDescription; } + /** + * + * + * @generated + */ + @Override + public RichTextDescription createRichTextDescription() { + RichTextDescriptionImpl richTextDescription = new RichTextDescriptionImpl(); + return richTextDescription; + } + /** * * 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 7cdd37035b..c2823ab866 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 @@ -76,6 +76,7 @@ import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; +import org.eclipse.sirius.components.view.RichTextDescription; import org.eclipse.sirius.components.view.SelectDescription; import org.eclipse.sirius.components.view.SelectDescriptionStyle; import org.eclipse.sirius.components.view.SetValue; @@ -344,6 +345,13 @@ public class ViewPackageImpl extends EPackageImpl implements ViewPackage { */ private EClass textAreaDescriptionEClass = null; + /** + * + * + * @generated + */ + private EClass richTextDescriptionEClass = null; + /** * * @@ -1944,6 +1952,36 @@ public EReference getTextAreaDescription_ConditionalStyles() { return (EReference) this.textAreaDescriptionEClass.getEStructuralFeatures().get(3); } + /** + * + * + * @generated + */ + @Override + public EClass getRichTextDescription() { + return this.richTextDescriptionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getRichTextDescription_ValueExpression() { + return (EAttribute) this.richTextDescriptionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getRichTextDescription_Body() { + return (EReference) this.richTextDescriptionEClass.getEStructuralFeatures().get(1); + } + /** * * @@ -3036,6 +3074,10 @@ public void createPackageContents() { this.createEReference(this.textAreaDescriptionEClass, TEXT_AREA_DESCRIPTION__STYLE); this.createEReference(this.textAreaDescriptionEClass, TEXT_AREA_DESCRIPTION__CONDITIONAL_STYLES); + this.richTextDescriptionEClass = this.createEClass(RICH_TEXT_DESCRIPTION); + this.createEAttribute(this.richTextDescriptionEClass, RICH_TEXT_DESCRIPTION__VALUE_EXPRESSION); + this.createEReference(this.richTextDescriptionEClass, RICH_TEXT_DESCRIPTION__BODY); + this.radioDescriptionEClass = this.createEClass(RADIO_DESCRIPTION); this.createEAttribute(this.radioDescriptionEClass, RADIO_DESCRIPTION__VALUE_EXPRESSION); this.createEAttribute(this.radioDescriptionEClass, RADIO_DESCRIPTION__CANDIDATES_EXPRESSION); @@ -3220,6 +3262,7 @@ public void initializePackageContents() { this.selectDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); this.multiSelectDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); this.textAreaDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); + this.richTextDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); this.radioDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); this.barChartDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); this.pieChartDescriptionEClass.getESuperTypes().add(this.getWidgetDescription()); @@ -3533,6 +3576,12 @@ public void initializePackageContents() { this.initEReference(this.getTextAreaDescription_ConditionalStyles(), this.getConditionalTextareaDescriptionStyle(), null, "conditionalStyles", null, 0, -1, TextAreaDescription.class, //$NON-NLS-1$ !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.richTextDescriptionEClass, RichTextDescription.class, "RichTextDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + this.initEAttribute(this.getRichTextDescription_ValueExpression(), this.ecorePackage.getEString(), "valueExpression", null, 0, 1, RichTextDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getRichTextDescription_Body(), this.getOperation(), null, "body", null, 0, -1, RichTextDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, //$NON-NLS-1$ + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEClass(this.radioDescriptionEClass, RadioDescription.class, "RadioDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ this.initEAttribute(this.getRadioDescription_ValueExpression(), this.ecorePackage.getEString(), "valueExpression", null, 0, 1, RadioDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); 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 858df8981b..000b87a350 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 @@ -71,6 +71,7 @@ import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; +import org.eclipse.sirius.components.view.RichTextDescription; import org.eclipse.sirius.components.view.SelectDescription; import org.eclipse.sirius.components.view.SelectDescriptionStyle; import org.eclipse.sirius.components.view.SetValue; @@ -312,6 +313,11 @@ public Adapter caseTextAreaDescription(TextAreaDescription object) { return ViewAdapterFactory.this.createTextAreaDescriptionAdapter(); } + @Override + public Adapter caseRichTextDescription(RichTextDescription object) { + return ViewAdapterFactory.this.createRichTextDescriptionAdapter(); + } + @Override public Adapter caseRadioDescription(RadioDescription object) { return ViewAdapterFactory.this.createRadioDescriptionAdapter(); @@ -964,6 +970,20 @@ public Adapter createTextAreaDescriptionAdapter() { return null; } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.RichTextDescription + * Rich Text 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.RichTextDescription + * @generated + */ + public Adapter createRichTextDescriptionAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.RadioDescription * Radio 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 31267832a3..6b7b824872 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 @@ -70,6 +70,7 @@ import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; +import org.eclipse.sirius.components.view.RichTextDescription; import org.eclipse.sirius.components.view.SelectDescription; import org.eclipse.sirius.components.view.SelectDescriptionStyle; import org.eclipse.sirius.components.view.SetValue; @@ -451,6 +452,15 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case ViewPackage.RICH_TEXT_DESCRIPTION: { + RichTextDescription richTextDescription = (RichTextDescription) theEObject; + T result = this.caseRichTextDescription(richTextDescription); + if (result == null) + result = this.caseWidgetDescription(richTextDescription); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } case ViewPackage.RADIO_DESCRIPTION: { RadioDescription radioDescription = (RadioDescription) theEObject; T result = this.caseRadioDescription(radioDescription); @@ -1351,6 +1361,21 @@ public T caseTextAreaDescription(TextAreaDescription object) { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Rich Text 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 'Rich Text Description'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseRichTextDescription(RichTextDescription object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Radio Description'. This implementation returns null; returning a non-null result will terminate the switch.