我想我已经弄清楚了。
在带有 TabLayoutPanel 的演示者中(我们称之为 MainPresenter):
@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_first = new Type<RevealContentHandler<?>>();
@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_second = new Type<RevealContentHandler<?>>();
public interface MyView extends View {
public void setMainPresenter(MainPresenter presenter);
public TabLayoutPanel getTeamsPanel();
}
@Inject PlaceManager placeMananger;
@Inject FirstPresenter firstPresenter;
@Inject SecondPresenter secondPresenter;
@ProxyCodeSplit
public interface MyProxy extends Proxy<MainPresenter> {
}
@Inject
public MainPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy) {
super(eventBus, view, proxy);
view.setMainPresenter(this);
}
@Override
protected void revealInParent() {
RevealRootContentEvent.fire(this, this);
}
public void setTabContents(Integer tab) {
if (tab == 0) {
placeMananger.revealPlace(new PlaceRequest("first"));
} else if (tab == 1) {
placeMananger.revealPlace(new PlaceRequest("second"));
}
然后在您的 MainView 中实现方法 setMainPresenter() 以在本地存储引用。实现通常的 setInSlot(),然后添加这个选项卡处理程序:
@UiHandler("mainTabs")
void onMainTabsBeforeSelection(BeforeSelectionEvent<Integer> event) {
mainPresenter.setTabContents(event.getItem());
}
每次用户更改选项卡时,处理程序都会调用 MainPresenter。然后 setTabContents() 将为适当的“选项卡”Presenter 调用revealInParent()。