/******************************************************************************* * Copyright (c) 2008 Hallvard Traetteberg. * 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: * Hallvard Traetteberg - initial API and implementation ******************************************************************************/ /** * <copyright> * </copyright> * * $Id: StyledImpl.java,v 1.4 2009/10/23 12:40:32 htraetteb Exp $ */ package org.eclipse.e4.tm.styles.impl; import org.eclipse.e4.tm.styles.Style; import org.eclipse.e4.tm.styles.StyleItem; import org.eclipse.e4.tm.styles.Styled; import org.eclipse.e4.tm.styles.StylesPackage; 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.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Styled</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.e4.tm.styles.impl.StyledImpl#getName <em>Name</em>}</li> * <li>{@link org.eclipse.e4.tm.styles.impl.StyledImpl#getRole <em>Role</em>}</li> * <li>{@link org.eclipse.e4.tm.styles.impl.StyledImpl#getStyle <em>Style</em>}</li> * </ul> * </p> * * @generated */ public class StyledImpl extends EObjectImpl implements Styled { /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * The default value of the '{@link #getRole() <em>Role</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRole() * @generated * @ordered */ protected static final String ROLE_EDEFAULT = null; /** * The cached value of the '{@link #getRole() <em>Role</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRole() * @generated * @ordered */ protected String role = ROLE_EDEFAULT; /** * The cached value of the '{@link #getStyle() <em>Style</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getStyle() * @generated * @ordered */ protected Style style; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected StyledImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return StylesPackage.Literals.STYLED; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLED__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getRole() { return role; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRole(String newRole) { String oldRole = role; role = newRole; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLED__ROLE, oldRole, role)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Style getStyle() { if (style != null && style.eIsProxy()) { InternalEObject oldStyle = (InternalEObject)style; style = (Style)eResolveProxy(oldStyle); if (style != oldStyle) { InternalEObject newStyle = (InternalEObject)style; NotificationChain msgs = oldStyle.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StylesPackage.STYLED__STYLE, null, null); if (newStyle.eInternalContainer() == null) { msgs = newStyle.eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StylesPackage.STYLED__STYLE, null, msgs); } if (msgs != null) msgs.dispatch(); if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, StylesPackage.STYLED__STYLE, oldStyle, style)); } } return style; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Style basicGetStyle() { return style; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetStyle(Style newStyle, NotificationChain msgs) { Style oldStyle = style; style = newStyle; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StylesPackage.STYLED__STYLE, oldStyle, newStyle); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStyle(Style newStyle) { if (newStyle != style) { NotificationChain msgs = null; if (style != null) msgs = ((InternalEObject)style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StylesPackage.STYLED__STYLE, null, msgs); if (newStyle != null) msgs = ((InternalEObject)newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StylesPackage.STYLED__STYLE, null, msgs); msgs = basicSetStyle(newStyle, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLED__STYLE, newStyle, newStyle)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case StylesPackage.STYLED__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.STYLED__NAME: return getName(); case StylesPackage.STYLED__ROLE: return getRole(); case StylesPackage.STYLED__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.STYLED__NAME: setName((String)newValue); return; case StylesPackage.STYLED__ROLE: setRole((String)newValue); return; case StylesPackage.STYLED__STYLE: setStyle((Style)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case StylesPackage.STYLED__NAME: setName(NAME_EDEFAULT); return; case StylesPackage.STYLED__ROLE: setRole(ROLE_EDEFAULT); return; case StylesPackage.STYLED__STYLE: setStyle((Style)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case StylesPackage.STYLED__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case StylesPackage.STYLED__ROLE: return ROLE_EDEFAULT == null ? role != null : !ROLE_EDEFAULT.equals(role); case StylesPackage.STYLED__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(" (name: "); result.append(name); result.append(", role: "); result.append(role); result.append(')'); return result.toString(); } } //StyledImpl