blob: 92c4b6556c6d7e81a19efa0891fb843e886919e3 [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.Date;
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.osbp.ecview.core.common.model.core.CoreModelFactory;
import org.eclipse.osbp.ecview.core.common.model.core.CoreModelPackage;
import org.eclipse.osbp.ecview.core.common.model.core.YBindable;
import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddableValueEndpoint;
import org.eclipse.osbp.ecview.core.common.model.core.YValueBindable;
import org.eclipse.osbp.ecview.core.common.model.core.impl.custom.ChangeAdapter;
import org.eclipse.osbp.ecview.core.common.model.datatypes.YDatadescription;
import org.eclipse.osbp.ecview.core.extension.model.datatypes.ExtDatatypesFactory;
import org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeDatatype;
import org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeFormat;
import org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeResolution;
import org.eclipse.osbp.ecview.core.extension.model.extension.ExtensionModelPackage;
import org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime;
// TODO: Auto-generated Javadoc
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>YDate Time</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YDateTimeImpl#getValueBindingEndpoint <em>Value Binding Endpoint</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YDateTimeImpl#getDatatype <em>Datatype</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YDateTimeImpl#getDatadescription <em>Datadescription</em>}</li>
* <li>{@link org.eclipse.osbp.ecview.core.extension.model.extension.impl.YDateTimeImpl#getValue <em>Value</em>}</li>
* </ul>
* </p>
*
* @generated
*/
@SuppressWarnings("restriction")
public class YDateTimeImpl extends YInputImpl implements YDateTime {
/**
* The cached value of the '{@link #getValueBindingEndpoint() <em>Value Binding Endpoint</em>}' reference.
* <!-- begin-user-doc --> <!--
* end-user-doc -->
* @see #getValueBindingEndpoint()
* @generated
* @ordered
*/
protected YEmbeddableValueEndpoint valueBindingEndpoint;
/**
* The cached value of the '{@link #getDatatype() <em>Datatype</em>}' reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getDatatype()
* @generated
* @ordered
*/
protected YDateTimeDatatype datatype;
/**
* 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 default value of the '{@link #getValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected static final Date VALUE_EDEFAULT = null;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected Date value = VALUE_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @generated
*/
protected YDateTimeImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the e class
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExtensionModelPackage.Literals.YDATE_TIME;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getValueBindingEndpoint()
* <em>Value Binding Endpoint</em>}' reference
* @generated
*/
public YEmbeddableValueEndpoint getValueBindingEndpoint() {
if (valueBindingEndpoint != null && valueBindingEndpoint.eIsProxy()) {
InternalEObject oldValueBindingEndpoint = (InternalEObject)valueBindingEndpoint;
valueBindingEndpoint = (YEmbeddableValueEndpoint)eResolveProxy(oldValueBindingEndpoint);
if (valueBindingEndpoint != oldValueBindingEndpoint) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT, oldValueBindingEndpoint, valueBindingEndpoint));
}
}
return valueBindingEndpoint;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the y embeddable value endpoint
* @generated
*/
public YEmbeddableValueEndpoint basicGetValueBindingEndpoint() {
return valueBindingEndpoint;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newValueBindingEndpoint
* the new value binding endpoint
* @param msgs
* the msgs
* @return the notification chain
* @generated
*/
public NotificationChain basicSetValueBindingEndpoint(
YEmbeddableValueEndpoint newValueBindingEndpoint,
NotificationChain msgs) {
YEmbeddableValueEndpoint oldValueBindingEndpoint = valueBindingEndpoint;
valueBindingEndpoint = newValueBindingEndpoint;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT, oldValueBindingEndpoint, newValueBindingEndpoint);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newValueBindingEndpoint
* the new cached value of the '
* {@link #getValueBindingEndpoint()
* <em>Value Binding Endpoint</em>}' reference
* @generated
*/
public void setValueBindingEndpoint(
YEmbeddableValueEndpoint newValueBindingEndpoint) {
if (newValueBindingEndpoint != valueBindingEndpoint) {
NotificationChain msgs = null;
if (valueBindingEndpoint != null)
msgs = ((InternalEObject)valueBindingEndpoint).eInverseRemove(this, CoreModelPackage.YEMBEDDABLE_VALUE_ENDPOINT__ELEMENT, YEmbeddableValueEndpoint.class, msgs);
if (newValueBindingEndpoint != null)
msgs = ((InternalEObject)newValueBindingEndpoint).eInverseAdd(this, CoreModelPackage.YEMBEDDABLE_VALUE_ENDPOINT__ELEMENT, YEmbeddableValueEndpoint.class, msgs);
msgs = basicSetValueBindingEndpoint(newValueBindingEndpoint, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT, newValueBindingEndpoint, newValueBindingEndpoint));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getDatatype() <em>Datatype</em>}
* ' reference
* @generated
*/
public YDateTimeDatatype getDatatype() {
if (datatype != null && datatype.eIsProxy()) {
InternalEObject oldDatatype = (InternalEObject)datatype;
datatype = (YDateTimeDatatype)eResolveProxy(oldDatatype);
if (datatype != oldDatatype) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtensionModelPackage.YDATE_TIME__DATATYPE, oldDatatype, datatype));
}
}
return datatype;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the y date time datatype
* @generated
*/
public YDateTimeDatatype basicGetDatatype() {
return datatype;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newDatatype
* the new cached value of the '{@link #getDatatype()
* <em>Datatype</em>}' reference
* @generated
*/
public void setDatatype(YDateTimeDatatype newDatatype) {
YDateTimeDatatype oldDatatype = datatype;
datatype = newDatatype;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YDATE_TIME__DATATYPE, oldDatatype, datatype));
}
/**
* <!-- 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.YDATE_TIME__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.YDATE_TIME__DATADESCRIPTION, oldDatadescription, datadescription));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the cached value of the '{@link #getValue() <em>Value</em>}'
* attribute
* @generated
*/
public Date getValue() {
return value;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param newValue
* the new cached value of the '{@link #getValue()
* <em>Value</em>}' attribute
* @generated
*/
public void setValue(Date newValue) {
Date oldValue = value;
value = newValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionModelPackage.YDATE_TIME__VALUE, oldValue, value));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @return the y embeddable value endpoint
* @generated
*/
public YEmbeddableValueEndpoint createValueEndpointGen() {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* Creates a new instance of value endpoint with a reference to that
* embeddable.
*
* @return the y embeddable value endpoint
* @generated NOT
*/
public YEmbeddableValueEndpoint createValueEndpoint() {
YEmbeddableValueEndpoint ep = CoreModelFactory.eINSTANCE
.createYEmbeddableValueEndpoint();
ep.setElement(this);
return ep;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param otherEnd
* the other end
* @param featureID
* the feature id
* @param msgs
* the msgs
* @return the notification chain
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT:
if (valueBindingEndpoint != null)
msgs = ((InternalEObject)valueBindingEndpoint).eInverseRemove(this, CoreModelPackage.YEMBEDDABLE_VALUE_ENDPOINT__ELEMENT, YEmbeddableValueEndpoint.class, msgs);
return basicSetValueBindingEndpoint((YEmbeddableValueEndpoint)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param otherEnd
* the other end
* @param featureID
* the feature id
* @param msgs
* the msgs
* @return the notification chain
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT:
return basicSetValueBindingEndpoint(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* Returns a new instance of the change adapter config. Has to be overridden
* by subclasses.
*
* @return the change adapter. config
* @generated NOT
*/
protected ChangeAdapter.Config createNewChangeAdapterConfig() {
return new ChangeAdapter.Config(
ExtensionModelPackage.Literals.YDATE_TIME__VALUE,
Notification.SET);
}
/**
* <!-- 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.YDATE_TIME__VALUE_BINDING_ENDPOINT:
if (resolve) return getValueBindingEndpoint();
return basicGetValueBindingEndpoint();
case ExtensionModelPackage.YDATE_TIME__DATATYPE:
if (resolve) return getDatatype();
return basicGetDatatype();
case ExtensionModelPackage.YDATE_TIME__DATADESCRIPTION:
if (resolve) return getDatadescription();
return basicGetDatadescription();
case ExtensionModelPackage.YDATE_TIME__VALUE:
return getValue();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->.
*
* @param featureID
* the feature id
* @param newValue
* the new value
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT:
setValueBindingEndpoint((YEmbeddableValueEndpoint)newValue);
return;
case ExtensionModelPackage.YDATE_TIME__DATATYPE:
setDatatype((YDateTimeDatatype)newValue);
return;
case ExtensionModelPackage.YDATE_TIME__DATADESCRIPTION:
setDatadescription((YDatadescription)newValue);
return;
case ExtensionModelPackage.YDATE_TIME__VALUE:
setValue((Date)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.YDATE_TIME__VALUE_BINDING_ENDPOINT:
setValueBindingEndpoint((YEmbeddableValueEndpoint)null);
return;
case ExtensionModelPackage.YDATE_TIME__DATATYPE:
setDatatype((YDateTimeDatatype)null);
return;
case ExtensionModelPackage.YDATE_TIME__DATADESCRIPTION:
setDatadescription((YDatadescription)null);
return;
case ExtensionModelPackage.YDATE_TIME__VALUE:
setValue(VALUE_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.YDATE_TIME__VALUE_BINDING_ENDPOINT:
return valueBindingEndpoint != null;
case ExtensionModelPackage.YDATE_TIME__DATATYPE:
return datatype != null;
case ExtensionModelPackage.YDATE_TIME__DATADESCRIPTION:
return datadescription != null;
case ExtensionModelPackage.YDATE_TIME__VALUE:
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
}
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 == YBindable.class) {
switch (derivedFeatureID) {
default: return -1;
}
}
if (baseClass == YValueBindable.class) {
switch (derivedFeatureID) {
case ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT: return CoreModelPackage.YVALUE_BINDABLE__VALUE_BINDING_ENDPOINT;
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 == YBindable.class) {
switch (baseFeatureID) {
default: return -1;
}
}
if (baseClass == YValueBindable.class) {
switch (baseFeatureID) {
case CoreModelPackage.YVALUE_BINDABLE__VALUE_BINDING_ENDPOINT: return ExtensionModelPackage.YDATE_TIME__VALUE_BINDING_ENDPOINT;
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(" (value: ");
result.append(value);
result.append(')');
return result.toString();
}
/**
* Sets the label by creating a new datadescription.
*
* @param label
* the new label
*/
public void setLabel(String label) {
YDatadescription ds = getDatadescription();
if (ds == null) {
setDatadescription(createDatadescription(label));
getOrphanDatadescriptions().add(getDatadescription());
} else {
ds.setLabel(label);
}
}
/**
* Sets the label i18nKey by creating a new datadescription.
*
* @param i18nKey
* the new label i18n key
*/
public void setLabelI18nKey(String i18nKey) {
YDatadescription ds = getDatadescription();
if (ds == null) {
setDatadescription(createDatadescriptionForI18n(i18nKey));
getOrphanDatadescriptions().add(getDatadescription());
} else {
ds.setLabelI18nKey(i18nKey);
}
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime#setDateFormat(org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeFormat)
*/
@Override
public void setDateFormat(YDateTimeFormat format) {
YDateTimeDatatype dt = getDatatype();
if (dt == null) {
dt = ExtDatatypesFactory.eINSTANCE.createYDateTimeDatatype();
setDatatype(dt);
getOrphanDatatypes().add(dt);
}
dt.setFormat(format);
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime#getDateFormat()
*/
@Override
public YDateTimeFormat getDateFormat() {
YDateTimeDatatype dt = getDatatype();
return dt != null ? dt.getFormat() : null;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime#setResolution(org.eclipse.osbp.ecview.core.extension.model.datatypes.YDateTimeResolution)
*/
@Override
public void setResolution(YDateTimeResolution resolution) {
YDateTimeDatatype dt = getDatatype();
if (dt == null) {
dt = ExtDatatypesFactory.eINSTANCE.createYDateTimeDatatype();
setDatatype(dt);
getOrphanDatatypes().add(dt);
}
dt.setResolution(resolution);
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.extension.model.extension.YDateTime#getResolution()
*/
@Override
public YDateTimeResolution getResolution() {
YDateTimeDatatype dt = getDatatype();
return dt != null ? dt.getResolution() : null;
}
/* (non-Javadoc)
* @see org.eclipse.osbp.ecview.core.common.model.core.impl.YFieldImpl#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.YFieldImpl#getLabelI18nKey()
*/
@Override
public String getLabelI18nKey() {
YDatadescription ds = getDatadescription();
if (ds != null) {
return ds.getLabelI18nKey();
}
return "";
}
} // YDateTimeImpl