Search in sources :

Example 11 with MutableEmbeddedComponentModel

use of org.apache.tapestry5.model.MutableEmbeddedComponentModel in project tapestry-5 by apache.

the class ComponentWorker method addMixinClasses.

private void addMixinClasses(PlasticField field, MutableEmbeddedComponentModel model) {
    MixinClasses annotation = field.getAnnotation(MixinClasses.class);
    if (annotation == null)
        return;
    boolean orderEmpty = annotation.order().length == 0;
    if (!orderEmpty && annotation.order().length != annotation.value().length)
        throw new TapestryException(String.format("%d mixins defined via @MixinClasses on field '%s', but %d ordering constraints \\\n" + " specified (expected 0 or %1$d).", annotation.value().length, field.getName(), annotation.order().length), model, null);
    for (int i = 0; i < annotation.value().length; i++) {
        String[] constraints = orderEmpty ? CommonsUtils.EMPTY_STRING_ARRAY : TapestryInternalUtils.splitMixinConstraints(annotation.order()[i]);
        model.addMixin(annotation.value()[i].getName(), constraints);
    }
}
Also used : MixinClasses(org.apache.tapestry5.annotations.MixinClasses) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 12 with MutableEmbeddedComponentModel

use of org.apache.tapestry5.model.MutableEmbeddedComponentModel in project tapestry-5 by apache.

the class ComponentWorker method addMixinTypes.

private void addMixinTypes(PlasticField field, MutableEmbeddedComponentModel model) {
    Mixins annotation = field.getAnnotation(Mixins.class);
    if (annotation == null)
        return;
    for (String typeName : annotation.value()) {
        Orderable<String> typeAndOrder = TapestryInternalUtils.mixinTypeAndOrder(typeName);
        String mixinClassName = resolver.resolveMixinTypeToClassName(typeAndOrder.getTarget());
        model.addMixin(mixinClassName, typeAndOrder.getConstraints());
    }
}
Also used : Mixins(org.apache.tapestry5.annotations.Mixins)

Aggregations

MutableEmbeddedComponentModel (org.apache.tapestry5.model.MutableEmbeddedComponentModel)9 Resource (org.apache.tapestry5.commons.Resource)8 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)8 Logger (org.slf4j.Logger)8 Test (org.testng.annotations.Test)8 Location (org.apache.tapestry5.commons.Location)3 Component (org.apache.tapestry5.annotations.Component)1 MixinClasses (org.apache.tapestry5.annotations.MixinClasses)1 Mixins (org.apache.tapestry5.annotations.Mixins)1 StringLocation (org.apache.tapestry5.commons.internal.services.StringLocation)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1 KeyValue (org.apache.tapestry5.internal.KeyValue)1