/*
   * (non-Javadoc)
   *
   * @see org.eclipse.e4.core.services.context.IEclipseContext#dispose()
   */
  public void dispose() {
    // dispose of child contexts first
    for (EclipseContext childContext : getChildren()) {
      childContext.dispose();
    }

    ContextChangeEvent event =
        new ContextChangeEvent(this, ContextChangeEvent.DISPOSE, null, null, null);
    Set<Scheduled> scheduled = new LinkedHashSet<Scheduled>();
    Set<Computation> allComputations = getListeners();
    listeners.clear();
    allComputations.addAll(activeRATs);
    activeRATs.clear();
    for (Computation computation : allComputations) {
      computation.handleInvalid(event, scheduled);
    }
    processScheduled(scheduled);

    synchronized (notifyOnDisposal) {
      for (IContextDisposalListener listener : notifyOnDisposal) {
        listener.disposed(this);
      }
    }

    localValueComputations.clear();

    // if this was the parent's active child, deactivate it
    EclipseContext parent = getParent();
    if (parent != null) {
      if (this == parent.getActiveChild()) parent.set(ACTIVE_CHILD, null);
    }

    localValues.clear();

    if (parent != null) parent.removeChild(this);

    if (debugAddOn != null)
      debugAddOn.notify(this, IEclipseContextDebugger.EventType.DISPOSED, null);
  }