| /** |
| * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others. |
| * |
| * 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: |
| * Eugen Neufeld - initial API and implementation |
| */ |
| package org.eclipse.emf.ecp.view.spi.model.impl; |
| |
| import java.util.Collection; |
| |
| 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.EReference; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecp.view.spi.model.LabelAlignment; |
| import org.eclipse.emf.ecp.view.spi.model.ModelReferenceHelper; |
| import org.eclipse.emf.ecp.view.spi.model.VControl; |
| import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference; |
| import org.eclipse.emf.ecp.view.spi.model.VViewPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Control</b></em>'. |
| * |
| * @since 1.2 |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.emf.ecp.view.spi.model.impl.VControlImpl#getLabelAlignment <em>Label |
| * Alignment</em>}</li> |
| * <li>{@link org.eclipse.emf.ecp.view.spi.model.impl.VControlImpl#getDomainModelReference <em>Domain Model |
| * Reference</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class VControlImpl extends VContainedElementImpl implements VControl { |
| /** |
| * The default value of the '{@link #getLabelAlignment() <em>Label Alignment</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getLabelAlignment() |
| * @generated |
| * @ordered |
| */ |
| protected static final LabelAlignment LABEL_ALIGNMENT_EDEFAULT = LabelAlignment.DEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getLabelAlignment() <em>Label Alignment</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getLabelAlignment() |
| * @generated |
| * @ordered |
| */ |
| protected LabelAlignment labelAlignment = LABEL_ALIGNMENT_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getDomainModelReference() <em>Domain Model Reference</em>}' containment |
| * reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getDomainModelReference() |
| * @generated |
| * @ordered |
| */ |
| protected VDomainModelReference domainModelReference; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected VControlImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return VViewPackage.Literals.CONTROL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public VDomainModelReference getDomainModelReference() { |
| return domainModelReference; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public NotificationChain basicSetDomainModelReference(VDomainModelReference newDomainModelReference, |
| NotificationChain msgs) { |
| final VDomainModelReference oldDomainModelReference = domainModelReference; |
| domainModelReference = newDomainModelReference; |
| if (eNotificationRequired()) { |
| final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, |
| VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE, oldDomainModelReference, newDomainModelReference); |
| if (msgs == null) { |
| msgs = notification; |
| } else { |
| msgs.add(notification); |
| } |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setDomainModelReference(VDomainModelReference newDomainModelReference) { |
| if (newDomainModelReference != domainModelReference) { |
| NotificationChain msgs = null; |
| if (domainModelReference != null) { |
| msgs = ((InternalEObject) domainModelReference).eInverseRemove(this, |
| EOPPOSITE_FEATURE_BASE - VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE, null, msgs); |
| } |
| if (newDomainModelReference != null) { |
| msgs = ((InternalEObject) newDomainModelReference).eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE - VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE, null, msgs); |
| } |
| msgs = basicSetDomainModelReference(newDomainModelReference, msgs); |
| if (msgs != null) { |
| msgs.dispatch(); |
| } |
| } else if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE, |
| newDomainModelReference, newDomainModelReference)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE: |
| return basicSetDomainModelReference(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public LabelAlignment getLabelAlignment() { |
| return labelAlignment; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setLabelAlignment(LabelAlignment newLabelAlignment) { |
| final LabelAlignment oldLabelAlignment = labelAlignment; |
| labelAlignment = newLabelAlignment == null ? LABEL_ALIGNMENT_EDEFAULT : newLabelAlignment; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, VViewPackage.CONTROL__LABEL_ALIGNMENT, |
| oldLabelAlignment, labelAlignment)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case VViewPackage.CONTROL__LABEL_ALIGNMENT: |
| return getLabelAlignment(); |
| case VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE: |
| return getDomainModelReference(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case VViewPackage.CONTROL__LABEL_ALIGNMENT: |
| setLabelAlignment((LabelAlignment) newValue); |
| return; |
| case VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE: |
| setDomainModelReference((VDomainModelReference) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case VViewPackage.CONTROL__LABEL_ALIGNMENT: |
| setLabelAlignment(LABEL_ALIGNMENT_EDEFAULT); |
| return; |
| case VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE: |
| setDomainModelReference((VDomainModelReference) null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case VViewPackage.CONTROL__LABEL_ALIGNMENT: |
| return labelAlignment != LABEL_ALIGNMENT_EDEFAULT; |
| case VViewPackage.CONTROL__DOMAIN_MODEL_REFERENCE: |
| return domainModelReference != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) { |
| return super.toString(); |
| } |
| |
| final StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (labelAlignment: "); //$NON-NLS-1$ |
| result.append(labelAlignment); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emf.ecp.view.spi.model.VControl#setDomainModelReference(org.eclipse.emf.ecore.EStructuralFeature) |
| */ |
| @Override |
| public void setDomainModelReference(EStructuralFeature feature) { |
| setDomainModelReference(ModelReferenceHelper.createDomainModelReference(feature)); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emf.ecp.view.spi.model.VControl#setDomainModelReference(org.eclipse.emf.ecore.EStructuralFeature, |
| * java.util.Collection) |
| */ |
| @Override |
| public void setDomainModelReference(EStructuralFeature feature, Collection<EReference> eReferences) { |
| setDomainModelReference(ModelReferenceHelper.createDomainModelReference(feature, eReferences)); |
| } |
| |
| } // ControlImpl |