| /** |
| * Copyright (c) 2015 Obeo. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Obeo - initial API and implementation and/or initial documentation |
| * ... |
| * |
| */ |
| package org.eclipse.intent.mapping.provider; |
| |
| import java.util.Collection; |
| import java.util.List; |
| |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
| import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ViewerNotification; |
| import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; |
| import org.eclipse.intent.mapping.EObjectLocation; |
| import org.eclipse.intent.mapping.MappingPackage; |
| import org.eclipse.intent.mapping.MappingUtils; |
| import org.eclipse.intent.mapping.base.ILocation; |
| import org.eclipse.jface.viewers.ILabelProvider; |
| |
| /** |
| * This is the item provider adapter for a {@link org.eclipse.intent.mapping.EObjectLocation} object. <!-- |
| * begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public class EObjectLocationItemProvider extends LocationItemProvider { |
| |
| /** |
| * The EMF {@link ILabelProvider}. |
| * |
| * @generated NOT |
| */ |
| private final ILabelProvider eLabelProvider; |
| |
| /** |
| * This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated NOT |
| */ |
| public EObjectLocationItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| final ComposedAdapterFactory factory = new ComposedAdapterFactory( |
| ComposedAdapterFactory.Descriptor.Registry.INSTANCE); |
| eLabelProvider = new AdapterFactoryLabelProvider(factory); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose() |
| * @generated NOT |
| */ |
| @Override |
| public void dispose() { |
| super.dispose(); |
| eLabelProvider.dispose(); |
| } |
| |
| /** |
| * This returns the property descriptors for the adapted class. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| @Override |
| public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| if (itemPropertyDescriptors == null) { |
| super.getPropertyDescriptors(object); |
| |
| addURIFragmentPropertyDescriptor(object); |
| addSavedURIFragmentPropertyDescriptor(object); |
| addFeatureNamePropertyDescriptor(object); |
| addIndexPropertyDescriptor(object); |
| } |
| return itemPropertyDescriptors; |
| } |
| |
| /** |
| * This adds a property descriptor for the URI Fragment feature. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| protected void addURIFragmentPropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_EObjectLocation_URIFragment_feature"), getString( |
| "_UI_PropertyDescriptor_description", |
| "_UI_EObjectLocation_URIFragment_feature", "_UI_EObjectLocation_type"), |
| MappingPackage.Literals.EOBJECT_LOCATION__URI_FRAGMENT, true, false, false, |
| ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This adds a property descriptor for the Saved URI Fragment feature. <!-- begin-user-doc --> <!-- |
| * end-user-doc --> |
| * |
| * @generated |
| */ |
| protected void addSavedURIFragmentPropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_EObjectLocation_savedURIFragment_feature"), getString( |
| "_UI_PropertyDescriptor_description", |
| "_UI_EObjectLocation_savedURIFragment_feature", "_UI_EObjectLocation_type"), |
| MappingPackage.Literals.EOBJECT_LOCATION__SAVED_URI_FRAGMENT, true, false, false, |
| ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This adds a property descriptor for the Feature Name feature. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| protected void addFeatureNamePropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_EObjectLocation_featureName_feature"), getString( |
| "_UI_PropertyDescriptor_description", |
| "_UI_EObjectLocation_featureName_feature", "_UI_EObjectLocation_type"), |
| MappingPackage.Literals.EOBJECT_LOCATION__FEATURE_NAME, true, false, false, |
| ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This adds a property descriptor for the Index feature. <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected void addIndexPropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_EObjectLocation_index_feature"), getString("_UI_PropertyDescriptor_description", |
| "_UI_EObjectLocation_index_feature", "_UI_EObjectLocation_type"), |
| MappingPackage.Literals.EOBJECT_LOCATION__INDEX, true, false, false, |
| ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This returns EObjectLocation.gif. <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object getImage(Object object) { |
| return overlayImage(object, getResourceLocator().getImage("full/obj16/EObjectLocation")); |
| } |
| |
| /** |
| * This returns the label text for the adapted class. <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public String getText(Object object) { |
| final String label; |
| |
| label = MappingUtils.getConnectorRegistry().getName((ILocation)object); |
| |
| return label == null || label.length() == 0 ? getString("_UI_EObjectLocation_type") |
| : getString("_UI_EObjectLocation_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) { |
| updateChildren(notification); |
| |
| switch (notification.getFeatureID(EObjectLocation.class)) { |
| case MappingPackage.EOBJECT_LOCATION__URI_FRAGMENT: |
| case MappingPackage.EOBJECT_LOCATION__SAVED_URI_FRAGMENT: |
| case MappingPackage.EOBJECT_LOCATION__FEATURE_NAME: |
| case MappingPackage.EOBJECT_LOCATION__INDEX: |
| 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); |
| } |
| |
| } |