0

我使用 MVP,并且我有用于移动和桌面的通用视图界面。然后我为移动设备和桌面实现一次视图界面。我使用延迟绑定将接口替换为类的实际实现。视图在 ClientFactory 中实例化。

如何进行代码拆分,以便移动设备的所有视图都包含在一个文件中,而桌面的所有视图都包含在另一个文件中?

4

1 回答 1

0

这是 gwt.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='apllo'>
    <inherits name='com.google.gwt.user.User'/>
    <inherits name='com.google.gwt.user.theme.clean.Clean'/>
    <inherits name="com.google.gwt.resources.Resources" />
    <inherits name="com.google.gwt.user.Debug"/>
    <inherits name="com.google.gwt.activity.Activity"/>
    <inherits name="com.google.gwt.place.Place"/>
    <inherits name="com.google.gwt.http.HTTP"/>
    <inherits name="com.google.gwt.i18n.I18N"/>
    <inherits name="com.google.gwt.visualization.Visualization"/>

    <inherits name='com.apllo.client.FormFactor'/>

    <entry-point class='com.apllo.client.Apllo'/>


    <!-- Specify the paths for translatable code                    -->
    <source path='client'/>
    <source path='shared'/>
    <!-- Specify public paths -->
    <public path="files"/>

    <!-- Use ClientFactoryImpl by default -->
    <replace-with class="com.apllo.client.factory.ClientFactoryImpl"> 
        <when-type-is class="com.apllo.client.factory.ClientFactory"/>
    </replace-with>

    <!-- Use ClientFactoryImplMobile for mobile form factor. -->
    <replace-with class="com.apllo.client.factory.ClientFactoryMobileImpl">
      <when-type-is class="com.apllo.client.factory.ClientFactory"/>
      <when-property-is name="formfactor" value="mobile"/>
    </replace-with>

    <!-- 1.Use HeaderViewImpl by default -->
    <replace-with class="com.apllo.client.view.computer.HeaderViewImpl"> 
        <when-type-is class="com.apllo.client.view.HeaderView"/>
    </replace-with>
    <replace-with class="com.apllo.client.view.mobile.HeaderMobileViewImpl"> 
        <when-type-is class="com.apllo.client.view.HeaderView"/>
        <when-property-is name="formfactor" value="mobile"/>
    </replace-with>
    <!-- 2 -->
    <replace-with class="com.apllo.client.view.computer.StatusViewImpl"> 
        <when-type-is class="com.apllo.client.view.StatusView"/>
    </replace-with>
    <replace-with class="com.apllo.client.view.mobile.StatusMobileViewImpl"> 
        <when-type-is class="com.apllo.client.view.StatusView"/>
        <when-property-is name="formfactor" value="mobile"/>
    </replace-with>
    <!-- 3 -->
    <replace-with class="com.apllo.client.view.computer.PublicViewImpl"> 
        <when-type-is class="com.apllo.client.view.PublicView"/>
    </replace-with>
    <replace-with class="com.apllo.client.view.mobile.PublicMobileViewImpl"> 
        <when-type-is class="com.apllo.client.view.PublicView"/>
        <when-property-is name="formfactor" value="mobile"/>
    </replace-with>

    <!-- 4 -->
    <replace-with class="com.apllo.client.view.computer.MessageViewImpl"> 
        <when-type-is class="com.apllo.client.view.MessageView"/>
    </replace-with>
    <replace-with class="com.apllo.client.view.mobile.MessageMobileViewImpl"> 
        <when-type-is class="com.apllo.client.view.MessageView"/>
        <when-property-is name="formfactor" value="mobile"/>
    </replace-with>     

    <!-- 5 -->
    <replace-with class="com.apllo.client.view.computer.ContactsViewImpl"> 
        <when-type-is class="com.apllo.client.view.ContactsView"/>
    </replace-with>


    <!-- 6 -->
    <replace-with class="com.apllo.client.view.computer.AdvertisementViewImpl"> 
        <when-type-is class="com.apllo.client.view.AdvertisementView"/>
    </replace-with>


    <!-- 7 -->
    <replace-with class="com.apllo.client.view.computer.NewEditAdViewImpl"> 
        <when-type-is class="com.apllo.client.view.NewEditAdView"/>
    </replace-with>


    <!-- 8 -->
    <replace-with class="com.apllo.client.view.computer.AccountViewImpl"> 
        <when-type-is class="com.apllo.client.view.AccountView"/>
    </replace-with>
    <replace-with class="com.apllo.client.view.mobile.AccountMobileViewImpl"> 
        <when-type-is class="com.apllo.client.view.AccountView"/>
        <when-property-is name="formfactor" value="mobile"/>
    </replace-with> 


    <!-- 9 -->
    <replace-with class="com.apllo.client.view.computer.UtilityViewImpl"> 
        <when-type-is class="com.apllo.client.view.UtilityView"/>
    </replace-with>

</module>
于 2013-05-02T03:36:46.890 回答