Skip to content

Commit

Permalink
[2096] Add style for the reference widget
Browse files Browse the repository at this point in the history
Bug: #2096
Signed-off-by: Florian ROUËNÉ <[email protected]>
  • Loading branch information
frouene committed Jul 5, 2023
1 parent 143ab88 commit ef965e0
Show file tree
Hide file tree
Showing 36 changed files with 3,455 additions and 604 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ image:doc/images/Diagram_closed_arrow_with_dots.png[closed arrow with dots]
- https://github.com/eclipse-sirius/sirius-components/issues/2135[#2135] [tree] Allow `TreeItemContextMenuContribution`s to only apply to specific trees (based on the tree id).
The existing context menu contributions now only apply to the _Explorer_ view.
- https://github.com/eclipse-sirius/sirius-components/issues/2128[#2128] [releng] Update generated classes copyright to apply the same format as other classes.
- https://github.com/eclipse-sirius/sirius-components/issues/2096[#2096] [form] Add style for the reference widget.
Use the same style properties as the list widget.

== v2023.6.0

Expand Down Expand Up @@ -186,7 +188,7 @@ These representations can be created programmatically or loaded from `.view` EMF
+
Introducing providers interfaces to help creating view programmatically.
+
Introducing a generator of builders aimed to help creating view programmatically, the generation makes use of emf-merge and modifications to these builders can be annotated to live during future regeneration.
Introducing a generator of builders aimed to help creating view programmatically, the generation makes use of emf-merge and modifications to these builders can be annotated to live during future regeneration.

- https://github.com/eclipse-sirius/sirius-components/issues/1912[#1912] [core] Add the possibility to send feedback messages to the frontend after an action.
- https://github.com/eclipse-sirius/sirius-components/issues/1989[#1989] [diagram] Contribute a new way to render diagrams to evaluate an alternate layouting strategy
Expand Down Expand Up @@ -244,7 +246,6 @@ Such calls will not work anymore since `null` will not be an acceptable value an
+
Removing dependencies from sirius-components-compatibility-emf in the canHandle methods of sirius-components-view-emf services


=== Dependency update

- [form] Switch to lexical 0.8.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,23 @@ describe('/projects/:projectId/edit - FormDescriptionEditor', () => {
cy.getByTestId('FormDescriptionEditor-ReferenceWidget').trigger('dragstart', { dataTransfer });
cy.get('[data-testid^="Group-Widgets-DropArea-"]').trigger('drop', { dataTransfer });
cy.get('[title="ReferenceWidget"]').should('be.visible');
cy.getByTestId('PageDescription').dblclick();
cy.getByTestId('GroupDescription').dblclick();
cy.getByTestId('ReferenceWidgetDescription-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-object').click();
cy.getByTestId('childCreationDescription').children('[role="button"]').invoke('text').should('have.length.gt', 1);
cy.getByTestId('childCreationDescription')
.click()
.get('[data-value="Conditional Styles Conditional Reference Widget Description Style"]')
.should('exist');
cy.get('[data-value="Style Widget Description Style"]').should('exist').click();
cy.getByTestId('create-object').click();
cy.getByTestId('Font Size').should('exist');
cy.getByTestId('Italic').should('exist');
cy.getByTestId('Bold').should('exist');
cy.getByTestId('Underline').should('exist');
cy.getByTestId('Strike Through').should('exist');
cy.getByTestId('Color').should('exist');
});

it('can create a reference widget in a Flexbox Container', () => {
Expand All @@ -210,13 +227,16 @@ describe('/projects/:projectId/edit - FormDescriptionEditor', () => {
cy.get('[title="ReferenceWidget"]').should('be.visible');
});


function checkWidgetIsEnabledExpression(widgetName, should) {
cy.getByTestId("GroupDescription-more").click();
cy.getByTestId("treeitem-contextmenu").findByTestId("new-object").click();
cy.getByTestId("childCreationDescription").children("[role=\"button\"]").invoke("text").should("have.length.gt", 1);
cy.getByTestId("childCreationDescription").click().get("[data-value=\"" + widgetName + " Description\"]").should("exist").click();
cy.getByTestId("create-object").click();
cy.getByTestId('GroupDescription-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-object').click();
cy.getByTestId('childCreationDescription').children('[role="button"]').invoke('text').should('have.length.gt', 1);
cy.getByTestId('childCreationDescription')
.click()
.get('[data-value="' + widgetName + ' Description"]')
.should('exist')
.click();
cy.getByTestId('create-object').click();
cy.getByTestId('Is Enabled Expression').should(should);
}

Expand All @@ -235,20 +255,20 @@ describe('/projects/:projectId/edit - FormDescriptionEditor', () => {
});

function createBorderStyleAndCheckProperties(styleName) {
cy.getByTestId("treeitem-contextmenu").findByTestId("new-object").click();
cy.getByTestId("childCreationDescription").children("[role=\"button\"]").invoke("text").should("have.length.gt", 1);
cy.getByTestId("childCreationDescription")
cy.getByTestId('treeitem-contextmenu').findByTestId('new-object').click();
cy.getByTestId('childCreationDescription').children('[role="button"]').invoke('text').should('have.length.gt', 1);
cy.getByTestId('childCreationDescription')
.click()
.get("[data-value=\"" + styleName + "\"]")
.should("exist")
.get('[data-value="' + styleName + '"]')
.should('exist')
.click();
cy.getByTestId("create-object").click();
cy.getByTestId("Border Color").should("exist");
cy.getByTestId("Border Radius").should("exist");
cy.getByTestId("Border Size").should("exist");
cy.getByTestId("Solid").should("exist");
cy.getByTestId("Dashed").should("exist");
cy.getByTestId("Dotted").should("exist");
cy.getByTestId('create-object').click();
cy.getByTestId('Border Color').should('exist');
cy.getByTestId('Border Radius').should('exist');
cy.getByTestId('Border Size').should('exist');
cy.getByTestId('Solid').should('exist');
cy.getByTestId('Dashed').should('exist');
cy.getByTestId('Dotted').should('exist');
}

it('can create border style in a Group', () => {
Expand Down Expand Up @@ -277,6 +297,5 @@ describe('/projects/:projectId/edit - FormDescriptionEditor', () => {
cy.getByTestId('FlexboxContainerDescription-more').click();
createBorderStyleAndCheckProperties('Conditional Border Styles Conditional Container Border Style');
cy.getByTestId('Condition').should('exist');

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.widgets.reference.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.common.util.ResourceLocator;
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.ViewPackage;
import org.eclipse.sirius.components.view.provider.ConditionalItemProvider;
import org.eclipse.sirius.components.widgets.reference.ConditionalReferenceWidgetDescriptionStyle;
import org.eclipse.sirius.components.widgets.reference.ReferencePackage;

/**
* This is the item provider adapter for a
* {@link org.eclipse.sirius.components.widgets.reference.ConditionalReferenceWidgetDescriptionStyle}
* object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public class ConditionalReferenceWidgetDescriptionStyleItemProvider extends ConditionalItemProvider {

/**
* This constructs an instance from a factory and a notifier. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public ConditionalReferenceWidgetDescriptionStyleItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}

/**
* This returns the property descriptors for the adapted class. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public List<IItemPropertyDescriptor> 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. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addFontSizePropertyDescriptor(Object object) {
this.itemPropertyDescriptors
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(),
this.getResourceLocator(), this.getString("_UI_LabelStyle_fontSize_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature",
"_UI_LabelStyle_type"),
ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Italic feature. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @generated
*/
protected void addItalicPropertyDescriptor(Object object) {
this.itemPropertyDescriptors
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(),
this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature",
"_UI_LabelStyle_type"),
ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Bold feature. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected void addBoldPropertyDescriptor(Object object) {
this.itemPropertyDescriptors
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(),
this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature",
"_UI_LabelStyle_type"),
ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Underline feature. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addUnderlinePropertyDescriptor(Object object) {
this.itemPropertyDescriptors
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(),
this.getResourceLocator(), this.getString("_UI_LabelStyle_underline_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature",
"_UI_LabelStyle_type"),
ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Strike Through feature. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addStrikeThroughPropertyDescriptor(Object object) {
this.itemPropertyDescriptors
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(),
this.getResourceLocator(), this.getString("_UI_LabelStyle_strikeThrough_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature",
"_UI_LabelStyle_type"),
ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Color feature. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @generated
*/
protected void addColorPropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(
((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
this.getString("_UI_ReferenceWidgetDescriptionStyle_color_feature"),
this.getString("_UI_PropertyDescriptor_description", "_UI_ReferenceWidgetDescriptionStyle_color_feature",
"_UI_ReferenceWidgetDescriptionStyle_type"),
ReferencePackage.Literals.REFERENCE_WIDGET_DESCRIPTION_STYLE__COLOR, true, false, true, null, null,
null));
}

/**
* This returns ConditionalReferenceWidgetDescriptionStyle.gif. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Object getImage(Object object) {
return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.svg"));
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected boolean shouldComposeCreationImage() {
return true;
}

/**
* This returns the label text for the adapted class. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public String getText(Object object) {
String label = ((ConditionalReferenceWidgetDescriptionStyle) object).getCondition();
return label == null || label.length() == 0 ? this.getString("_UI_ConditionalReferenceWidgetDescriptionStyle_type")
: this.getString("_UI_ConditionalReferenceWidgetDescriptionStyle_type") + " " + label;
}

/**
* 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}. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
this.updateChildren(notification);

switch (notification.getFeatureID(ConditionalReferenceWidgetDescriptionStyle.class)) {
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__FONT_SIZE:
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__ITALIC:
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__BOLD:
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__UNDERLINE:
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__STRIKE_THROUGH:
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. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}

/**
* Return the resource locator for this item provider's resources. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return ReferenceEditPlugin.INSTANCE;
}

}
Loading

0 comments on commit ef965e0

Please sign in to comment.