/******************************************************************************* * Copyright (c) 2008, 2011 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 *******************************************************************************/ package org.eclipse.emf.eef.views.impl; import java.util.Collection; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.emf.eef.views.Category; import org.eclipse.emf.eef.views.View; import org.eclipse.emf.eef.views.ViewsPackage; import org.eclipse.emf.eef.views.ViewsRepository; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Category</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.eef.views.impl.CategoryImpl#getViews <em>Views</em>}</li> * <li>{@link org.eclipse.emf.eef.views.impl.CategoryImpl#getRepository <em>Repository</em>}</li> * <li>{@link org.eclipse.emf.eef.views.impl.CategoryImpl#getCategories <em>Categories</em>}</li> * <li>{@link org.eclipse.emf.eef.views.impl.CategoryImpl#getName <em>Name</em>}</li> * </ul> * </p> * * @generated */ public class CategoryImpl extends DocumentedElementImpl implements Category { /** * The cached value of the '{@link #getViews() <em>Views</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getViews() * @generated * @ordered */ protected EList<View> views; /** * The cached value of the '{@link #getCategories() <em>Categories</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCategories() * @generated * @ordered */ protected EList<Category> categories; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected CategoryImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ViewsPackage.Literals.CATEGORY; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<View> getViews() { if (views == null) { views = new EObjectContainmentWithInverseEList<View>(View.class, this, ViewsPackage.CATEGORY__VIEWS, ViewsPackage.VIEW__CATEGORY); } return views; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ViewsPackage.CATEGORY__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ViewsRepository getRepository() { if (eContainerFeatureID() != ViewsPackage.CATEGORY__REPOSITORY) return null; return (ViewsRepository) eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetRepository(ViewsRepository newRepository, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject) newRepository, ViewsPackage.CATEGORY__REPOSITORY, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRepository(ViewsRepository newRepository) { if (newRepository != eInternalContainer() || (eContainerFeatureID() != ViewsPackage.CATEGORY__REPOSITORY && newRepository != null)) { if (EcoreUtil.isAncestor(this, newRepository)) throw new IllegalArgumentException( "Recursive containment not allowed for " + toString()); //$NON-NLS-1$ NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newRepository != null) msgs = ((InternalEObject) newRepository).eInverseAdd(this, ViewsPackage.VIEWS_REPOSITORY__CATEGORIES, ViewsRepository.class, msgs); msgs = basicSetRepository(newRepository, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ViewsPackage.CATEGORY__REPOSITORY, newRepository, newRepository)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Category> getCategories() { if (categories == null) { categories = new EObjectContainmentEList<Category>(Category.class, this, ViewsPackage.CATEGORY__CATEGORIES); } return categories; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: return ((InternalEList<InternalEObject>) (InternalEList<?>) getViews()) .basicAdd(otherEnd, msgs); case ViewsPackage.CATEGORY__REPOSITORY: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetRepository((ViewsRepository) otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: return ((InternalEList<?>) getViews()).basicRemove(otherEnd, msgs); case ViewsPackage.CATEGORY__REPOSITORY: return basicSetRepository(null, msgs); case ViewsPackage.CATEGORY__CATEGORIES: return ((InternalEList<?>) getCategories()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature( NotificationChain msgs) { switch (eContainerFeatureID()) { case ViewsPackage.CATEGORY__REPOSITORY: return eInternalContainer().eInverseRemove(this, ViewsPackage.VIEWS_REPOSITORY__CATEGORIES, ViewsRepository.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: return getViews(); case ViewsPackage.CATEGORY__REPOSITORY: return getRepository(); case ViewsPackage.CATEGORY__CATEGORIES: return getCategories(); case ViewsPackage.CATEGORY__NAME: return getName(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: getViews().clear(); getViews().addAll((Collection<? extends View>) newValue); return; case ViewsPackage.CATEGORY__REPOSITORY: setRepository((ViewsRepository) newValue); return; case ViewsPackage.CATEGORY__CATEGORIES: getCategories().clear(); getCategories().addAll((Collection<? extends Category>) newValue); return; case ViewsPackage.CATEGORY__NAME: setName((String) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: getViews().clear(); return; case ViewsPackage.CATEGORY__REPOSITORY: setRepository((ViewsRepository) null); return; case ViewsPackage.CATEGORY__CATEGORIES: getCategories().clear(); return; case ViewsPackage.CATEGORY__NAME: setName(NAME_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ViewsPackage.CATEGORY__VIEWS: return views != null && !views.isEmpty(); case ViewsPackage.CATEGORY__REPOSITORY: return getRepository() != null; case ViewsPackage.CATEGORY__CATEGORIES: return categories != null && !categories.isEmpty(); case ViewsPackage.CATEGORY__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT .equals(name); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (name: "); //$NON-NLS-1$ result.append(name); result.append(')'); return result.toString(); } } //CategoryImpl