Beispiel #1
0
  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);
  }
Beispiel #2
0
  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());
  }
Beispiel #3
0
  public IMethod createAsWidgetMethod(boolean useUiBinder) throws JavaModelException {
    SourceWriter sw = sourceWriterFactory.createForNewClassBodyComponent();

    workingCopy.createImport(C_WIDGET, null, new NullProgressMonitor());
    sw.writeLines(
        "@Override",
        "public Widget asWidget() {",
        "  return " + (useUiBinder ? "widget" : "null") + ";",
        "}");

    return createMethod(sw);
  }
Beispiel #4
0
 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);
 }