我有一个CssResource,我想让一些css类"映射"到方法:
@ClassName("top-table")
String topTable();
Run Code Online (Sandbox Code Playgroud)
但我想关闭GWT的混淆(至少在开发时,为了在firebug中进行更好的调试等).
有没有一种简单的方法来实现这一目标?我知道我可以在我的css文件中使用@external然后我必须定义所有我的css类,如@external .c1,.c2,.c3等...
像@external.*这样的东西可以解决我的问题,但至少在gwt 2.0.x中似乎没有
我目前的解决方案是使用:
<set-configuration-property name="CssResource.style" value="pretty"/>
Run Code Online (Sandbox Code Playgroud)
但这并没有关闭混淆,只是让它更漂亮:)我知道obf是需要避免碰撞但我不喜欢我的情况,并真的想关闭混淆
我正在寻找一种方法来做这样的事情:
// style.css
@def borderSize '2px';
.style {
width: borderSize + 2;
height: borderSize + 2;
}
Run Code Online (Sandbox Code Playgroud)
其中width和height属性最终的值为4px.
我想在GWT CssResource中将一些颜色定义为常量,并在整个应用程序中使用这些常量; 但我不知道该怎么做.
我会告诉你我尝试了什么.我创建了一个ClientBundle和一个CssResource,如下所示:
public interface Resources extends ClientBundle {
public interface MyStyle extends CssResource {
String JUNGLEGREEN();
String example();
...
}
@Source("Resources.css")
MyStyle css();
}
Run Code Online (Sandbox Code Playgroud)
我在Resources.css中定义了一些常量:
@def JUNGLEGREEN #1F3D0A;
Run Code Online (Sandbox Code Playgroud)
在Resources.css中,我使用这样的常量:
.example { color:JUNGLEGREEN; }
Run Code Online (Sandbox Code Playgroud)
我不知道在其他CSS文件和UiBinder模板中重用这些常量的方法.我想在其他一些UiBinder文件中执行此操作,比如LoginView.ui.xml:
<ui:with field='resources' type='com.example.Resources' />
<ui:style>
.mainPanel {
background:{resources.css.JUNGLEGREEN};
...
}
</ui:style>
Run Code Online (Sandbox Code Playgroud)
...但它似乎没有编译.你知道我怎么能实现我的目标吗?
我有一个带有两个源文件夹的Eclipse GWT项目:一个用于源代码,另一个用于资源.这应该并且确实可以正常工作,但Eclipse显示以下错误消息:
缺少资源文件style.css(预期在com.example.gwt.client)
如果Resources在我的源代码源文件夹中有一个类:
package com.example.gwt.client;
import com.google.gwt.resources.client.*;
interface Resources extends ClientBundle {
@Source("style.css")
Style style();
}
Run Code Online (Sandbox Code Playgroud)
引用CSS文件位于我用于资源的源文件夹中的相同包中.
这不是一个真正的问题,因为它确实有效,但我想在任何情况下摆脱错误信息,它让我感到紧张.有任何想法吗?
我通过CssResource访问样式名称,来自UiBinder和java视图.问题是由于类名混淆,我无法找到添加和删除后缀的方法.
到目前为止,我已经使用主要和从属名称的@external anotation管理了这种情况,但我不认为这是一个很好的解决方案.
我意识到GWT使用的CSS解析器只会处理CSS2,但我的目标是iPhone Safari,所以我希望能够使用一些CSS3的东西.对于属性,我一直很好地使用literalGWT提供的功能,但我遇到了CSS3选择器的问题 - 尤其是not()伪类.
我有一点像这样的CSS:
.iMore:not (.__lod ):active {
color: #fff
}
Run Code Online (Sandbox Code Playgroud)
当GWT将此文件作为资源加载时,我得到:
遇到"(".期待其中一个:"{"","
该literal函数适用于属性,但我试过这个:
.iMore:literal("not (.__lod )"):active {
color: #fff
}
Run Code Online (Sandbox Code Playgroud)
并得到一个不同的错误信息:
遇到""不是(.__ lod):"".期待其中一个:
<IDENT>
我把literal整个块放在一边,错误消息就消失了,但是如果没有@external使用它的选择器中引用的所有内容(我在这个文件中有很多其他内容),我认为这样做不会有效.
从以下页面:开发人员指南 - CSS样式
很明显,在现代GWT应用程序中,有两种方式来声明css样式:
使用ClientBundle中包含的CssResource.在UiBinder模板中使用内联元素.
你如何使用这两种方法来覆盖GWT默认风格,如gwt-Button,gwt-TextBox等?
我知道仍然可以使用从html页面或.gwt.xml文件引用的css样式表.但是,我想避免这种情况,因为现在不推荐使用这些方法.
想象一下,您使用UiBinder创建了以下简单小部件:
<!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">
<ui:style type="my.package.Widget1.Widget1Style">
.childWidgetStyle {
border-width: 1px;
border-style: dotted;
}
</ui:style>
<g:TextArea styleName="{style.childWidgetStyle}"/>
</ui:UiBinder>
Run Code Online (Sandbox Code Playgroud)
package my.package;
// some imports here
public class Widget1 extends Composite {
private static Widget1UiBinder uiBinder = GWT.create(Widget1UiBinder.class);
interface Widget1UiBinder extends UiBinder<Widget, Widget1> {
}
public interface Widget1Style extends CssResource {
String childWidgetStyle();
}
@UiField
TextArea textArea;
public Widget1(String text) {
initWidget(uiBinder.createAndBindUi(this));
textArea.setText(text);
}
}
Run Code Online (Sandbox Code Playgroud)
在您创建的另一个(父)窗口小部件中使用此简单窗口小部件:
<!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">
<ui:style>
.parentWidgetStyle .childWidgetStyle {
margin-bottom: 10px; …Run Code Online (Sandbox Code Playgroud) 目前我有一个在gwt中使用CssResource的应用程序,就像这样......
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/two.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/main.css")
MyCssResource css();
}
Run Code Online (Sandbox Code Playgroud)
然后是CssResource接口
interface MyCssResource extends CssResource{
String someStyleThatNeverChanges();
String someStyleThatChangesDependingOnTheClient();
}
Run Code Online (Sandbox Code Playgroud)
如果我重写MyClientBundle来创建和接口名为MyPinkThemedClientBundle
interface MyClientBundle extends ClientBundle{
@Source("images/one.png")
Image someImageThatAlwaysLooksTheSame();
@Source("images/**twoPinkVersion**.png")
Image someImageThatDependingOnTheClientThemeChanges();
@Source("css/**mainPinkVersion**.css")
MyPinkCssResource css();
}
Run Code Online (Sandbox Code Playgroud)
当然,MyPinkCssResource扩展了MyCssResource
interface MyPinkCssResource extends MyCssResource{
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我尝试编译它时,GWT编译器抱怨"css/mainPinkVersion.css"缺少样式名称"someStyleThatNeverChanges".我原以为cssresource接口会继承其超类的后备css文件.如果不是这种情况,是否可以实现扩展CssResource并仅覆盖您关心的类但是否使用超类的后备.css文件的效果?
我想说,在一个集中的位置,
@def mainColor = #f00;
Run Code Online (Sandbox Code Playgroud)
然后,在我的所有其他css文件中,mainColor无需重新定义它.然后,当我在一次更改mainColor时,我的整个应用程序会改变颜色.
到目前为止,我能想到的最好方法是@Source为每个CssResource声明包含两个文件,并始终包含全局def文件.还有其他方法吗?
我想在GWT应用程序中删除注入的CSSResource.
我使用了以下代码 MyClass.INSTANCE.ensureInjected();
我只想在特定页面上使用上面的CSSResource.所以剩下的页面应该按照实际的css/theme来工作.
一旦我注入了它,那么它适用于整个应用程序.我怎么能克服这个?
帮我.
我广泛使用CssResource,现在我生成的html充满了GWXSHFKADAish类名.我得到的所有的的优点,但对于调试它会是有益的补充,会变成一个标志.selected进入GWXSTY_selected.有没有办法做到这一点?
cssresource ×12
gwt ×12
clientbundle ×5
css ×3
gwt2 ×3
uibinder ×2
css3 ×1
eclipse ×1
import ×1
java ×1
math ×1
obfuscation ×1