| /* |
| * Copyright (c) 2014, 2015, 2018 Eike Stepper (Loehne, Germany) and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Eike Stepper - initial API and implementation |
| */ |
| package org.eclipse.oomph.setup.impl; |
| |
| import org.eclipse.oomph.setup.Scope; |
| import org.eclipse.oomph.setup.ScopeType; |
| import org.eclipse.oomph.setup.SetupPackage; |
| import org.eclipse.oomph.util.StringUtil; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Scope</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.oomph.setup.impl.ScopeImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.impl.ScopeImpl#getLabel <em>Label</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.impl.ScopeImpl#getDescription <em>Description</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.impl.ScopeImpl#getQualifiedName <em>Qualified Name</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class ScopeImpl extends SetupTaskContainerImpl implements Scope |
| { |
| /** |
| * 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 #getLabel() <em>Label</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLabel() |
| * @generated |
| * @ordered |
| */ |
| protected static final String LABEL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getLabel() <em>Label</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLabel() |
| * @generated |
| * @ordered |
| */ |
| protected String label = LABEL_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getDescription() <em>Description</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getDescription() |
| * @generated |
| * @ordered |
| */ |
| protected static final String DESCRIPTION_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getDescription() |
| * @generated |
| * @ordered |
| */ |
| protected String description = DESCRIPTION_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getQualifiedName() <em>Qualified Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getQualifiedName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String QUALIFIED_NAME_EDEFAULT = null; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ScopeImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return SetupPackage.Literals.SCOPE; |
| } |
| |
| /** |
| * <!-- 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, SetupPackage.SCOPE__NAME, oldName, name)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getLabel() |
| { |
| return label; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLabel(String newLabel) |
| { |
| String oldLabel = label; |
| label = newLabel; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, SetupPackage.SCOPE__LABEL, oldLabel, label)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getDescription() |
| { |
| return description; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setDescription(String newDescription) |
| { |
| String oldDescription = description; |
| description = newDescription; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, SetupPackage.SCOPE__DESCRIPTION, oldDescription, description)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String getQualifiedName() |
| { |
| StringBuilder result = new StringBuilder(); |
| result.append(getName()); |
| for (Scope parent = getParentScope(); parent != null; parent = parent.getParentScope()) |
| { |
| result.insert(0, '.'); |
| result.insert(0, parent.getName()); |
| } |
| |
| return result.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public abstract ScopeType getType(); |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String getQualifiedLabel() |
| { |
| String label = getLabel(); |
| if (StringUtil.isEmpty(label)) |
| { |
| label = getName(); |
| } |
| |
| List<String> labelQualifiers = new ArrayList<String>(); |
| for (Scope parentScope = getParentScope(); parentScope != null; parentScope = parentScope.getParentScope()) |
| { |
| String parentLabel = parentScope.getLabel(); |
| if (StringUtil.isEmpty(parentLabel)) |
| { |
| parentLabel = parentScope.getName(); |
| } |
| |
| if (!StringUtil.isEmpty(parentLabel)) |
| { |
| labelQualifiers.add(0, parentLabel); |
| } |
| } |
| |
| if (!labelQualifiers.isEmpty()) |
| { |
| StringBuilder result = new StringBuilder(label); |
| result.append(" ("); //$NON-NLS-1$ |
| boolean first = true; |
| for (String labelQualifier : labelQualifiers) |
| { |
| if (first) |
| { |
| first = false; |
| } |
| else |
| { |
| result.append(" - "); //$NON-NLS-1$ |
| |
| } |
| |
| result.append(labelQualifier); |
| } |
| |
| result.append(")"); //$NON-NLS-1$ |
| |
| label = result.toString(); |
| } |
| |
| return label; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case SetupPackage.SCOPE__NAME: |
| return getName(); |
| case SetupPackage.SCOPE__LABEL: |
| return getLabel(); |
| case SetupPackage.SCOPE__DESCRIPTION: |
| return getDescription(); |
| case SetupPackage.SCOPE__QUALIFIED_NAME: |
| return getQualifiedName(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case SetupPackage.SCOPE__NAME: |
| setName((String)newValue); |
| return; |
| case SetupPackage.SCOPE__LABEL: |
| setLabel((String)newValue); |
| return; |
| case SetupPackage.SCOPE__DESCRIPTION: |
| setDescription((String)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case SetupPackage.SCOPE__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case SetupPackage.SCOPE__LABEL: |
| setLabel(LABEL_EDEFAULT); |
| return; |
| case SetupPackage.SCOPE__DESCRIPTION: |
| setDescription(DESCRIPTION_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case SetupPackage.SCOPE__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case SetupPackage.SCOPE__LABEL: |
| return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); |
| case SetupPackage.SCOPE__DESCRIPTION: |
| return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); |
| case SetupPackage.SCOPE__QUALIFIED_NAME: |
| return QUALIFIED_NAME_EDEFAULT == null ? getQualifiedName() != null : !QUALIFIED_NAME_EDEFAULT.equals(getQualifiedName()); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() |
| { |
| if (eIsProxy()) |
| { |
| return super.toString(); |
| } |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (name: "); //$NON-NLS-1$ |
| result.append(name); |
| result.append(", label: "); //$NON-NLS-1$ |
| result.append(label); |
| result.append(", description: "); //$NON-NLS-1$ |
| result.append(description); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Scope getParentScope() |
| { |
| return null; |
| } |
| |
| } // ScopeImpl |