private MContext getParentWithContext(MUIElement part) {
    MElementContainer<MUIElement> parent = part.getParent();
    MUIElement intermediate = parent;
    if (intermediate == null) {
      intermediate = part;
    } else {
      while (parent != null) {
        if (parent instanceof MContext) {
          if (((MContext) parent).getContext() != null) return (MContext) parent;
        }
        intermediate = parent;
        parent = parent.getParent();
      }
    }

    MPlaceholder placeholder = modelService.findPlaceholderFor(getWindow(), intermediate);
    parent = placeholder.getParent();
    while (parent != null) {
      if (parent instanceof MContext) {
        if (((MContext) parent).getContext() != null) return (MContext) parent;
      }
      parent = parent.getParent();
    }
    return null;
  }
 /** @param parent */
 private void setStackVisibility(MElementContainer<MUIElement> parent) {
   for (MUIElement child : parent.getChildren()) {
     if (child.isToBeRendered() && child.isVisible()) {
       parent.setToBeRendered(true);
       return;
     }
   }
   parent.setToBeRendered(false);
   // continue modifying the visibility as the parent's parent may also
   // need to be hidden from the user
   setStackVisibility(parent.getParent());
 }
예제 #3
0
  @SuppressWarnings("unchecked")
  public void exchange() {
    MPart activeEditor = partService.getActivePart();

    MElementContainer<MUIElement> oldEditorStack = activeEditor.getParent();
    MElementContainer<MUIElement> splitSash = oldEditorStack.getParent();
    if (splitSash.getChildren().size() != 2) {
      return;
    }

    int oldStackIndex = splitSash.getChildren().indexOf(oldEditorStack);
    MElementContainer<MUIElement> newEditorStack =
        (MElementContainer<MUIElement>) splitSash.getChildren().get(oldStackIndex == 1 ? 0 : 1);

    exchange_editor_with_selected_in_new_stack(activeEditor, oldEditorStack, newEditorStack);

    activate(activeEditor);
  }
  private void createElement(MUIElement element) {
    if (modelService.isHostedElement(element, workbenchWindow)) {
      // assume the client has full control
      return;
    }

    MPlaceholder placeholder = element.getCurSharedRef();
    if (placeholder != null) {
      element.setToBeRendered(true);
      element = placeholder;
    }

    // render this element
    element.setToBeRendered(true);

    // render all of its parents
    MUIElement parentWindow = workbenchWindow;
    // determine the top parent that needs to be forcibly created
    MUIElement target = null;
    MElementContainer<MUIElement> parent = element.getParent();
    while (parent != null && parent != parentWindow) {
      parent.setToBeRendered(true);
      if (parent.getWidget() == null) {
        target = parent;
      }
      parent = parent.getParent();
    }
    if (target != null) {
      // force the element's parent hierarchy to be created
      engine.createGui(target);
    }
    // ask the engine to create the element
    if (element.getWidget() == null) engine.createGui(element);

    parent = element.getParent();
    if (parent != null && parent.getChildren().size() == 1) {
      // if we're the only child, set ourselves as the selected element
      parent.setSelectedElement(element);
    }
  }