| /** |
| * Copyright (c) 2019 CEA LIST. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation |
| */ |
| package org.eclipse.papyrus.model2doc.core.builtintypes.impl; |
| |
| import java.lang.reflect.InvocationTargetException; |
| |
| 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.MinimalEObjectImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.papyrus.model2doc.core.builtintypes.BuiltInTypesPackage; |
| import org.eclipse.papyrus.model2doc.core.builtintypes.ListItem; |
| import org.eclipse.papyrus.model2doc.core.builtintypes.TextListItem; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Text List Item</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.papyrus.model2doc.core.builtintypes.impl.TextListItemImpl#getSubItems <em>Sub Items</em>}</li> |
| * <li>{@link org.eclipse.papyrus.model2doc.core.builtintypes.impl.TextListItemImpl#getText <em>Text</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class TextListItemImpl extends MinimalEObjectImpl.Container implements TextListItem { |
| /** |
| * The cached value of the '{@link #getSubItems() <em>Sub Items</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getSubItems() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ListItem> subItems; |
| |
| /** |
| * The default value of the '{@link #getText() <em>Text</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getText() |
| * @generated |
| * @ordered |
| */ |
| protected static final String TEXT_EDEFAULT = ""; //$NON-NLS-1$ |
| |
| /** |
| * The cached value of the '{@link #getText() <em>Text</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getText() |
| * @generated |
| * @ordered |
| */ |
| protected String text = TEXT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected TextListItemImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return BuiltInTypesPackage.Literals.TEXT_LIST_ITEM; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<ListItem> getSubItems() { |
| if (subItems == null) { |
| subItems = new EObjectContainmentEList<>(ListItem.class, this, BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS); |
| } |
| return subItems; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String getText() { |
| return text; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setText(String newText) { |
| String oldText = text; |
| text = newText; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, BuiltInTypesPackage.TEXT_LIST_ITEM__TEXT, oldText, text)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public int getLevel() { |
| int level = 1; |
| org.eclipse.emf.ecore.EObject eContainer = eContainer(); |
| while (eContainer != null && eContainer instanceof org.eclipse.papyrus.model2doc.core.builtintypes.ListItem) { |
| level++; |
| eContainer = eContainer.eContainer(); |
| } |
| return level; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS: |
| return ((InternalEList<?>) getSubItems()).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 BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS: |
| return getSubItems(); |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__TEXT: |
| return getText(); |
| } |
| 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 BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS: |
| getSubItems().clear(); |
| getSubItems().addAll((Collection<? extends ListItem>) newValue); |
| return; |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__TEXT: |
| setText((String) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS: |
| getSubItems().clear(); |
| return; |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__TEXT: |
| setText(TEXT_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__SUB_ITEMS: |
| return subItems != null && !subItems.isEmpty(); |
| case BuiltInTypesPackage.TEXT_LIST_ITEM__TEXT: |
| return TEXT_EDEFAULT == null ? text != null : !TEXT_EDEFAULT.equals(text); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { |
| switch (operationID) { |
| case BuiltInTypesPackage.TEXT_LIST_ITEM___GET_LEVEL: |
| return getLevel(); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) { |
| return super.toString(); |
| } |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (text: "); //$NON-NLS-1$ |
| result.append(text); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // TextListItemImpl |