Friday, May 28, 2010

 

GWT event template

Just created this, and thought it worth preserving (not sure about lifespan of: http://pastie.org/981696):

public class ${argType}Event extends GwtEvent<${argType}Event.${argType}EventHandler> {

public interface ${argType}EventHandler extends EventHandler {
void on${argType}(${argType}Event ${argType});
}

public static final Type<${argType}EventHandler> TYPE = new Type<${argType}EventHandler>();
private final String reason;

public ${argType}Event(String reason) {
this.reason = reason;
}

@Override
protected void dispatch(${argType}EventHandler handler) {
handler.on${argType}(this);
}

@Override
public com.google.gwt.event.shared.GwtEvent.Type<${argType}EventHandler> getAssociatedType() {
return TYPE;
}

public String getReason() {
return reason;
}

public String toString() {
return "${argType}Event:"+reason+":"+super.toString();
}

}


GWT events are key to building a maintainable GUI I think, but it's a pain to cut'n'paste code for it.

Labels: , ,


Comments:
Very good codes for anyone who needs some indications!
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?