@Override
  public void bringToTop(MUIElement element) {
    if (element instanceof MApplication) {
      return;
    }

    MWindow window = getTopLevelWindowFor(element);
    if (window == element) {
      if (!element.isToBeRendered()) {
        element.setToBeRendered(true);
      }

      window.getParent().setSelectedElement(window);
    } else {
      showElementInWindow(window, element);
    }
    UIEvents.publishEvent(UIEvents.UILifeCycle.BRINGTOTOP, element);
  }
  private void activate(MPart part, boolean requiresFocus, boolean activateBranch) {
    if (part == null) {
      if (constructed && activePart != null) {
        firePartDeactivated(activePart);
      }
      activePart = part;
      return;
    }

    // Delegate activations to a CompositePart's inner part (if any)
    if (part instanceof MCompositePart) {
      if (part.getContext() != null) {
        IEclipseContext pContext = part.getContext();
        if (pContext.getActiveLeaf() != null) {
          MPart inner = pContext.getActiveLeaf().get(MPart.class);
          if (inner != null) {
            part = inner;
          }
        }
      }
    }

    // only activate parts that is under our control
    if (!isInContainer(part)) {
      return;
    }

    MWindow window = getWindow();
    IEclipseContext windowContext = window.getContext();
    // check if the active part has changed or if we are no longer the active window
    if (windowContext.getParent().getActiveChild() == windowContext && part == activePart) {
      // insert it in the beginning of the activation history, it may not have been inserted
      // pending when this service was instantiated
      partActivationHistory.prepend(part);
      UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
      return;
    }
    if (contextService != null) {
      contextService.deferUpdates(true);
    }
    if (contextManager != null) {
      contextManager.deferUpdates(true);
    }

    MPart lastActivePart = activePart;
    activePart = part;

    if (constructed && lastActivePart != null && lastActivePart != activePart) {
      firePartDeactivated(lastActivePart);
    }

    try {
      // record any sibling into the activation history if necessary, this will allow it to be
      // reselected again in the future as it will be an activation candidate in the future,
      // this
      // prevents other unrendered elements from being selected arbitrarily which would cause
      // unwanted bundle activation
      recordStackActivation(part);

      delegateBringToTop(part);
      window.getParent().setSelectedElement(window);

      partActivationHistory.activate(part, activateBranch);

      if (requiresFocus) {
        IPresentationEngine pe = part.getContext().get(IPresentationEngine.class);
        pe.focusGui(part);
      }

      firePartActivated(part);
      UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
    } finally {
      if (contextService != null) {
        contextService.deferUpdates(false);
      }
      if (contextManager != null) {
        contextManager.deferUpdates(false);
      }
    }
  }