Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.ComponentLibraryInfo


    @Test
    public void validator_with_constraint() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
View Full Code Here


        }

        // Let subclasses do more.
        configure(config);

        renderSupport.addInit("autocompleter", new JSONArray(id, menuId, link.toAbsoluteURI(), config));
    }
View Full Code Here

        expect(response.getPrintWriter("application/json;charset=UTF-8")).andReturn(pw);

        replay();

        JSONArray array = new JSONArray("   [ \"fred\", \"barney\" \n\n]");

        JSONArrayEventResultProcessor p = new JSONArrayEventResultProcessor(response, encoding);

        p.processResultValue(array);
View Full Code Here

        "class", "t-autocomplete-menu");
        writer.end();

        Link link = resources.createEventLink(EVENT_NAME);

        JSONObject config = new JSONObject();
        config.put("paramName", PARAM_NAME);
        config.put("indicator", loaderId);

        if (resources.isBound("minChars"))
            config.put("minChars", minChars);

        if (resources.isBound("frequency"))
            config.put("frequency", frequency);

        if (resources.isBound("tokens"))
        {
            for (int i = 0; i < tokens.length(); i++)
            {
                config.accumulate("tokens", tokens.substring(i, i + 1));
            }
        }

        // Let subclasses do more.
        configure(config);
View Full Code Here

     * not formatted correct.
     */
    JSONObject onParse(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            Date date = format.parse(input);

            response.put(RESULT, date.getTime());
        }
        catch (ParseException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

     * the result.
     */
    JSONObject onFormat(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            long millis = Long.parseLong(input);

            Date date = new Date(millis);

            response.put(RESULT, format.format(date));
        }
        catch (NumberFormatException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

        "src", icon.toClientURL(),

        "alt", "[Show]");
        writer.end(); // img

        JSONObject spec = new JSONObject();

        spec.put("field", clientId);
        spec.put("parseURL", resources.createEventLink("parse").toAbsoluteURI());
        spec.put("formatURL", resources.createEventLink("format").toAbsoluteURI());

        support.addInitializerCall("dateField", spec);
    }
View Full Code Here

    }

    @Override
    public ComponentLibraryInfo find(LibraryMapping libraryMapping)
    {
        ComponentLibraryInfo info = null;
        if (cache.containsKey(libraryMapping.libraryName))
        {
            info = cache.get(libraryMapping.libraryName);
        }
        else
        {
            final String pomPath = getPomPath(libraryMapping);
            if (pomPath != null)
            {
                InputStream inputStream = getClass().getResourceAsStream("/" + pomPath);
                info = parse(inputStream);
                info.setLibraryMapping(libraryMapping);
                cache.put(libraryMapping.libraryName, info);
            }
            else
            {
                cache.put(libraryMapping.libraryName, null);
View Full Code Here

        return info;
    }

    private ComponentLibraryInfo parse(InputStream inputStream)
    {
        ComponentLibraryInfo info = null;
        if (inputStream != null)
        {
           
            Document document;
           
            try
            {
                DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
                document = documentBuilder.parse(inputStream);
            }
            catch (Exception e)
            {
                logger.warn("Exception while parsing pom.xml", e);
                return null;
            }
           
            info = new ComponentLibraryInfo();
            info.setGroupId(extractText(document, "(/project/groupId | /project/parent/groupId)[1]"));
            info.setArtifactId(extractText(document, "/project/artifactId"));
            info.setVersion(extractText(document, "/project/version"));
            info.setName(extractText(document, "/project/name"));
            info.setDescription(extractText(document, "/project/description"));
            info.setDocumentationUrl(extractText(document, "/project/properties/documentationUrl"));
            info.setHomepageUrl(extractText(document, "/project/properties/homepageUrl"));
            info.setIssueTrackerUrl(extractText(document, "/project/issueManagement/url"));
            info.setJavadocUrl(extractText(document, "/project/properties/javadocUrl"));
            info.setSourceBrowseUrl(extractText(document, "/project/scm/url"));
            info.setSourceRootUrl(extractText(document, "/project/properties/sourceRootUrl"));
            info.setTapestryVersion(extractText(document, "(/project/dependencies/dependency[./groupId='org.apache.tapestry'][./artifactId='tapestry-core']/version | /project/properties/tapestryVersion)[1]"));
            String tags = extractText(document, "/project/properties/tags");
            if (tags != null && tags.length() > 0)
            {
                info.setTags(Arrays.asList(tags.split(",")));
            }
           
        }
       
        return info;
View Full Code Here

        }
        JSONObject object = new JSONObject();
        object.put("libraryName", libraryName);
        object.put("rootPackage", libraryMapping.getRootPackage());
       
        final ComponentLibraryInfo info = getInfo();
        if (info != null)
        {
            JSONObject infoJsonObject = new JSONObject();
            putIfNotNull("description", info.getDescription(), infoJsonObject);
            putIfNotNull("homepage", info.getHomepageUrl(), infoJsonObject);
            putIfNotNull("documentationUrl", info.getDocumentationUrl(), infoJsonObject);
            putIfNotNull("javadocUrl", info.getJavadocUrl(), infoJsonObject);
            putIfNotNull("groupId", info.getGroupId(), infoJsonObject);
            putIfNotNull("artifactId", info.getArtifactId(), infoJsonObject);
            putIfNotNull("version", info.getVersion(), infoJsonObject);
            putIfNotNull("sourceBrowseUrl", info.getSourceBrowseUrl(), infoJsonObject);
            putIfNotNull("sourceRootUrl", info.getSourceRootUrl(), infoJsonObject);
            putIfNotNull("issueTrackerUrl", info.getIssueTrackerUrl(), infoJsonObject);
            putIfNotNull("dependencyInfoUrl", info.getDependencyManagementInfoUrl(), infoJsonObject);
           
            if (info.getTags() != null)
            {
                for (String tag : info.getTags())
                {
                    infoJsonObject.accumulate("tags", tag);
                }
            }
           
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.ComponentLibraryInfo

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.