Examples of PageActivationContext


Examples of org.apache.tapestry5.annotations.PageActivationContext

        }
    }

    private void transformField(ClassTransformation transformation, MutableComponentModel model, TransformField field)
    {
        PageActivationContext annotation = field.getAnnotation(PageActivationContext.class);

        FieldAccess access = field.getAccess();

        if (annotation.activate())
        {
            transformation.addComponentEventHandler(EventConstants.ACTIVATE, 1,
                    "PageActivationContextWorker activate event handler",
                    createActivationHandler(field.getType(), access));
        }

        if (annotation.passivate())
        {
            transformation.addComponentEventHandler(EventConstants.PASSIVATE, 0,
                    "PageActivationContextWorker passivate event handler", createPassivateHandler(access));
        }
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        }
    }

    private void transformField(TransformationSupport support, PlasticField field)
    {
        PageActivationContext annotation = field.getAnnotation(PageActivationContext.class);

        FieldHandle handle = field.getHandle();

        if (annotation.activate())
        {
            support.addEventHandler(EventConstants.ACTIVATE, 1,
                    "PageActivationContextWorker activate event handler",
                    createActivationHandler(field.getTypeName(), handle));
        }

        if (annotation.passivate())
        {
            support.addEventHandler(EventConstants.PASSIVATE, 0,
                    "PageActivationContextWorker passivate event handler", createPassivateHandler(handle));
        }
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        List<PlasticField> sortedFields = CollectionFactory.newList(fields);
        Collections.sort(sortedFields, INDEX_COMPARATOR);
        validateSortedFields(sortedFields);

        PlasticField firstField = sortedFields.get(0);
        PageActivationContext firstAnnotation = firstField.getAnnotation(PageActivationContext.class);

        // these arrays reduce memory usage and allow the PlasticField instances to be garbage collected
        FieldHandle[] handles = new FieldHandle[sortedFields.size()];
        String[] typeNames = new String[sortedFields.size()];

        int i = 0;
        for (PlasticField field : sortedFields) {
            handles[i] = field.getHandle();
            typeNames[i] = field.getTypeName();
            ++i;
        }

        if (firstAnnotation.activate())
        {
            support.addEventHandler(EventConstants.ACTIVATE, 1,
                    "PageActivationContextWorker activate event handler", createActivationHandler(handles, typeNames));
        }

        if (firstAnnotation.passivate())
        {
            support.addEventHandler(EventConstants.PASSIVATE, 0,
                    "PageActivationContextWorker passivate event handler", createPassivateHandler(handles));
        }
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        Set<Boolean> activates = CollectionFactory.newSet();
        Set<Boolean> passivates = CollectionFactory.newSet();

        for (int i = 0; i < sortedFields.size(); ++i) {
            PlasticField field = sortedFields.get(i);
            PageActivationContext annotation = field.getAnnotation(PageActivationContext.class);
            expectedIndexes.add(i);
            actualIndexes.add(annotation.index());
            activates.add(annotation.activate());
            passivates.add(annotation.passivate());
        }

        List<String> errors = CollectionFactory.newList();
        if (!expectedIndexes.equals(actualIndexes)) {
            errors.add(String.format("Index values must start at 0 and increment by 1 (expected [%s], found [%s])",
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        }
    }

    private void transformField(ClassTransformation transformation, MutableComponentModel model, TransformField field)
    {
        PageActivationContext annotation = field.getAnnotation(PageActivationContext.class);

        FieldAccess access = field.getAccess();

        if (annotation.activate())
        {
            transformation.addComponentEventHandler(EventConstants.ACTIVATE, 1,
                    "PageActivationContextWorker activate event handler",
                    createActivationHandler(field.getType(), access));
        }

        if (annotation.passivate())
        {
            transformation.addComponentEventHandler(EventConstants.PASSIVATE, 0,
                    "PageActivationContextWorker passivate event handler", createPassivateHandler(access));
        }
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        if (fields.size() > 1)
            throw new RuntimeException(TransformMessages.illegalNumberOfPageActivationContextHandlers(fields));

        for (String fieldName : fields)
        {
            PageActivationContext annotation = transformation.getFieldAnnotation(fieldName,
                                                                                 PageActivationContext.class);

            String fieldType = transformation.getFieldType(fieldName);

            if (annotation.activate())
            {
                TransformMethodSignature activate
                        = new TransformMethodSignature(Modifier.PROTECTED | Modifier.FINAL, "void",
                                                       "onActivate",
                                                       new String[] { fieldType }, null);
                transformation.addTransformedMethod(activate, fieldName + " = $1;");
            }

            if (annotation.passivate())
            {
                TransformMethodSignature passivate
                        = new TransformMethodSignature(Modifier.PROTECTED | Modifier.FINAL, "java.lang.Object",
                                                       "onPassivate",
                                                       null, null);
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

        }
    }

    private void transformField(TransformationSupport support, PlasticField field)
    {
        PageActivationContext annotation = field.getAnnotation(PageActivationContext.class);

        FieldHandle handle = field.getHandle();

        if (annotation.activate())
        {
            support.addEventHandler(EventConstants.ACTIVATE, 1,
                    "PageActivationContextWorker activate event handler",
                    createActivationHandler(field.getTypeName(), handle));
        }

        if (annotation.passivate())
        {
            support.addEventHandler(EventConstants.PASSIVATE, 0,
                    "PageActivationContextWorker passivate event handler", createPassivateHandler(handle));
        }
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

    @Test
    public void activate_dafault_passivate_false()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(true);

        TransformMethodSignature sig = new TransformMethodSignature(
                Modifier.PROTECTED | Modifier.FINAL, "void", "onActivate",
                new String[]{CLASS_NAME}, null);

        ct.addTransformedMethod(sig, "myfield = $1;");

        expect(annotation.passivate()).andReturn(false);

        replay();

        worker.transform(ct, model);
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

    @Test
    public void activate_false_passivate_default()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(false);

        expect(annotation.passivate()).andReturn(true);

        TransformMethodSignature sig = new TransformMethodSignature(
                Modifier.PROTECTED | Modifier.FINAL, "java.lang.Object",
                "onPassivate", null, null);
View Full Code Here

Examples of org.apache.tapestry5.annotations.PageActivationContext

    @Test
    public void activate_false_passivate_false()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(false);

        expect(annotation.passivate()).andReturn(false);

        replay();

        worker.transform(ct, model);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.