Search in sources :

Example 1 with MenuItem

use of org.apache.maven.doxia.site.decoration.MenuItem in project maven-plugins by apache.

the class DocumentModelBuilder method getDocumentTOC.

/**
 * Extract a DocumentTOC from a DecorationModel.
 *
 * @param decorationModel a DecorationModel. May be null.
 * @return a DocumentTOC, always non-null.
 */
private static DocumentTOC getDocumentTOC(DecorationModel decorationModel) {
    final DocumentTOC toc = new DocumentTOC();
    if (decorationModel != null && decorationModel.getMenus() != null) {
        for (final Menu menu : decorationModel.getMenus()) {
            for (final MenuItem item : menu.getItems()) {
                final DocumentTOCItem documentTOCItem = new DocumentTOCItem();
                documentTOCItem.setName(item.getName());
                documentTOCItem.setRef(item.getHref());
                toc.addItem(documentTOCItem);
            }
        }
    }
    return toc;
}
Also used : DocumentTOC(org.apache.maven.doxia.document.DocumentTOC) DocumentTOCItem(org.apache.maven.doxia.document.DocumentTOCItem) MenuItem(org.apache.maven.doxia.site.decoration.MenuItem) Menu(org.apache.maven.doxia.site.decoration.Menu)

Example 2 with MenuItem

use of org.apache.maven.doxia.site.decoration.MenuItem in project maven-plugins by apache.

the class AbstractSiteRenderingMojo method populateItemRefs.

private void populateItemRefs(List<MenuItem> items, Locale locale, Map<String, MavenReport> reportsByOutputName) {
    for (Iterator<MenuItem> i = items.iterator(); i.hasNext(); ) {
        MenuItem item = i.next();
        if (item.getRef() != null) {
            MavenReport report = reportsByOutputName.get(item.getRef());
            if (report != null) {
                if (item.getName() == null) {
                    item.setName(report.getName(locale));
                }
                if (item.getHref() == null || item.getHref().length() == 0) {
                    item.setHref(report.getOutputName() + ".html");
                }
            } else {
                getLog().warn("Unrecognised reference: '" + item.getRef() + "'");
                i.remove();
            }
        }
        populateItemRefs(item.getItems(), locale, reportsByOutputName);
    }
}
Also used : MavenReport(org.apache.maven.reporting.MavenReport) MenuItem(org.apache.maven.doxia.site.decoration.MenuItem)

Example 3 with MenuItem

use of org.apache.maven.doxia.site.decoration.MenuItem in project maven-plugins by apache.

the class SiteMap method extractItems.

private static void extractItems(List<MenuItem> items, Sink sink) {
    if (items == null || items.isEmpty()) {
        return;
    }
    sink.list();
    for (MenuItem item : items) {
        sink.listItem();
        sink.link(relativePath(item.getHref()));
        sink.text(item.getName());
        sink.link_();
        extractItems(item.getItems(), sink);
        sink.listItem_();
    }
    sink.list_();
}
Also used : MenuItem(org.apache.maven.doxia.site.decoration.MenuItem)

Aggregations

MenuItem (org.apache.maven.doxia.site.decoration.MenuItem)3 DocumentTOC (org.apache.maven.doxia.document.DocumentTOC)1 DocumentTOCItem (org.apache.maven.doxia.document.DocumentTOCItem)1 Menu (org.apache.maven.doxia.site.decoration.Menu)1 MavenReport (org.apache.maven.reporting.MavenReport)1