2012-07-11 54 views
0

所以問題是,我有一個CommonLayout小部件,它有自己的ui.xml。GWT ui.xml - 無法將DocklayoutPanel轉換爲自定義面板

public class MyLayout extends Composite implements IsWidget,MyLayoutIntf,AcceptsOneWidget { 

    private static MyLayoutUiBinder uiBinder = GWT.create(MyLayoutUiBinder.class); 

    private FaGuiI18nConstant faGui18Const = GWT.create(FaGuiI18nConstant.class); 

    interface MyLayoutUiBinder extends UiBinder<Widget, MyLayout>{ 
    } 

@UiField 
FaSplitLayoutPanel centerPanel; 

@UiField 
Label applnTitle; 

@UiField 
Label loggedInUser; 

@UiField 
FaButton logoutButton; 

@UiField 
FaButton homeButton; 

Presenter presenter; 

public MyLayout(){ 
    initWidget(uiBinder.createAndBindUi(this)); 
    this.logoutButton.setButtonText(faGui18Const.logout()); 
    this.logoutButton.setVisible(false); 
    this.homeButton.setButtonText(faGui18Const.home()); 
    this.homeButton.setVisible(false); 
} 



public SplitLayoutPanel getCenterPanel(){ 
    return centerPanel; 
} 

@Override 
public void setPresenter(Presenter presenter){ 
    this.presenter = presenter; 
} 

@Override 
public void setWidgetName(String widgetName){ 
    // TODO Auto-generated method stub 
} 

@Override 
public void setAppName(String appName){ 
    applnTitle.setText(appName); 

} 

@Override 
public void setUsername(String userName){ 
    loggedInUser.setText(userName); 
} 

@Override 
public void setWidget(IsWidget w){ 
    asWidgetOrNull(w); 
} 

@Override 
public FaButton getLogoutButton(){ 
    return this.logoutButton; 
} 

@Override 
public FaButton getHomeButton(){ 
    return this.homeButton; 
} 
} 

這是它的ui.xml:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> 
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
xmlns:g="urn:import:com.google.gwt.user.client.ui" 
xmlns:commonEditor="urn:import:com.amadeus.psp.fa.gui.common.client.view"> 
<ui:with 
    type="com.amadeus.psp.fa.gui.common.client.constants.FaGuiI18nConstant" 
    field="c" /> 
<ui:style field='layoutStyle' src="FACommon.css"> 

</ui:style> 

<g:DockLayoutPanel unit='PX'> 
    <g:north size='82'> 
     <g:HTMLPanel styleName="{layoutStyle.headerPanel}"> 
      <table cellspcing="0" cellpadding="0" border="0" width="100%" 
       height="100%"> 
       <tr> 
        <td class="{layoutStyle.logo}" align="center" valign="middle">&nbsp;</td> 
        <td align="center" class="{layoutStyle.applicationTitle}"> 
         <g:Label styleName="{layoutStyle.welcomeTitle}" text="{c.welcomeTitle}"></g:Label> 
         <br /> 
         <g:Label ui:field="applnTitle" styleName="{layoutStyle.applnTitle}"></g:Label> 
        </td> 
        <td align="right" valign="top" width="250" class="{layoutStyle.user}"> 
         <commonEditor:FaButton ui:field="homeButton" styleName="{layoutStyle.leftFloated}"/><commonEditor:FaButton ui:field="logoutButton" styleName="{layoutStyle.leftFloated}"/> 
         <g:Label styleName="{layoutStyle.welcomeUser}" text="{c.userWelcome}" /> 
         <g:Label ui:field="loggedInUser" styleName="{layoutStyle.loggedinUser}"></g:Label> 
        </td> 
       </tr> 
      </table> 
     </g:HTMLPanel> 
    </g:north> 
    <g:center> 

    **<commonEditor:FaSplitLayoutPanel ui:field="centerPanel" 
      styleName="{layoutStyle.westBorder} {layoutStyle.centerBorder}"/>** 

    </g:center> 
    <g:south size='5'> 
     <g:HTMLPanel styleName="{layoutStyle.footer}"> 
     </g:HTMLPanel> 
    </g:south> 
</g:DockLayoutPanel> 

而在這ui.xml我使用的延伸SplitLayout面板自定義窗口小部件。

這是我的自定義面板:

public class FaSplitLayoutPanel extends SplitLayoutPanel{ 
public FaSplitLayoutPanel(){ 
super(); 
} 

@Override 
public void onResize(){ 
    if (this.getWidgetCount() == 3){ 
    final Widget splitterWidget = this.getWidget(1); 
    if (this.getWidget(0).getOffsetWidth() >= 330){ 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeCursor()); 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeRightCursor()); 
    splitterWidget.addStyleName(FaResources.INSTANCE.css().resizeLeftCursor()); 

    } else if (this.getWidget(0).getOffsetWidth() == 0){ 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeCursor()); 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeLeftCursor()); 
    splitterWidget.addStyleName(FaResources.INSTANCE.css().resizeRightCursor()); 
    } else{ 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeLeftCursor()); 
    splitterWidget.removeStyleName(FaResources.INSTANCE.css().resizeRightCursor()); 
    splitterWidget.addStyleName(FaResources.INSTANCE.css().resizeCursor()); 

    } 
} 
} 
} 

當我運行此:它顯示了一個錯誤,指出不能施放Docklayout到FaSplitlayout並說看到生成的代碼。並在生成的代碼中找到導致Probelm的行:

com.google.gwt.user.client.ui.Label f_Label4 = (com.google.gwt.user.client.ui.Label) GWT.create(com.google.gwt.user.client.ui.Label.class); 
java.lang.String domId5 = com.google.gwt.dom.client.Document.get().createUniqueId(); 
com.google.gwt.user.client.ui.Label loggedInUser = (com.google.gwt.user.client.ui.Label) GWT.create(com.google.gwt.user.client.ui.Label.class); 
com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel2 = new com.google.gwt.user.client.ui.HTMLPanel(template.html1("" + layoutStyle.logo() + "", "" + layoutStyle.applicationTitle() + "", domId0, domId1, "" + layoutStyle.user() + "", domId2, domId3, domId4, domId5).asString()); 
***com.amadeus.psp.fa.gui.common.client.view.FaSplitLayoutPanel centerPanel = new com.google.gwt.user.client.ui.DockLayoutPanel(com.google.gwt.dom.client.Style.Unit.PX);*** 
com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel5 = new com.google.gwt.user.client.ui.HTMLPanel(template.html2().asString()); 
com.google.gwt.user.client.ui.DockLayoutPanel f_DockLayoutPanel1 = new com.google.gwt.user.client.ui.DockLayoutPanel(com.google.gwt.dom.client.Style.Unit.PX); 

這裏有什麼問題?任何人都可以請幫忙..

回答