001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id$
006: */package net.refractions.udig.printing.model.impl;
007:
008: import java.util.Collection;
009: import java.util.Iterator;
010: import java.util.List;
011:
012: import net.refractions.udig.printing.model.Box;
013: import net.refractions.udig.printing.model.ModelPackage;
014: import net.refractions.udig.printing.model.Page;
015: import net.refractions.udig.project.IProject;
016: import net.refractions.udig.project.IProjectElement;
017: import net.refractions.udig.project.internal.Project;
018: import net.refractions.udig.project.internal.ProjectElement;
019: import net.refractions.udig.project.internal.ProjectPackage;
020:
021: import org.eclipse.core.runtime.IAdaptable;
022: import org.eclipse.draw2d.geometry.Dimension;
023: import org.eclipse.draw2d.geometry.Point;
024: import org.eclipse.emf.common.notify.Notification;
025: import org.eclipse.emf.common.notify.NotificationChain;
026: import org.eclipse.emf.common.util.EList;
027: import org.eclipse.emf.ecore.EClass;
028: import org.eclipse.emf.ecore.EStructuralFeature;
029: import org.eclipse.emf.ecore.InternalEObject;
030: import org.eclipse.emf.ecore.impl.ENotificationImpl;
031: import org.eclipse.emf.ecore.util.EObjectContainmentEList;
032: import org.eclipse.emf.ecore.util.InternalEList;
033:
034: /**
035: * <!-- begin-user-doc -->
036: * An implementation of the model object '<em><b>Page</b></em>'.
037: * <!-- end-user-doc -->
038: * <p>
039: * The following features are implemented:
040: * <ul>
041: * <li>{@link net.refractions.udig.printing.model.impl.PageImpl#getName <em>Name</em>}</li>
042: * <li>{@link net.refractions.udig.printing.model.impl.PageImpl#getProjectInternal <em>Project Internal</em>}</li>
043: * <li>{@link net.refractions.udig.printing.model.impl.PageImpl#getBoxes <em>Boxes</em>}</li>
044: * </ul>
045: * </p>
046: *
047: * @generated
048: */
049: public class PageImpl extends ElementImpl implements Page {
050: /**
051: * The default value of the '{@link #getName() <em>Name</em>}' attribute.
052: * <!-- begin-user-doc -->
053: * <!-- end-user-doc -->
054: * @see #getName()
055: * @generated
056: * @ordered
057: */
058: protected static final String NAME_EDEFAULT = null;
059:
060: /**
061: * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
062: * <!-- begin-user-doc -->
063: * <!-- end-user-doc -->
064: * @see #getName()
065: * @generated
066: * @ordered
067: */
068: protected String name = NAME_EDEFAULT;
069:
070: /**
071: * The cached value of the '{@link #getProjectInternal() <em>Project Internal</em>}' reference.
072: * <!-- begin-user-doc -->
073: * <!-- end-user-doc -->
074: * @see #getProjectInternal()
075: * @generated
076: * @ordered
077: */
078: protected Project projectInternal = null;
079:
080: /**
081: * The cached value of the '{@link #getBoxes() <em>Boxes</em>}' containment reference list.
082: * <!-- begin-user-doc -->
083: * <!-- end-user-doc -->
084: * @see #getBoxes()
085: * @generated
086: * @ordered
087: */
088: protected EList boxes = null;
089:
090: /**
091: * <!-- begin-user-doc -->
092: * <!-- end-user-doc -->
093: * @generated NOT
094: */
095: public PageImpl() {
096: super ();
097: }
098:
099: /**
100: * <!-- begin-user-doc -->
101: * <!-- end-user-doc -->
102: * @generated
103: */
104: protected EClass eStaticClass() {
105: return ModelPackage.eINSTANCE.getPage();
106: }
107:
108: /**
109: * <!-- begin-user-doc -->
110: * <!-- end-user-doc -->
111: * @generated
112: */
113: public Project getProjectInternal() {
114: if (projectInternal != null && projectInternal.eIsProxy()) {
115: Project oldProjectInternal = projectInternal;
116: projectInternal = (Project) eResolveProxy((InternalEObject) projectInternal);
117: if (projectInternal != oldProjectInternal) {
118: if (eNotificationRequired())
119: eNotify(new ENotificationImpl(this ,
120: Notification.RESOLVE,
121: ModelPackage.PAGE__PROJECT_INTERNAL,
122: oldProjectInternal, projectInternal));
123: }
124: }
125: return projectInternal;
126: }
127:
128: /**
129: * <!-- begin-user-doc -->
130: * <!-- end-user-doc -->
131: * @generated
132: */
133: public Project basicGetProjectInternal() {
134: return projectInternal;
135: }
136:
137: /**
138: * <!-- begin-user-doc -->
139: * <!-- end-user-doc -->
140: * @generated
141: */
142: public NotificationChain basicSetProjectInternal(
143: Project newProjectInternal, NotificationChain msgs) {
144: Project oldProjectInternal = projectInternal;
145: projectInternal = newProjectInternal;
146: if (eNotificationRequired()) {
147: ENotificationImpl notification = new ENotificationImpl(
148: this , Notification.SET,
149: ModelPackage.PAGE__PROJECT_INTERNAL,
150: oldProjectInternal, newProjectInternal);
151: if (msgs == null)
152: msgs = notification;
153: else
154: msgs.add(notification);
155: }
156: return msgs;
157: }
158:
159: /**
160: * <!-- begin-user-doc -->
161: * <!-- end-user-doc -->
162: * @generated
163: */
164: public void setProjectInternal(Project newProjectInternal) {
165: if (newProjectInternal != projectInternal) {
166: NotificationChain msgs = null;
167: if (projectInternal != null)
168: msgs = ((InternalEObject) projectInternal)
169: .eInverseRemove(
170: this ,
171: ProjectPackage.PROJECT__ELEMENTS_INTERNAL,
172: Project.class, msgs);
173: if (newProjectInternal != null)
174: msgs = ((InternalEObject) newProjectInternal)
175: .eInverseAdd(
176: this ,
177: ProjectPackage.PROJECT__ELEMENTS_INTERNAL,
178: Project.class, msgs);
179: msgs = basicSetProjectInternal(newProjectInternal, msgs);
180: if (msgs != null)
181: msgs.dispatch();
182: } else if (eNotificationRequired())
183: eNotify(new ENotificationImpl(this , Notification.SET,
184: ModelPackage.PAGE__PROJECT_INTERNAL,
185: newProjectInternal, newProjectInternal));
186: }
187:
188: /**
189: * <!-- begin-user-doc -->
190: * <!-- end-user-doc -->
191: * @generated
192: */
193: public List getBoxes() {
194: if (boxes == null) {
195: boxes = new EObjectContainmentEList(Box.class, this ,
196: ModelPackage.PAGE__BOXES);
197: }
198: return boxes;
199: }
200:
201: /**
202: * <!-- begin-user-doc -->
203: * <!-- end-user-doc -->
204: * @generated
205: */
206: public NotificationChain eInverseAdd(InternalEObject otherEnd,
207: int featureID, Class baseClass, NotificationChain msgs) {
208: if (featureID >= 0) {
209: switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
210: case ModelPackage.PAGE__PROJECT_INTERNAL:
211: if (projectInternal != null)
212: msgs = ((InternalEObject) projectInternal)
213: .eInverseRemove(
214: this ,
215: ProjectPackage.PROJECT__ELEMENTS_INTERNAL,
216: Project.class, msgs);
217: return basicSetProjectInternal((Project) otherEnd, msgs);
218: default:
219: return eDynamicInverseAdd(otherEnd, featureID,
220: baseClass, msgs);
221: }
222: }
223: if (eContainer != null)
224: msgs = eBasicRemoveFromContainer(msgs);
225: return eBasicSetContainer(otherEnd, featureID, msgs);
226: }
227:
228: /**
229: * <!-- begin-user-doc -->
230: * <!-- end-user-doc -->
231: * @generated
232: */
233: public NotificationChain eInverseRemove(InternalEObject otherEnd,
234: int featureID, Class baseClass, NotificationChain msgs) {
235: if (featureID >= 0) {
236: switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
237: case ModelPackage.PAGE__PROJECT_INTERNAL:
238: return basicSetProjectInternal(null, msgs);
239: case ModelPackage.PAGE__BOXES:
240: return ((InternalEList) getBoxes()).basicRemove(
241: otherEnd, msgs);
242: default:
243: return eDynamicInverseRemove(otherEnd, featureID,
244: baseClass, msgs);
245: }
246: }
247: return eBasicSetContainer(null, featureID, msgs);
248: }
249:
250: /**
251: * <!-- begin-user-doc -->
252: * <!-- end-user-doc -->
253: * @generated
254: */
255: public Object eGet(EStructuralFeature eFeature, boolean resolve) {
256: switch (eDerivedStructuralFeatureID(eFeature)) {
257: case ModelPackage.PAGE__LOCATION:
258: return getLocation();
259: case ModelPackage.PAGE__SIZE:
260: return getSize();
261: case ModelPackage.PAGE__NAME:
262: return getName();
263: case ModelPackage.PAGE__PROJECT_INTERNAL:
264: if (resolve)
265: return getProjectInternal();
266: return basicGetProjectInternal();
267: case ModelPackage.PAGE__BOXES:
268: return getBoxes();
269: }
270: return eDynamicGet(eFeature, resolve);
271: }
272:
273: /**
274: * <!-- begin-user-doc -->
275: * <!-- end-user-doc -->
276: * @generated
277: */
278: public void eSet(EStructuralFeature eFeature, Object newValue) {
279: switch (eDerivedStructuralFeatureID(eFeature)) {
280: case ModelPackage.PAGE__LOCATION:
281: setLocation((Point) newValue);
282: return;
283: case ModelPackage.PAGE__SIZE:
284: setSize((Dimension) newValue);
285: return;
286: case ModelPackage.PAGE__NAME:
287: setName((String) newValue);
288: return;
289: case ModelPackage.PAGE__PROJECT_INTERNAL:
290: setProjectInternal((Project) newValue);
291: return;
292: case ModelPackage.PAGE__BOXES:
293: getBoxes().clear();
294: getBoxes().addAll((Collection) newValue);
295: return;
296: }
297: eDynamicSet(eFeature, newValue);
298: }
299:
300: /**
301: * <!-- begin-user-doc -->
302: * <!-- end-user-doc -->
303: * @generated
304: */
305: public void eUnset(EStructuralFeature eFeature) {
306: switch (eDerivedStructuralFeatureID(eFeature)) {
307: case ModelPackage.PAGE__LOCATION:
308: setLocation(LOCATION_EDEFAULT);
309: return;
310: case ModelPackage.PAGE__SIZE:
311: setSize(SIZE_EDEFAULT);
312: return;
313: case ModelPackage.PAGE__NAME:
314: setName(NAME_EDEFAULT);
315: return;
316: case ModelPackage.PAGE__PROJECT_INTERNAL:
317: setProjectInternal((Project) null);
318: return;
319: case ModelPackage.PAGE__BOXES:
320: getBoxes().clear();
321: return;
322: }
323: eDynamicUnset(eFeature);
324: }
325:
326: /**
327: * <!-- begin-user-doc -->
328: * <!-- end-user-doc -->
329: * @generated
330: */
331: public boolean eIsSet(EStructuralFeature eFeature) {
332: switch (eDerivedStructuralFeatureID(eFeature)) {
333: case ModelPackage.PAGE__LOCATION:
334: return LOCATION_EDEFAULT == null ? location != null
335: : !LOCATION_EDEFAULT.equals(location);
336: case ModelPackage.PAGE__SIZE:
337: return SIZE_EDEFAULT == null ? size != null
338: : !SIZE_EDEFAULT.equals(size);
339: case ModelPackage.PAGE__NAME:
340: return NAME_EDEFAULT == null ? name != null
341: : !NAME_EDEFAULT.equals(name);
342: case ModelPackage.PAGE__PROJECT_INTERNAL:
343: return projectInternal != null;
344: case ModelPackage.PAGE__BOXES:
345: return boxes != null && !boxes.isEmpty();
346: }
347: return eDynamicIsSet(eFeature);
348: }
349:
350: /**
351: * <!-- begin-user-doc -->
352: * <!-- end-user-doc -->
353: * @generated
354: */
355: public int eBaseStructuralFeatureID(int derivedFeatureID,
356: Class baseClass) {
357: if (baseClass == IProjectElement.class) {
358: switch (derivedFeatureID) {
359: default:
360: return -1;
361: }
362: }
363: if (baseClass == IAdaptable.class) {
364: switch (derivedFeatureID) {
365: default:
366: return -1;
367: }
368: }
369: if (baseClass == ProjectElement.class) {
370: switch (derivedFeatureID) {
371: case ModelPackage.PAGE__NAME:
372: return ProjectPackage.PROJECT_ELEMENT__NAME;
373: case ModelPackage.PAGE__PROJECT_INTERNAL:
374: return ProjectPackage.PROJECT_ELEMENT__PROJECT_INTERNAL;
375: default:
376: return -1;
377: }
378: }
379: return super .eBaseStructuralFeatureID(derivedFeatureID,
380: baseClass);
381: }
382:
383: /**
384: * <!-- begin-user-doc -->
385: * <!-- end-user-doc -->
386: * @generated
387: */
388: public int eDerivedStructuralFeatureID(int baseFeatureID,
389: Class baseClass) {
390: if (baseClass == IProjectElement.class) {
391: switch (baseFeatureID) {
392: default:
393: return -1;
394: }
395: }
396: if (baseClass == IAdaptable.class) {
397: switch (baseFeatureID) {
398: default:
399: return -1;
400: }
401: }
402: if (baseClass == ProjectElement.class) {
403: switch (baseFeatureID) {
404: case ProjectPackage.PROJECT_ELEMENT__NAME:
405: return ModelPackage.PAGE__NAME;
406: case ProjectPackage.PROJECT_ELEMENT__PROJECT_INTERNAL:
407: return ModelPackage.PAGE__PROJECT_INTERNAL;
408: default:
409: return -1;
410: }
411: }
412: return super .eDerivedStructuralFeatureID(baseFeatureID,
413: baseClass);
414: }
415:
416: /**
417: * <!-- begin-user-doc -->
418: * <!-- end-user-doc -->
419: * @generated
420: */
421: public String toString() {
422: if (eIsProxy())
423: return super .toString();
424:
425: StringBuffer result = new StringBuffer(super .toString());
426: result.append(" (name: "); //$NON-NLS-1$
427: result.append(name);
428: result.append(')');
429: return result.toString();
430: }
431:
432: /**
433: * TODO summary sentence for getName ...
434: *
435: * @see org.eclipse.ui.IEditorInput#getName()
436: * @return
437: * @generated
438: */
439: public String getName() {
440: return name;
441: }
442:
443: /**
444: * <!-- begin-user-doc -->
445: * <!-- end-user-doc -->
446: * @generated
447: */
448: public void setName(String newName) {
449: String oldName = name;
450: name = newName;
451: if (eNotificationRequired())
452: eNotify(new ENotificationImpl(this , Notification.SET,
453: ModelPackage.PAGE__NAME, oldName, name));
454: }
455:
456: /**
457: * @see net.refractions.udig.project.IProjectElement#getProject()
458: */
459: public IProject getProject() {
460: return getProjectInternal();
461: }
462:
463: /**
464: * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
465: */
466: public Object getAdapter(Class adapter) {
467: for (Iterator i = eAdapters().iterator(); i.hasNext();) {
468: Object o = i.next();
469: if (o.getClass().isAssignableFrom(adapter))
470: return o;
471: }
472: return null;
473: }
474:
475: public String getFileExtension() {
476: return "upage"; //$NON-NLS-1$
477: }
478:
479: } //PageImpl
|