blob: ca60c7e4329b9b65145027eb7a92d665f12fd0d0 [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* 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:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.ecview.core.extension.model.extension.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.osbp.ecview.core.common.model.binding.BindingFactory;
import org.eclipse.osbp.ecview.core.common.model.binding.YECViewModelValueBindingEndpoint;
import org.eclipse.osbp.ecview.core.common.model.binding.YValueBindingEndpoint;
import org.eclipse.osbp.ecview.core.common.model.core.CoreModelPackage;
import org.eclipse.osbp.ecview.core.common.model.core.YEditable;
import org.eclipse.osbp.ecview.core.common.model.core.YFocusable;
import org.eclipse.osbp.ecview.core.common.model.core.impl.YActionImpl;
import org.eclipse.osbp.ecview.core.common.model.datatypes.YDatadescription;
import org.eclipse.osbp.ecview.core.extension.model.extension.ExtensionModelPackage;
import org.eclipse.osbp.ecview.core.extension.model.extension.YButton;
import org.eclipse.osbp.ecview.core.extension.model.extension.listener.YButtonClickListener;
// TODO: Auto-generated Javadoc
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>YButton</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#isInitialEditable <em>Initial Editable</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#isEditable <em>Editable</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#getTabIndex <em>Tab Index</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#getDatadescription <em>Datadescription</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#getClickListeners <em>Click Listeners</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#getLastClickTime <em>Last Click Time</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YButtonImpl#getImage <em>Image</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class YButtonImpl extends YActionImpl implements YButton {
/**
* The default value of the '{@link #isInitialEditable() <em>Initial Editable</em>}' attribute.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #isInitialEditable()
* @generated
* @ordered
*/
protected static final boolean INITIAL_EDITABLE_EDEFAULT = true;
/**
* The cached value of the '{@link #isInitialEditable() <em>Initial Editable</em>}' attribute.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #isInitialEditable()
* @generated
* @ordered
*/
protected boolean initialEditable = INITIAL_EDITABLE_EDEFAULT;
/**
* The default value of the '{@link #isEditable() <em>Editable</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isEditable()
* @generated
* @ordered
*/
protected static final boolean EDITABLE_EDEFAULT = true;
/**
* The cached value of the '{@link #isEditable() <em>Editable</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isEditable()
* @generated
* @ordered
*/
protected boolean editable = EDITABLE_EDEFAULT;
/**
* The default value of the '{@link #getTabIndex() <em>Tab Index</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTabIndex()
* @generated
* @ordered
*/
protected static final int TAB_INDEX_EDEFAULT = -1;
/**
* The cached value of the '{@link #getTabIndex() <em>Tab Index</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTabIndex()
* @generated
* @ordered
*/
protected int tabIndex = TAB_INDEX_EDEFAULT;
/**
* The cached value of the '{@link #getDatadescription() <em>Datadescription</em>}' reference.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #getDatadescription()
* @generated
* @ordered
*/
protected YDatadescription datadescription;
/**
* The cached value of the '{@link #getClickListeners() <em>Click Listeners</em>}' attribute list.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #getClickListeners()
* @generated
* @ordered
*/
protected EList<YButtonClickListener> clickListeners;
/**
* The default value of the '{@link #getLastClickTime() <em>Last Click Time</em>}' attribute.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #getLastClickTime()
* @generated
* @ordered
*/
protected static final long LAST_CLICK_TIME_EDEFAULT = 0L;
/**
* The cached value of the '{@link #getLastClickTime() <em>Last Click Time</em>}' attribute.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #getLastClickTime()
* @generated
* @ordered
*/
protected long lastClickTime = LAST_CLICK_TIME_EDEFAULT;
/**
* The default value of the '{@link #getImage() <em>Image</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getImage()
* @generated
* @ordered
*/
protected static final Object IMAGE_EDEFAULT = null;
/**
* The cached value of the '{@link #getImage() <em>Image</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getImage()
* @generated
* @ordered
*/
protected Object image = IMAGE_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @generated
*/
protected YButtonImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the e class
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExtensionModelPackage.Literals.YBUTTON;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #isInitialEditable()
* <em>Initial Editable</em>}' attribute
* @generated
*/
public boolean isInitialEditable() {
return initialEditable;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newInitialEditable
* the new cached value of the '{@link #isInitialEditable()
* <em>Initial Editable</em>}' attribute
* @generated
*/
public void setInitialEditable(boolean newInitialEditable) {
boolean oldInitialEditable = initialEditable;
initialEditable = newInitialEditable;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE, oldInitialEditable, initialEditable));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #isEditable() <em>Editable</em>}'
* attribute
* @generated
*/
public boolean isEditable() {
return editable;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newEditable
* the new cached value of the '{@link #isEditable()
* <em>Editable</em>}' attribute
* @generated
*/
public void setEditable(boolean newEditable) {
boolean oldEditable = editable;
editable = newEditable;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__EDITABLE, oldEditable, editable));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getTabIndex()
* <em>Tab Index</em>}' attribute
* @generated
*/
public int getTabIndex() {
return tabIndex;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newTabIndex
* the new cached value of the '{@link #getTabIndex()
* <em>Tab Index</em>}' attribute
* @generated
*/
public void setTabIndex(int newTabIndex) {
int oldTabIndex = tabIndex;
tabIndex = newTabIndex;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__TAB_INDEX, oldTabIndex, tabIndex));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getDatadescription()
* <em>Datadescription</em>}' reference
* @generated
*/
public YDatadescription getDatadescription() {
if (datadescription != null && datadescription.eIsProxy()) {
InternalEObject oldDatadescription = (InternalEObject)datadescription;
datadescription = (YDatadescription)eResolveProxy(oldDatadescription);
if (datadescription != oldDatadescription) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtensionModelPackage.YBUTTON__DATADESCRIPTION, oldDatadescription, datadescription));
}
}
return datadescription;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the y datadescription
* @generated
*/
public YDatadescription basicGetDatadescription() {
return datadescription;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newDatadescription
* the new cached value of the '{@link #getDatadescription()
* <em>Datadescription</em>}' reference
* @generated
*/
public void setDatadescription(YDatadescription newDatadescription) {
YDatadescription oldDatadescription = datadescription;
datadescription = newDatadescription;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__DATADESCRIPTION, oldDatadescription, datadescription));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getClickListeners()
* <em>Click Listeners</em>}' attribute list
* @generated
*/
public EList<YButtonClickListener> getClickListeners() {
if (clickListeners == null) {
clickListeners = new EDataTypeUniqueEList<YButtonClickListener>(YButtonClickListener.class, this, ExtensionModelPackage.YBUTTON__CLICK_LISTENERS);
}
return clickListeners;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getLastClickTime()
* <em>Last Click Time</em>}' attribute
* @generated
*/
public long getLastClickTime() {
return lastClickTime;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newLastClickTime
* the new cached value of the '{@link #getLastClickTime()
* <em>Last Click Time</em>}' attribute
* @generated
*/
public void setLastClickTime(long newLastClickTime) {
long oldLastClickTime = lastClickTime;
lastClickTime = newLastClickTime;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__LAST_CLICK_TIME, oldLastClickTime, lastClickTime));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object getImage() {
return image;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setImage(Object newImage) {
Object oldImage = image;
image = newImage;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YBUTTON__IMAGE, oldImage, image));
}
/**
* Adds a listener that is notified if the button was clicked.
*
* @param listener
* the listener
* @generated NOT
*/
@Override
public void addClickListener(YButtonClickListener listener) {
getClickListeners().add(listener);
}
/**
* Removes a listener that is notified if the button was clicked.
*
* @param listener
* the listener
* @generated NOT
*/
@Override
public void removeClickListener(YButtonClickListener listener) {
getClickListeners().remove(listener);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param featureID
* the feature id
* @param resolve
* the resolve
* @param coreType
* the core type
* @return the object
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE:
return isInitialEditable();
case ExtensionModelPackage.YBUTTON__EDITABLE:
return isEditable();
case ExtensionModelPackage.YBUTTON__TAB_INDEX:
return getTabIndex();
case ExtensionModelPackage.YBUTTON__DATADESCRIPTION:
if (resolve) return getDatadescription();
return basicGetDatadescription();
case ExtensionModelPackage.YBUTTON__CLICK_LISTENERS:
return getClickListeners();
case ExtensionModelPackage.YBUTTON__LAST_CLICK_TIME:
return getLastClickTime();
case ExtensionModelPackage.YBUTTON__IMAGE:
return getImage();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param featureID
* the feature id
* @param newValue
* the new value
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE:
setInitialEditable((Boolean)newValue);
return;
case ExtensionModelPackage.YBUTTON__EDITABLE:
setEditable((Boolean)newValue);
return;
case ExtensionModelPackage.YBUTTON__TAB_INDEX:
setTabIndex((Integer)newValue);
return;
case ExtensionModelPackage.YBUTTON__DATADESCRIPTION:
setDatadescription((YDatadescription)newValue);
return;
case ExtensionModelPackage.YBUTTON__CLICK_LISTENERS:
getClickListeners().clear();
getClickListeners().addAll((Collection<? extends YButtonClickListener>)newValue);
return;
case ExtensionModelPackage.YBUTTON__LAST_CLICK_TIME:
setLastClickTime((Long)newValue);
return;
case ExtensionModelPackage.YBUTTON__IMAGE:
setImage(newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param featureID
* the feature id
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE:
setInitialEditable(INITIAL_EDITABLE_EDEFAULT);
return;
case ExtensionModelPackage.YBUTTON__EDITABLE:
setEditable(EDITABLE_EDEFAULT);
return;
case ExtensionModelPackage.YBUTTON__TAB_INDEX:
setTabIndex(TAB_INDEX_EDEFAULT);
return;
case ExtensionModelPackage.YBUTTON__DATADESCRIPTION:
setDatadescription((YDatadescription)null);
return;
case ExtensionModelPackage.YBUTTON__CLICK_LISTENERS:
getClickListeners().clear();
return;
case ExtensionModelPackage.YBUTTON__LAST_CLICK_TIME:
setLastClickTime(LAST_CLICK_TIME_EDEFAULT);
return;
case ExtensionModelPackage.YBUTTON__IMAGE:
setImage(IMAGE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param featureID
* the feature id
* @return true, if successful
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE:
return initialEditable != INITIAL_EDITABLE_EDEFAULT;
case ExtensionModelPackage.YBUTTON__EDITABLE:
return editable != EDITABLE_EDEFAULT;
case ExtensionModelPackage.YBUTTON__TAB_INDEX:
return tabIndex != TAB_INDEX_EDEFAULT;
case ExtensionModelPackage.YBUTTON__DATADESCRIPTION:
return datadescription != null;
case ExtensionModelPackage.YBUTTON__CLICK_LISTENERS:
return clickListeners != null && !clickListeners.isEmpty();
case ExtensionModelPackage.YBUTTON__LAST_CLICK_TIME:
return lastClickTime != LAST_CLICK_TIME_EDEFAULT;
case ExtensionModelPackage.YBUTTON__IMAGE:
return IMAGE_EDEFAULT == null ? image != null : !IMAGE_EDEFAULT.equals(image);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param derivedFeatureID
* the derived feature id
* @param baseClass
* the base class
* @return the int
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == YEditable.class) {
switch (derivedFeatureID) {
case ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE: return CoreModelPackage.YEDITABLE__INITIAL_EDITABLE;
case ExtensionModelPackage.YBUTTON__EDITABLE: return CoreModelPackage.YEDITABLE__EDITABLE;
default: return -1;
}
}
if (baseClass == YFocusable.class) {
switch (derivedFeatureID) {
case ExtensionModelPackage.YBUTTON__TAB_INDEX: return CoreModelPackage.YFOCUSABLE__TAB_INDEX;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param baseFeatureID
* the base feature id
* @param baseClass
* the base class
* @return the int
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == YEditable.class) {
switch (baseFeatureID) {
case CoreModelPackage.YEDITABLE__INITIAL_EDITABLE: return ExtensionModelPackage.YBUTTON__INITIAL_EDITABLE;
case CoreModelPackage.YEDITABLE__EDITABLE: return ExtensionModelPackage.YBUTTON__EDITABLE;
default: return -1;
}
}
if (baseClass == YFocusable.class) {
switch (baseFeatureID) {
case CoreModelPackage.YFOCUSABLE__TAB_INDEX: return ExtensionModelPackage.YBUTTON__TAB_INDEX;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the string
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (initialEditable: ");
result.append(initialEditable);
result.append(", editable: ");
result.append(editable);
result.append(", tabIndex: ");
result.append(tabIndex);
result.append(", clickListeners: ");
result.append(clickListeners);
result.append(", lastClickTime: ");
result.append(lastClickTime);
result.append(", image: ");
result.append(image);
result.append(')');
return result.toString();
}
/**
* Sets the label by creating a new datadescription.
*
* @param label
* the new label
*/
public void setLabel(String label) {
String oldLabel = null;
YDatadescription ds = getDatadescription();
if (ds == null) {
setDatadescription(createDatadescription(label));
getOrphanDatadescriptions().add(getDatadescription());
} else {
oldLabel = ds.getLabel();
ds.setLabel(label);
}
// TODO add this to all YEmbeddables where a notification is required
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CoreModelPackage.YEMBEDDABLE__LABEL, oldLabel, label));
}
/**
* Sets the label i18nKey by creating a new datadescription.
*
* @param i18nKey
* the new label i18n key
*/
public void setLabelI18nKey(String i18nKey) {
String oldI18nKey = null;
YDatadescription ds = getDatadescription();
if (ds == null) {
setDatadescription(createDatadescriptionForI18n(i18nKey));
getOrphanDatadescriptions().add(getDatadescription());
} else {
oldI18nKey = ds.getLabelI18nKey();
ds.setLabelI18nKey(i18nKey);
}
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CoreModelPackage.YEMBEDDABLE__LABEL_I1_8N_KEY, oldI18nKey, i18nKey));
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.common.model.core.impl.YActionImpl#getLabel()
*/
@Override
public String getLabel() {
YDatadescription ds = getDatadescription();
if (ds != null) {
return ds.getLabel();
}
return "";
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.common.model.core.impl.YActionImpl#getLabelI18nKey()
*/
@Override
public String getLabelI18nKey() {
YDatadescription ds = getDatadescription();
if (ds != null) {
return ds.getLabelI18nKey();
}
return "";
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YButton#createEditableEndpoint()
*/
@Override
public YValueBindingEndpoint createEditableEndpoint() {
YECViewModelValueBindingEndpoint endpoint = BindingFactory.eINSTANCE
.createYECViewModelValueBindingEndpoint();
endpoint.setElement(this);
endpoint.getFeatures()
.add((EStructuralFeature) CoreModelPackage.Literals.YEDITABLE__EDITABLE);
return endpoint;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YButton#createEnabledEndpoint()
*/
@Override
public YValueBindingEndpoint createEnabledEndpoint() {
YECViewModelValueBindingEndpoint endpoint = BindingFactory.eINSTANCE
.createYECViewModelValueBindingEndpoint();
endpoint.setElement(this);
endpoint.getFeatures()
.add((EStructuralFeature) CoreModelPackage.Literals.YENABLE__ENABLED);
return endpoint;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YButton#createClickEndpoint()
*/
public YECViewModelValueBindingEndpoint createClickEndpoint() {
YECViewModelValueBindingEndpoint endpoint = BindingFactory.eINSTANCE
.createYECViewModelValueBindingEndpoint();
endpoint.setElement(this);
endpoint.getFeatures()
.add((EStructuralFeature) ExtensionModelPackage.Literals.YBUTTON__LAST_CLICK_TIME);
return endpoint;
}
} // YButtonImpl