| /** |
| * 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.MTrimStructure; |
| 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>Trim Structure</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getChildren <em>Children</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getActiveChild <em>Active Child</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getTop <em>Top</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getBottom <em>Bottom</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getLeft <em>Left</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.TrimStructureImpl#getRight <em>Right</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class TrimStructureImpl<T extends MUIElement> extends UIElementImpl implements MTrimStructure<T> { |
| /** |
| * 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<T> children; |
| |
| /** |
| * The cached value of the '{@link #getActiveChild() <em>Active Child</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getActiveChild() |
| * @generated |
| * @ordered |
| */ |
| protected T activeChild; |
| |
| /** |
| * The cached value of the '{@link #getTop() <em>Top</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTop() |
| * @generated |
| * @ordered |
| */ |
| protected MElementContainer<MUIElement> top; |
| |
| /** |
| * The cached value of the '{@link #getBottom() <em>Bottom</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBottom() |
| * @generated |
| * @ordered |
| */ |
| protected MElementContainer<MUIElement> bottom; |
| |
| /** |
| * The cached value of the '{@link #getLeft() <em>Left</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLeft() |
| * @generated |
| * @ordered |
| */ |
| protected MElementContainer<MUIElement> left; |
| |
| /** |
| * The cached value of the '{@link #getRight() <em>Right</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getRight() |
| * @generated |
| * @ordered |
| */ |
| protected MElementContainer<MUIElement> right; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TrimStructureImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MApplicationPackage.Literals.TRIM_STRUCTURE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<T> getChildren() { |
| if (children == null) { |
| children = new EObjectContainmentWithInverseEList<T>(MUIElement.class, this, MApplicationPackage.TRIM_STRUCTURE__CHILDREN, MApplicationPackage.UI_ELEMENT__PARENT); |
| } |
| return children; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public T getActiveChild() { |
| if (activeChild != null && ((EObject)activeChild).eIsProxy()) { |
| InternalEObject oldActiveChild = (InternalEObject)activeChild; |
| activeChild = (T)eResolveProxy(oldActiveChild); |
| if (activeChild != oldActiveChild) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD, oldActiveChild, activeChild)); |
| } |
| } |
| return activeChild; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public T basicGetActiveChild() { |
| return activeChild; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setActiveChild(T newActiveChild) { |
| T oldActiveChild = activeChild; |
| activeChild = newActiveChild; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD, oldActiveChild, activeChild)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public MElementContainer<MUIElement> getTop() { |
| if (top != null && ((EObject)top).eIsProxy()) { |
| InternalEObject oldTop = (InternalEObject)top; |
| top = (MElementContainer<MUIElement>)eResolveProxy(oldTop); |
| if (top != oldTop) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.TRIM_STRUCTURE__TOP, oldTop, top)); |
| } |
| } |
| return top; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MElementContainer<MUIElement> basicGetTop() { |
| return top; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTop(MElementContainer<MUIElement> newTop) { |
| MElementContainer<MUIElement> oldTop = top; |
| top = newTop; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.TRIM_STRUCTURE__TOP, oldTop, top)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public MElementContainer<MUIElement> getBottom() { |
| if (bottom != null && ((EObject)bottom).eIsProxy()) { |
| InternalEObject oldBottom = (InternalEObject)bottom; |
| bottom = (MElementContainer<MUIElement>)eResolveProxy(oldBottom); |
| if (bottom != oldBottom) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.TRIM_STRUCTURE__BOTTOM, oldBottom, bottom)); |
| } |
| } |
| return bottom; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MElementContainer<MUIElement> basicGetBottom() { |
| return bottom; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setBottom(MElementContainer<MUIElement> newBottom) { |
| MElementContainer<MUIElement> oldBottom = bottom; |
| bottom = newBottom; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.TRIM_STRUCTURE__BOTTOM, oldBottom, bottom)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public MElementContainer<MUIElement> getLeft() { |
| if (left != null && ((EObject)left).eIsProxy()) { |
| InternalEObject oldLeft = (InternalEObject)left; |
| left = (MElementContainer<MUIElement>)eResolveProxy(oldLeft); |
| if (left != oldLeft) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.TRIM_STRUCTURE__LEFT, oldLeft, left)); |
| } |
| } |
| return left; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MElementContainer<MUIElement> basicGetLeft() { |
| return left; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLeft(MElementContainer<MUIElement> newLeft) { |
| MElementContainer<MUIElement> oldLeft = left; |
| left = newLeft; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.TRIM_STRUCTURE__LEFT, oldLeft, left)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public MElementContainer<MUIElement> getRight() { |
| if (right != null && ((EObject)right).eIsProxy()) { |
| InternalEObject oldRight = (InternalEObject)right; |
| right = (MElementContainer<MUIElement>)eResolveProxy(oldRight); |
| if (right != oldRight) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.TRIM_STRUCTURE__RIGHT, oldRight, right)); |
| } |
| } |
| return right; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MElementContainer<MUIElement> basicGetRight() { |
| return right; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setRight(MElementContainer<MUIElement> newRight) { |
| MElementContainer<MUIElement> oldRight = right; |
| right = newRight; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.TRIM_STRUCTURE__RIGHT, oldRight, right)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MApplicationPackage.TRIM_STRUCTURE__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.TRIM_STRUCTURE__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.TRIM_STRUCTURE__CHILDREN: |
| return getChildren(); |
| case MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD: |
| if (resolve) return getActiveChild(); |
| return basicGetActiveChild(); |
| case MApplicationPackage.TRIM_STRUCTURE__TOP: |
| if (resolve) return getTop(); |
| return basicGetTop(); |
| case MApplicationPackage.TRIM_STRUCTURE__BOTTOM: |
| if (resolve) return getBottom(); |
| return basicGetBottom(); |
| case MApplicationPackage.TRIM_STRUCTURE__LEFT: |
| if (resolve) return getLeft(); |
| return basicGetLeft(); |
| case MApplicationPackage.TRIM_STRUCTURE__RIGHT: |
| if (resolve) return getRight(); |
| return basicGetRight(); |
| } |
| 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.TRIM_STRUCTURE__CHILDREN: |
| getChildren().clear(); |
| getChildren().addAll((Collection<? extends T>)newValue); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD: |
| setActiveChild((T)newValue); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__TOP: |
| setTop((MElementContainer<MUIElement>)newValue); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__BOTTOM: |
| setBottom((MElementContainer<MUIElement>)newValue); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__LEFT: |
| setLeft((MElementContainer<MUIElement>)newValue); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__RIGHT: |
| setRight((MElementContainer<MUIElement>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MApplicationPackage.TRIM_STRUCTURE__CHILDREN: |
| getChildren().clear(); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD: |
| setActiveChild((T)null); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__TOP: |
| setTop((MElementContainer<MUIElement>)null); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__BOTTOM: |
| setBottom((MElementContainer<MUIElement>)null); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__LEFT: |
| setLeft((MElementContainer<MUIElement>)null); |
| return; |
| case MApplicationPackage.TRIM_STRUCTURE__RIGHT: |
| setRight((MElementContainer<MUIElement>)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MApplicationPackage.TRIM_STRUCTURE__CHILDREN: |
| return children != null && !children.isEmpty(); |
| case MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD: |
| return activeChild != null; |
| case MApplicationPackage.TRIM_STRUCTURE__TOP: |
| return top != null; |
| case MApplicationPackage.TRIM_STRUCTURE__BOTTOM: |
| return bottom != null; |
| case MApplicationPackage.TRIM_STRUCTURE__LEFT: |
| return left != null; |
| case MApplicationPackage.TRIM_STRUCTURE__RIGHT: |
| return right != 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.TRIM_STRUCTURE__CHILDREN: return MApplicationPackage.ELEMENT_CONTAINER__CHILDREN; |
| case MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD: return MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD; |
| 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.TRIM_STRUCTURE__CHILDREN; |
| case MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD: return MApplicationPackage.TRIM_STRUCTURE__ACTIVE_CHILD; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| } //TrimStructureImpl |