blob: 8a8a1004d67ca8179970b8aa04e839f57f8a4b40 [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.core.services.context.IEclipseContext;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.MApplicationPackage;
import org.eclipse.e4.ui.model.application.MContext;
import org.eclipse.e4.ui.model.application.MElementContainer;
import org.eclipse.e4.ui.model.application.MPerspective;
import org.eclipse.e4.ui.model.application.MUIElement;
import org.eclipse.e4.ui.model.application.MVSCElement;
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.EDataTypeUniqueEList;
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>Perspective</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getId <em>Id</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getWidget <em>Widget</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getFactory <em>Factory</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#isVisible <em>Visible</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getParent <em>Parent</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getChildren <em>Children</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getActiveChild <em>Active Child</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getContext <em>Context</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.PerspectiveImpl#getVariables <em>Variables</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PerspectiveImpl extends UIItemImpl implements MPerspective {
/**
* 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<MVSCElement> children;
/**
* The cached value of the '{@link #getActiveChild() <em>Active Child</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getActiveChild()
* @generated
* @ordered
*/
protected MVSCElement activeChild;
/**
* The default value of the '{@link #getContext() <em>Context</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContext()
* @generated
* @ordered
*/
protected static final IEclipseContext CONTEXT_EDEFAULT = null;
/**
* The cached value of the '{@link #getContext() <em>Context</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContext()
* @generated
* @ordered
*/
protected IEclipseContext context = CONTEXT_EDEFAULT;
/**
* The cached value of the '{@link #getVariables() <em>Variables</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariables()
* @generated
* @ordered
*/
protected EList<String> variables;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PerspectiveImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MApplicationPackage.Literals.PERSPECTIVE;
}
/**
* <!-- 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.PERSPECTIVE__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.PERSPECTIVE__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.PERSPECTIVE__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.PERSPECTIVE__VISIBLE, oldVisible, visible));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
public MElementContainer<MUIElement> getParent() {
if (eContainerFeatureID() != MApplicationPackage.PERSPECTIVE__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.PERSPECTIVE__PARENT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParent(MElementContainer<MUIElement> newParent) {
if (newParent != eInternalContainer() || (eContainerFeatureID() != MApplicationPackage.PERSPECTIVE__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.PERSPECTIVE__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<MVSCElement> getChildren() {
if (children == null) {
children = new EObjectContainmentWithInverseEList<MVSCElement>(MUIElement.class, this, MApplicationPackage.PERSPECTIVE__CHILDREN, MApplicationPackage.UI_ELEMENT__PARENT);
}
return children;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MVSCElement getActiveChild() {
if (activeChild != null && ((EObject)activeChild).eIsProxy()) {
InternalEObject oldActiveChild = (InternalEObject)activeChild;
activeChild = (MVSCElement)eResolveProxy(oldActiveChild);
if (activeChild != oldActiveChild) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD, oldActiveChild, activeChild));
}
}
return activeChild;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MVSCElement basicGetActiveChild() {
return activeChild;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setActiveChild(MVSCElement newActiveChild) {
MVSCElement oldActiveChild = activeChild;
activeChild = newActiveChild;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD, oldActiveChild, activeChild));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IEclipseContext getContext() {
return context;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setContext(IEclipseContext newContext) {
IEclipseContext oldContext = context;
context = newContext;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MApplicationPackage.PERSPECTIVE__CONTEXT, oldContext, context));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<String> getVariables() {
if (variables == null) {
variables = new EDataTypeUniqueEList<String>(String.class, this, MApplicationPackage.PERSPECTIVE__VARIABLES);
}
return variables;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MApplicationPackage.PERSPECTIVE__PARENT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetParent((MElementContainer<MUIElement>)otherEnd, msgs);
case MApplicationPackage.PERSPECTIVE__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.PERSPECTIVE__PARENT:
return basicSetParent(null, msgs);
case MApplicationPackage.PERSPECTIVE__CHILDREN:
return ((InternalEList<?>)getChildren()).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.PERSPECTIVE__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.PERSPECTIVE__ID:
return getId();
case MApplicationPackage.PERSPECTIVE__WIDGET:
return getWidget();
case MApplicationPackage.PERSPECTIVE__FACTORY:
return getFactory();
case MApplicationPackage.PERSPECTIVE__VISIBLE:
return isVisible();
case MApplicationPackage.PERSPECTIVE__PARENT:
return getParent();
case MApplicationPackage.PERSPECTIVE__CHILDREN:
return getChildren();
case MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD:
if (resolve) return getActiveChild();
return basicGetActiveChild();
case MApplicationPackage.PERSPECTIVE__CONTEXT:
return getContext();
case MApplicationPackage.PERSPECTIVE__VARIABLES:
return getVariables();
}
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.PERSPECTIVE__ID:
setId((String)newValue);
return;
case MApplicationPackage.PERSPECTIVE__WIDGET:
setWidget(newValue);
return;
case MApplicationPackage.PERSPECTIVE__FACTORY:
setFactory(newValue);
return;
case MApplicationPackage.PERSPECTIVE__VISIBLE:
setVisible((Boolean)newValue);
return;
case MApplicationPackage.PERSPECTIVE__PARENT:
setParent((MElementContainer<MUIElement>)newValue);
return;
case MApplicationPackage.PERSPECTIVE__CHILDREN:
getChildren().clear();
getChildren().addAll((Collection<? extends MVSCElement>)newValue);
return;
case MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD:
setActiveChild((MVSCElement)newValue);
return;
case MApplicationPackage.PERSPECTIVE__CONTEXT:
setContext((IEclipseContext)newValue);
return;
case MApplicationPackage.PERSPECTIVE__VARIABLES:
getVariables().clear();
getVariables().addAll((Collection<? extends String>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MApplicationPackage.PERSPECTIVE__ID:
setId(ID_EDEFAULT);
return;
case MApplicationPackage.PERSPECTIVE__WIDGET:
setWidget(WIDGET_EDEFAULT);
return;
case MApplicationPackage.PERSPECTIVE__FACTORY:
setFactory(FACTORY_EDEFAULT);
return;
case MApplicationPackage.PERSPECTIVE__VISIBLE:
setVisible(VISIBLE_EDEFAULT);
return;
case MApplicationPackage.PERSPECTIVE__PARENT:
setParent((MElementContainer<MUIElement>)null);
return;
case MApplicationPackage.PERSPECTIVE__CHILDREN:
getChildren().clear();
return;
case MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD:
setActiveChild((MVSCElement)null);
return;
case MApplicationPackage.PERSPECTIVE__CONTEXT:
setContext(CONTEXT_EDEFAULT);
return;
case MApplicationPackage.PERSPECTIVE__VARIABLES:
getVariables().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MApplicationPackage.PERSPECTIVE__ID:
return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
case MApplicationPackage.PERSPECTIVE__WIDGET:
return WIDGET_EDEFAULT == null ? widget != null : !WIDGET_EDEFAULT.equals(widget);
case MApplicationPackage.PERSPECTIVE__FACTORY:
return FACTORY_EDEFAULT == null ? factory != null : !FACTORY_EDEFAULT.equals(factory);
case MApplicationPackage.PERSPECTIVE__VISIBLE:
return visible != VISIBLE_EDEFAULT;
case MApplicationPackage.PERSPECTIVE__PARENT:
return getParent() != null;
case MApplicationPackage.PERSPECTIVE__CHILDREN:
return children != null && !children.isEmpty();
case MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD:
return activeChild != null;
case MApplicationPackage.PERSPECTIVE__CONTEXT:
return CONTEXT_EDEFAULT == null ? context != null : !CONTEXT_EDEFAULT.equals(context);
case MApplicationPackage.PERSPECTIVE__VARIABLES:
return variables != null && !variables.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.PERSPECTIVE__ID: return MApplicationPackage.APPLICATION_ELEMENT__ID;
default: return -1;
}
}
if (baseClass == MUIElement.class) {
switch (derivedFeatureID) {
case MApplicationPackage.PERSPECTIVE__WIDGET: return MApplicationPackage.UI_ELEMENT__WIDGET;
case MApplicationPackage.PERSPECTIVE__FACTORY: return MApplicationPackage.UI_ELEMENT__FACTORY;
case MApplicationPackage.PERSPECTIVE__VISIBLE: return MApplicationPackage.UI_ELEMENT__VISIBLE;
case MApplicationPackage.PERSPECTIVE__PARENT: return MApplicationPackage.UI_ELEMENT__PARENT;
default: return -1;
}
}
if (baseClass == MElementContainer.class) {
switch (derivedFeatureID) {
case MApplicationPackage.PERSPECTIVE__CHILDREN: return MApplicationPackage.ELEMENT_CONTAINER__CHILDREN;
case MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD: return MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD;
default: return -1;
}
}
if (baseClass == MContext.class) {
switch (derivedFeatureID) {
case MApplicationPackage.PERSPECTIVE__CONTEXT: return MApplicationPackage.CONTEXT__CONTEXT;
case MApplicationPackage.PERSPECTIVE__VARIABLES: return MApplicationPackage.CONTEXT__VARIABLES;
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.PERSPECTIVE__ID;
default: return -1;
}
}
if (baseClass == MUIElement.class) {
switch (baseFeatureID) {
case MApplicationPackage.UI_ELEMENT__WIDGET: return MApplicationPackage.PERSPECTIVE__WIDGET;
case MApplicationPackage.UI_ELEMENT__FACTORY: return MApplicationPackage.PERSPECTIVE__FACTORY;
case MApplicationPackage.UI_ELEMENT__VISIBLE: return MApplicationPackage.PERSPECTIVE__VISIBLE;
case MApplicationPackage.UI_ELEMENT__PARENT: return MApplicationPackage.PERSPECTIVE__PARENT;
default: return -1;
}
}
if (baseClass == MElementContainer.class) {
switch (baseFeatureID) {
case MApplicationPackage.ELEMENT_CONTAINER__CHILDREN: return MApplicationPackage.PERSPECTIVE__CHILDREN;
case MApplicationPackage.ELEMENT_CONTAINER__ACTIVE_CHILD: return MApplicationPackage.PERSPECTIVE__ACTIVE_CHILD;
default: return -1;
}
}
if (baseClass == MContext.class) {
switch (baseFeatureID) {
case MApplicationPackage.CONTEXT__CONTEXT: return MApplicationPackage.PERSPECTIVE__CONTEXT;
case MApplicationPackage.CONTEXT__VARIABLES: return MApplicationPackage.PERSPECTIVE__VARIABLES;
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(", context: "); //$NON-NLS-1$
result.append(context);
result.append(", variables: "); //$NON-NLS-1$
result.append(variables);
result.append(')');
return result.toString();
}
} //PerspectiveImpl