blob: 3ac7f553ce24c4fdab359af59df72a7b28e465a7 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2019 Xored Software Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.rcptt.tesla.core.ui.impl;
import org.eclipse.rcptt.tesla.core.ui.Image;
import org.eclipse.rcptt.tesla.core.ui.Label;
import org.eclipse.rcptt.tesla.core.ui.UiPackage;
import org.eclipse.rcptt.tesla.core.ui.WithImage;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Label</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.LabelImpl#getImage <em>Image</em>}</li>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.LabelImpl#getCaption <em>Caption</em>}</li>
* </ul>
*
* @generated
*/
public class LabelImpl extends ControlImpl implements Label {
/**
* The cached value of the '{@link #getImage() <em>Image</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getImage()
* @generated
* @ordered
*/
protected Image image;
/**
* 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 LabelImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return UiPackage.Literals.LABEL;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Image getImage() {
return image;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetImage(Image newImage, NotificationChain msgs) {
Image oldImage = image;
image = newImage;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UiPackage.LABEL__IMAGE, oldImage, newImage);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setImage(Image newImage) {
if (newImage != image) {
NotificationChain msgs = null;
if (image != null)
msgs = ((InternalEObject)image).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UiPackage.LABEL__IMAGE, null, msgs);
if (newImage != null)
msgs = ((InternalEObject)newImage).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UiPackage.LABEL__IMAGE, null, msgs);
msgs = basicSetImage(newImage, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.LABEL__IMAGE, newImage, newImage));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getCaption() {
return caption;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCaption(String newCaption) {
String oldCaption = caption;
caption = newCaption;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.LABEL__CAPTION, oldCaption, caption));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case UiPackage.LABEL__IMAGE:
return basicSetImage(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 UiPackage.LABEL__IMAGE:
return getImage();
case UiPackage.LABEL__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 UiPackage.LABEL__IMAGE:
setImage((Image)newValue);
return;
case UiPackage.LABEL__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 UiPackage.LABEL__IMAGE:
setImage((Image)null);
return;
case UiPackage.LABEL__CAPTION:
setCaption(CAPTION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case UiPackage.LABEL__IMAGE:
return image != null;
case UiPackage.LABEL__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 == WithImage.class) {
switch (derivedFeatureID) {
case UiPackage.LABEL__IMAGE: return UiPackage.WITH_IMAGE__IMAGE;
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 == WithImage.class) {
switch (baseFeatureID) {
case UiPackage.WITH_IMAGE__IMAGE: return UiPackage.LABEL__IMAGE;
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(" (caption: ");
result.append(caption);
result.append(')');
return result.toString();
}
} //LabelImpl