| /** |
| * 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.IItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| import org.eclipse.emf.edit.provider.ViewerNotification; |
| import org.eclipse.intent.mapping.MappingPackage; |
| import org.eclipse.intent.mapping.MappingUtils; |
| import org.eclipse.intent.mapping.TextLocation; |
| import org.eclipse.intent.mapping.base.ILocation; |
| |
| /** |
| * This is the item provider adapter for a {@link org.eclipse.intent.mapping.TextLocation} object. <!-- |
| * begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public class TextLocationItemProvider extends LocationItemProvider { |
| /** |
| * This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| public TextLocationItemProvider(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 (itemPropertyDescriptors == null) { |
| super.getPropertyDescriptors(object); |
| |
| addStartOffsetPropertyDescriptor(object); |
| addEndOffsetPropertyDescriptor(object); |
| } |
| return itemPropertyDescriptors; |
| } |
| |
| /** |
| * This adds a property descriptor for the Start Offset feature. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| protected void addStartOffsetPropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_TextLocation_startOffset_feature"), getString( |
| "_UI_PropertyDescriptor_description", "_UI_TextLocation_startOffset_feature", |
| "_UI_TextLocation_type"), MappingPackage.Literals.TEXT_LOCATION__START_OFFSET, |
| true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This adds a property descriptor for the End Offset feature. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @generated |
| */ |
| protected void addEndOffsetPropertyDescriptor(Object object) { |
| itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) |
| .getRootAdapterFactory(), getResourceLocator(), getString( |
| "_UI_TextLocation_endOffset_feature"), getString("_UI_PropertyDescriptor_description", |
| "_UI_TextLocation_endOffset_feature", "_UI_TextLocation_type"), |
| MappingPackage.Literals.TEXT_LOCATION__END_OFFSET, true, false, false, |
| ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); |
| } |
| |
| /** |
| * This returns TextLocation.gif. <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object getImage(Object object) { |
| return overlayImage(object, getResourceLocator().getImage("full/obj16/TextLocation")); |
| } |
| |
| /** |
| * 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 = MappingUtils.getConnectorRegistry().getName((ILocation)object); |
| return label == null || label.length() == 0 ? getString("_UI_TextLocation_type") |
| : getString("_UI_TextLocation_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(TextLocation.class)) { |
| case MappingPackage.TEXT_LOCATION__START_OFFSET: |
| case MappingPackage.TEXT_LOCATION__END_OFFSET: |
| 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); |
| } |
| |
| } |