001: /**
002: * <copyright></copyright> $Id: ContextModelImpl.java 22843 2006-11-20 21:19:19Z jeichar $
003: */package net.refractions.udig.project.internal.impl;
004:
005: import java.util.Collection;
006: import java.util.List;
007:
008: import net.refractions.udig.project.internal.ContextModel;
009: import net.refractions.udig.project.internal.Layer;
010: import net.refractions.udig.project.internal.Map;
011: import net.refractions.udig.project.internal.ProjectPackage;
012:
013: import org.eclipse.emf.common.notify.Adapter;
014: import org.eclipse.emf.common.notify.Notification;
015: import org.eclipse.emf.common.notify.NotificationChain;
016: import org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EAdapterList;
017: import org.eclipse.emf.common.util.EList;
018: import org.eclipse.emf.ecore.EClass;
019: import org.eclipse.emf.ecore.EObject;
020: import org.eclipse.emf.ecore.EStructuralFeature;
021: import org.eclipse.emf.ecore.InternalEObject;
022: import org.eclipse.emf.ecore.impl.ENotificationImpl;
023: import org.eclipse.emf.ecore.impl.EObjectImpl;
024: import org.eclipse.emf.ecore.util.EcoreUtil;
025: import org.eclipse.emf.ecore.util.InternalEList;
026: import org.geotools.filter.Filter;
027:
028: import com.vividsolutions.jts.geom.Envelope;
029:
030: /**
031: * TODO Purpose of net.refractions.udig.project.internal.impl
032: * <p>
033: * </p>
034: *
035: * @author Jesse
036: * @since 1.0.0
037: * @generated
038: */
039: @SuppressWarnings("deprecation")
040: public class ContextModelImpl extends EObjectImpl implements
041: ContextModel {
042:
043: private LayersList2 layers = new LayersList2(Layer.class, this ,
044: ProjectPackage.CONTEXT_MODEL__LAYERS,
045: ProjectPackage.LAYER__CONTEXT_MODEL);
046:
047: @SuppressWarnings("unchecked")
048: protected ContextModelImpl() {
049: super ();
050: }
051:
052: /**
053: * <!-- begin-user-doc --> <!-- end-user-doc -->
054: * @generated
055: */
056: protected EClass eStaticClass() {
057: return ProjectPackage.eINSTANCE.getContextModel();
058: }
059:
060: /**
061: * <!-- begin-user-doc --> <!-- end-user-doc -->
062: * @generated not
063: */
064: @SuppressWarnings("unchecked")
065: public List<Layer> getLayers() {
066: return layers;
067:
068: }
069:
070: /**
071: * Typesafe Layer access as a workaround for EMF generation bug.
072: *
073: * @return
074: * @deprecated
075: */
076: public List<Layer> layers() {
077: return getLayers();
078: }
079:
080: /**
081: * <!-- begin-user-doc --> <!-- end-user-doc -->
082: * @generated
083: */
084: public Map getMap() {
085: if (eContainerFeatureID != ProjectPackage.CONTEXT_MODEL__MAP)
086: return null;
087: return (Map) eContainer;
088: }
089:
090: /**
091: * <!-- begin-user-doc --> <!-- end-user-doc -->
092: * @generated
093: */
094: public void setMap(Map newMap) {
095: if (newMap != eContainer
096: || (eContainerFeatureID != ProjectPackage.CONTEXT_MODEL__MAP && newMap != null)) {
097: if (EcoreUtil.isAncestor(this , (EObject) newMap))
098: throw new IllegalArgumentException(
099: "Recursive containment not allowed for " + toString()); //$NON-NLS-1$
100: NotificationChain msgs = null;
101: if (eContainer != null)
102: msgs = eBasicRemoveFromContainer(msgs);
103: if (newMap != null)
104: msgs = ((InternalEObject) newMap).eInverseAdd(this ,
105: ProjectPackage.MAP__CONTEXT_MODEL, Map.class,
106: msgs);
107: msgs = eBasicSetContainer((InternalEObject) newMap,
108: ProjectPackage.CONTEXT_MODEL__MAP, msgs);
109: if (msgs != null)
110: msgs.dispatch();
111: } else if (eNotificationRequired())
112: eNotify(new ENotificationImpl(this , Notification.SET,
113: ProjectPackage.CONTEXT_MODEL__MAP, newMap, newMap));
114: }
115:
116: public void addDeepAdapter(Adapter adapter) {
117: getMap().addDeepAdapter(adapter);
118: }
119:
120: public void removeDeepAdapter(Adapter adapter) {
121: getMap().removeDeepAdapter(adapter);
122: }
123:
124: /**
125: * <!-- begin-user-doc --> <!-- end-user-doc -->
126: *
127: * @generated NOT
128: */
129: public void lowerLayer(Layer layer) {
130: getMap().lowerLayer(layer);
131: }
132:
133: /**
134: * <!-- begin-user-doc --> <!-- end-user-doc -->
135: *
136: * @generated NOT
137: */
138: public void raiseLayer(Layer layer) {
139: getMap().raiseLayer(layer);
140: }
141:
142: /**
143: * <!-- begin-user-doc --> <!-- end-user-doc -->
144: * @generated
145: */
146: @SuppressWarnings("unchecked")
147: public NotificationChain eInverseAdd(InternalEObject otherEnd,
148: int featureID, Class baseClass, NotificationChain msgs) {
149: if (featureID >= 0) {
150: switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
151: case ProjectPackage.CONTEXT_MODEL__LAYERS:
152: return ((InternalEList) getLayers()).basicAdd(otherEnd,
153: msgs);
154: case ProjectPackage.CONTEXT_MODEL__MAP:
155: if (eContainer != null)
156: msgs = eBasicRemoveFromContainer(msgs);
157: return eBasicSetContainer(otherEnd,
158: ProjectPackage.CONTEXT_MODEL__MAP, msgs);
159: default:
160: return eDynamicInverseAdd(otherEnd, featureID,
161: baseClass, msgs);
162: }
163: }
164: if (eContainer != null)
165: msgs = eBasicRemoveFromContainer(msgs);
166: return eBasicSetContainer(otherEnd, featureID, msgs);
167: }
168:
169: /**
170: * <!-- begin-user-doc --> <!-- end-user-doc -->
171: * @generated
172: */
173: @SuppressWarnings("unchecked")
174: public NotificationChain eInverseRemove(InternalEObject otherEnd,
175: int featureID, Class baseClass, NotificationChain msgs) {
176: if (featureID >= 0) {
177: switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
178: case ProjectPackage.CONTEXT_MODEL__LAYERS:
179: return ((InternalEList) getLayers()).basicRemove(
180: otherEnd, msgs);
181: case ProjectPackage.CONTEXT_MODEL__MAP:
182: return eBasicSetContainer(null,
183: ProjectPackage.CONTEXT_MODEL__MAP, msgs);
184: default:
185: return eDynamicInverseRemove(otherEnd, featureID,
186: baseClass, msgs);
187: }
188: }
189: return eBasicSetContainer(null, featureID, msgs);
190: }
191:
192: /**
193: * <!-- begin-user-doc --> <!-- end-user-doc -->
194: * @generated
195: */
196: public NotificationChain eBasicRemoveFromContainer(
197: NotificationChain msgs) {
198: if (eContainerFeatureID >= 0) {
199: switch (eContainerFeatureID) {
200: case ProjectPackage.CONTEXT_MODEL__MAP:
201: return eContainer.eInverseRemove(this ,
202: ProjectPackage.MAP__CONTEXT_MODEL, Map.class,
203: msgs);
204: default:
205: return eDynamicBasicRemoveFromContainer(msgs);
206: }
207: }
208: return eContainer.eInverseRemove(this , EOPPOSITE_FEATURE_BASE
209: - eContainerFeatureID, null, msgs);
210: }
211:
212: /**
213: * <!-- begin-user-doc --> <!-- end-user-doc -->
214: * @generated
215: */
216: public Object eGet(EStructuralFeature eFeature, boolean resolve) {
217: switch (eDerivedStructuralFeatureID(eFeature)) {
218: case ProjectPackage.CONTEXT_MODEL__LAYERS:
219: return getLayers();
220: case ProjectPackage.CONTEXT_MODEL__MAP:
221: return getMap();
222: }
223: return eDynamicGet(eFeature, resolve);
224: }
225:
226: /**
227: * <!-- begin-user-doc --> <!-- end-user-doc -->
228: * @generated
229: */
230: @SuppressWarnings("unchecked")
231: public void eSet(EStructuralFeature eFeature, Object newValue) {
232: switch (eDerivedStructuralFeatureID(eFeature)) {
233: case ProjectPackage.CONTEXT_MODEL__LAYERS:
234: getLayers().clear();
235: getLayers().addAll((Collection) newValue);
236: return;
237: case ProjectPackage.CONTEXT_MODEL__MAP:
238: setMap((Map) newValue);
239: return;
240: }
241: eDynamicSet(eFeature, newValue);
242: }
243:
244: /**
245: * <!-- begin-user-doc --> <!-- end-user-doc -->
246: * @generated
247: */
248: public void eUnset(EStructuralFeature eFeature) {
249: switch (eDerivedStructuralFeatureID(eFeature)) {
250: case ProjectPackage.CONTEXT_MODEL__LAYERS:
251: getLayers().clear();
252: return;
253: case ProjectPackage.CONTEXT_MODEL__MAP:
254: setMap((Map) null);
255: return;
256: }
257: eDynamicUnset(eFeature);
258: }
259:
260: /**
261: * <!-- begin-user-doc --> <!-- end-user-doc -->
262: * @generated NOT
263: */
264: public boolean eIsSet(EStructuralFeature eFeature) {
265: switch (eDerivedStructuralFeatureID(eFeature)) {
266: case ProjectPackage.CONTEXT_MODEL__LAYERS:
267: return getLayers() != null && !getLayers().isEmpty();
268: case ProjectPackage.CONTEXT_MODEL__MAP:
269: return getMap() != null;
270: }
271: return eDynamicIsSet(eFeature);
272: }
273:
274: /**
275: * <!-- begin-user-doc --> <!-- end-user-doc -->
276: * @generated
277: */
278: public String toString() {
279: if (eIsProxy())
280: return super .toString();
281:
282: return "Layers" + getLayers().toString(); //$NON-NLS-1$
283: }
284:
285: /**
286: * Turns off emf notification
287: *
288: * @param notify true if notifications should be used.
289: */
290: public void setNotification(boolean notify) {
291: if (notify)
292: eFlags = eFlags | (EDELIVER);
293: else
294: eFlags = eFlags & (~EDELIVER);
295: }
296:
297: public void select(Envelope boundingBox) {
298: getMap().select(boundingBox);
299: }
300:
301: public void select(Envelope boundingBox, boolean and) {
302: getMap().select(boundingBox, and);
303: }
304:
305: public void select(Filter filter) {
306: getMap().select(filter);
307: }
308:
309: public void select(Filter filter, boolean and) {
310: getMap().select(filter, and);
311: }
312:
313: private volatile EList eAdapters;
314:
315: @Override
316: public EList eAdapters() {
317: if (eAdapters == null) {
318: synchronized (this ) {
319: if (eAdapters == null) {
320: eAdapters = new SynchronizedEList(super.eAdapters());
321: }
322: }
323: }
324: return eAdapters;
325: }
326:
327: }
|