| /** |
| * 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 org.eclipse.e4.ui.model.application.MApplicationPackage; |
| import org.eclipse.e4.ui.model.application.MElementContainer; |
| 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.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.EcoreUtil; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>UI Element</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.UIElementImpl#getWidget <em>Widget</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.UIElementImpl#getFactory <em>Factory</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.UIElementImpl#isVisible <em>Visible</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.impl.UIElementImpl#getParent <em>Parent</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public abstract class UIElementImpl extends ApplicationElementImpl implements MUIElement { |
| /** |
| * The default value of the '{@link #getWidget() <em>Widget</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getWidget() |
| * @generated |
| * @ordered |
| */ |
| protected static final Object WIDGET_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getWidget() <em>Widget</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getWidget() |
| * @generated |
| * @ordered |
| */ |
| protected Object widget = WIDGET_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getFactory() <em>Factory</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFactory() |
| * @generated |
| * @ordered |
| */ |
| protected static final Object FACTORY_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getFactory() <em>Factory</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFactory() |
| * @generated |
| * @ordered |
| */ |
| protected Object factory = FACTORY_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #isVisible() <em>Visible</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isVisible() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean VISIBLE_EDEFAULT = true; |
| |
| /** |
| * The cached value of the '{@link #isVisible() <em>Visible</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isVisible() |
| * @generated |
| * @ordered |
| */ |
| protected boolean visible = VISIBLE_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected UIElementImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MApplicationPackage.Literals.UI_ELEMENT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object getWidget() { |
| return widget; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setWidget(Object newWidget) { |
| Object oldWidget = widget; |
| widget = newWidget; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.UI_ELEMENT__WIDGET, oldWidget, widget)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object getFactory() { |
| return factory; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setFactory(Object newFactory) { |
| Object oldFactory = factory; |
| factory = newFactory; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.UI_ELEMENT__FACTORY, oldFactory, factory)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isVisible() { |
| return visible; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setVisible(boolean newVisible) { |
| boolean oldVisible = visible; |
| visible = newVisible; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.UI_ELEMENT__VISIBLE, oldVisible, visible)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| public MElementContainer<MUIElement> getParent() { |
| if (eContainerFeatureID() != MApplicationPackage.UI_ELEMENT__PARENT) return null; |
| return (MElementContainer<MUIElement>)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetParent(MElementContainer<MUIElement> newParent, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newParent, MApplicationPackage.UI_ELEMENT__PARENT, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setParent(MElementContainer<MUIElement> newParent) { |
| if (newParent != eInternalContainer() || (eContainerFeatureID() != MApplicationPackage.UI_ELEMENT__PARENT && newParent != null)) { |
| if (EcoreUtil.isAncestor(this, (EObject)newParent)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newParent != null) |
| msgs = ((InternalEObject)newParent).eInverseAdd(this, MApplicationPackage.ELEMENT_CONTAINER__CHILDREN, MElementContainer.class, msgs); |
| msgs = basicSetParent(newParent, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.UI_ELEMENT__PARENT, newParent, newParent)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetParent((MElementContainer<MUIElement>)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.UI_ELEMENT__PARENT: |
| return basicSetParent(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| return eInternalContainer().eInverseRemove(this, MApplicationPackage.ELEMENT_CONTAINER__CHILDREN, MElementContainer.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 MApplicationPackage.UI_ELEMENT__WIDGET: |
| return getWidget(); |
| case MApplicationPackage.UI_ELEMENT__FACTORY: |
| return getFactory(); |
| case MApplicationPackage.UI_ELEMENT__VISIBLE: |
| return isVisible(); |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| return getParent(); |
| } |
| 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.UI_ELEMENT__WIDGET: |
| setWidget(newValue); |
| return; |
| case MApplicationPackage.UI_ELEMENT__FACTORY: |
| setFactory(newValue); |
| return; |
| case MApplicationPackage.UI_ELEMENT__VISIBLE: |
| setVisible((Boolean)newValue); |
| return; |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| setParent((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.UI_ELEMENT__WIDGET: |
| setWidget(WIDGET_EDEFAULT); |
| return; |
| case MApplicationPackage.UI_ELEMENT__FACTORY: |
| setFactory(FACTORY_EDEFAULT); |
| return; |
| case MApplicationPackage.UI_ELEMENT__VISIBLE: |
| setVisible(VISIBLE_EDEFAULT); |
| return; |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| setParent((MElementContainer<MUIElement>)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MApplicationPackage.UI_ELEMENT__WIDGET: |
| return WIDGET_EDEFAULT == null ? widget != null : !WIDGET_EDEFAULT.equals(widget); |
| case MApplicationPackage.UI_ELEMENT__FACTORY: |
| return FACTORY_EDEFAULT == null ? factory != null : !FACTORY_EDEFAULT.equals(factory); |
| case MApplicationPackage.UI_ELEMENT__VISIBLE: |
| return visible != VISIBLE_EDEFAULT; |
| case MApplicationPackage.UI_ELEMENT__PARENT: |
| return getParent() != null; |
| } |
| 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(" (widget: "); //$NON-NLS-1$ |
| result.append(widget); |
| result.append(", factory: "); //$NON-NLS-1$ |
| result.append(factory); |
| result.append(", visible: "); //$NON-NLS-1$ |
| result.append(visible); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //UIElementImpl |