Examples of SnippetDefinition


Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

     */
    private static List getAdvisorSnippets(int pageRegion) {
        List result = new ArrayList();
        Set snippets = SnippetDefinitionManager.getAllSnippets();
        for (Iterator i = snippets.iterator(); i.hasNext();) {
            SnippetDefinition snipDef = (SnippetDefinition) i.next();
            if (snipDef.matchesCategory(ADVISOR_SNIPPET_CATEGORY)) {
                SnippetInstanceTO snip = new SnippetInstanceTO();
                snip.setSnippetID(snipDef.getId());
                snip.setDefinition(snipDef);
                snip.setPageRegion(pageRegion);
                result.add(snip);
            }
        }
View Full Code Here

Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

    private void applySnippetFilters(PageContentTO page, String mode) {
        Map<SnippetInstanceTO, SnippetPageFilter> filters = null;
        for (Iterator i = page.getSnippets().iterator(); i.hasNext();) {
            SnippetInstanceTO snip = (SnippetInstanceTO) i.next();
            SnippetDefinition def = snip.getDefinition();
            SnippetPageFilter filter = null;

            try {
                if (def != null)
                    filter = def.getFilter(mode, null);
            } catch (Exception e) {
                logger.log(Level.SEVERE,
                    "Unable to create page filter for snippet '"
                            + snip.getSnippetID() + "'", e);
            }
View Full Code Here

Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

     */
    public String invoke(SnippetInstanceTO snippet) throws IOException {
        if (!test(snippet))
            return null;       

        SnippetDefinition defn = snippet.getDefinition();
        if (XMLUtils.hasValue(mode)
                && !"view".equalsIgnoreCase(mode)
                && !defn.getModes().contains(mode)) {
            snippet.setStatus(SnippetInvoker.UNSUPPORTED_MODE);
            return null;
        }

        String uri = defn.getUri(mode, action);
        if (uri == null) {
            snippet.setStatus(SnippetInvoker.UNSUPPORTED_MODE);
            return null;
        }

        String namespace = snippet.getNamespace();

        Map extraEnvironment = new HashMap();
        extraEnvironment.put(SNIPPET_ID, snippet.getSnippetID());
        extraEnvironment.put(SNIPPET_VERSION, snippet.getSnippetVersion());
        extraEnvironment.put(PERSISTED_TEXT, snippet.getPersistedText());
        extraEnvironment.put(RESOURCES, defn.getResources());
        extraEnvironment.put(HTMLPreprocessor.REPLACEMENTS_PARAM, Collections
                .singletonMap("$$$_", namespace));
        for (int i = 0; i < PROPAGATE_TO_ENV.length; i++)
            extraEnvironment.put(PROPAGATE_TO_ENV[i], parentParameters
                    .get(PROPAGATE_TO_ENV[i]));

        StringBuffer queryString = new StringBuffer(this.queryString);
        addNamespacedParameters(parentParameters, namespace, queryString);
        if (defn.shouldParsePersistedText())
            addParsedParameters(snippet.getPersistedText(), queryString);

        StringBuffer fullUri = new StringBuffer();
        fullUri.append(WebServer.urlEncodePath(prefix)).append("/").append(uri);
        HTMLUtils.appendQuery(fullUri, queryString.toString());
View Full Code Here

Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

     * @return  true if the definition for this snippet matches the context
     *    of this invoker.  If false is returned, the snippet's status will
     *    be set to indicate the problem.
     */
    public boolean test(SnippetInstanceTO snippet) {
        SnippetDefinition defn = snippet.getDefinition();
        if (defn == null) {
            snippet.setStatus(SnippetInvoker.STATUS_NO_DEFINITION);
            return false;
        } else if (!defn.matchesContext(dataContext)) {
            snippet.setStatus(SnippetInvoker.STATUS_CONTEXT_MISMATCH);
            return false;
        }
       
        return true;
View Full Code Here

Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

       
        if (parameters.containsKey(SNIPPET_VERBATIM_TEXT_ + ns)) {
            snip.setPersistedText(getParameter(SNIPPET_VERBATIM_TEXT_ + ns));
            snip.setPersisterID(getParameter(SNIPPET_VERBATIM_PERSISTER_+ ns));
        } else {
            SnippetDefinition defn = SnippetDefinitionManager.getSnippet(snip
                    .getSnippetID());
            if (defn == null)
                return snip;
            snip.setDefinition(defn);
            if (defn.shouldParsePersistedText())
                parseParameters(snip, ns);
            else
                invokeSnippet(snip, ns);
        }
        return snip;
View Full Code Here

Examples of net.sourceforge.processdash.ui.snippet.SnippetDefinition

        String[] deny = (String[]) parameters.get("deny_ALL");
       
        Set allSnippets = SnippetDefinitionManager.getAllSnippets();
        TreeSet snippets = new TreeSet();
        for (Iterator i = allSnippets.iterator(); i.hasNext();) {
            SnippetDefinition d = (SnippetDefinition) i.next();
            if (!d.shouldHide() && !denied(d, deny) && d.matchesContext(ctx))
                snippets.add(new SnipData(d));
        }
        return snippets;
    }
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.