/**
* <copyright>
* </copyright>
*
* $Id$
*/
package com.openMap1.mapper.provider;
import com.openMap1.mapper.ConversionArgument;
import com.openMap1.mapper.ConversionSense;
import com.openMap1.mapper.MapperFactory;
import com.openMap1.mapper.MapperPackage;
import com.openMap1.mapper.PropertyConversion;
import java.util.Collection;
import java.util.List;
import java.util.Iterator;
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.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
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.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
/**
* This is the item provider adapter for a {@link com.openMap1.mapper.PropertyConversion} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class PropertyConversionItemProvider
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 PropertyConversionItemProvider(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);
addSubsetPropertyDescriptor(object);
addResultSlotPropertyDescriptor(object);
addSensePropertyDescriptor(object);
addDescriptionPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Subset feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSubsetPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_PropertyConversion_subset_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_PropertyConversion_subset_feature", "_UI_PropertyConversion_type"),
MapperPackage.Literals.PROPERTY_CONVERSION__SUBSET,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Result Slot feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addResultSlotPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_PropertyConversion_resultSlot_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_PropertyConversion_resultSlot_feature", "_UI_PropertyConversion_type"),
MapperPackage.Literals.PROPERTY_CONVERSION__RESULT_SLOT,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Sense feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSensePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_PropertyConversion_sense_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_PropertyConversion_sense_feature", "_UI_PropertyConversion_type"),
MapperPackage.Literals.PROPERTY_CONVERSION__SENSE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Description feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addDescriptionPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_PropertyConversion_description_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_PropertyConversion_description_feature", "_UI_PropertyConversion_type"),
MapperPackage.Literals.PROPERTY_CONVERSION__DESCRIPTION,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(MapperPackage.Literals.PROPERTY_CONVERSION__CONVERSION_IMPLEMENTATIONS);
childrenFeatures.add(MapperPackage.Literals.PROPERTY_CONVERSION__CONVERSION_ARGUMENTS);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This returns PropertyConversion.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/PropertyConversion"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public String getText(Object object) {
PropertyConversion pc = (PropertyConversion)object;
String label = "";
String arguments = "(";
for (Iterator<ConversionArgument> it = pc.getConversionArguments().iterator();it.hasNext();)
{
arguments = arguments + it.next().getPropertyName();
if (it.hasNext()) arguments = arguments + ", ";
}
arguments = arguments + ")";
if (pc.getSense().equals(ConversionSense.IN))
{
label = "Convert " + arguments + "=>" + pc.getResultSlot();
}
else if (pc.getSense().equals(ConversionSense.OUT))
{
label = "Convert " + pc.getResultSlot() + "<=" + arguments;
}
if (!pc.getSubset().equals(""))
label = label + " [" + pc.getSubset() + "]";
return 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(PropertyConversion.class)) {
case MapperPackage.PROPERTY_CONVERSION__SUBSET:
case MapperPackage.PROPERTY_CONVERSION__RESULT_SLOT:
case MapperPackage.PROPERTY_CONVERSION__SENSE:
case MapperPackage.PROPERTY_CONVERSION__DESCRIPTION:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case MapperPackage.PROPERTY_CONVERSION__CONVERSION_IMPLEMENTATIONS:
case MapperPackage.PROPERTY_CONVERSION__CONVERSION_ARGUMENTS:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
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);
newChildDescriptors.add
(createChildParameter
(MapperPackage.Literals.PROPERTY_CONVERSION__CONVERSION_IMPLEMENTATIONS,
MapperFactory.eINSTANCE.createJavaConversionImplementation()));
newChildDescriptors.add
(createChildParameter
(MapperPackage.Literals.PROPERTY_CONVERSION__CONVERSION_IMPLEMENTATIONS,
MapperFactory.eINSTANCE.createXSLTConversionImplementation()));
newChildDescriptors.add
(createChildParameter
(MapperPackage.Literals.PROPERTY_CONVERSION__CONVERSION_ARGUMENTS,
MapperFactory.eINSTANCE.createConversionArgument()));
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return MapperEditPlugin.INSTANCE;
}
}