Skip to content

Commit

Permalink
[1316][1339] Enhance the view model
Browse files Browse the repository at this point in the history
Now there are two separated concepts:
 * The node style description concept that tells how the node is
represented
 * The new concept of LayoutStrategyDescription that tells how the
children are layouted.

* Add new Styles
 - RectangularNodeStyleDescription
 - ImageNodeStyleDescription
 - IconLabelNodeStyleDescription
* Add a "childrenLayoutStrategy" feature to NodeDescription. There are
two implementations
 - FreeFormLayoutStrategyDescription
 - ListLayoutStrategyDescription

Bug: #1316
Bug: #1339
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
  • Loading branch information
lfasani committed Sep 23, 2022
1 parent ae16f85 commit d122376
Show file tree
Hide file tree
Showing 44 changed files with 5,585 additions and 1,940 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors

NodeDescription nodeChild = ViewFactory.eINSTANCE.createNodeDescription();
nodeChild.setName("Node"); //$NON-NLS-1$
nodeChild.setStyle(ViewFactory.eINSTANCE.createNodeStyle());
nodeChild.setStyle(ViewFactory.eINSTANCE.createRectangularNodeStyleDescription());
nodeChild.setChildrenLayoutStrategy(ViewFactory.eINSTANCE.createFreeFormLayoutStrategyDescription());
newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.DIAGRAM_DESCRIPTION__NODE_DESCRIPTIONS, nodeChild));

EdgeDescription edgeChild = ViewFactory.eINSTANCE.createEdgeDescription();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**
* 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.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;

/**
* This is the item provider adapter for a {@link org.eclipse.sirius.components.view.FreeFormLayoutStrategyDescription}
* object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public class FreeFormLayoutStrategyDescriptionItemProvider extends ItemProviderAdapter
implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public FreeFormLayoutStrategyDescriptionItemProvider(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);

}
return this.itemPropertyDescriptors;
}

/**
* This returns FreeFormLayoutStrategyDescription.gif. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object getImage(Object object) {
return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/FreeFormLayoutStrategyDescription")); //$NON-NLS-1$
}

/**
* <!-- 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) {
return this.getString("_UI_FreeFormLayoutStrategyDescription_type"); //$NON-NLS-1$
}

/**
* 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);
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 ViewEditPlugin.INSTANCE;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Obeo.
* 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
Expand All @@ -21,22 +21,22 @@
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.NodeStyle;
import org.eclipse.sirius.components.view.IconLabelNodeStyleDescription;
import org.eclipse.sirius.components.view.ViewPackage;

/**
* This is the item provider adapter for a {@link org.eclipse.sirius.components.view.NodeStyle} object. <!--
* begin-user-doc --> <!-- end-user-doc -->
* This is the item provider adapter for a {@link org.eclipse.sirius.components.view.IconLabelNodeStyleDescription}
* object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public class NodeStyleItemProvider extends StyleItemProvider {
public class IconLabelNodeStyleDescriptionItemProvider extends StyleItemProvider {
/**
* This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NodeStyleItemProvider(AdapterFactory adapterFactory) {
public IconLabelNodeStyleDescriptionItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}

Expand All @@ -59,10 +59,9 @@ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
this.addBorderRadiusPropertyDescriptor(object);
this.addBorderSizePropertyDescriptor(object);
this.addBorderLineStylePropertyDescriptor(object);
this.addListModePropertyDescriptor(object);
this.addShapePropertyDescriptor(object);
this.addLabelColorPropertyDescriptor(object);
this.addSizeComputationExpressionPropertyDescriptor(object);
this.addShowIconPropertyDescriptor(object);
}
return this.itemPropertyDescriptors;
}
Expand Down Expand Up @@ -139,18 +138,6 @@ protected void addBorderColorPropertyDescriptor(Object object) {
ViewPackage.Literals.BORDER_STYLE__BORDER_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the List Mode feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addListModePropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
this.getString("_UI_NodeStyle_listMode_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyle_listMode_feature", "_UI_NodeStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE__LIST_MODE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Border Radius feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
Expand All @@ -163,18 +150,6 @@ protected void addBorderRadiusPropertyDescriptor(Object object) {
ViewPackage.Literals.BORDER_STYLE__BORDER_RADIUS, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Shape feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addShapePropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(
this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_NodeStyle_shape_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyle_shape_feature", "_UI_NodeStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE__SHAPE, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Border Size feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
Expand Down Expand Up @@ -206,9 +181,9 @@ protected void addBorderLineStylePropertyDescriptor(Object object) {
*/
protected void addLabelColorPropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
this.getString("_UI_NodeStyle_labelColor_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyle_labelColor_feature", "_UI_NodeStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE__LABEL_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
this.getString("_UI_NodeStyleDescription_labelColor_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_labelColor_feature", "_UI_NodeStyleDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__LABEL_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}

/**
Expand All @@ -219,13 +194,25 @@ protected void addLabelColorPropertyDescriptor(Object object) {
*/
protected void addSizeComputationExpressionPropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
this.getString("_UI_NodeStyle_sizeComputationExpression_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyle_sizeComputationExpression_feature", "_UI_NodeStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE__SIZE_COMPUTATION_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
this.getString("_UI_NodeStyleDescription_sizeComputationExpression_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_sizeComputationExpression_feature", "_UI_NodeStyleDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SIZE_COMPUTATION_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}

/**
* This adds a property descriptor for the Show Icon feature. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected void addShowIconPropertyDescriptor(Object object) {
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(),
this.getString("_UI_NodeStyleDescription_showIcon_feature"), //$NON-NLS-1$
this.getString("_UI_PropertyDescriptor_description", "_UI_NodeStyleDescription_showIcon_feature", "_UI_NodeStyleDescription_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ViewPackage.Literals.NODE_STYLE_DESCRIPTION__SHOW_ICON, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}

/**
* This returns NodeStyle.gif. <!-- begin-user-doc --> <!-- end-user-doc -->
* This returns IconLabelNodeStyleDescription.gif. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
Expand All @@ -251,9 +238,9 @@ protected boolean shouldComposeCreationImage() {
*/
@Override
public String getText(Object object) {
String label = ((NodeStyle) object).getColor();
return label == null || label.length() == 0 ? this.getString("_UI_NodeStyle_type") : //$NON-NLS-1$
this.getString("_UI_NodeStyle_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
String label = ((IconLabelNodeStyleDescription) object).getColor();
return label == null || label.length() == 0 ? this.getString("_UI_IconLabelNodeStyleDescription_type") : //$NON-NLS-1$
this.getString("_UI_IconLabelNodeStyleDescription_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
}

/**
Expand All @@ -267,20 +254,19 @@ public String getText(Object object) {
public void notifyChanged(Notification notification) {
this.updateChildren(notification);

switch (notification.getFeatureID(NodeStyle.class)) {
case ViewPackage.NODE_STYLE__FONT_SIZE:
case ViewPackage.NODE_STYLE__ITALIC:
case ViewPackage.NODE_STYLE__BOLD:
case ViewPackage.NODE_STYLE__UNDERLINE:
case ViewPackage.NODE_STYLE__STRIKE_THROUGH:
case ViewPackage.NODE_STYLE__BORDER_COLOR:
case ViewPackage.NODE_STYLE__BORDER_RADIUS:
case ViewPackage.NODE_STYLE__BORDER_SIZE:
case ViewPackage.NODE_STYLE__BORDER_LINE_STYLE:
case ViewPackage.NODE_STYLE__LIST_MODE:
case ViewPackage.NODE_STYLE__SHAPE:
case ViewPackage.NODE_STYLE__LABEL_COLOR:
case ViewPackage.NODE_STYLE__SIZE_COMPUTATION_EXPRESSION:
switch (notification.getFeatureID(IconLabelNodeStyleDescription.class)) {
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__FONT_SIZE:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__ITALIC:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__BOLD:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__UNDERLINE:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__STRIKE_THROUGH:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__BORDER_COLOR:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__BORDER_RADIUS:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__BORDER_SIZE:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__BORDER_LINE_STYLE:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__LABEL_COLOR:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SIZE_COMPUTATION_EXPRESSION:
case ViewPackage.ICON_LABEL_NODE_STYLE_DESCRIPTION__SHOW_ICON:
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
Expand Down
Loading

0 comments on commit d122376

Please sign in to comment.