|
GuitGen
Guit generators
InstallDownload guit-gen-version.jar and add it to your project as described in the following link: http://www.eclipse.org/jdt/apt/introToAPT.html @GwtPresenter, @GwtController and @GwtWidgetGwtPresenter is what you know as uiBinder, a java class and a ui.xml file. GwtController is just a java class with access to the placeManager, the eventBus and all guit bindings. GwtWidget is a GwtPresenter that you can use directly on a uiBinder xml. @GwtPresenter
public class Login extends LoginPresenter { // --> LoginPresenter is a generated class from {className}Presenter
}This presenter empty as it is already works! just add a Login.ui.xml file. @GuitServiceThis one is explained in CommandService. @GwtEventThe easiest way to declare an event! @GwtEvent(EventKind.DOM)
public class FinishLoading {
int width;
int height;
}This is what gets generated: package com.google.gwt.event.dom.client;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.dom.client.FinishLoadingEvent.FinishLoadingHandler;
public class FinishLoadingEvent extends GwtEvent<FinishLoadingHandler> {
private final int height;
public int getHeight() {
return height;
}
private final int width;
public int getWidth() {
return width;
}
public static interface FinishLoadingHandler extends EventHandler {
void onFinishLoading(FinishLoadingEvent event);
}
public final static Type<FinishLoadingHandler> TYPE = new Type<FinishLoadingHandler>();
public FinishLoadingEvent(int height, int width) {
this.height = height;this.width = width;
}
@Override
protected void dispatch(FinishLoadingHandler handler) {
handler.onFinishLoading(this);
}
@Override
public Type<FinishLoadingHandler> getAssociatedType() {
return TYPE;
}
}
The event kind tells the generator where to put the event:
@GwtI18nDealing with UiBinder i18n properties files is kind of a nightmare? not anymore!! Annotate your presenters with this annotation and specify your locales: @GwtI18n({"en", "es"})
@GwtPresenter
public class Login extends LoginPresenter {
....
}Login.ui.xml <ui:msg key="text1">Hello</ui:msg> <ui:msg key="text2">World!</ui:msg> Login_es.properties text1 = Hola text2 = Mundo! Login_en.properties text1 = Hello text2 = World! Thats it! Guit's generator will move this files to the right location and set the correct name. IMPORTANT! when you edit the properties files you need to go to the presenter class, edit it and save, to force the generators to process the locales. | |