boolean isPopup() { return slot != null && slot.isPopup(); }
/** * Remove a child from its parent and make it a child of the current presenter. * * @param slot the new slot to add this {@code child} to. * @param child the child to adopt. */ private <T extends PresenterWidget<?>> void adoptChild(IsSlot<T> slot, PresenterWidget<?> child) { if (child.parent != this) { if (child.parent != null) { if (!child.slot.isRemovable()) { throw new IllegalArgumentException("Cannot move a child of a permanent slot to another slot"); } child.parent.children.remove(child); } child.parent = this; children.add(child); } child.slot = slot; }
private void rawRemoveFromSlot(IsSlot<?> slot, PresenterWidget<?> child) { if (child == null || child.slot != slot) { return; } if (!child.isPopup()) { getView().removeFromSlot(slot.getRawSlot(), child); } child.orphan(); }
/** * This method sets some content in a specific slot of the {@link Presenter}. The attached {@link View} should * manage this slot when its {@link View#setInSlot(Object, IsWidget)} is called. It should also clear the slot when * called with {@code null} as a parameter. * <p/> * For more details on slots, see {@link HasSlots}. * * @param slot The slot for which the content is being set. * @param child The content, a {@link PresenterWidget}. Passing {@code null} will clear the slot. * @param performReset Pass {@code true} if you want a {@link ResetPresentersEvent} to be fired after the content * has been added and this presenter is visible, pass {@code false} otherwise. */ @Override public <T extends PresenterWidget<?>> void setInSlot(IsSlot<T> slot, T child, boolean performReset) { if (child == null) { clearSlot((RemovableSlot<?>) slot); return; } adoptChild(slot, child); internalClearSlot(slot, child); if (!child.isPopup()) { getView().setInSlot(slot.getRawSlot(), child); } if (isVisible()) { child.internalReveal(); if (performReset) { ResetPresentersEvent.fire(this); } } }
/** * Disconnects a child from its parent. */ private void orphan() { if (slot == null) { return; } if (!slot.isRemovable()) { throw new IllegalArgumentException("Cannot remove a child from a permanent slot"); } if (parent != null) { internalHide(); parent.children.remove(this); parent = null; } slot = null; }