de.knightsoftnet.gwtp.spring.annotation.processor.BackofficeModuleCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwtp-spring-integration-client Show documentation
Show all versions of gwtp-spring-integration-client Show documentation
Basics to bring GWTP and Spring together.
package de.knightsoftnet.gwtp.spring.annotation.processor;
import de.knightsoftnet.gwtp.spring.client.annotation.BackofficeClientGenerator;
import java.io.PrintWriter;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
/**
* Create gwtp module class.
*/
public class BackofficeModuleCreator extends AbstractBackofficeCreator {
protected static final String CLASS_SUFFIX = "Module";
public BackofficeModuleCreator() {
super(CLASS_SUFFIX);
}
@Override
protected void addAdditionalImports(final String serverPackage, final Element element,
final BackofficeClientGenerator annotationInterface,
final ProcessingEnvironment processingEnv) {
addImports(//
"com.gwtplatform.mvp.client.gin.AbstractPresenterModule", //
"javax.inject.Singleton");
final String entityName = getEntityNameOfElement(element);
addImport(
serverPackage + "." + entityName + BackofficePresenterCreator.CLASS_SUFFIX + ".MyProxy");
addImport(
serverPackage + "." + entityName + BackofficePresenterCreator.CLASS_SUFFIX + ".MyView");
addImport(serverPackage + "." + entityName + CLASS_SUFFIX_VIEW + ".Driver");
}
@Override
protected void writeBody(final PrintWriter out, final String serverPackage, final Element element,
final BackofficeClientGenerator annotationInterface,
final ProcessingEnvironment processingEnv) {
final String entityName = getEntityNameOfElement(element);
out.print("public class ");
out.print(entityName);
out.print(suffix);
out.println(" extends AbstractPresenterModule {");
out.println();
out.println(" @Override");
out.println(" protected void configure() {");
out.print(" bindPresenter(");
out.print(entityName);
out.print(BackofficePresenterCreator.CLASS_SUFFIX);
out.print(".class, MyView.class, ");
out.print(entityName);
out.print(CLASS_SUFFIX_VIEW);
out.println(".class, MyProxy.class);");
out.print(" bind(Driver.class).to(");
out.print(entityName);
out.print(CLASS_SUFFIX_VIEW);
out.println("_Driver_Impl.class).in(Singleton.class);");
out.println(" }");
out.println("}");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy