Search in sources :

Example 1 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project kindling by HL7.

the class PageProcessor method generateToc.

private String generateToc() throws Exception {
    // return breadCrumbManager.makeToc();
    List<String> entries = new ArrayList<String>();
    entries.addAll(toc.keySet());
    Collections.sort(entries, new SectionSorter());
    Set<String> pages = new HashSet<String>();
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(folders.dstDir, false, true);
    TableModel model = gen.new TableModel("toc", true);
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Table of Contents", "Table of Contents", null, 0));
    Deque<TocItem> stack = new ArrayDeque<TocItem>();
    for (String s : entries) {
        TocEntry t = toc.get(s);
        if (!t.isIg() && !s.startsWith("?")) {
            String nd = s;
            while (nd.endsWith(".0")) nd = nd.substring(0, nd.length() - 2);
            int d = Utilities.charCount(nd, '.');
            if (d < 4 && !pages.contains(t.getLink())) {
                String np = getNormativePackageForPage(t.getLink());
                pages.add(t.getLink());
                while (!stack.isEmpty() && stack.getFirst().depth >= d) stack.pop();
                Row row = gen.new Row();
                row.setIcon("icon_page.gif", null);
                String td = t.getText();
                if (!stack.isEmpty()) {
                    if (td.startsWith(stack.getFirst().entry.getText() + " - "))
                        td = td.substring(stack.getFirst().entry.getText().length() + 3);
                    else if (td.startsWith(stack.getFirst().entry.getText()))
                        td = td.substring(stack.getFirst().entry.getText().length());
                }
                Cell cell = gen.new Cell(null, t.getLink(), nd + " " + td, t.getText() + " ", null);
                row.getCells().add(cell);
                if (np != null) {
                    cell.addPiece(gen.new Piece(null, " ", null));
                    cell.addPiece(gen.new Piece("versions.html#std-process", "basic".equals(np) ? "(Normative)" : "(Normative / " + Utilities.capitalize(np) + ")", null).addStyle("color: #008000"));
                    if (np.equals("infrastructure"))
                        row.setIcon("icon_page_n_i.gif", null);
                    else if (np.equals("conformance"))
                        row.setIcon("icon_page_n_c.gif", null);
                    else if (np.equals("patient"))
                        row.setIcon("icon_page_n_p.gif", null);
                    else if (np.equals("observation"))
                        row.setIcon("icon_page_n_o.gif", null);
                    else
                        row.setIcon("icon_page_n.gif", null);
                } else {
                    cell.addPiece(gen.new Piece(null, " ", null));
                    cell.addPiece(gen.new Piece("versions.html#std-process", "(Trial Use)", null).addStyle("color: #b3b3b3"));
                }
                if (stack.isEmpty())
                    model.getRows().add(row);
                else
                    stack.getFirst().row.getSubRows().add(row);
                stack.push(new TocItem(t, row, d));
            }
        }
    }
    return new XhtmlComposer(XhtmlComposer.HTML).compose(gen.generate(model, "", 0, null));
}
Also used : ArrayList(java.util.ArrayList) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) ArrayDeque(java.util.ArrayDeque) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) HashSet(java.util.HashSet)

Example 2 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project kindling by HL7.

the class ImplementationGuideDefn method genToc.

public TableModel genToc(HierarchicalTableGenerator gen, String id) throws FHIRException {
    TableModel model = gen.new TableModel(id, true);
    model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Table Of Contents", null, null, 0));
    addPage(gen, model.getRows(), ig.getDefinition().getPage());
    return model;
}
Also used : TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)

Example 3 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project kindling by HL7.

the class ResourceDependencyGenerator method generate.

public XhtmlNode generate(ElementDefn e, String prefix) throws Exception {
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(dest, inlineGraphics, true);
    RenderMode mode = RenderMode.RESOURCE;
    TableModel model = initTable(gen, prefix, mode == RenderMode.LOGICAL, e.getName());
    model.getRows().add(genElement(e, gen, true, e.getName(), false, prefix, mode, true));
    return gen.generate(model, prefix, 0, null);
}
Also used : HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)

Example 4 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project kindling by HL7.

the class ResourceTableGenerator method generate.

public XhtmlNode generate(ResourceDefn r, String prefix, boolean isActive) throws Exception {
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(dest, inlineGraphics, true);
    ElementDefn e = r.getRoot();
    RenderMode mode = e.typeCode().equals("Logical") && hasLogicalMapping(e) ? RenderMode.LOGICAL : RenderMode.RESOURCE;
    TableModel model = gen.initNormalTable(prefix, mode == RenderMode.LOGICAL, true, r.getName(), isActive);
    model.getRows().add(genElement(e, gen, true, e.getName(), false, prefix, mode, true, r.getStatus(), r.isAbstract(), r.isInterface()));
    return gen.generate(model, prefix, 0, null);
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)

Example 5 with TableModel

use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel in project kindling by HL7.

the class DataTypeTableGenerator method generate.

public XhtmlNode generate(ElementDefn e, Set<String> outputTracker, boolean isActive) throws Exception {
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(dest, inlineGraphics, false);
    TableModel model = gen.initNormalTable("", false, true, e.getName(), isActive);
    model.getRows().add(genElement(e, gen, false, e.getName(), false, "", RenderMode.DATATYPE, true, e.getStandardsStatus(), e.isAbstractType(), false));
    return gen.generate(model, "", 0, outputTracker);
}
Also used : HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)

Aggregations

TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)51 HierarchicalTableGenerator (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator)45 ArrayList (java.util.ArrayList)17 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)14 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)11 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)7 List (java.util.List)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 HashSet (java.util.HashSet)5 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)3 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)2 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)2 Element (org.hl7.fhir.r4b.model.Element)2 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)2