コード例 #1
0
  @Override
  public MPart showPart(MPart part, PartState partState) {
    Assert.isNotNull(part);
    Assert.isNotNull(partState);

    MPart addedPart = addPart(part);
    MPlaceholder localPlaceholder = getLocalPlaceholder(addedPart);
    // correct the placeholder setting if necessary
    if (localPlaceholder != null && addedPart.getCurSharedRef() != localPlaceholder) {
      addedPart.setCurSharedRef(localPlaceholder);
    }

    switch (partState) {
      case ACTIVATE:
        activate(addedPart);
        return addedPart;
      case VISIBLE:
        MPart activePart = getActivePart();
        if (activePart == null
            || (activePart != addedPart && getParent(activePart) == getParent(addedPart))) {
          delegateBringToTop(addedPart);
          activate(addedPart);
        } else {
          bringToTop(addedPart);
        }
        return addedPart;
      case CREATE:
        createElement(addedPart);
        return addedPart;
    }
    return addedPart;
  }
コード例 #2
0
 private void adjustPlaceholder(MPart part) {
   if (isShared(part)) {
     MPlaceholder placeholder = part.getCurSharedRef();
     // if this part doesn't have any placeholders, we need to make one
     if (placeholder == null
         // alternatively, if it has one but it's not in the current container, then we
         // need to spawn another one as we don't want to reuse the same one and end up
         // shifting that placeholder to the current container during the add operation
         || (placeholder.getParent() != null && !isInContainer(placeholder))) {
       placeholder = createSharedPart(part);
       part.setCurSharedRef(placeholder);
     }
   }
 }