/*******************************************************************************
 * 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
 *******************************************************************************/
/**
 */
package com.irtsaintexupery.fiacre.instance.fiacreinstance.provider;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

import com.irtsaintexupery.fiacre.instance.fiacreinstance.util.FiacreinstanceAdapterFactory;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class FiacreinstanceItemProviderAdapterFactory extends FiacreinstanceAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FiacreinstanceItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceModel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InstanceModelItemProvider instanceModelItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceModel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInstanceModelAdapter() {
		if (instanceModelItemProvider == null) {
			instanceModelItemProvider = new InstanceModelItemProvider(this);
		}

		return instanceModelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutedStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExecutedStatementBlockItemProvider executedStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutedStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExecutedStatementBlockAdapter() {
		if (executedStatementBlockItemProvider == null) {
			executedStatementBlockItemProvider = new ExecutedStatementBlockItemProvider(this);
		}

		return executedStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutableStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExecutableStatementBlockItemProvider executableStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ExecutableStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExecutableStatementBlockAdapter() {
		if (executableStatementBlockItemProvider == null) {
			executableStatementBlockItemProvider = new ExecutableStatementBlockItemProvider(this);
		}

		return executableStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.FireableStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FireableStatementBlockItemProvider fireableStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.FireableStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createFireableStatementBlockAdapter() {
		if (fireableStatementBlockItemProvider == null) {
			fireableStatementBlockItemProvider = new FireableStatementBlockItemProvider(this);
		}

		return fireableStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.EnabledStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnabledStatementBlockItemProvider enabledStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.EnabledStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEnabledStatementBlockAdapter() {
		if (enabledStatementBlockItemProvider == null) {
			enabledStatementBlockItemProvider = new EnabledStatementBlockItemProvider(this);
		}

		return enabledStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.CompositionInstance} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CompositionInstanceItemProvider compositionInstanceItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.CompositionInstance}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCompositionInstanceAdapter() {
		if (compositionInstanceItemProvider == null) {
			compositionInstanceItemProvider = new CompositionInstanceItemProvider(this);
		}

		return compositionInstanceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ComponentDeclarationInstance} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComponentDeclarationInstanceItemProvider componentDeclarationInstanceItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ComponentDeclarationInstance}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createComponentDeclarationInstanceAdapter() {
		if (componentDeclarationInstanceItemProvider == null) {
			componentDeclarationInstanceItemProvider = new ComponentDeclarationInstanceItemProvider(this);
		}

		return componentDeclarationInstanceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ProcessDeclarationInstance} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProcessDeclarationInstanceItemProvider processDeclarationInstanceItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.ProcessDeclarationInstance}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createProcessDeclarationInstanceAdapter() {
		if (processDeclarationInstanceItemProvider == null) {
			processDeclarationInstanceItemProvider = new ProcessDeclarationInstanceItemProvider(this);
		}

		return processDeclarationInstanceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceExecutedStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InstanceExecutedStatementBlockItemProvider instanceExecutedStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceExecutedStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInstanceExecutedStatementBlockAdapter() {
		if (instanceExecutedStatementBlockItemProvider == null) {
			instanceExecutedStatementBlockItemProvider = new InstanceExecutedStatementBlockItemProvider(this);
		}

		return instanceExecutedStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceFireableStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InstanceFireableStatementBlockItemProvider instanceFireableStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceFireableStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInstanceFireableStatementBlockAdapter() {
		if (instanceFireableStatementBlockItemProvider == null) {
			instanceFireableStatementBlockItemProvider = new InstanceFireableStatementBlockItemProvider(this);
		}

		return instanceFireableStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceEnabledStatementBlock} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InstanceEnabledStatementBlockItemProvider instanceEnabledStatementBlockItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceEnabledStatementBlock}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInstanceEnabledStatementBlockAdapter() {
		if (instanceEnabledStatementBlockItemProvider == null) {
			instanceEnabledStatementBlockItemProvider = new InstanceEnabledStatementBlockItemProvider(this);
		}

		return instanceEnabledStatementBlockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.VariableDeclarationInstance} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected VariableDeclarationInstanceItemProvider variableDeclarationInstanceItemProvider;

	/**
	 * This creates an adapter for a {@link com.irtsaintexupery.fiacre.instance.fiacreinstance.VariableDeclarationInstance}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createVariableDeclarationInstanceAdapter() {
		if (variableDeclarationInstanceItemProvider == null) {
			variableDeclarationInstanceItemProvider = new VariableDeclarationInstanceItemProvider(this);
		}

		return variableDeclarationInstanceItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (instanceModelItemProvider != null) instanceModelItemProvider.dispose();
		if (executedStatementBlockItemProvider != null) executedStatementBlockItemProvider.dispose();
		if (executableStatementBlockItemProvider != null) executableStatementBlockItemProvider.dispose();
		if (fireableStatementBlockItemProvider != null) fireableStatementBlockItemProvider.dispose();
		if (enabledStatementBlockItemProvider != null) enabledStatementBlockItemProvider.dispose();
		if (compositionInstanceItemProvider != null) compositionInstanceItemProvider.dispose();
		if (componentDeclarationInstanceItemProvider != null) componentDeclarationInstanceItemProvider.dispose();
		if (processDeclarationInstanceItemProvider != null) processDeclarationInstanceItemProvider.dispose();
		if (instanceExecutedStatementBlockItemProvider != null) instanceExecutedStatementBlockItemProvider.dispose();
		if (instanceFireableStatementBlockItemProvider != null) instanceFireableStatementBlockItemProvider.dispose();
		if (instanceEnabledStatementBlockItemProvider != null) instanceEnabledStatementBlockItemProvider.dispose();
		if (variableDeclarationInstanceItemProvider != null) variableDeclarationInstanceItemProvider.dispose();
	}

}
