2011-11-08 24 views

回答

0

那么你的NotificationMole有一个关联的ui.xml文件,所以你想应用的任何自定义样式都应该在那里应用。

+0

,我看着它,它只是宣布 “在线” 的UiBinder的文件的样式。我对CSS不太了解,但我不认为我可以根据这些名称设置样式。如果您检查NM元素,则会为每个“内嵌”样式定义样式,其中包含看起来像由GWT编译器生成的粗糙名称。使用我可以设计的风格,但是我怀疑当名称改变时,下一个GWT版本会崩溃。 –

0

这可能很简单:首先定义你自己的风格,在NotificationMole初始化之后,用你定义的类替换它的内置类,这就是我在我的项目中所做的。使用DOM来替换类或使用gwtquery,两者都可以。

1

一个肮脏的解决方案:

package com.google.gwt.user.client.ui; // important for package visibility access 

import com.google.gwt.dom.client.DivElement; 
import com.google.gwt.dom.client.SpanElement; 

public class NotificationMoleHelper { 

    protected NotificationMole notificationMole; 

    public NotificationMoleHelper(NotificationMole notificationMole) { 
     super(); 
     this.notificationMole = notificationMole; 
    } 

    public SpanElement getNotificationText() { 
     return notificationMole.notificationText; 
    } 

    public DivElement getHeightMeasure() { 
     return notificationMole.heightMeasure; 
    } 

public DivElement getBorderElement() { 
    return notificationMole.borderElement; 
} 

    /** 
    * Change heightMeasure's background color 
    * 
    * @param backgroundColor 
    */ 
    public void setBackgroundColor(String backgroundColor) { 

     getBorderElement().getStyle().setBackgroundColor(backgroundColor); 
    } 
} 

例子:

final NotificationMoleHelper notificationMoleHelper = new NotificationMoleHelper(notificationMole); 
notificationMoleHelper.setBackgroundColor("#FF1111");