blob: 3fb65b32fdaf0cae2fd28e464cd66200dd4226f1 [file] [log] [blame]
/**
* 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.MApplication;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.MApplicationPackage;
import org.eclipse.e4.ui.model.application.MCommand;
import org.eclipse.e4.ui.model.application.MElementContainer;
import org.eclipse.e4.ui.model.application.MUIElement;
import org.eclipse.e4.ui.model.application.MWindow;
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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Application</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getId <em>Id</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getWidget <em>Widget</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getFactory <em>Factory</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#isVisible <em>Visible</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getParent <em>Parent</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getChildren <em>Children</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getActiveChild <em>Active Child</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationImpl#getCommands <em>Commands</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ApplicationImpl extends ContextImpl implements MApplication {
/**
* The default value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getId()
* @generated
* @ordered
*/
protected static final String ID_EDEFAULT = null;
/**
* The cached value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getId()
* @generated
* @ordered
*/
protected String id = ID_EDEFAULT;
/**
* 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;
/**
* 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<MWindow> children;
/**
* The cached value of the '{@link #getActiveChild() <em>Active Child</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getActiveChild()
* @generated
* @ordered
*/
protected MWindow activeChild;
/**
* The cached value of the '{@link #getCommands() <em>Commands</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCommands()
* @generated
* @ordered
*/
protected EList<MCommand> commands;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ApplicationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MApplicationPackage.Literals.APPLICATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getId() {
return id;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setId(String newId) {
String oldId = id;
id = newId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.APPLICATION__ID, oldId, id));
}
/**
* <!-- 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.APPLICATION__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.APPLICATION__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.APPLICATION__VISIBLE, oldVisible, visible));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
public MElementContainer<MUIElement> getParent() {
if (eContainerFeatureID() != MApplicationPackage.APPLICATION__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.APPLICATION__PARENT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParent(MElementContainer<MUIElement> newParent) {
if (newParent != eInternalContainer() || (eContainerFeatureID() != MApplicationPackage.APPLICATION__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.APPLICATION__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<MWindow> getChildren() {
if (children == null) {
children = new EObjectContainmentWithInverseEList<MWindow>(MUIElement.class, this, MApplicationPackage.APPLICATION__CHILDREN, MApplicationPackage.UI_ELEMENT__PARENT);
}
return children;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MWindow getActiveChild() {
if (activeChild != null && ((EObject)activeChild).eIsProxy()) {
InternalEObject oldActiveChild = (InternalEObject)activeChild;
activeChild = (MWindow)eResolveProxy(oldActiveChild);
if (activeChild != oldActiveChild) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.APPLICATION__ACTIVE_CHILD, oldActiveChild, activeChild));
}
}
return activeChild;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MWindow basicGetActiveChild() {
return activeChild;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setActiveChild(MWindow newActiveChild) {
MWindow oldActiveChild = activeChild;
activeChild = newActiveChild;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.APPLICATION__ACTIVE_CHILD, oldActiveChild, activeChild));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<MCommand> getCommands() {
if (commands == null) {
commands = new EObjectContainmentEList<MCommand>(MCommand.class, this, MApplicationPackage.APPLICATION__COMMANDS);
}
return commands;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MApplicationPackage.APPLICATION__PARENT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetParent((MElementContainer<MUIElement>)otherEnd, msgs);
case MApplicationPackage.APPLICATION__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.APPLICATION__PARENT:
return basicSetParent(null, msgs);
case MApplicationPackage.APPLICATION__CHILDREN:
return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
case MApplicationPackage.APPLICATION__COMMANDS:
return ((InternalEList<?>)getCommands()).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 MApplicationPackage.APPLICATION__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.APPLICATION__ID:
return getId();
case MApplicationPackage.APPLICATION__WIDGET:
return getWidget();
case MApplicationPackage.APPLICATION__FACTORY:
return getFactory();
case MApplicationPackage.APPLICATION__VISIBLE:
return isVisible();
case MApplicationPackage.APPLICATION__PARENT:
return getParent();
case MApplicationPackage.APPLICATION__CHILDREN:
return getChildren();
case MApplicationPackage.APPLICATION__ACTIVE_CHILD:
if (resolve) return getActiveChild();
return basicGetActiveChild();
case MApplicationPackage.APPLICATION__COMMANDS:
return getCommands();
}
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.APPLICATION__ID:
setId((String)newValue);
return;
case MApplicationPackage.APPLICATION__WIDGET:
setWidget(newValue);
return;
case MApplicationPackage.APPLICATION__FACTORY:
setFactory(newValue);
return;
case MApplicationPackage.APPLICATION__VISIBLE:
setVisible((Boolean)newValue);
return;
case MApplicationPackage.APPLICATION__PARENT:
setParent((MElementContainer<MUIElement>)newValue);
return;
case MApplicationPackage.APPLICATION__CHILDREN:
getChildren().clear();
getChildren().addAll((Collection<? extends MWindow>)newValue);
return;
case MApplicationPackage.APPLICATION__ACTIVE_CHILD:
setActiveChild((MWindow)newValue);
return;
case MApplicationPackage.APPLICATION__COMMANDS:
getCommands().clear();
getCommands().addAll((Collection<? extends MCommand>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MApplicationPackage.APPLICATION__ID:
setId(ID_EDEFAULT);
return;
case MApplicationPackage.APPLICATION__WIDGET:
setWidget(WIDGET_EDEFAULT);
return;
case MApplicationPackage.APPLICATION__FACTORY:
setFactory(FACTORY_EDEFAULT);
return;
case MApplicationPackage.APPLICATION__VISIBLE:
setVisible(VISIBLE_EDEFAULT);
return;
case MApplicationPackage.APPLICATION__PARENT:
setParent((MElementContainer<MUIElement>)null);
return;
case MApplicationPackage.APPLICATION__CHILDREN:
getChildren().clear();
return;
case MApplicationPackage.APPLICATION__ACTIVE_CHILD:
setActiveChild((MWindow)null);
return;
case MApplicationPackage.APPLICATION__COMMANDS:
getCommands().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MApplicationPackage.APPLICATION__ID:
return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
case MApplicationPackage.APPLICATION__WIDGET:
return WIDGET_EDEFAULT == null ? widget != null : !WIDGET_EDEFAULT.equals(widget);
case MApplicationPackage.APPLICATION__FACTORY:
return FACTORY_EDEFAULT == null ? factory != null : !FACTORY_EDEFAULT.equals(factory);
case MApplicationPackage.APPLICATION__VISIBLE:
return visible != VISIBLE_EDEFAULT;
case MApplicationPackage.APPLICATION__PARENT:
return getParent() != null;
case MApplicationPackage.APPLICATION__CHILDREN:
return children != null && !children.isEmpty();
case MApplicationPackage.APPLICATION__ACTIVE_CHILD:
return activeChild != null;
case MApplicationPackage.APPLICATION__COMMANDS:
return commands != null && !commands.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == MApplicationElement.class) {
switch (derivedFeatureID) {
case MApplicationPackage.APPLICATION__ID: return MApplicationPackage.APPLICATION_ELEMENT__ID;
default: return -1;
}
}
if (baseClass == MUIElement.class) {
switch (derivedFeatureID) {
case MApplicationPackage.APPLICATION__WIDGET: return MApplicationPackage.UI_ELEMENT__WIDGET;
case MApplicationPackage.APPLICATION__FACTORY: return MApplicationPackage.UI_ELEMENT__FACTORY;
case MApplicationPackage.APPLICATION__VISIBLE: return MApplicationPackage.UI_ELEMENT__VISIBLE;
case MApplicationPackage.APPLICATION__PARENT: return MApplicationPackage.UI_ELEMENT__PARENT;
default: return -1;
}
}
if (baseClass == MElementContainer.class) {
switch (derivedFeatureID) {
case MApplicationPackage.APPLICATION__CHILDREN: return MApplicationPackage.ELEMENT_CONTAINER__CHILDREN;
case MApplicationPackage.APPLICATION__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 == MApplicationElement.class) {
switch (baseFeatureID) {
case MApplicationPackage.APPLICATION_ELEMENT__ID: return MApplicationPackage.APPLICATION__ID;
default: return -1;
}
}
if (baseClass == MUIElement.class) {
switch (baseFeatureID) {
case MApplicationPackage.UI_ELEMENT__WIDGET: return MApplicationPackage.APPLICATION__WIDGET;
case MApplicationPackage.UI_ELEMENT__FACTORY: return MApplicationPackage.APPLICATION__FACTORY;
case MApplicationPackage.UI_ELEMENT__VISIBLE: return MApplicationPackage.APPLICATION__VISIBLE;
case MApplicationPackage.UI_ELEMENT__PARENT: return MApplicationPackage.APPLICATION__PARENT;
default: return -1;
}
}
if (baseClass == MElementContainer.class) {
switch (baseFeatureID) {
case MApplicationPackage.ELEMENT_CONTAINER__CHILDREN: return MApplicationPackage.APPLICATION__CHILDREN;
case MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD: return MApplicationPackage.APPLICATION__ACTIVE_CHILD;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (id: "); //$NON-NLS-1$
result.append(id);
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();
}
} //ApplicationImpl