我想我已经弄明白了。
在与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()将为相应的“选项卡”演示者调用revealInParent()。