Пример #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);
  }
Пример #2
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);
  }