diff options
Diffstat (limited to 'extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/FillInstanceImpl.java')
-rw-r--r-- | extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/FillInstanceImpl.java | 291 |
1 files changed, 291 insertions, 0 deletions
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/FillInstanceImpl.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/FillInstanceImpl.java new file mode 100644 index 00000000000..ee48d5b1245 --- /dev/null +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel/src/org/eclipse/papyrus/layers/stackmodel/layers/impl/FillInstanceImpl.java @@ -0,0 +1,291 @@ +/******************************************************************************* + * Copyright (c) 2013 CEA LIST. + * 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: + * Cedric Dumoulin - cedric.dumoulin@lifl.fr + ******************************************************************************/ +/** + */ +package org.eclipse.papyrus.layers.stackmodel.layers.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.layers.stackmodel.layers.ColorInstance; +import org.eclipse.papyrus.layers.stackmodel.layers.FillInstance; +import org.eclipse.papyrus.layers.stackmodel.layers.LayersPackage; +import org.eclipse.papyrus.layers.stackmodel.layers.TypeInstance; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Fill Instance</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.papyrus.layers.stackmodel.layers.impl.FillInstanceImpl#getTransparency <em>Transparency</em>}</li> + * <li>{@link org.eclipse.papyrus.layers.stackmodel.layers.impl.FillInstanceImpl#getFillColor <em>Fill Color</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class FillInstanceImpl extends TypeInstanceImpl implements FillInstance { + /** + * The default value of the '{@link #getTransparency() <em>Transparency</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTransparency() + * @generated + * @ordered + */ + protected static final int TRANSPARENCY_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getTransparency() <em>Transparency</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTransparency() + * @generated + * @ordered + */ + protected int transparency = TRANSPARENCY_EDEFAULT; + + /** + * The cached value of the '{@link #getFillColor() <em>Fill Color</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFillColor() + * @generated + * @ordered + */ + protected ColorInstance fillColor; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected FillInstanceImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return LayersPackage.Literals.FILL_INSTANCE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int getTransparency() { + return transparency; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setTransparency(int newTransparency) { + int oldTransparency = transparency; + transparency = newTransparency; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.FILL_INSTANCE__TRANSPARENCY, oldTransparency, transparency)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ColorInstance getFillColor() { + return fillColor; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetFillColor(ColorInstance newFillColor, NotificationChain msgs) { + ColorInstance oldFillColor = fillColor; + fillColor = newFillColor; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LayersPackage.FILL_INSTANCE__FILL_COLOR, oldFillColor, newFillColor); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setFillColor(ColorInstance newFillColor) { + if (newFillColor != fillColor) { + NotificationChain msgs = null; + if (fillColor != null) + msgs = ((InternalEObject)fillColor).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LayersPackage.FILL_INSTANCE__FILL_COLOR, null, msgs); + if (newFillColor != null) + msgs = ((InternalEObject)newFillColor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LayersPackage.FILL_INSTANCE__FILL_COLOR, null, msgs); + msgs = basicSetFillColor(newFillColor, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LayersPackage.FILL_INSTANCE__FILL_COLOR, newFillColor, newFillColor)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case LayersPackage.FILL_INSTANCE__FILL_COLOR: + return basicSetFillColor(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 LayersPackage.FILL_INSTANCE__TRANSPARENCY: + return getTransparency(); + case LayersPackage.FILL_INSTANCE__FILL_COLOR: + return getFillColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case LayersPackage.FILL_INSTANCE__TRANSPARENCY: + setTransparency((Integer)newValue); + return; + case LayersPackage.FILL_INSTANCE__FILL_COLOR: + setFillColor((ColorInstance)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case LayersPackage.FILL_INSTANCE__TRANSPARENCY: + setTransparency(TRANSPARENCY_EDEFAULT); + return; + case LayersPackage.FILL_INSTANCE__FILL_COLOR: + setFillColor((ColorInstance)null); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case LayersPackage.FILL_INSTANCE__TRANSPARENCY: + return transparency != TRANSPARENCY_EDEFAULT; + case LayersPackage.FILL_INSTANCE__FILL_COLOR: + return fillColor != null; + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setValueFromString(String value) { + + if(value==null || value.length()==0) { + return; + } + + // The value should contains the 2 values, separated by comma + // "transparency, fillColor" + String[] values = value.split(","); + try { + setTransparency(Integer.parseInt(values[0].trim())); + getFillColor().setValueFromString(values[1]); + } catch (NumberFormatException e) { + // fail silently + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setValueFromInstance(TypeInstance value) { + + // Check if the value is of the right instance + if( ! getClass().isInstance(value) ) { + return; + } + + FillInstance instance = (FillInstance)value; + setTransparency(instance.getTransparency()); + // Set by copy + getFillColor().setValueFromInstance(instance.getFillColor()); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (transparency: "); + result.append(transparency); + result.append(')'); + return result.toString(); + } + +} //FillInstanceImpl |