我正在尝试在 GWTP 中嵌套一个选项卡演示器。我有一帧(北)是选项卡组 1 和一帧(西)是选项卡组 2。当我与组 1 交互时,我更新了控制组 2 的嵌套选项卡演示器。我查看了嵌套选项卡的示例演示者,但我无法从中确定我的错误。
两个 TabContainerPresenter 是 ManagmentTabsPresenter 和 SettingsTabsPresenter。这些的孩子就像下面的 HomePresenter。这些子项的内容显示在 DockLayoutPanel 的中心。我希望 ManagementTabsPresenter 和 SettingsTabsPresenter 显示在同一个 DockLayoutPanel 的 West 插槽中。
我看到的问题是,当运行此代码时,ManagementTabsPresenter 的revealInParent() 方法和SettingsTabsPresenter 的revealInParent() 方法都会在我尝试在子选项卡上查看一个时被调用。(即 homePresenter)。为什么要调用这两个revealInParent 方法?我错过了什么?确实,SettingsTabsPresenter 和 ManagementTabsPresenter 都位于显示的父选项卡中。这是否意味着当父 tabcontainerpreseter 是 revelatedinparent 时,这两个 tabcontainerpresetners(nonleavetabcontentproxy) 的revealInParent 将被调用?
public class HomePresenter extends Presenter<HomePresenter.MyView, HomePresenter.MyProxy> {
@Inject
AppPlaceManager appPlaceManager;
@NameToken(NameTokens.homePage)
@ProxyStandard
@NoGatekeeper
public interface MyProxy extends TabContentProxyPlace<HomePresenter> {
}
public interface MyView extends View {
}
@TabInfo(container = ManagementTabsPresenter.class)
static TabData getTabLabel(MainAppGinjector injector) {
return new TabDataBasic(injector.getVSMMessages().home_tab(), ClientConstants.HOME_TAB_POSITION);
}
@Inject
public HomePresenter(final EventBus eventBus, final MyView view, final MyProxy proxy) {
super(eventBus, view, proxy);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, ManagementTabsPresenter.TYPE_MAIN_CONTENT_SLOT, this);
}
}
public class ManagementTabsPresenter extends TabContainerPresenter<ManagementTabsPresenter.MyView, ManagementTabsPresenter.MyProxy> {
/**
* {@link ManagementTabsPresenter}'s proxy.
*/
@ProxyStandard
public interface MyProxy extends Proxy<ManagementTabsPresenter> {
}
/**
* {@link ManagementTabsPresenter}'s view.
*/
public interface MyView extends TabView {
}
/**
* Fired by child proxie's when their tab content is changed.
*/
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_Management_ChangeTab = new Type<ChangeTabHandler>();
/**
* Use this in leaf presenters, inside their {@link #revealInParent} method.
*/
@ContentSlot
public static final GwtEvent.Type<RevealContentHandler<?>> TYPE_MAIN_CONTENT_SLOT = MainPresenter.CENTER_SLOT;
/**
* This will be the event sent to our "unknown" child presenters, in order for
* them to register their tabs.
*/
@RequestTabs
public static final Type<RequestTabsHandler> TYPE_Management_RequestTabs = new Type<RequestTabsHandler>();
@Inject
public ManagementTabsPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, AppPlaceManager appPlaceManager) {
super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Management_RequestTabs, TYPE_Management_ChangeTab);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, MainPresenter.WEST_SLOT, this);
}
}
public class SettingsTabsPresenter extends TabContainerPresenter<SettingsTabsPresenter.MyView, SettingsTabsPresenter.MyProxy> {
/**
* {@link SettingsTabsPresenter}'s proxy.
*/
@ProxyStandard
public interface MyProxy extends Proxy<SettingsTabsPresenter> {
}
/**
* {@link SettingsTabsPresenter}'s view.
*/
public interface MyView extends TabView {
}
/**
* Fired by child proxie's when their tab content is changed.
*/
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_Settings_ChangeTab = new Type<ChangeTabHandler>();
/**
* Use this in leaf presenters, inside their {@link #revealInParent} method.
*/
@ContentSlot
public static final GwtEvent.Type<RevealContentHandler<?>> TYPE_MAIN_CONTENT_SLOT = MainPresenter.CENTER_SLOT;
/**
* This will be the event sent to our "unknown" child presenters, in order for
* them to register their tabs.
*/
@RequestTabs
public static final Type<RequestTabsHandler> TYPE_Settings_RequestTabs = new Type<RequestTabsHandler>();
@Inject
public ManagementTabsPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, AppPlaceManager appPlaceManager) {
super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Settings_RequestTabs, TYPE_Settings_ChangeTab);
}
@Override
protected void revealInParent() {
RevealContentEvent.fire(this, MainPresenter.WEST_SLOT, this);
}
}
public class MainPresenter extends Presenter<MainPresenter.MyView, MainPresenter.MyProxy>{
@Inject VSMRequestFactory requestFactory;
@Inject VSMMessages vsmMessages;
@Inject VSMExceptionMessages vsmExceptionMessages;
@Inject EventBus eventBus;
@ProxyStandard
@NoGatekeeper
public interface MyProxy extends Proxy<MainPresenter> {
}
public interface MyView extends View {
}
@ContentSlot
public static final Type<RevealContentHandler<?>> SOUTH_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> WEST_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> CENTER_SLOT = new Type<RevealContentHandler<?>>();
@ContentSlot
public static final Type<RevealContentHandler<?>> NORTH_SLOT = new Type<RevealContentHandler<?>>();
@Inject
public MainPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy);
}
@Override
protected void revealInParent() {
RevealRootLayoutContentEvent.fire(this, this);
}
@Override
protected void onReveal() {
super.onReveal();
initializeAppUser();
}
}