/** * <copyright> * * Copyright (c) 2005, 2011 SAP AG. * 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: * SAP AG - initial API, implementation and documentation * * </copyright> */ package org.eclipse.graphiti.mm.algorithms.styles.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.emf.ecore.impl.EObjectImpl; import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage; import org.eclipse.graphiti.mm.algorithms.styles.TextStyle; import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Text Style Region</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.TextStyleRegionImpl#getStart <em>Start</em>}</li> * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.TextStyleRegionImpl#getEnd <em>End</em>}</li> * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.TextStyleRegionImpl#getStyle <em>Style</em>}</li> * </ul> * </p> * * @generated */ public class TextStyleRegionImpl extends EObjectImpl implements TextStyleRegion { /** * The default value of the '{@link #getStart() <em>Start</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getStart() * @generated * @ordered */ protected static final int START_EDEFAULT = 0; /** * The cached value of the '{@link #getStart() <em>Start</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getStart() * @generated * @ordered */ protected int start = START_EDEFAULT; /** * The default value of the '{@link #getEnd() <em>End</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getEnd() * @generated * @ordered */ protected static final int END_EDEFAULT = 0; /** * The cached value of the '{@link #getEnd() <em>End</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getEnd() * @generated * @ordered */ protected int end = END_EDEFAULT; /** * The cached value of the '{@link #getStyle() <em>Style</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getStyle() * @generated * @ordered */ protected TextStyle style; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected TextStyleRegionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return StylesPackage.Literals.TEXT_STYLE_REGION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public int getStart() { return start; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStart(int newStart) { int oldStart = start; start = newStart; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.TEXT_STYLE_REGION__START, oldStart, start)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public int getEnd() { return end; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setEnd(int newEnd) { int oldEnd = end; end = newEnd; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.TEXT_STYLE_REGION__END, oldEnd, end)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public TextStyle getStyle() { if (style != null && style.eIsProxy()) { InternalEObject oldStyle = (InternalEObject)style; style = (TextStyle)eResolveProxy(oldStyle); if (style != oldStyle) { InternalEObject newStyle = (InternalEObject)style; NotificationChain msgs = oldStyle.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StylesPackage.TEXT_STYLE_REGION__STYLE, null, null); if (newStyle.eInternalContainer() == null) { msgs = newStyle.eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StylesPackage.TEXT_STYLE_REGION__STYLE, null, msgs); } if (msgs != null) msgs.dispatch(); if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, StylesPackage.TEXT_STYLE_REGION__STYLE, oldStyle, style)); } } return style; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public TextStyle basicGetStyle() { return style; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetStyle(TextStyle newStyle, NotificationChain msgs) { TextStyle oldStyle = style; style = newStyle; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StylesPackage.TEXT_STYLE_REGION__STYLE, oldStyle, newStyle); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStyle(TextStyle newStyle) { if (newStyle != style) { NotificationChain msgs = null; if (style != null) msgs = ((InternalEObject)style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StylesPackage.TEXT_STYLE_REGION__STYLE, null, msgs); if (newStyle != null) msgs = ((InternalEObject)newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StylesPackage.TEXT_STYLE_REGION__STYLE, null, msgs); msgs = basicSetStyle(newStyle, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.TEXT_STYLE_REGION__STYLE, newStyle, newStyle)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case StylesPackage.TEXT_STYLE_REGION__STYLE: return basicSetStyle(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 StylesPackage.TEXT_STYLE_REGION__START: return getStart(); case StylesPackage.TEXT_STYLE_REGION__END: return getEnd(); case StylesPackage.TEXT_STYLE_REGION__STYLE: if (resolve) return getStyle(); return basicGetStyle(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case StylesPackage.TEXT_STYLE_REGION__START: setStart((Integer)newValue); return; case StylesPackage.TEXT_STYLE_REGION__END: setEnd((Integer)newValue); return; case StylesPackage.TEXT_STYLE_REGION__STYLE: setStyle((TextStyle)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case StylesPackage.TEXT_STYLE_REGION__START: setStart(START_EDEFAULT); return; case StylesPackage.TEXT_STYLE_REGION__END: setEnd(END_EDEFAULT); return; case StylesPackage.TEXT_STYLE_REGION__STYLE: setStyle((TextStyle)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case StylesPackage.TEXT_STYLE_REGION__START: return start != START_EDEFAULT; case StylesPackage.TEXT_STYLE_REGION__END: return end != END_EDEFAULT; case StylesPackage.TEXT_STYLE_REGION__STYLE: return style != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (start: "); result.append(start); result.append(", end: "); result.append(end); result.append(')'); return result.toString(); } } //TextStyleRegionImpl