GWT ui.xml - 无法将DocklayoutPanel转换为自定义面板

时间:2012-07-11 13:32:27

标签: gwt uibinder

所以问题是,我有一个CommonLayout小部件,它有自己的ui.xml。

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

这可能是什么问题?任何人都可以帮忙..

1 个答案:

答案 0 :(得分:1)

这是GWT中的一个错误。它应该在最近发布的2.5.0-rc1中修复。 见http://code.google.com/p/google-web-toolkit/issues/detail?id=4342

相关问题