| package org.eclipse.stem.core.graph.impl; |
| |
| /******************************************************************************* |
| * Copyright (c) 2006 IBM Corporation 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| |
| 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.stem.core.common.Identifiable; |
| import org.eclipse.stem.core.graph.DynamicNodeLabel; |
| import org.eclipse.stem.core.graph.GraphPackage; |
| import org.eclipse.stem.core.graph.Node; |
| import org.eclipse.stem.core.graph.NodeLabel; |
| |
| /** |
| * <!-- begin-user-doc --> An implementation of the model object '<em><b>Dynamic Node Label</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.stem.core.graph.impl.DynamicNodeLabelImpl#getNode <em>Node</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public abstract class DynamicNodeLabelImpl extends DynamicLabelImpl implements |
| DynamicNodeLabel { |
| /** |
| * The cached value of the '{@link #getNode() <em>Node</em>}' reference. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @see #getNode() |
| * @generated |
| * @ordered |
| */ |
| protected Node node; |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DynamicNodeLabelImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return GraphPackage.Literals.DYNAMIC_NODE_LABEL; |
| } |
| |
| /** |
| * @see org.eclipse.stem.core.graph.impl.LabelImpl#getIdentifiable() |
| */ |
| @Override |
| public Identifiable getIdentifiable() { |
| return getNode(); |
| } // getIdentifiable |
| |
| |
| /** |
| * @see org.eclipse.stem.core.graph.impl.LabelImpl#setIdentifiable(org.eclipse.stem.core.common.Identifiable) |
| */ |
| @Override |
| public void setIdentifiable(Identifiable newIdentifiable) { |
| setNode((Node)newIdentifiable); |
| } // setIdentifiable |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Node getNode() { |
| if (node != null && node.eIsProxy()) { |
| InternalEObject oldNode = (InternalEObject)node; |
| node = (Node)eResolveProxy(oldNode); |
| if (node != oldNode) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, GraphPackage.DYNAMIC_NODE_LABEL__NODE, oldNode, node)); |
| } |
| } |
| return node; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Node basicGetNode() { |
| return node; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetNode(Node newNode, NotificationChain msgs) { |
| Node oldNode = node; |
| node = newNode; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GraphPackage.DYNAMIC_NODE_LABEL__NODE, oldNode, newNode); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setNode(Node newNode) { |
| if (newNode != node) { |
| NotificationChain msgs = null; |
| if (node != null) |
| msgs = ((InternalEObject)node).eInverseRemove(this, GraphPackage.NODE__LABELS, Node.class, msgs); |
| if (newNode != null) |
| msgs = ((InternalEObject)newNode).eInverseAdd(this, GraphPackage.NODE__LABELS, Node.class, msgs); |
| msgs = basicSetNode(newNode, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.DYNAMIC_NODE_LABEL__NODE, newNode, newNode)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| if (node != null) |
| msgs = ((InternalEObject)node).eInverseRemove(this, GraphPackage.NODE__LABELS, Node.class, msgs); |
| return basicSetNode((Node)otherEnd, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| return basicSetNode(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * @see org.eclipse.stem.graph.impl.DynamicLabelImpl#toString() |
| */ |
| @Override |
| public String toString() { |
| final StringBuilder sb = new StringBuilder(super.toString()); |
| |
| sb.append(" Node:"); |
| sb.append(getNode() == null ? "null" : getNode().toString()); |
| return sb.toString(); |
| } // toString |
| |
| /** |
| * @see org.eclipse.stem.graph.impl.DynamicLabelImpl#sane() |
| */ |
| @Override |
| public boolean sane() { |
| boolean retValue = super.sane(); |
| |
| retValue = retValue && getNode() != null ? getURIOfIdentifiableToBeLabeled() |
| .equals(getNode().getURI()) |
| : true; |
| assert retValue; |
| |
| retValue = retValue && getNode() == getIdentifiable(); |
| assert retValue; |
| |
| return retValue; |
| } // sane |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| if (resolve) return getNode(); |
| return basicGetNode(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| setNode((Node)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| setNode((Node)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: |
| return node != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == NodeLabel.class) { |
| switch (derivedFeatureID) { |
| case GraphPackage.DYNAMIC_NODE_LABEL__NODE: return GraphPackage.NODE_LABEL__NODE; |
| default: return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == NodeLabel.class) { |
| switch (baseFeatureID) { |
| case GraphPackage.NODE_LABEL__NODE: return GraphPackage.DYNAMIC_NODE_LABEL__NODE; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| } // DynamicNodeLabelImpl |