blob: 0a258cc62a468d027f3bf3cf9f2e1f04cf89c59d [file] [log] [blame]
/**
* Copyright (c) 2013, 2017 CEA LIST & LIFL
*
* 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:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
* Quentin Le Menez quentin.lemenez@cea.fr
*
*/
package org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.LayersException;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.command.ComputePropertyValueCommand;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayerExpression;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayerState;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersPackage;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersStack;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Property;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Stack</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.LayersStackImpl#getLayers <em>Layers</em>}</li>
* <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.LayersStackImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.LayersStackImpl#getDescription <em>Description</em>}</li>
* <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.LayersStackImpl#getDiagram <em>Diagram</em>}</li>
* <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.LayersStackImpl#getState <em>State</em>}</li>
* </ul>
*
* @generated
*/
public class LayersStackImpl extends EObjectImpl implements LayersStack {
/**
* The cached value of the '{@link #getLayers() <em>Layers</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLayers()
* @generated
* @ordered
*/
protected LayerExpression layers;
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected static final String DESCRIPTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected String description = DESCRIPTION_EDEFAULT;
/**
* The cached value of the '{@link #getDiagram() <em>Diagram</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDiagram()
* @generated
* @ordered
*/
protected Diagram diagram;
/**
* The default value of the '{@link #getState() <em>State</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getState()
* @generated
* @ordered
*/
protected static final LayerState STATE_EDEFAULT = LayerState.DETACHED;
/**
* The cached value of the '{@link #getState() <em>State</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getState()
* @generated
* @ordered
*/
protected LayerState state = STATE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LayersStackImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return LayersPackage.Literals.LAYERS_STACK;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LayerExpression getLayers() {
return layers;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetLayers(LayerExpression newLayers, NotificationChain msgs) {
LayerExpression oldLayers = layers;
layers = newLayers;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__LAYERS, oldLayers, newLayers);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLayers(LayerExpression newLayers) {
if (newLayers != layers) {
NotificationChain msgs = null;
if (layers != null)
msgs = ((InternalEObject)layers).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LayersPackage.LAYERS_STACK__LAYERS, null, msgs);
if (newLayers != null)
msgs = ((InternalEObject)newLayers).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LayersPackage.LAYERS_STACK__LAYERS, null, msgs);
msgs = basicSetLayers(newLayers, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__LAYERS, newLayers, newLayers));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getDescription() {
return description;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDescription(String newDescription) {
String oldDescription = description;
description = newDescription;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__DESCRIPTION, oldDescription, description));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagram getDiagram() {
if (diagram != null && diagram.eIsProxy()) {
InternalEObject oldDiagram = (InternalEObject)diagram;
diagram = (Diagram)eResolveProxy(oldDiagram);
if (diagram != oldDiagram) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, LayersPackage.LAYERS_STACK__DIAGRAM, oldDiagram, diagram));
}
}
return diagram;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Diagram basicGetDiagram() {
return diagram;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDiagram(Diagram newDiagram) {
Diagram oldDiagram = diagram;
diagram = newDiagram;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__DIAGRAM, oldDiagram, diagram));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LayerState getState() {
return state;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setState(LayerState newState) {
LayerState oldState = state;
state = newState == null ? STATE_EDEFAULT : newState;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.LAYERS_STACK__STATE, oldState, state));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void addLayer(LayerExpression layer) {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ComputePropertyValueCommand getComputePropertyValueCommand(View view, Property property) throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List<ComputePropertyValueCommand> getPropertiesComputePropertyValueCommand(View view, List<Property> property) throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List<ComputePropertyValueCommand> getViewsComputePropertyValueCommand(List<View> view, Property property) throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void startAfterCreation() {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void attachLayers() throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void attach() throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void detach() throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void enterAttachedState() throws LayersException {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void exitAttachedState() {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case LayersPackage.LAYERS_STACK__LAYERS:
return basicSetLayers(null, 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 LayersPackage.LAYERS_STACK__LAYERS:
return getLayers();
case LayersPackage.LAYERS_STACK__NAME:
return getName();
case LayersPackage.LAYERS_STACK__DESCRIPTION:
return getDescription();
case LayersPackage.LAYERS_STACK__DIAGRAM:
if (resolve) return getDiagram();
return basicGetDiagram();
case LayersPackage.LAYERS_STACK__STATE:
return getState();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case LayersPackage.LAYERS_STACK__LAYERS:
setLayers((LayerExpression)newValue);
return;
case LayersPackage.LAYERS_STACK__NAME:
setName((String)newValue);
return;
case LayersPackage.LAYERS_STACK__DESCRIPTION:
setDescription((String)newValue);
return;
case LayersPackage.LAYERS_STACK__DIAGRAM:
setDiagram((Diagram)newValue);
return;
case LayersPackage.LAYERS_STACK__STATE:
setState((LayerState)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case LayersPackage.LAYERS_STACK__LAYERS:
setLayers((LayerExpression)null);
return;
case LayersPackage.LAYERS_STACK__NAME:
setName(NAME_EDEFAULT);
return;
case LayersPackage.LAYERS_STACK__DESCRIPTION:
setDescription(DESCRIPTION_EDEFAULT);
return;
case LayersPackage.LAYERS_STACK__DIAGRAM:
setDiagram((Diagram)null);
return;
case LayersPackage.LAYERS_STACK__STATE:
setState(STATE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case LayersPackage.LAYERS_STACK__LAYERS:
return layers != null;
case LayersPackage.LAYERS_STACK__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case LayersPackage.LAYERS_STACK__DESCRIPTION:
return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
case LayersPackage.LAYERS_STACK__DIAGRAM:
return diagram != null;
case LayersPackage.LAYERS_STACK__STATE:
return state != STATE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case LayersPackage.LAYERS_STACK___ADD_LAYER__LAYEREXPRESSION:
addLayer((LayerExpression)arguments.get(0));
return null;
case LayersPackage.LAYERS_STACK___GET_COMPUTE_PROPERTY_VALUE_COMMAND__VIEW_PROPERTY:
try {
return getComputePropertyValueCommand((View)arguments.get(0), (Property)arguments.get(1));
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___GET_PROPERTIES_COMPUTE_PROPERTY_VALUE_COMMAND__VIEW_LIST:
try {
return getPropertiesComputePropertyValueCommand((View)arguments.get(0), (List<Property>)arguments.get(1));
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___GET_VIEWS_COMPUTE_PROPERTY_VALUE_COMMAND__LIST_PROPERTY:
try {
return getViewsComputePropertyValueCommand((List<View>)arguments.get(0), (Property)arguments.get(1));
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___START_AFTER_CREATION:
startAfterCreation();
return null;
case LayersPackage.LAYERS_STACK___ATTACH_LAYERS:
try {
attachLayers();
return null;
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___ATTACH:
try {
attach();
return null;
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___DETACH:
try {
detach();
return null;
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___ENTER_ATTACHED_STATE:
try {
enterAttachedState();
return null;
}
catch (Throwable throwable) {
throw new InvocationTargetException(throwable);
}
case LayersPackage.LAYERS_STACK___EXIT_ATTACHED_STATE:
exitAttachedState();
return null;
}
return super.eInvoke(operationID, arguments);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", description: "); //$NON-NLS-1$
result.append(description);
result.append(", state: "); //$NON-NLS-1$
result.append(state);
result.append(')');
return result.toString();
}
} //LayersStackImpl