/*******************************************************************************
 * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the LGPL 3.0
 * which accompanies this distribution, and is available at
 * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *
 * Contributors:
 *      Faiez Zalila - initial API and implementation and/or initial documentation
 *******************************************************************************/
/**
 * generated by Xtext 2.10.0
 */
package fr.irit.fiacre.xtext.fiacre.provider;


import fr.irit.fiacre.xtext.fiacre.FiacreFactory;
import fr.irit.fiacre.xtext.fiacre.FiacrePackage;
import fr.irit.fiacre.xtext.fiacre.PresencePattern;

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.ecore.EStructuralFeature;

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;

/**
 * This is the item provider adapter for a {@link fr.irit.fiacre.xtext.fiacre.PresencePattern} object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class PresencePatternItemProvider extends PatternPropertyItemProvider {
	/**
	 * This constructs an instance from a factory and a notifier.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresencePatternItemProvider(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);

			addLastingPropertyDescriptor(object);
		}
		return itemPropertyDescriptors;
	}

	/**
	 * This adds a property descriptor for the Lasting feature.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected void addLastingPropertyDescriptor(Object object) {
		itemPropertyDescriptors.add
			(createItemPropertyDescriptor
				(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
				 getResourceLocator(),
				 getString("_UI_PresencePattern_lasting_feature"),
				 getString("_UI_PropertyDescriptor_description", "_UI_PresencePattern_lasting_feature", "_UI_PresencePattern_type"),
				 FiacrePackage.eINSTANCE.getPresencePattern_Lasting(),
				 true,
				 false,
				 false,
				 ItemPropertyDescriptor.INTEGRAL_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(FiacrePackage.eINSTANCE.getPresencePattern_Subject());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_After());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Lower());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Upper());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Until());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Before());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Min());
			childrenFeatures.add(FiacrePackage.eINSTANCE.getPresencePattern_Max());
		}
		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 PresencePattern.gif.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object getImage(Object object) {
		return overlayImage(object, getResourceLocator().getImage("full/obj16/PresencePattern"));
	}

	/**
	 * This returns the label text for the adapted class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String getText(Object object) {
		PresencePattern presencePattern = (PresencePattern)object;
		return getString("_UI_PresencePattern_type") + " " + presencePattern.getLasting();
	}
	

	/**
	 * 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(PresencePattern.class)) {
			case FiacrePackage.PRESENCE_PATTERN__LASTING:
				fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
				return;
			case FiacrePackage.PRESENCE_PATTERN__SUBJECT:
			case FiacrePackage.PRESENCE_PATTERN__AFTER:
			case FiacrePackage.PRESENCE_PATTERN__LOWER:
			case FiacrePackage.PRESENCE_PATTERN__UPPER:
			case FiacrePackage.PRESENCE_PATTERN__UNTIL:
			case FiacrePackage.PRESENCE_PATTERN__BEFORE:
			case FiacrePackage.PRESENCE_PATTERN__MIN:
			case FiacrePackage.PRESENCE_PATTERN__MAX:
				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
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Subject(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_After(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Lower(),
				 FiacreFactory.eINSTANCE.createLowerBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Lower(),
				 FiacreFactory.eINSTANCE.createNaturalLowerBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Lower(),
				 FiacreFactory.eINSTANCE.createDecimalLowerBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Lower(),
				 FiacreFactory.eINSTANCE.createVariableLowerBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Upper(),
				 FiacreFactory.eINSTANCE.createUpperBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Upper(),
				 FiacreFactory.eINSTANCE.createNaturalUpperBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Upper(),
				 FiacreFactory.eINSTANCE.createDecimalUpperBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Upper(),
				 FiacreFactory.eINSTANCE.createVariableUpperBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Upper(),
				 FiacreFactory.eINSTANCE.createInfiniteUpperBound()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Until(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Before(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Min(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservableEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createEnterStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createLeaveStateEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservable()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createPathEvent()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservableDisjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservableImplication()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservableConjunction()));

		newChildDescriptors.add
			(createChildParameter
				(FiacrePackage.eINSTANCE.getPresencePattern_Max(),
				 FiacreFactory.eINSTANCE.createObservableNegation()));
	}

	/**
	 * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) {
		Object childFeature = feature;
		Object childObject = child;

		boolean qualify =
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_Subject() ||
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_After() ||
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_Until() ||
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_Before() ||
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_Min() ||
			childFeature == FiacrePackage.eINSTANCE.getPresencePattern_Max();

		if (qualify) {
			return getString
				("_UI_CreateChild_text2",
				 new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) });
		}
		return super.getCreateChildText(owner, feature, child, selection);
	}

}
