| /******************************************************************************* |
| * Copyright (c) 2014 Xored Software Inc 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: |
| * Xored Software Inc - initial API and implementation and/or initial documentation |
| *******************************************************************************/ |
| |
| package org.eclipse.rcptt.preferences.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| |
| import org.eclipse.emf.common.util.EList; |
| |
| 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.emf.ecore.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.rcptt.preferences.PrefData; |
| import org.eclipse.rcptt.preferences.PrefNode; |
| import org.eclipse.rcptt.preferences.PreferencesPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Pref Node</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.rcptt.preferences.impl.PrefNodeImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.rcptt.preferences.impl.PrefNodeImpl#getChilds <em>Childs</em>}</li> |
| * <li>{@link org.eclipse.rcptt.preferences.impl.PrefNodeImpl#getData <em>Data</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class PrefNodeImpl extends EObjectImpl implements PrefNode { |
| /** |
| * 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 cached value of the '{@link #getChilds() <em>Childs</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getChilds() |
| * @generated |
| * @ordered |
| */ |
| protected EList<PrefNode> childs; |
| |
| /** |
| * The cached value of the '{@link #getData() <em>Data</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getData() |
| * @generated |
| * @ordered |
| */ |
| protected EList<PrefData> data; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PrefNodeImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PreferencesPackage.Literals.PREF_NODE; |
| } |
| |
| /** |
| * <!-- 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, PreferencesPackage.PREF_NODE__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<PrefNode> getChilds() { |
| if (childs == null) { |
| childs = new EObjectContainmentEList<PrefNode>(PrefNode.class, this, PreferencesPackage.PREF_NODE__CHILDS); |
| } |
| return childs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<PrefData> getData() { |
| if (data == null) { |
| data = new EObjectContainmentEList<PrefData>(PrefData.class, this, PreferencesPackage.PREF_NODE__DATA); |
| } |
| return data; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case PreferencesPackage.PREF_NODE__CHILDS: |
| return ((InternalEList<?>)getChilds()).basicRemove(otherEnd, msgs); |
| case PreferencesPackage.PREF_NODE__DATA: |
| return ((InternalEList<?>)getData()).basicRemove(otherEnd, 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 PreferencesPackage.PREF_NODE__NAME: |
| return getName(); |
| case PreferencesPackage.PREF_NODE__CHILDS: |
| return getChilds(); |
| case PreferencesPackage.PREF_NODE__DATA: |
| return getData(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case PreferencesPackage.PREF_NODE__NAME: |
| setName((String)newValue); |
| return; |
| case PreferencesPackage.PREF_NODE__CHILDS: |
| getChilds().clear(); |
| getChilds().addAll((Collection<? extends PrefNode>)newValue); |
| return; |
| case PreferencesPackage.PREF_NODE__DATA: |
| getData().clear(); |
| getData().addAll((Collection<? extends PrefData>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case PreferencesPackage.PREF_NODE__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case PreferencesPackage.PREF_NODE__CHILDS: |
| getChilds().clear(); |
| return; |
| case PreferencesPackage.PREF_NODE__DATA: |
| getData().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case PreferencesPackage.PREF_NODE__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case PreferencesPackage.PREF_NODE__CHILDS: |
| return childs != null && !childs.isEmpty(); |
| case PreferencesPackage.PREF_NODE__DATA: |
| return data != null && !data.isEmpty(); |
| } |
| 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(')'); |
| return result.toString(); |
| } |
| |
| } //PrefNodeImpl |