Package org.jboss.errai.ui.shared.api.annotations

Examples of org.jboss.errai.ui.shared.api.annotations.Bound


     * Bind each bound data field if data binder is found and has been initialized.
     */
    Map<String, BoundDataField> boundDataFields = DecoratorDataField.aggregateDataFieldBoundMap(ctx, ctx.getType());
    BlockBuilder<ElseBlockBuilder> binderBlock = If.isNotNull(Variable.get("binder"));
    for (Entry<String, BoundDataField> boundDataField : boundDataFields.entrySet()) {
      Bound bound = boundDataField.getValue().getBound();
      if (dataBinderRef != null) {
        String property = bound.property().equals("") ? boundDataField.getKey() : bound.property();
        // Check if bound property exists in data model type
        if (!DataBindingValidator.isValidPropertyChain(dataModelType, property)) {
          throw new GenerationException("Invalid binding of DataField " + boundDataField.getValue().getName()
              + " in class " + ctx.getInjector().getInjectedType() + "! Property " + property
              + " not resolvable from class " + dataModelType +
              ". Hint: All types in a property chain must be @Bindable!");
        }

        Statement converter =
            bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
        binderBlock.append(Stmt.loadVariable("binder")
            .invoke("bind", boundDataField.getValue().getWidgetStatement(), property, converter));
      }
      else {
        throw new GenerationException("No @AutoBound data binder found for @Bound @DataField "
View Full Code Here


                    + ctx.getInjector().getInjectedType()
                    + " has not been initialized. Either initialize or add @Inject!")).finish());
      }

      // Check if the bound property exists in data model type
      Bound bound = ctx.getAnnotation();
      String property = bound.property().equals("") ? ctx.getMemberName() : bound.property();
      if (!DataBindingValidator.isValidPropertyChain(binderLookup.getDataModelType(), property)) {
        throw new GenerationException("Invalid binding of field " + ctx.getMemberName()
            + " in class " + ctx.getInjector().getInjectedType() + "! Property " + property
            + " not resolvable from class " + binderLookup.getDataModelType()
            + "! Hint: Is " + binderLookup.getDataModelType() + " marked as @Bindable? When binding to a "
            + "property chain, all properties but the last in a chain must be of a @Bindable type!");
      }

      Statement widget = ctx.getValueStatement();
      // Ensure the @Bound field or method provides a widget or DOM element
      MetaClass widgetType = ctx.getElementTypeOrMethodReturnType();
      if (widgetType.isAssignableTo(Widget.class)) {
        // Ensure @Bound widget field is initialized
        if (!ctx.isAnnotationPresent(Inject.class) && ctx.getField() != null && widgetType.isDefaultInstantiable()) {
          Statement widgetInit = Stmt.invokeStatic(
              ctx.getInjectionContext().getProcessingContext().getBootstrapClass(),
              PrivateAccessUtil.getPrivateFieldInjectorName(ctx.getField()),
              Refs.get(ctx.getInjector().getInstanceVarName()),
              ObjectBuilder.newInstanceOf(widgetType));

          statements.add(If.isNull(widget).append(widgetInit).finish());
        }
      }
      else if (widgetType.isAssignableTo(Element.class)) {
        widget = Stmt.invokeStatic(ElementWrapperWidget.class, "getWidget", widget);
      }
      else {
        throw new GenerationException("@Bound field or method " + ctx.getMemberName()
            + " in class " + ctx.getInjector().getInjectedType()
            + " must provide a widget or DOM element type but provides: "
            + widgetType.getFullyQualifiedName());
      }

      // Generate the binding
      Statement conv = bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
      statements.add(Stmt.loadVariable("binder").invoke("bind", widget, property, conv));
    }
    else {
      throw new GenerationException("No @Model or @AutoBound data binder found for @Bound field or method "
          + ctx.getMemberName() + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

    /*
     * Bind each widget if data binder is found and has been initialized.
     */
    BlockBuilder<ElseBlockBuilder> binderBlock = If.isNotNull(Variable.get("binder"));
    for (Entry<String, Statement> dataField : dataFields.entrySet()) {
      Bound bound = DecoratorDataField.aggregateDataFieldBoundMap(ctx, ctx.getType()).get(dataField.getKey());
      if (bound != null) {
        if (dataBinderRef != null) {
          String property = bound.property().equals("") ? dataField.getKey() : bound.property();
          // Check if bound property exists in data model type
          if (!dataModelType.getBeanDescriptor().getProperties().contains(property)) {
            throw new GenerationException("Invalid binding of DataField " + dataField.getKey() + " in class "
                + ctx.getInjector().getInjectedType() + "! Property with name " + property + " not found in class "
                + dataModelType);
          }

          Statement converter =
              bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
          binderBlock.append(Stmt.loadVariable("binder").invoke("bind", dataField.getValue(), property, converter));
        }
        else {
          throw new GenerationException("No @AutoBound data binder found for @Bound @DataField " + dataField.getKey()
              + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

    /*
     * Bind each widget if data binder is found and has been initialized.
     */
    BlockBuilder<ElseBlockBuilder> binderBlock = If.isNotNull(Variable.get("binder"));
    for (Entry<String, Statement> dataField : dataFields.entrySet()) {
      Bound bound = DecoratorDataField.aggregateDataFieldBoundMap(ctx, ctx.getType()).get(dataField.getKey());
      if (bound != null) {
        if (dataBinderRef != null) {
          String property = bound.property().equals("") ? dataField.getKey() : bound.property();
          // Check if bound property exists in data model type
          if (!dataModelType.getBeanDescriptor().getProperties().contains(property)) {
            throw new GenerationException("Invalid binding of DataField " + dataField.getKey() + " in class "
                + ctx.getInjector().getInjectedType() + "! Property with name " + property + " not found in class "
                + dataModelType);
          }

          Statement converter =
              bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
          binderBlock.append(Stmt.loadVariable("binder").invoke("bind", dataField.getValue(), property, converter));
        }
        else {
          throw new GenerationException("No @AutoBound data binder found for @Bound @DataField " + dataField.getKey()
              + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

    /*
     * Bind each widget if data binder is found and has been initialized.
     */
    BlockBuilder<ElseBlockBuilder> binderBlock = If.isNotNull(Variable.get("binder"));
    for (Entry<String, Statement> dataField : dataFields.entrySet()) {
      Bound bound = DecoratorDataField.aggregateDataFieldBoundMap(ctx, ctx.getType()).get(dataField.getKey());
      if (bound != null) {
        if (dataBinderRef != null) {
          String property = bound.property().equals("") ? dataField.getKey() : bound.property();
          // Check if bound property exists in data model type
          if (!DataBindingValidator.isValidPropertyChain(dataModelType, property)) {
            throw new GenerationException("Invalid binding of DataField " + dataField.getKey() + " in class "
                + ctx.getInjector().getInjectedType() + "! Property " + property + " not resolvable from class "
                + dataModelType + ". Hint: All types in a property chain must be @Bindable!");
          }

          Statement converter =
              bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
          binderBlock.append(Stmt.loadVariable("binder").invoke("bind", dataField.getValue(), property, converter));
        }
        else {
          throw new GenerationException("No @AutoBound data binder found for @Bound @DataField " + dataField.getKey()
              + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

                    + ctx.getInjector().getInjectedType()
                    + " has not been initialized. Either initialize or add @Inject!")).finish());
      }

      // Check if the bound property exists in data model type
      Bound bound = ctx.getAnnotation();
      String property = bound.property().equals("") ? ctx.getMemberName() : bound.property();
      if (!DataBindingValidator.isValidPropertyChain(binderLookup.getDataModelType(), property)) {
        throw new GenerationException("Invalid binding of field " + ctx.getMemberName()
            + " in class " + ctx.getInjector().getInjectedType() + "! Property " + property
            + " not resolvable from class " + binderLookup.getDataModelType() +
            ". Hint: All types in a property chain must be @Bindable!");
      }

      Statement widget = ctx.getValueStatement();
      // Ensure the @Bound field or method provides a widget or DOM element
      MetaClass widgetType = ctx.getElementTypeOrMethodReturnType();
      if (widgetType.isAssignableTo(Widget.class)) {
        // Ensure @Bound widget field is initialized
        if (!ctx.isAnnotationPresent(Inject.class) && ctx.getField() != null && widgetType.isDefaultInstantiable()) {
          Statement widgetInit = Stmt.invokeStatic(
              ctx.getInjectionContext().getProcessingContext().getBootstrapClass(),
              PrivateAccessUtil.getPrivateFieldInjectorName(ctx.getField()),
              Refs.get(ctx.getInjector().getInstanceVarName()),
              ObjectBuilder.newInstanceOf(widgetType));

          statements.add(If.isNull(widget).append(widgetInit).finish());
        }
      }
      else if (widgetType.isAssignableTo(Element.class)) {
        widget = Stmt.invokeStatic(ElementWrapperWidget.class, "getWidget", widget);
      }
      else {
        throw new GenerationException("@Bound field or method " + ctx.getMemberName()
            + " in class " + ctx.getInjector().getInjectedType()
            + " must provide a widget or DOM element type but provides: "
            + widgetType.getFullyQualifiedName());
      }

      // Generate the binding
      Statement conv = bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
      statements.add(Stmt.loadVariable("binder").invoke("bind", widget, property, conv));
    }
    else {
      throw new GenerationException("No @Model or @AutoBound data binder found for @Bound field or method "
          + ctx.getMemberName() + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

    /*
     * Bind each widget if data binder is found and has been initialized.
     */
    BlockBuilder<ElseBlockBuilder> binderBlock = If.isNotNull(Variable.get("binder"));
    for (Entry<String, Statement> dataField : dataFields.entrySet()) {
      Bound bound = DecoratorDataField.aggregateDataFieldBoundMap(ctx, ctx.getType()).get(dataField.getKey());
      if (bound != null) {
        if (dataBinderRef != null) {
          String property = bound.property().equals("") ? dataField.getKey() : bound.property();
          // Check if bound property exists in data model type
          if (!DataBindingValidator.isValidPropertyChain(dataModelType, property)) {
            throw new GenerationException("Invalid binding of DataField " + dataField.getKey() + " in class "
                + ctx.getInjector().getInjectedType() + "! Property " + property + " not resolvable from class "
                + dataModelType + ". Hint: All types in a property chain must be @Bindable!");
          }

          Statement converter =
              bound.converter().equals(Bound.NO_CONVERTER.class) ? null : Stmt.newObject(bound.converter());
          binderBlock.append(Stmt.loadVariable("binder").invoke("bind", dataField.getValue(), property, converter));
        }
        else {
          throw new GenerationException("No @AutoBound data binder found for @Bound @DataField " + dataField.getKey()
              + " in class " + ctx.getInjector().getInjectedType());
View Full Code Here

TOP

Related Classes of org.jboss.errai.ui.shared.api.annotations.Bound

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.