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 dfffcfa commit b35d9ed
Show file tree
Hide file tree
Showing 45 changed files with 5,599 additions and 2,024 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;
}

}
Loading

0 comments on commit b35d9ed

Please sign in to comment.