| /** |
| * Copyright (c) 2008 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.e4.ui.model.application.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.e4.ui.model.application.MApplicationPackage; |
| import org.eclipse.e4.ui.model.application.MElementContainer; |
| import org.eclipse.e4.ui.model.application.MMenu; |
| import org.eclipse.e4.ui.model.application.MMenuItem; |
| import org.eclipse.e4.ui.model.application.MUIElement; |
| |
| 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.EObject; |
| import org.eclipse.emf.ecore.InternalEObject; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Menu Item</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.MenuItemImpl#getChildren <em>Children</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.MenuItemImpl#getActiveChild <em>Active Child</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class MenuItemImpl extends ItemImpl implements MMenuItem { |
| /** |
| * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getChildren() |
| * @generated |
| * @ordered |
| */ |
| protected EList<MMenuItem> children; |
| |
| /** |
| * The cached value of the '{@link #getActiveChild() <em>Active Child</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getActiveChild() |
| * @generated |
| * @ordered |
| */ |
| protected MMenuItem activeChild; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected MenuItemImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MApplicationPackage.Literals.MENU_ITEM; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<MMenuItem> getChildren() { |
| if (children == null) { |
| children = new EObjectContainmentWithInverseEList<MMenuItem>(MUIElement.class, this, MApplicationPackage.MENU_ITEM__CHILDREN, MApplicationPackage.UI_ELEMENT__PARENT); |
| } |
| return children; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MMenuItem getActiveChild() { |
| if (activeChild != null && ((EObject)activeChild).eIsProxy()) { |
| InternalEObject oldActiveChild = (InternalEObject)activeChild; |
| activeChild = (MMenuItem)eResolveProxy(oldActiveChild); |
| if (activeChild != oldActiveChild) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.MENU_ITEM__ACTIVE_CHILD, oldActiveChild, activeChild)); |
| } |
| } |
| return activeChild; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MMenuItem basicGetActiveChild() { |
| return activeChild; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setActiveChild(MMenuItem newActiveChild) { |
| MMenuItem oldActiveChild = activeChild; |
| activeChild = newActiveChild; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.MENU_ITEM__ACTIVE_CHILD, oldActiveChild, activeChild)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MApplicationPackage.MENU_ITEM__CHILDREN: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(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 MApplicationPackage.MENU_ITEM__CHILDREN: |
| return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case MApplicationPackage.MENU_ITEM__CHILDREN: |
| return getChildren(); |
| case MApplicationPackage.MENU_ITEM__ACTIVE_CHILD: |
| if (resolve) return getActiveChild(); |
| return basicGetActiveChild(); |
| } |
| 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 MApplicationPackage.MENU_ITEM__CHILDREN: |
| getChildren().clear(); |
| getChildren().addAll((Collection<? extends MMenuItem>)newValue); |
| return; |
| case MApplicationPackage.MENU_ITEM__ACTIVE_CHILD: |
| setActiveChild((MMenuItem)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MApplicationPackage.MENU_ITEM__CHILDREN: |
| getChildren().clear(); |
| return; |
| case MApplicationPackage.MENU_ITEM__ACTIVE_CHILD: |
| setActiveChild((MMenuItem)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MApplicationPackage.MENU_ITEM__CHILDREN: |
| return children != null && !children.isEmpty(); |
| case MApplicationPackage.MENU_ITEM__ACTIVE_CHILD: |
| return activeChild != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == MElementContainer.class) { |
| switch (derivedFeatureID) { |
| case MApplicationPackage.MENU_ITEM__CHILDREN: return MApplicationPackage.ELEMENT_CONTAINER__CHILDREN; |
| case MApplicationPackage.MENU_ITEM__ACTIVE_CHILD: return MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD; |
| default: return -1; |
| } |
| } |
| if (baseClass == MMenu.class) { |
| switch (derivedFeatureID) { |
| default: return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == MElementContainer.class) { |
| switch (baseFeatureID) { |
| case MApplicationPackage.ELEMENT_CONTAINER__CHILDREN: return MApplicationPackage.MENU_ITEM__CHILDREN; |
| case MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD: return MApplicationPackage.MENU_ITEM__ACTIVE_CHILD; |
| default: return -1; |
| } |
| } |
| if (baseClass == MMenu.class) { |
| switch (baseFeatureID) { |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| } //MenuItemImpl |