Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 28d9af77371fc4693ab18a2865b33daefc10bec7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************************
 * Copyright (c) 2001, 2004 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
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.ejb.util;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jst.j2ee.ejb.EJBRelation;
import org.eclipse.jst.j2ee.internal.ejb.impl.EjbFactoryImpl;

public class RelationshipsAttributeMaintenanceAdapter extends AdapterImpl {
	/**
	 * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(Notification)
	 */
	public void notifyChanged(Notification msg) {
		if ((EStructuralFeature)msg.getFeature() == EjbFactoryImpl.getPackage().getRelationships_EjbRelations()) {
			switch (msg.getEventType()) {
				case Notification.ADD :
					addedEJBRelation((EJBRelation) msg.getNewValue(), (EStructuralFeature)msg.getFeature());
					break;
				case Notification.REMOVE :
					removedEJBRelation((EJBRelation) msg.getOldValue(), (EStructuralFeature)msg.getFeature());
					break;
			}
		}
	}
	private void removedEJBRelation(EJBRelation aRelation, EObject sf) {
		Adapter a = getAdapter(aRelation);
		if (a != null) {
			Notification not = new ENotificationImpl((InternalEObject)aRelation, Notification.REMOVE,(EStructuralFeature) sf, aRelation, null, Notification.NO_INDEX);
			a.notifyChanged(not);
		}
	}
	private void addedEJBRelation(EJBRelation aRelation, EObject sf) {
		Adapter a = getAdapter(aRelation);
		if (a != null) {
			Notification not = new ENotificationImpl((InternalEObject)aRelation, Notification.ADD,(EStructuralFeature) sf, null, aRelation, Notification.NO_INDEX);
			a.notifyChanged(not);
		}
	}
	private Adapter getAdapter(EObject anObject) {
		return EcoreUtil.getAdapter(anObject.eAdapters(),EJBAttributeMaintenanceFactoryImpl.ADAPTER_KEY);
	}
}

Back to the top