blob: 3ee1cf9df10cd7692bdb72858943c8ecff1dbb27 [file] [log] [blame]
/**
* Copyright (c) 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*/
package org.eclipse.papyrus.model2doc.emf.documentstructure.impl;
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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.papyrus.model2doc.core.builtintypes.impl.DefaultFileReferenceImpl;
import org.eclipse.papyrus.model2doc.emf.documentstructure.BodyPart;
import org.eclipse.papyrus.model2doc.emf.documentstructure.DataSource;
import org.eclipse.papyrus.model2doc.emf.documentstructure.DocumentStructurePackage;
import org.eclipse.papyrus.model2doc.emf.documentstructure.IGeneratedFile;
import org.eclipse.papyrus.model2doc.emf.documentstructure.Image;
import org.eclipse.papyrus.model2doc.emf.documentstructure.LeafBodyPart;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Image</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.model2doc.emf.documentstructure.impl.ImageImpl#getDataSource <em>Data Source</em>}</li>
* <li>{@link org.eclipse.papyrus.model2doc.emf.documentstructure.impl.ImageImpl#getCaption <em>Caption</em>}</li>
* </ul>
*
* @generated
*/
public class ImageImpl extends DefaultFileReferenceImpl implements Image {
/**
* The cached value of the '{@link #getDataSource() <em>Data Source</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getDataSource()
* @generated
* @ordered
*/
protected DataSource dataSource;
/**
* The default value of the '{@link #getCaption() <em>Caption</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getCaption()
* @generated
* @ordered
*/
protected static final String CAPTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getCaption() <em>Caption</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getCaption()
* @generated
* @ordered
*/
protected String caption = CAPTION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected ImageImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return DocumentStructurePackage.Literals.IMAGE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public DataSource getDataSource() {
return dataSource;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetDataSource(DataSource newDataSource, NotificationChain msgs) {
DataSource oldDataSource = dataSource;
dataSource = newDataSource;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DocumentStructurePackage.IMAGE__DATA_SOURCE, oldDataSource, newDataSource);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setDataSource(DataSource newDataSource) {
if (newDataSource != dataSource) {
NotificationChain msgs = null;
if (dataSource != null) {
msgs = ((InternalEObject) dataSource).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DocumentStructurePackage.IMAGE__DATA_SOURCE, null, msgs);
}
if (newDataSource != null) {
msgs = ((InternalEObject) newDataSource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DocumentStructurePackage.IMAGE__DATA_SOURCE, null, msgs);
}
msgs = basicSetDataSource(newDataSource, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, DocumentStructurePackage.IMAGE__DATA_SOURCE, newDataSource, newDataSource));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public String getCaption() {
return caption;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setCaption(String newCaption) {
String oldCaption = caption;
caption = newCaption;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, DocumentStructurePackage.IMAGE__CAPTION, oldCaption, caption));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DocumentStructurePackage.IMAGE__DATA_SOURCE:
return basicSetDataSource(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 DocumentStructurePackage.IMAGE__DATA_SOURCE:
return getDataSource();
case DocumentStructurePackage.IMAGE__CAPTION:
return getCaption();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DocumentStructurePackage.IMAGE__DATA_SOURCE:
setDataSource((DataSource) newValue);
return;
case DocumentStructurePackage.IMAGE__CAPTION:
setCaption((String) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DocumentStructurePackage.IMAGE__DATA_SOURCE:
setDataSource((DataSource) null);
return;
case DocumentStructurePackage.IMAGE__CAPTION:
setCaption(CAPTION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DocumentStructurePackage.IMAGE__DATA_SOURCE:
return dataSource != null;
case DocumentStructurePackage.IMAGE__CAPTION:
return CAPTION_EDEFAULT == null ? caption != null : !CAPTION_EDEFAULT.equals(caption);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == BodyPart.class) {
switch (derivedFeatureID) {
case DocumentStructurePackage.IMAGE__DATA_SOURCE:
return DocumentStructurePackage.BODY_PART__DATA_SOURCE;
default:
return -1;
}
}
if (baseClass == LeafBodyPart.class) {
switch (derivedFeatureID) {
default:
return -1;
}
}
if (baseClass == IGeneratedFile.class) {
switch (derivedFeatureID) {
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 == BodyPart.class) {
switch (baseFeatureID) {
case DocumentStructurePackage.BODY_PART__DATA_SOURCE:
return DocumentStructurePackage.IMAGE__DATA_SOURCE;
default:
return -1;
}
}
if (baseClass == LeafBodyPart.class) {
switch (baseFeatureID) {
default:
return -1;
}
}
if (baseClass == IGeneratedFile.class) {
switch (baseFeatureID) {
default:
return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) {
return super.toString();
}
StringBuilder result = new StringBuilder(super.toString());
result.append(" (caption: "); //$NON-NLS-1$
result.append(caption);
result.append(')');
return result.toString();
}
} // ImageImpl