|
Lines 366-381
Link Here
|
| 366 |
} |
366 |
} |
| 367 |
|
367 |
|
| 368 |
/** |
368 |
/** |
| 369 |
* A notifying list implementation for supporting {@link Resource#getContents}. |
369 |
* A basic reusable notifying list implementation for supporting {@link Resource#getContents}. |
| 370 |
*/ |
370 |
*/ |
| 371 |
protected class ContentsEList<E extends Object & EObject> extends NotifyingInternalEListImpl<E> implements InternalEList<E> |
371 |
public static abstract class ResourceContentsEList<E extends Object & EObject> extends NotifyingInternalEListImpl<E> implements InternalEList<E> |
| 372 |
{ |
372 |
{ |
| 373 |
private static final long serialVersionUID = 1L; |
373 |
private static final long serialVersionUID = 1L; |
| 374 |
|
374 |
|
|
|
375 |
protected abstract Resource.Internal getResource(); |
| 376 |
protected abstract Notification setLoaded(boolean loaded); |
| 377 |
|
| 375 |
@Override |
378 |
@Override |
| 376 |
public Object getNotifier() |
379 |
public Object getNotifier() |
| 377 |
{ |
380 |
{ |
| 378 |
return ResourceImpl.this; |
381 |
return getResource(); |
| 379 |
} |
382 |
} |
| 380 |
|
383 |
|
| 381 |
@Override |
384 |
@Override |
|
Lines 387-393
Link Here
|
| 387 |
@Override |
390 |
@Override |
| 388 |
protected boolean isNotificationRequired() |
391 |
protected boolean isNotificationRequired() |
| 389 |
{ |
392 |
{ |
| 390 |
return ResourceImpl.this.eNotificationRequired(); |
393 |
return !getResource().eAdapters().isEmpty(); |
| 391 |
} |
394 |
} |
| 392 |
|
395 |
|
| 393 |
@Override |
396 |
@Override |
|
Lines 412-419
Link Here
|
| 412 |
public NotificationChain inverseAdd(E object, NotificationChain notifications) |
415 |
public NotificationChain inverseAdd(E object, NotificationChain notifications) |
| 413 |
{ |
416 |
{ |
| 414 |
InternalEObject eObject = (InternalEObject)object; |
417 |
InternalEObject eObject = (InternalEObject)object; |
| 415 |
notifications = eObject.eSetResource(ResourceImpl.this, notifications); |
418 |
notifications = eObject.eSetResource(getResource(), notifications); |
| 416 |
ResourceImpl.this.attached(eObject); |
419 |
getResource().attached(eObject); |
| 417 |
return notifications; |
420 |
return notifications; |
| 418 |
} |
421 |
} |
| 419 |
|
422 |
|
|
Lines 421-429
Link Here
|
| 421 |
public NotificationChain inverseRemove(E object, NotificationChain notifications) |
424 |
public NotificationChain inverseRemove(E object, NotificationChain notifications) |
| 422 |
{ |
425 |
{ |
| 423 |
InternalEObject eObject = (InternalEObject)object; |
426 |
InternalEObject eObject = (InternalEObject)object; |
| 424 |
if (ResourceImpl.this.isLoaded) |
427 |
if (getResource().isLoaded()) |
| 425 |
{ |
428 |
{ |
| 426 |
ResourceImpl.this.detached(eObject); |
429 |
getResource().detached(eObject); |
| 427 |
} |
430 |
} |
| 428 |
return eObject.eSetResource(null, notifications); |
431 |
return eObject.eSetResource(null, notifications); |
| 429 |
} |
432 |
} |
|
Lines 474-501
Link Here
|
| 474 |
|
477 |
|
| 475 |
protected void loaded() |
478 |
protected void loaded() |
| 476 |
{ |
479 |
{ |
| 477 |
if (!ResourceImpl.this.isLoaded()) |
480 |
if (!getResource().isLoaded()) |
| 478 |
{ |
481 |
{ |
| 479 |
Notification notification = ResourceImpl.this.setLoaded(true); |
482 |
Notification notification = setLoaded(true); |
| 480 |
if (notification != null) |
483 |
if (notification != null) |
| 481 |
{ |
484 |
{ |
| 482 |
ResourceImpl.this.eNotify(notification); |
485 |
getResource().eNotify(notification); |
| 483 |
} |
486 |
} |
| 484 |
} |
487 |
} |
| 485 |
} |
488 |
} |
| 486 |
|
489 |
|
| 487 |
protected void modified() |
490 |
protected void modified() |
| 488 |
{ |
491 |
{ |
| 489 |
if (isTrackingModification()) |
492 |
if (getResource().isTrackingModification()) |
| 490 |
{ |
493 |
{ |
| 491 |
setModified(true); |
494 |
getResource().setModified(true); |
| 492 |
} |
495 |
} |
| 493 |
} |
496 |
} |
| 494 |
|
497 |
|
| 495 |
@Override |
498 |
@Override |
| 496 |
public boolean contains(Object object) |
499 |
public boolean contains(Object object) |
| 497 |
{ |
500 |
{ |
| 498 |
return size <= 4 ? super.contains(object) : object instanceof InternalEObject && ((InternalEObject)object).eDirectResource() == ResourceImpl.this; |
501 |
return size <= 4 ? super.contains(object) : object instanceof InternalEObject && ((InternalEObject)object).eDirectResource() == getResource(); |
|
|
502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
/** |
| 506 |
* A notifying list implementation for supporting {@link Resource#getContents}. |
| 507 |
*/ |
| 508 |
protected class ContentsEList<E extends Object & EObject> extends ResourceContentsEList<E> |
| 509 |
{ |
| 510 |
private static final long serialVersionUID = 1L; |
| 511 |
|
| 512 |
@Override |
| 513 |
protected ResourceImpl getResource() |
| 514 |
{ |
| 515 |
return ResourceImpl.this; |
| 516 |
} |
| 517 |
|
| 518 |
@Override |
| 519 |
protected Notification setLoaded(boolean loaded) |
| 520 |
{ |
| 521 |
return getResource().setLoaded(loaded); |
| 522 |
} |
| 523 |
|
| 524 |
@Override |
| 525 |
protected boolean isNotificationRequired() |
| 526 |
{ |
| 527 |
return getResource().eNotificationRequired(); |
| 499 |
} |
528 |
} |
| 500 |
} |
529 |
} |
| 501 |
|
530 |
|