GWT CellTable 样式

GWT CellTable Styling

我喜欢为我的手机定制设计Table。出于这个原因,我在 Whosebug 和一些教程中尝试了很多建议的方法。它对我不起作用,我不知道为什么。欢迎任何提示。

使用 GWT 2.8.1。

Log/Error:

    Creating assignment for cellTableStyle()
                 Creating image sprite classes
                 Replacing property-based @if blocks
                 Replacing CSS class names
                    [ERROR] The following unobfuscated classes were present in a strict CssResource:
                       [ERROR] gwt-cellTableHoveredRow
                       [ERROR] gwt-cellTableSelectedRowCell
                       [ERROR] gwt-cellTableKeyboardSelectedCell
                       [ERROR] gwt-cellTableLastColumnHeader
                       [ERROR] gwt-cellTable
                       [ERROR] gwt-cellTableKeyboardSelectedRow
                       [ERROR] gwt-cellTableHoveredRowCell
                       [ERROR] gwt-cellTableFirstColumnHeader
                       [ERROR] gwt-cellTableKeyboardSelectedRowCell
                       [ERROR] gwt-cellTableCell
                       [ERROR] gwt-cellTableHeader
                       [ERROR] gwt-cellTableSelectedRow
                       [ERROR] gwt-cellTableOddRow
                       [ERROR] gwt-cellTableEvenRow
                       Fix by adding String accessor method(s) to the CssResource interface for obfuscated classes, or using an @external declaration for unobfuscated classes.
              [ERROR] Generator 'com.google.gwt.resources.rebind.context.InlineClientBundleGenerator' threw an exception while rebinding 'de.testProject.modules.gui.controls.table.MyCellTableResources'
     com.google.gwt.resources.css.ast.CssCompilerException: Missing a CSS replacement
        at com.google.gwt.resources.css.ClassRenamer.endVisit(ClassRenamer.java:209)
        at com.google.gwt.resources.css.ast.CssStylesheet.traverse(CssStylesheet.java:59)
        at com.google.gwt.resources.css.ast.CssVisitor.doTraverse(CssVisitor.java:325)
        at com.google.gwt.resources.css.ast.CssVisitor.doAccept(CssVisitor.java:313)
        at com.google.gwt.resources.css.ast.CssVisitor.accept(CssVisitor.java:59)
        at com.google.gwt.resources.rg.CssResourceGenerator.optimize(CssResourceGenerator.java:1093)
        at com.google.gwt.resources.rg.CssResourceGenerator.createAssignment(CssResourceGenerator.java:452)
        at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.createFieldsAndAssignments(AbstractClientBundleGenerator.java:752)
        at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.createFieldsAndAssignments(AbstractClientBundleGenerator.java:821)
        at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.generateIncrementally(AbstractClientBundleGenerator.java:469)
        at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:739)
        at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:103)
        at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
        at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:262)
        at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:251)
        at com.google.gwt.dev.PrecompilationContextCreator.getAllPossibleRebindAnswers(PrecompilationContextCreator.java:86)
        at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createStaticRebindExpression(UnifyAst.java:519)
        at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createRebindExpression(UnifyAst.java:487)
        at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.maybeHandleMagicMethodCall(UnifyAst.java:415)
        at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.visit(UnifyAst.java:402)
        at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:265)
        at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
        at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
        at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
         at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:76)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
         at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:76)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.acceptImmutable(JModVisitor.java:305)
         at com.google.gwt.dev.jjs.ast.JMethodCall.visitChildren(JMethodCall.java:275)
         at com.google.gwt.dev.jjs.ast.JNewInstance.traverse(JNewInstance.java:74)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
         at com.google.gwt.dev.jjs.ast.JBinaryOperation.traverse(JBinaryOperation.java:89)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:118)
         at com.google.gwt.dev.jjs.ast.JExpressionStatement.traverse(JExpressionStatement.java:42)
         at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:88)
         at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:331)
         at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:94)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:139)
         at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:135)
         at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:786)
         at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:778)
         at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
         at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
         at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:1401)
         at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:896)
         at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.unifyJavaAst(JavaToJavaScriptCompiler.java:1410)
         at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.constructJavaAst(JavaToJavaScriptCompiler.java:1222)
         at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:1140)
         at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:255)
         at com.google.gwt.dev.Precompile.precompile(Precompile.java:255)
         at com.google.gwt.dev.Precompile.precompile(Precompile.java:202)
         at com.google.gwt.dev.Precompile.precompile(Precompile.java:143)
         at com.google.gwt.dev.Compiler.compile(Compiler.java:204)
         at com.google.gwt.dev.codeserver.Recompiler.doCompile(Recompiler.java:362)
         at com.google.gwt.dev.codeserver.Recompiler.compile(Recompiler.java:175)
         at com.google.gwt.dev.codeserver.Recompiler.recompile(Recompiler.java:134)
         at com.google.gwt.dev.codeserver.Outbox.recompile(Outbox.java:135)
         at com.google.gwt.dev.codeserver.JobRunner.recompile(JobRunner.java:113)
         at com.google.gwt.dev.codeserver.JobRunner.access[=10=]0(JobRunner.java:37)
         at com.google.gwt.dev.codeserver.JobRunner.run(JobRunner.java:90)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
         at java.util.concurrent.FutureTask.run(FutureTask.java:262)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
         at java.lang.Thread.run(Thread.java:745)
     [ERROR] Errors in 'de/testproject/apps/gwt/javaviewer/client/app/testTable/TableTest.java'
        [ERROR] Line 47: Failed to resolve 'de.testProject.modules.gui.controls.table.MyCellTableResources' via deferred binding

代码:

 public interface MyCellTableResources extends CellTable.Resources {

     @Source({CellTable.Style.DEFAULT_CSS, "resources/gwtcelltable.css" })
     public CellTable.Style cellTableStyle();
 }

这就是我创建 table 的方式:

 table = new CellTable<Contact>(10, (CellTable.Resources)GWT.create(MyCellTableResources.class));

css 中的 CellTable 中没有 CSS 类,所有错误都消失了,但我无法设置我的 Table

CSS 文件看起来:

.gwt-cellTable {
    color: #00ff00;
    background-color: #ff00ff;
}

.gwt-cellTableHeader {
    color: #00ff00;
    background-color: #ff00ff;
}
.gwt-cellTableFirstColumnHeader {
    color: #15ffdd;
}
.gwt-cellTableLastColumnHeader {
    color: #15ffdd;
}
.gwt-cellTableCell {
    color: #15ffdd;
}
.gwt-cellTableEvenRow {
    background: #5500FF;
}
.gwt-cellTableOddRow {
    background: #FF0055;
}
.gwt-cellTableSelectedRow {
    background: #aaaa00;
}
.gwt-cellTableSelectedRowCell {
    background: #aaaa00;
    color: #15ffdd;
}
.gwt-cellTableHoveredRow {
    background: #ff12ff;
}
.gwt-cellTableHoveredRowCell {
    background-color: #15ffdd;
}
.gwt-cellTableKeyboardSelectedRow {
    background: #15ffdd;
}
.gwt-cellTableKeyboardSelectedRowCell {
    color: #15ffdd;
}
.gwt-cellTableKeyboardSelectedCell {
    color: #15ffdd;
}

我做错了什么?我需要包含更多内容吗?

您只需删除每个 class 名称的 gwt- 前缀。

还有一个问题:没有cellTable class(你文件中的第一个)。也许您的意思是 cellTableWidget 应用于 <table> 元素:

.cellTableWidget {
    color: #00ff00;
    background-color: #ff00ff;
}
.cellTableHeader {
    color: #00ff00;
    background-color: #ff00ff;
}
...