使用UiBinder将自定义样式设置为GWT CellBrowser

使用UiBinder将自定义样式设置为GWT CellBrowser,gwt,uibinder,cellbrowser,Gwt,Uibinder,Cellbrowser,我试图使用UiBinder为GWT CellBrowser小部件设置自定义样式,但我无法更改任何相关样式(即,我可以为整个小部件设置不同的背景颜色,但我不知道如何更改所选项目的样式) 我试着在论坛中为其他小部件(例如或)使用“@external”,但没有任何效果,我想这是因为CellBrowser中指定样式的方式 我认为我应该采取的方法应该更类似于。使其代码适应CellBrowser而不是我使用的CellTable: @UiField(提供=true)手机浏览器手机浏览器; 接口CellBro

我试图使用UiBinder为GWT CellBrowser小部件设置自定义样式,但我无法更改任何相关样式(即,我可以为整个小部件设置不同的背景颜色,但我不知道如何更改所选项目的样式)

我试着在论坛中为其他小部件(例如或)使用“@external”,但没有任何效果,我想这是因为CellBrowser中指定样式的方式

我认为我应该采取的方法应该更类似于。使其代码适应CellBrowser而不是我使用的CellTable:

@UiField(提供=true)手机浏览器手机浏览器;
接口CellBrowserCompanyUiBinder扩展UiBinder{}
公共手机浏览器公司(){
TreeViewModel tvm=新的TreeViewModelLimpl();
CellBrowser.Resources reso=GWT.create(CellBrowsRes.class);
cellbrowser=新的cellbrowser(tvm、null、reso);
cellbrowser.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
initWidget(uiBinder.createAndBindUi(this));
}
公共界面CellBrowser扩展了CellBrowser.Resources{
@Source({CellBrowser.Style.DEFAULT_CSS,“path/to/CSS.CSS”})
BrowserStyle单元格BrowserStyle();
接口浏览器样式扩展了CellBrowser.Style{}
}
我使用来自的CSS文件作为参考

在ui.xml文件中,在标记中:


如果我不使用“CellBrosRes”,代码可以正常工作。因此,如果我将创建CellBrowser的行替换为以下行,它就会起作用:

CellBrowser=newcellbrowser(tvm,null);
如果我使用“CellBrosRes”,它只会忽略我的风格。我认为问题在于我创建样式资源的方式

任何关于如何使这项工作的帮助都将不胜感激。如果你需要更多的细节或者有些事情不够清楚,请告诉我


谢谢

经过一番努力,我决定为它创建自己的小部件。它肯定可以改进,我很想听到建议,但到目前为止,我正在使用它

这是结构:CellBrowser>CellPanel[]>Cell[]

  • CellBrowser小部件使用单元格数组初始化

  • 这些单元放置在第一个单元面板上。每一个你想要的细胞 可以设置要在其上显示的小部件和将显示的CellPanel 控制它的孩子


由于整个过程使用了几个文件,我已将代码上传为

,您可以扩展CellBrowser并更改默认css

public class CustomCellBrowser extends CellBrowser {

/**
 * The resources applied to the table.
 */
interface CellResources extends CellBrowser.Resources {
    @Source({CellBrowser.Style.DEFAULT_CSS, "CustomCellBrowser.css"})
    CellBrowser.Style cellBrowserStyle();
}

public <T> CustomCellBrowser(TreeViewModel viewModel, T rootValue) {
    super(viewModel, rootValue, (CellBrowser.Resources) GWT.create(CellResources.class));
}
公共类CustomCellBrowser扩展了CellBrowser{
/**
*应用于表的资源。
*/
接口CellResources扩展了CellBrowser.Resources{
@源({CellBrowser.Style.DEFAULT_CSS,“CustomCellBrowser.CSS”})
CellBrowser.Style cellBrowserStyle();
}
公共CustomCellBrowser(TreeViewModel视图模型,T根值){
super(viewModel,rootValue,(CellBrowser.Resources)GWT.create(CellResources.class));
}
}

希望这有帮助