public IMethod createConstructor(boolean useUiBinder) throws JavaModelException { SourceWriter sw = sourceWriterFactory.createForNewClassBodyComponent(); String parameters = ""; if (isPopupView) { workingCopy.createImport(C_EVENT_BUS, null, new NullProgressMonitor()); parameters += "final EventBus eventBus"; if (useUiBinder) { parameters += ", "; } } if (useUiBinder) { parameters += "final Binder binder"; } workingCopy.createImport(A_INJECT, null, new NullProgressMonitor()); sw.writeLines( "@Inject", "public " + workingCopyType.getElementName() + "(" + parameters + ") {"); if (isPopupView) { sw.writeLine(" super(eventBus);"); } if (useUiBinder) { sw.writeLine(" widget = binder.createAndBindUi(this);"); } sw.writeLine("}"); return createMethod(sw); }
public IType createBinderInterface() throws JavaModelException { workingCopy.createImport(I_UI_BINDER, null, new NullProgressMonitor()); SourceWriter sw = sourceWriterFactory.createForNewClassBodyComponent(); sw.writeLine( "public interface Binder extends UiBinder<Widget, " + workingCopyType.getElementName() + "> { }"); return workingCopyType.createType(sw.toString(), null, false, new NullProgressMonitor()); }
public IField createWidgetField() throws JavaModelException { workingCopy.createImport(C_WIDGET, null, new NullProgressMonitor()); SourceWriter sw = sourceWriterFactory.createForNewClassBodyComponent(); sw.writeLine("private final Widget widget;"); return createField(sw); }