Debian Codegraph @

plugins/org.eclipse.xsd/src/org/eclipse/xsd/impl/XSDModelGroupImpl.java

raw
1 /**
2 * Copyright (c) 2002-2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 */
11 package org.eclipse.xsd.impl;
12
13
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.List;
17 import java.util.ListIterator;
18
19 import org.w3c.dom.Element;
20 import org.w3c.dom.Node;
21
22 import org.eclipse.emf.common.notify.Notification;
23 import org.eclipse.emf.common.notify.NotificationChain;
24 import org.eclipse.emf.common.util.EList;
25 import org.eclipse.emf.ecore.EAttribute;
26 import org.eclipse.emf.ecore.EClass;
27 import org.eclipse.emf.ecore.EReference;
28 import org.eclipse.emf.ecore.InternalEObject;
29 import org.eclipse.emf.ecore.impl.ENotificationImpl;
30 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
31 import org.eclipse.emf.ecore.util.EObjectEList;
32 import org.eclipse.emf.ecore.util.InternalEList;
33
34 import org.eclipse.xsd.XSDAnnotation;
35 import org.eclipse.xsd.XSDCompositor;
36 import org.eclipse.xsd.XSDConcreteComponent;
37 import org.eclipse.xsd.XSDDiagnostic;
38 import org.eclipse.xsd.XSDDiagnosticSeverity;
39 import org.eclipse.xsd.XSDFactory;
40 import org.eclipse.xsd.XSDModelGroup;
41 import org.eclipse.xsd.XSDModelGroupDefinition;
42 import org.eclipse.xsd.XSDPackage;
43 import org.eclipse.xsd.XSDParticle;
44 import org.eclipse.xsd.util.XSDConstants;
45
46
47 /**
48 * <!-- begin-user-doc -->
49 * An implementation of the model object '<em><b>Model Group</b></em>'.
50 * <!-- end-user-doc -->
51 * <p>
52 * The following features are implemented:
53 * </p>
54 * <ul>
55 * <li>{@link org.eclipse.xsd.impl.XSDModelGroupImpl#getCompositor <em>Compositor</em>}</li>
56 * <li>{@link org.eclipse.xsd.impl.XSDModelGroupImpl#getAnnotation <em>Annotation</em>}</li>
57 * <li>{@link org.eclipse.xsd.impl.XSDModelGroupImpl#getContents <em>Contents</em>}</li>
58 * <li>{@link org.eclipse.xsd.impl.XSDModelGroupImpl#getParticles <em>Particles</em>}</li>
59 * </ul>
60 *
61 * @generated
62 */
63 public class XSDModelGroupImpl
64 extends XSDTermImpl
65 implements XSDModelGroup
66 {
67 /**
68 * The default value of the '{@link #getCompositor() <em>Compositor</em>}' attribute.
69 * <!-- begin-user-doc -->
70 * <!-- end-user-doc -->
71 * @see #getCompositor()
72 * @generated
73 * @ordered
74 */
75 protected static final XSDCompositor COMPOSITOR_EDEFAULT = XSDCompositor.ALL_LITERAL;
76
77 /**
78 * The offset of the flags representing the value of the '{@link #getCompositor() <em>Compositor</em>}' attribute.
79 * <!-- begin-user-doc -->
80 * <!-- end-user-doc -->
81 * @generated
82 * @ordered
83 */
84 protected static final int COMPOSITOR_EFLAG_OFFSET = 8;
85
86 /**
87 * The flags representing the default value of the '{@link #getCompositor() <em>Compositor</em>}' attribute.
88 * <!-- begin-user-doc -->
89 * <!-- end-user-doc -->
90 * @generated
91 * @ordered
92 */
93 protected static final int COMPOSITOR_EFLAG_DEFAULT = COMPOSITOR_EDEFAULT.ordinal() << COMPOSITOR_EFLAG_OFFSET;
94
95 /**
96 * The array of enumeration values for '{@link XSDCompositor Compositor}'
97 * <!-- begin-user-doc -->
98 * <!-- end-user-doc -->
99 * @generated
100 * @ordered
101 */
102 private static final XSDCompositor[] COMPOSITOR_EFLAG_VALUES = XSDCompositor.values();
103
104 /**
105 * The flags representing the value of the '{@link #getCompositor() <em>Compositor</em>}' attribute.
106 * <!-- begin-user-doc -->
107 * <!-- end-user-doc -->
108 * @see #getCompositor()
109 * @generated
110 * @ordered
111 */
112 protected static final int COMPOSITOR_EFLAG = 0x3 << COMPOSITOR_EFLAG_OFFSET;
113
114 /**
115 * The cached value of the '{@link #getAnnotation() <em>Annotation</em>}' containment reference.
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
118 * @see #getAnnotation()
119 * @generated
120 * @ordered
121 */
122 protected XSDAnnotation annotation;
123
124 /**
125 * The cached value of the '{@link #getContents() <em>Contents</em>}' containment reference list.
126 * <!-- begin-user-doc -->
127 * <!-- end-user-doc -->
128 * @see #getContents()
129 * @generated
130 * @ordered
131 */
132 protected EList<XSDParticle> contents;
133
134 /**
135 * The cached value of the '{@link #getParticles() <em>Particles</em>}' reference list.
136 * <!-- begin-user-doc -->
137 * <!-- end-user-doc -->
138 * @see #getParticles()
139 * @generated
140 * @ordered
141 */
142 protected EList<XSDParticle> particles;
143
144 public static XSDModelGroup createModelGroup(Node node)
145 {
146 switch (XSDConstants.nodeType(node))
147 {
148 case XSDConstants.ALL_ELEMENT:
149 {
150 XSDModelGroup xsdModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
151 xsdModelGroup.setCompositor(XSDCompositor.ALL_LITERAL);
152 xsdModelGroup.setElement((Element)node);
153 return xsdModelGroup;
154 }
155 case XSDConstants.CHOICE_ELEMENT:
156 {
157 XSDModelGroup xsdModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
158 xsdModelGroup.setCompositor(XSDCompositor.CHOICE_LITERAL);
159 xsdModelGroup.setElement((Element)node);
160 return xsdModelGroup;
161 }
162 case XSDConstants.SEQUENCE_ELEMENT:
163 {
164 XSDModelGroup xsdModelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
165 xsdModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
166 xsdModelGroup.setElement((Element)node);
167 return xsdModelGroup;
168 }
169 }
170
171 return null;
172 }
173
174 /**
175 * <!-- begin-user-doc -->
176 * <!-- end-user-doc -->
177 * @generated
178 */
179 protected XSDModelGroupImpl()
180 {
181 super();
182 }
183
184 /**
185 * <!-- begin-user-doc -->
186 * <!-- end-user-doc -->
187 * @generated
188 */
189 @Override
190 protected EClass eStaticClass()
191 {
192 return XSDPackage.Literals.XSD_MODEL_GROUP;
193 }
194
195 /**
196 * <!-- begin-user-doc -->
197 * <!-- end-user-doc -->
198 * @generated
199 */
200 @Override
201 public XSDCompositor getCompositor()
202 {
203 return COMPOSITOR_EFLAG_VALUES[(eFlags & COMPOSITOR_EFLAG) >>> COMPOSITOR_EFLAG_OFFSET];
204 }
205
206 /**
207 * <!-- begin-user-doc -->
208 * <!-- end-user-doc -->
209 * @generated
210 */
211 @Override
212 public void setCompositor(XSDCompositor newCompositor)
213 {
214 XSDCompositor oldCompositor = COMPOSITOR_EFLAG_VALUES[(eFlags & COMPOSITOR_EFLAG) >>> COMPOSITOR_EFLAG_OFFSET];
215 if (newCompositor == null) newCompositor = COMPOSITOR_EDEFAULT;
216 eFlags = eFlags & ~COMPOSITOR_EFLAG | newCompositor.ordinal() << COMPOSITOR_EFLAG_OFFSET;
217 if (eNotificationRequired())
218 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_MODEL_GROUP__COMPOSITOR, oldCompositor, newCompositor));
219 }
220
221 /**
222 * <!-- begin-user-doc -->
223 * <!-- end-user-doc -->
224 * @generated
225 */
226 @Override
227 public XSDAnnotation getAnnotation()
228 {
229 return annotation;
230 }
231
232 /**
233 * <!-- begin-user-doc -->
234 * <!-- end-user-doc -->
235 * @generated
236 */
237 @Override
238 public void setAnnotation(XSDAnnotation newAnnotation)
239 {
240 if (newAnnotation != annotation)
241 {
242 NotificationChain msgs = null;
243 if (annotation != null)
244 msgs = ((InternalEObject)annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_MODEL_GROUP__ANNOTATION, null, msgs);
245 if (newAnnotation != null)
246 msgs = ((InternalEObject)newAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XSDPackage.XSD_MODEL_GROUP__ANNOTATION, null, msgs);
247 msgs = basicSetAnnotation(newAnnotation, msgs);
248 if (msgs != null) msgs.dispatch();
249 }
250 else if (eNotificationRequired())
251 eNotify(new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_MODEL_GROUP__ANNOTATION, newAnnotation, newAnnotation));
252 }
253
254 /**
255 * <!-- begin-user-doc -->
256 * <!-- end-user-doc -->
257 * @generated
258 */
259 public NotificationChain basicSetAnnotation(XSDAnnotation newAnnotation, NotificationChain msgs)
260 {
261 XSDAnnotation oldAnnotation = annotation;
262 annotation = newAnnotation;
263 if (eNotificationRequired())
264 {
265 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XSDPackage.XSD_MODEL_GROUP__ANNOTATION, oldAnnotation, newAnnotation);
266 if (msgs == null) msgs = notification; else msgs.add(notification);
267 }
268 return msgs;
269 }
270
271 /**
272 * <!-- begin-user-doc -->
273 * <!-- end-user-doc -->
274 * @generated
275 */
276 @Override
277 public EList<XSDParticle> getContents()
278 {
279 if (contents == null)
280 {
281 contents = new EObjectContainmentEList<XSDParticle>(XSDParticle.class, this, XSDPackage.XSD_MODEL_GROUP__CONTENTS);
282 }
283 return contents;
284 }
285
286 /**
287 * <!-- begin-user-doc -->
288 * <!-- end-user-doc -->
289 * @generated
290 */
291 @Override
292 public EList<XSDParticle> getParticles()
293 {
294 if (particles == null)
295 {
296 particles = new EObjectEList<XSDParticle>(XSDParticle.class, this, XSDPackage.XSD_MODEL_GROUP__PARTICLES);
297 }
298 return particles;
299 }
300
301 /**
302 * <!-- begin-user-doc -->
303 * <!-- end-user-doc -->
304 * @generated
305 */
306 @Override
307 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
308 {
309 switch (featureID)
310 {
311 case XSDPackage.XSD_MODEL_GROUP__ANNOTATION:
312 return basicSetAnnotation(null, msgs);
313 case XSDPackage.XSD_MODEL_GROUP__CONTENTS:
314 return ((InternalEList<?>)getContents()).basicRemove(otherEnd, msgs);
315 }
316 return super.eInverseRemove(otherEnd, featureID, msgs);
317 }
318
319 /**
320 * <!-- begin-user-doc -->
321 * <!-- end-user-doc -->
322 * @generated
323 */
324 @Override
325 public Object eGet(int featureID, boolean resolve, boolean coreType)
326 {
327 switch (featureID)
328 {
329 case XSDPackage.XSD_MODEL_GROUP__COMPOSITOR:
330 return getCompositor();
331 case XSDPackage.XSD_MODEL_GROUP__ANNOTATION:
332 return getAnnotation();
333 case XSDPackage.XSD_MODEL_GROUP__CONTENTS:
334 return getContents();
335 case XSDPackage.XSD_MODEL_GROUP__PARTICLES:
336 return getParticles();
337 }
338 return super.eGet(featureID, resolve, coreType);
339 }
340
341 /**
342 * <!-- begin-user-doc -->
343 * <!-- end-user-doc -->
344 * @generated
345 */
346 @SuppressWarnings("unchecked")
347 @Override
348 public void eSet(int featureID, Object newValue)
349 {
350 switch (featureID)
351 {
352 case XSDPackage.XSD_MODEL_GROUP__COMPOSITOR:
353 setCompositor((XSDCompositor)newValue);
354 return;
355 case XSDPackage.XSD_MODEL_GROUP__ANNOTATION:
356 setAnnotation((XSDAnnotation)newValue);
357 return;
358 case XSDPackage.XSD_MODEL_GROUP__CONTENTS:
359 getContents().clear();
360 getContents().addAll((Collection<? extends XSDParticle>)newValue);
361 return;
362 case XSDPackage.XSD_MODEL_GROUP__PARTICLES:
363 getParticles().clear();
364 getParticles().addAll((Collection<? extends XSDParticle>)newValue);
365 return;
366 }
367 super.eSet(featureID, newValue);
368 }
369
370 /**
371 * <!-- begin-user-doc -->
372 * <!-- end-user-doc -->
373 * @generated
374 */
375 @Override
376 public void eUnset(int featureID)
377 {
378 switch (featureID)
379 {
380 case XSDPackage.XSD_MODEL_GROUP__COMPOSITOR:
381 setCompositor(COMPOSITOR_EDEFAULT);
382 return;
383 case XSDPackage.XSD_MODEL_GROUP__ANNOTATION:
384 setAnnotation((XSDAnnotation)null);
385 return;
386 case XSDPackage.XSD_MODEL_GROUP__CONTENTS:
387 getContents().clear();
388 return;
389 case XSDPackage.XSD_MODEL_GROUP__PARTICLES:
390 getParticles().clear();
391 return;
392 }
393 super.eUnset(featureID);
394 }
395
396 /**
397 * <!-- begin-user-doc -->
398 * <!-- end-user-doc -->
399 * @generated
400 */
401 @Override
402 public boolean eIsSet(int featureID)
403 {
404 switch (featureID)
405 {
406 case XSDPackage.XSD_MODEL_GROUP__COMPOSITOR:
407 return (eFlags & COMPOSITOR_EFLAG) != COMPOSITOR_EFLAG_DEFAULT;
408 case XSDPackage.XSD_MODEL_GROUP__ANNOTATION:
409 return annotation != null;
410 case XSDPackage.XSD_MODEL_GROUP__CONTENTS:
411 return contents != null && !contents.isEmpty();
412 case XSDPackage.XSD_MODEL_GROUP__PARTICLES:
413 return particles != null && !particles.isEmpty();
414 }
415 return super.eIsSet(featureID);
416 }
417
418 /**
419 * <!-- begin-user-doc -->
420 * <!-- end-user-doc -->
421 * @generated
422 */
423 @Override
424 public String toString()
425 {
426 if (eIsProxy()) return super.toString();
427
428 StringBuilder result = new StringBuilder(super.toString());
429 result.append(" (compositor: ");
430 result.append(COMPOSITOR_EFLAG_VALUES[(eFlags & COMPOSITOR_EFLAG) >>> COMPOSITOR_EFLAG_OFFSET]);
431 result.append(')');
432 return result.toString();
433 }
434
435 @Override
436 public Element createElement()
437 {
438 XSDCompositor theCompositor = getCompositor();
439 Element newElement =
440 createElement
441 (XSDCompositor.ALL_LITERAL == theCompositor ?
442 XSDConstants.ALL_ELEMENT :
443 XSDCompositor.CHOICE_LITERAL == theCompositor ?
444 XSDConstants.CHOICE_ELEMENT :
445 XSDConstants.SEQUENCE_ELEMENT);
446
447 setElement(newElement);
448 for (XSDParticle xsdParticle : getContents())
449 {
450 Element newParticleElement = ((XSDConcreteComponentImpl)xsdParticle).createElement();
451 newElement.appendChild(newParticleElement);
452 }
453 return newElement;
454 }
455
456 @Override
457 protected void patch()
458 {
459 super.patch();
460
461 List<XSDParticle> newParticles = new ArrayList<XSDParticle>(getContents());
462 Collection<XSDParticle> remainingParticles = new ArrayList<XSDParticle>(getParticles());
463 for (ListIterator<XSDParticle> particles = newParticles.listIterator(); particles.hasNext(); )
464 {
465 XSDParticle xsdParticle = particles.next();
466 if (xsdParticle.getMaxOccurs() == 0)
467 {
468 particles.remove();
469 remainingParticles.add(xsdParticle);
470 }
471 else
472 {
473 remainingParticles.remove(xsdParticle);
474 }
475 }
476
477 if (!remainingParticles.isEmpty())
478 {
479 getParticles().removeAll(remainingParticles);
480 }
481
482 setListContentAndOrder(getParticles(), newParticles);
483 }
484
485 @Override
486 public void validate()
487 {
488 super.validate();
489
490 boolean hasBounds = !(getContainer() instanceof XSDModelGroupDefinition);
491 String anchor = null;
492 String contentType = null;
493 switch (getCompositor().getValue())
494 {
495 case XSDCompositor.ALL:
496 {
497 anchor = "element-all";
498 contentType = "all";
499
500 for (XSDParticle xsdParticle : getContents())
501 {
502 switch (xsdParticle.getMaxOccurs())
503 {
504 case 0:
505 case 1:
506 {
507 break;
508 }
509 default:
510 {
511 createDiagnostic(XSDDiagnosticSeverity.ERROR_LITERAL, "cos-all-limited.2");
512 }
513 }
514 }
515 break;
516 }
517 case XSDCompositor.SEQUENCE:
518 {
519 anchor = "element-sequence";
520 contentType = "explicitGroup";
521 break;
522 }
523 case XSDCompositor.CHOICE:
524 {
525 anchor = "element-choice";
526 contentType = "explicitGroup";
527 break;
528 }
529 }
530
531 Element theElement = getElement();
532 if (theElement != null)
533 {
534 String [] attributes =
535 hasBounds ?
536 new String []
537 {
538 XSDConstants.ID_ATTRIBUTE,
539 XSDConstants.MAXOCCURS_ATTRIBUTE,
540 XSDConstants.MINOCCURS_ATTRIBUTE
541 } :
542 new String []
543 {
544 XSDConstants.ID_ATTRIBUTE,
545 };
546
547 checkAttributes(XSDConstants.PART1, anchor, theElement, attributes);
548 checkBuiltInTypeConstraint("ID", null, XSDConstants.PART1, anchor, theElement, XSDConstants.ID_ATTRIBUTE, false);
549
550 if (hasBounds)
551 {
552 checkAttributeTypeConstraint
553 (contentType,
554 "maxOccurs",
555 null,
556 XSDConstants.PART1,
557 anchor,
558 theElement,
559 XSDConstants.MAXOCCURS_ATTRIBUTE,
560 false);
561
562 checkAttributeTypeConstraint
563 (contentType,
564 "minOccurs",
565 null,
566 XSDConstants.PART1,
567 anchor,
568 theElement,
569 XSDConstants.MINOCCURS_ATTRIBUTE,
570 false);
571 }
572
573 checkComplexContent(contentType, XSDConstants.PART1, anchor, theElement);
574 }
575 else
576 {
577 // EATM validate synthesized models too
578 }
579 }
580
581 public void validateRoot()
582 {
583 XSDConcreteComponent diagnosticTarget = this;
584 XSDParticle xsdParticle;
585 if (getContainer() instanceof XSDParticle)
586 {
587 xsdParticle = (XSDParticle)getContainer();
588 if (xsdParticle.eContainmentFeature() == XSDPackage.Literals.XSD_COMPLEX_TYPE_DEFINITION__SYNTHETIC_PARTICLE)
589 {
590 diagnosticTarget = xsdParticle.getContainer();
591 }
592 }
593 else
594 {
595 xsdParticle = XSDFactory.eINSTANCE.createXSDParticle();
596 xsdParticle.setTerm(this);
597 }
598
599 XSDParticleImpl.XSDNFA dfa = (XSDParticleImpl.XSDNFA)xsdParticle.getDFA();
600 Collection<XSDDiagnostic> diagnostics = dfa.getDiagnostics();
601 if (!diagnostics.isEmpty())
602 {
603 for (XSDDiagnostic xsdDiagnostic : diagnostics)
604 {
605 xsdDiagnostic.setPrimaryComponent(diagnosticTarget);
606 xsdDiagnostic.setNode(diagnosticTarget.getElement());
607 }
608 getDiagnostics().addAll(diagnostics);
609 }
610 }
611
612 @Override
613 protected boolean isUpdatingDOM()
614 {
615 return
616 super.isUpdatingDOM() ||
617 getContainer() instanceof XSDConcreteComponentImpl &&
618 ((XSDConcreteComponentImpl)getContainer()).isUpdatingDOM();
619 }
620
621 @Override
622 protected void handleUnreconciledElement(Element child, List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
623 {
624 XSDParticle xsdParticle = XSDParticleImpl.createParticle(child);
625 if (xsdParticle != null)
626 {
627 newContents.add(xsdParticle);
628 }
629 else
630 {
631 XSDAnnotation xsdAnnotation = XSDAnnotationImpl.createAnnotation(child);
632 if (xsdAnnotation != null)
633 {
634 if (newContents.isEmpty())
635 {
636 newContents.add(xsdAnnotation);
637 }
638 }
639 }
640 }
641
642 @Override
643 protected void handleReconciliation(List<XSDConcreteComponent> newContents, List<XSDConcreteComponent> remainingContents)
644 {
645 handleAnnotationReconciliation(XSDPackage.Literals.XSD_MODEL_GROUP__ANNOTATION, newContents, remainingContents);
646
647 if (!remainingContents.isEmpty())
648 {
649 getContents().removeAll(remainingContents);
650 }
651
652 if (!newContents.isEmpty())
653 {
654 @SuppressWarnings("unchecked") List<XSDParticle> list = (List<XSDParticle>)(List<?>)newContents;
655 setListContentAndOrder(getContents(), list);
656 }
657 }
658
659 @Override
660 protected void changeAttribute(EAttribute eAttribute)
661 {
662 super.changeAttribute(eAttribute);
663 Element theElement = getElement();
664 if (eAttribute == null || eAttribute == XSDPackage.Literals.XSD_MODEL_GROUP__COMPOSITOR)
665 {
666 if (theElement != null && eAttribute != null && !isReconciling)
667 {
668 XSDCompositor theCompositor = getCompositor();
669 Element newElement =
670 createElement
671 (XSDCompositor.ALL_LITERAL == theCompositor ?
672 XSDConstants.ALL_ELEMENT :
673 XSDCompositor.CHOICE_LITERAL == theCompositor ?
674 XSDConstants.CHOICE_ELEMENT :
675 XSDConstants.SEQUENCE_ELEMENT);
676
677 forceReplace(newElement, theElement);
678 setElement(newElement);
679
680 XSDConcreteComponentImpl container = (XSDConcreteComponentImpl)getContainer();
681 if (container instanceof XSDParticle)
682 {
683 ((XSDParticle)container).setElement(newElement);
684 container.changeAttribute(null);
685 }
686 }
687 }
688 }
689
690 @Override
691 protected void adoptContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
692 {
693 super.adoptContent(eReference, xsdConcreteComponent);
694 if (eReference == XSDPackage.Literals.XSD_MODEL_GROUP__CONTENTS)
695 {
696 traverseToRootForPatching();
697 }
698 }
699
700 @Override
701 protected void orphanContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
702 {
703 super.orphanContent(eReference, xsdConcreteComponent);
704 if (eReference == XSDPackage.Literals.XSD_MODEL_GROUP__CONTENTS)
705 {
706 traverseToRootForPatching();
707 }
708 }
709
710 @Override
711 public void moveContent(EReference eReference, XSDConcreteComponent xsdConcreteComponent)
712 {
713 super.moveContent(eReference, xsdConcreteComponent);
714 if (eReference == XSDPackage.Literals.XSD_MODEL_GROUP__CONTENTS)
715 {
716 traverseToRootForPatching();
717 }
718 }
719
720 @Override
721 public XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean shareDOM)
722 {
723 XSDModelGroupImpl clonedModelGroup =
724 (XSDModelGroupImpl)getXSDFactory().createXSDModelGroup();
725 clonedModelGroup.isReconciling = true;
726
727 clonedModelGroup.setCompositor(getCompositor());
728
729 if (deep)
730 {
731 if (getAnnotation() != null)
732 {
733 clonedModelGroup.setAnnotation((XSDAnnotation)getAnnotation().cloneConcreteComponent(deep, shareDOM));
734 }
735 if (!getContents().isEmpty())
736 {
737 clonedModelGroup.getContents().addAll(cloneConcreteComponents(getContents(), true, shareDOM));
738 }
739 }
740
741 if (shareDOM && getElement() != null)
742 {
743 clonedModelGroup.setElement(getElement());
744 }
745
746 clonedModelGroup.isReconciling = shareDOM;
747 return clonedModelGroup;
748 }
749 }