private void rawRemoveFromSlot(IsSlot<?> slot, PresenterWidget<?> child) { if (child == null || child.slot != slot) { return; } if (!child.isPopup()) { getView().removeFromSlot(slot.getRawSlot(), child); } child.orphan(); }
/** * Internal method called to reset a presenter. Instead of using that method, * fire a {@link ResetPresentersEvent} to perform a reset manually. */ void internalReset() { if (!isVisible()) { return; } onReset(); // use new set to prevent concurrent modification for (PresenterWidget<?> child: new HashSet<>(children)) { child.internalReset(); } if (isPopup()) { ((PopupView) getView()).show(); } }
/** * Internal method called to reveal a presenter. * See {@link PresenterWidget} and {@link Presenter} for ways to reveal a * presenter. */ @SuppressWarnings("unchecked") void internalReveal() { if (isVisible()) { return; } onReveal(); visible = true; // use new set to prevent concurrent modification for (PresenterWidget<?> child: new HashSet<>(children)) { child.internalReveal(); } if (isPopup()) { monitorCloseEvent((PresenterWidget<? extends PopupView>) this); ((PopupView) getView()).showAndReposition(); } registerVisibleHandlers(); }
/** * This method adds some content in a specific slot of the {@link Presenter}. The attached {@link View} should * manage this slot when its {@link View#addToSlot(Object, IsWidget)} is called. * <p/> * Contrary to the {@link #setInSlot(IsSlot, PresenterWidget)} method, no {@link ResetPresentersEvent} is fired, so * {@link PresenterWidget#onReset()} is not invoked. * <p/> * For more details on slots, see {@link HasSlots}. * * @param slot The slot into which the content is being added. * @param child The content, a {@link PresenterWidget}. Passing {@code null} will not add anything. */ @Override public <T extends PresenterWidget<?>> void addToSlot(MultiSlot<T> slot, T child) { assert child != null : "cannot add null to a slot"; if (child.slot == slot && child.parent == this) { return; } adoptChild(slot, child); if (!child.isPopup()) { getView().addToSlot(slot.getRawSlot(), child); } if (isVisible()) { child.internalReveal(); } }
/** * Internal method called to hide a presenter. * See {@link PresenterWidget} for ways to hide a presenter. */ void internalHide() { if (!isVisible()) { return; } for (PresenterWidget<?> child : children) { child.internalHide(); } if (isPopup()) { ((PopupView) this.getView()).setCloseHandler(null); ((PopupView) this.getView()).hide(); } unregisterVisibleHandlers(); visible = false; onHide(); }
/** * 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); } } }