嵌套选项卡gwtp

时间:2012-07-05 12:29:17

标签: google-app-engine gwt

我前几天发布了一个问题并没有得到太多回应。我尝试过一些东西,但仍然没有运气。我正在尝试在GWTP中嵌套制表符。我有一个框架(北)是选项卡组1和一个框架(西),它是选项卡组2.当我与组1交互时,我更新了控制组2的嵌套选项卡显示器。我已经查看了嵌套选项卡的示例主持人,但我无法从中确定我的错误。

两个TabContainerPresenters是ManagementTabsPresenter和SettingsTabsPresenter。这些孩子就像下面的HomePresenter。这些子项的内容显示在MainPreseter中的DockLayoutPanel的中心。我希望ManagementTabsPresenter和SettingsTabsPresenter显示在同一个DockLayoutPanel的West插槽中。

当我运行此代码时,所有内容都放在屏幕上的正确位置。您甚至可以单击选项卡并执行操作。问题始于首先显示SettingsPresenter,即使默认页面是HomePresenter。这就像它试图在启动的同时揭示两者。然后,当您选择属于​​ManagementTabsPresenter或SettingsTabsPresenter的任何选项卡时,它会在MainPresenter.Center_Slot中打开正确的内容,但MainPresenter.West_Slot中会显示不正确的演示者。我无法弄清楚这里出了什么问题。任何帮助,将不胜感激。

以下是代码:

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("home", 0);
}

@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 NonLeafTabContentProxy<ManagementTabsPresenter> {
}

/**
 * {@link ManagementTabsPresenter}'s view.
 */
public interface MyView extends TabView {
}

/**
 * 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>();

@TabInfo(container = HeaderTabsPresenter.class, nameToken = NameTokens.homePage)
static TabData getTabLabel(MainAppGinjector injector) {
    return new TabDataBasic("Management", 0);
}

@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);
}


@Override
protected void revealInParent() {
    RevealContentEvent.fire(this,  HeaderTabsPresenter.TYPE_VERTICAL_TABS_SLOT, this);
}
}



public class SettingsTabsPresenter extends TabContainerPresenter<SettingsTabsPresenter.MyView, SettingsTabsPresenter.MyProxy> {

/**
 * {@link SettingsTabsPresenter}'s proxy.
 */
@ProxyStandard
public interface MyProxy extends NonLeafTabContentProxy<SettingsTabsPresenter> {
}

/**
 * {@link SettingsTabsPresenter}'s view.
 */
public interface MyView extends TabView {
}

@TabInfo(container = HeaderTabsPresenter.class, nameToken = NameTokens.appUserCollectionPage)
static TabData getTabLabel(MainAppGinjector injector) {
    return new TabDataBasic("Settings", 1);
}

/**
 * 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 SettingsTabsPresenter(final EventBus eventBus, final MyView view,
                               final MyProxy proxy,  AppPlaceManager appPlaceManager) {
    super(eventBus, view, proxy,TYPE_MAIN_CONTENT_SLOT, TYPE_Settings_RequestTabs);
}


@Override
protected void revealInParent() {
    RevealContentEvent.fire(this,  HeaderTabsPresenter.TYPE_VERTICAL_TABS_SLOT, this);
}
}


public class HeaderTabsPresenter extends TabContainerPresenter<HeaderTabsPresenter.MyView, HeaderTabsPresenter.MyProxy> {
@Inject EventBus eventBus;

/**
 * {@link HeaderTabsPresenter}'s proxy.
 */
@ProxyStandard
public interface MyProxy extends Proxy<HeaderTabsPresenter> {
}

/**
 * {@link HeaderTabsPresenter}'s view.
 */
public interface MyView extends TabView {
    void changeTab(Tab tab, TabData tabData, String historyToken);
}

/**
 * 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_HEADER_RequestTabs = new Type<RequestTabsHandler>();

/**
 * Fired by child proxie's when their tab content is changed.
 */
@ChangeTab
public static final Type<ChangeTabHandler> TYPE_HEADER_ChangeTab = new Type<ChangeTabHandler>();

@ContentSlot
public static final Type<RevealContentHandler<?>> TYPE_VERTICAL_TABS_SLOT = MainPresenter.WEST_SLOT;

@Inject
public HeaderTabsPresenter(final EventBus eventBus, final MyView view,
                           final MyProxy proxy) {
    super(eventBus, view, proxy, TYPE_VERTICAL_TABS_SLOT, TYPE_HEADER_RequestTabs, TYPE_HEADER_ChangeTab);
}


@Override
protected void revealInParent() {
     RevealContentEvent.fire(this, MainPresenter.NORTH_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();
}

}

1 个答案:

答案 0 :(得分:0)

我偶然发现了类似的东西...我认为这是因为它们都继承自TabContainerPresenter并且gwtp中存在一个错误,它在错误的继承子上调用onReveal()。

看看这个gwtp论坛帖子: https://groups.google.com/forum/?fromgroups#!searchin/gwt-platform/gilad$20egozi/gwt-platform/p0s3BlN-ceE/5EL3nynaiu4J

是这样的吗?如果是这样,我认为没有人在gwtp问题跟踪器上提交错误,所以请告诉我。

(当然,最好的检查不是继承并查看其是否有效)