且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何覆盖 DataGrid 标头的 GWT 混淆样式

更新时间:2023-12-03 23:05:58

就像任何 ClientBundleCssResource 一样:创建一个扩展 Datagrid.Resources 的接口 并使用 @Source 批注覆盖 dataGridStyle 方法,该批注指向您自己的 CSS 文件(或可能同时指向原始文件和您自己的文件,因此它们将结合在一起).

Just like with any ClientBundle and CssResource: create an interface that extends Datagrid.Resources and overrides the dataGridStyle method with a @Source annotation pointing to your own CSS file (or possibly to both the original file and your own file, so they'll be combined together).

这样做将覆盖所有 DataGrid 在您的应用程序中的样式(它实际上取决于哪个 CssResource 实例获取 ensureInjected() 第一个:来自原始 DataGrid.Resources 或来自您子接口的那个):因为您使用相同的返回类型(DataGrid.Style),混淆后的类名将相同.

Doing it that way will override the style for all DataGrids in your app though (it actually depends on which CssResource instance gets ensureInjected() first: the one from the original DataGrid.Resources or the one from your sub-interface): because you use the same return type (DataGrid.Style), the obfuscated class names will be the same.

如果您想根据具体情况更改样式,则另外声明一个扩展 DataGrid.Style 的接口,并将其用作 的返回类型dataGridStyle 覆盖:因为混淆类名是基于接口完全限定名和方法名,你的 DataGrid.Style 子接口将生成与原始类不同的混淆类名DataGrid.Style 接口.

If you want to change the style on a case-by-case basis then, in addition, declare an interface that extends DataGrid.Style and use that as the return type to your dataGridStyle override: because the obfuscated class name is based on both the interface fully-qualified name and the method name, your DataGrid.Style sub-interface will generate different obfuscated class names than the original DataGrid.Style interface.

当然,GWT.create() 你的 DataGrid.Resources 子接口并将其作为参数传递给 DataGrid 构造函数.

Then of course, GWT.create() your DataGrid.Resources sub-interface and pass it as an argument to the DataGrid constructor.

另见 http://code.google.com/p/google-web-toolkit/issues/detail?id=6144