/*
   * (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);
  }
 public void deactivate() {
   EclipseContext parent = getParent();
   if (parent == null) return;
   if (this != parent.getActiveChild()) return; // this is not an active context; return
   parent.set(ACTIVE_CHILD, null);
 }
 public void activate() {
   EclipseContext parent = getParent();
   if (parent == null) return;
   if (this == parent.getActiveChild()) return;
   parent.set(ACTIVE_CHILD, this);
 }