| /******************************************************************************* |
| * Copyright (c) 2006 IBM Corporation and others. |
| * 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.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.InternalEList; |
| import org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.Defence; |
| import org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.DefencePositionKind; |
| import org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.HockeyleaguePackage; |
| import org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.PlayerStats; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Defence</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.impl.DefenceImpl#getPosition <em>Position</em>}</li> |
| * <li>{@link org.eclipse.ui.examples.views.properties.tabbed.hockeyleague.impl.DefenceImpl#getPlayerStats <em>Player Stats</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class DefenceImpl extends PlayerImpl implements Defence { |
| /** |
| * The default value of the '{@link #getPosition() <em>Position</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPosition() |
| * @generated |
| * @ordered |
| */ |
| protected static final DefencePositionKind POSITION_EDEFAULT = DefencePositionKind.LEFT_DEFENCE_LITERAL; |
| |
| /** |
| * The cached value of the '{@link #getPosition() <em>Position</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPosition() |
| * @generated |
| * @ordered |
| */ |
| protected DefencePositionKind position = POSITION_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getPlayerStats() <em>Player Stats</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPlayerStats() |
| * @generated |
| * @ordered |
| */ |
| protected EList playerStats = null; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DefenceImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return HockeyleaguePackage.Literals.DEFENCE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public DefencePositionKind getPosition() { |
| return position; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setPosition(DefencePositionKind newPosition) { |
| DefencePositionKind oldPosition = position; |
| position = newPosition == null ? POSITION_EDEFAULT : newPosition; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, HockeyleaguePackage.DEFENCE__POSITION, oldPosition, position)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList getPlayerStats() { |
| if (playerStats == null) { |
| playerStats = new EObjectContainmentEList(PlayerStats.class, this, HockeyleaguePackage.DEFENCE__PLAYER_STATS); |
| } |
| return playerStats; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case HockeyleaguePackage.DEFENCE__PLAYER_STATS: |
| return ((InternalEList)getPlayerStats()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case HockeyleaguePackage.DEFENCE__POSITION: |
| return getPosition(); |
| case HockeyleaguePackage.DEFENCE__PLAYER_STATS: |
| return getPlayerStats(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case HockeyleaguePackage.DEFENCE__POSITION: |
| setPosition((DefencePositionKind)newValue); |
| return; |
| case HockeyleaguePackage.DEFENCE__PLAYER_STATS: |
| getPlayerStats().clear(); |
| getPlayerStats().addAll((Collection)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case HockeyleaguePackage.DEFENCE__POSITION: |
| setPosition(POSITION_EDEFAULT); |
| return; |
| case HockeyleaguePackage.DEFENCE__PLAYER_STATS: |
| getPlayerStats().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case HockeyleaguePackage.DEFENCE__POSITION: |
| return position != POSITION_EDEFAULT; |
| case HockeyleaguePackage.DEFENCE__PLAYER_STATS: |
| return playerStats != null && !playerStats.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (position: "); //$NON-NLS-1$ |
| result.append(position); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //DefenceImpl |