Package org.apache.tapestry.parse

Examples of org.apache.tapestry.parse.ComponentTemplate


     */

    private void writeTemplate(IMarkupWriter writer, IRequestCycle cycle)
    {
        IComponent inspectedComponent = getInspectedComponent();
        ComponentTemplate template = null;

        try
        {
            template = getTemplateSource().getTemplate(cycle, inspectedComponent);
        }
        catch (Exception ex)
        {
            return;
        }

        writer.begin("pre");

        int count = template.getTokenCount();

        for (int i = 0; i < count; i++)
        {
            TemplateToken token = template.getToken(i);
            TokenType type = token.getType();

            if (type == TokenType.TEXT)
            {
                write(writer, (TextToken) token);
                continue;
            }

            if (type == TokenType.CLOSE)
            {
                write(writer, (CloseToken) token);

                continue;
            }

            if (token.getType() == TokenType.LOCALIZATION)
            {

                write(writer, (LocalizationToken) token);
                continue;
            }

            if (token.getType() == TokenType.OPEN)
            {
                boolean nextIsClose = (i + 1 < count)
                        && (template.getToken(i + 1).getType() == TokenType.CLOSE);

                write(writer, nextIsClose, (OpenToken) token);

                if (nextIsClose)
                    i++;
View Full Code Here


     */

    private void writeTemplate(IMarkupWriter writer, IRequestCycle cycle)
    {
        IComponent inspectedComponent = getInspectedComponent();
        ComponentTemplate template = null;

        try
        {
            template = getTemplateSource().getTemplate(cycle, inspectedComponent);
        }
        catch (Exception ex)
        {
            return;
        }

        writer.begin("pre");

        int count = template.getTokenCount();

        for (int i = 0; i < count; i++)
        {
            TemplateToken token = template.getToken(i);
            TokenType type = token.getType();

            if (type == TokenType.TEXT)
            {
                write(writer, (TextToken) token);
                continue;
            }

            if (type == TokenType.CLOSE)
            {
                write(writer, (CloseToken) token);

                continue;
            }

            if (token.getType() == TokenType.LOCALIZATION)
            {

                write(writer, (LocalizationToken) token);
                continue;
            }

            if (token.getType() == TokenType.OPEN)
            {
                boolean nextIsClose = (i + 1 < count)
                        && (template.getToken(i + 1).getType() == TokenType.CLOSE);

                write(writer, nextIsClose, (OpenToken) token);

                if (nextIsClose)
                    i++;
View Full Code Here

    private BindingSource _bindingSource;

    public void loadTemplate(IRequestCycle requestCycle, ITemplateComponent loadComponent)
    {
        ComponentTemplate template = _templateSource.getTemplate(requestCycle, loadComponent);

        ComponentTemplateLoaderLogic logic = new ComponentTemplateLoaderLogic(_log, _pageLoader,
                _bindingSource);

        logic.loadTemplate(requestCycle, loadComponent, template);
View Full Code Here

        Iterator i = _templates.values().iterator();

        while (i.hasNext())
        {
            ComponentTemplate template = (ComponentTemplate) i.next();

            templateCount++;

            int count = template.getTokenCount();

            tokenCount += count;

            for (int j = 0; j < count; j++)
            {
                TemplateToken token = template.getToken(j);

                if (token.getType() == TokenType.TEXT)
                {
                    TextToken tt = (TextToken) token;

                    characterCount += tt.getLength();
                }
            }
        }

        event.property("parsed templates", templateCount);
        event.property("total template tokens", tokenCount);
        event.property("total template characters", characterCount);

        event.section("Parsed template token counts");

        i = _templates.entrySet().iterator();

        while (i.hasNext())
        {
            Map.Entry entry = (Map.Entry) i.next();

            String key = entry.getKey().toString();

            ComponentTemplate template = (ComponentTemplate) entry.getValue();

            event.property(key, template.getTokenCount());
        }
    }
View Full Code Here

        Locale locale = component.getPage().getLocale();

        Object key = new MultiKey(new Object[]
        { resource, locale }, false);

        ComponentTemplate result = searchCache(key);
        if (result != null)
            return result;

        result = findTemplate(cycle, resource, component, locale);
View Full Code Here

        String name = resource.getName();
        int dotx = name.lastIndexOf('.');
        String templateExtension = getTemplateExtension(component);
        String templateBaseName = name.substring(0, dotx + 1) + templateExtension;

        ComponentTemplate result = findStandardTemplate(
                cycle,
                resource,
                component,
                templateBaseName,
                locale);
View Full Code Here

    private ComponentTemplate getOrParseTemplate(IRequestCycle cycle, Resource resource,
            IComponent component)
    {

        ComponentTemplate result = (ComponentTemplate) _templates.get(resource);
        if (result != null)
            return result;

        // Ok, see if it exists.
View Full Code Here

        }

        if (_log.isDebugEnabled())
            _log.debug("Parsed " + tokens.length + " tokens from template");

        return new ComponentTemplate(templateData, tokens);
    }
View Full Code Here

    private FlowDefinitionsManager flowDefinitionsManager;
    private Log log;
    @SuppressWarnings("unused")
    public ComponentTemplate findTemplate(IRequestCycle cycle, IComponent component, Locale locale) {
        ComponentTemplate ret = null;
        IComponentSpecification spec = component.getSpecification();
        boolean isFlowPage = FlowAwareSpecResolverDelegate.ID.equals(spec.getPublicId());
        if (isFlowPage || spec.getComponentClassName().equals(FullFlowComponent.class.getName())) {
            String type = spec.getDescription();
            Flow flow = flowDefinitionsManager.getFlowDefinition(type);
View Full Code Here

        trainParser(delegate);
        Locale locale = null;
        IRequestCycle cycle = createMock(IRequestCycle.class);

        replay(component, compSpec);
        ComponentTemplate bad = delegate.findTemplate(cycle, component, locale);
        assertEqualsExcludingWhitespace(new String(bad.getTemplateData()),
                "<div>[Flow "+componentName+" not found]</div>");
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.parse.ComponentTemplate

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.