private void renderRow(XElement table, Row r, int indent, List <Boolean> indents) { var tr = new XElement(XmlNs.XHTMLNS + "tr", new XAttribute("style", "border: 0px; padding:0px; vertical-align: top; background-color: white;")); table.Add(tr); bool first = true; foreach (Cell t in r.getCells()) { renderCell(tr, t, "td", first ? r.getIcon() : null, first ? indents : null, r.getSubRows().Any(), first ? r.getAnchor() : null); first = false; } // table.addText("\r\n"); for (int i = 0; i < r.getSubRows().Count; i++) { Row c = r.getSubRows()[i]; var ind = new List <Boolean>(); ind.AddRange(indents); if (i == r.getSubRows().Count - 1) { ind.Add(true); } else { ind.Add(false); } renderRow(table, c, indent + 1, ind); } }
private void check(Row r, String str, int size) { check(r.getCells().Count == size, "All rows must have the same number of columns as the titles"); foreach (Row c in r.getSubRows()) { check(c, "rows", size); } }
private void genProfile(List<Row> rows, Profile profile, bool extensionsOnly) { if (!extensionsOnly) { var r = new Row(); rows.Add(r); r.setIcon("icon_profile.png"); r.getCells().Add(new Cell(null, null, profile.Name, null, null)); r.getCells().Add(new Cell()); r.getCells().Add(new Cell(null, null, "Profile", null, null)); r.getCells().Add(new Cell(null, null, profile.Description, null, null)); foreach (var s in profile.Structure) { var re = new Row(); r.getSubRows().Add(re); re.setIcon("icon_resource.png"); var structureUrl = _pkp.GetLinkForLocalStructure(profile, s); re.getCells().Add(new Cell(null, structureUrl, s.Name, null, null)); re.getCells().Add(new Cell(null, null, "", null, null)); re.getCells().Add(new Cell(null, _pkp.GetLinkForTypeDocu(s.Type), s.Type, null, null)); re.getCells().Add(new Cell(null, null, s.Element[0].Definition.Short, null, null)); // DSTU1 //re.getCells().Add(new Cell(null, null, s.Base, null, null)); // DSTU2 } } if (profile.ExtensionDefn != null && (profile.ExtensionDefn.Any() || extensionsOnly)) { var re = new Row(); rows.Add(re); re.setIcon("icon_profile.png"); re.getCells().Add(new Cell(null, null, "Extensions", null, null)); re.getCells().Add(new Cell()); re.getCells().Add(new Cell()); re.getCells().Add(new Cell(null, null, "Extensions defined by this profile", null, null)); // DSTU1 //re.getCells().Add(new Cell(null, null, "Extensions defined by the URL \"" + profile.Url + "\"", null, null)); // DSTU2 foreach (var ext in profile.ExtensionDefn) { genExtension(re.getSubRows(), profile, ext, true); } } }
private void genProfile(List <Row> rows, Profile profile, bool extensionsOnly) { if (!extensionsOnly) { var r = new Row(); rows.Add(r); r.setIcon("icon_profile.png"); r.getCells().Add(new Cell(null, null, profile.Name, null, null)); r.getCells().Add(new Cell()); r.getCells().Add(new Cell(null, null, "Profile", null, null)); r.getCells().Add(new Cell(null, null, profile.Description, null, null)); foreach (var s in profile.Structure) { var re = new Row(); r.getSubRows().Add(re); re.setIcon("icon_resource.png"); var structureUrl = _pkp.GetLinkForLocalStructure(profile, s); re.getCells().Add(new Cell(null, structureUrl, s.Name, null, null)); re.getCells().Add(new Cell(null, null, "", null, null)); re.getCells().Add(new Cell(null, _pkp.GetLinkForTypeDocu(s.Type), s.Type, null, null)); re.getCells().Add(new Cell(null, null, s.Element[0].Definition.Short, null, null)); // DSTU1 //re.getCells().Add(new Cell(null, null, s.Base, null, null)); // DSTU2 } } if (profile.ExtensionDefn != null && (profile.ExtensionDefn.Any() || extensionsOnly)) { var re = new Row(); rows.Add(re); re.setIcon("icon_profile.png"); re.getCells().Add(new Cell(null, null, "Extensions", null, null)); re.getCells().Add(new Cell()); re.getCells().Add(new Cell()); re.getCells().Add(new Cell(null, null, "Extensions defined by this profile", null, null)); // DSTU1 //re.getCells().Add(new Cell(null, null, "Extensions defined by the URL \"" + profile.Url + "\"", null, null)); // DSTU2 foreach (var ext in profile.ExtensionDefn) { genExtension(re.getSubRows(), profile, ext, true); } } }
private void check(Row r, String str, int size) { check(r.getCells().Count == size, "All rows must have the same number of columns as the titles"); foreach (Row c in r.getSubRows()) check(c, "rows", size); }
private void renderRow(XElement table, Row r, int indent, List<Boolean> indents) { var tr = new XElement(XmlNs.XHTMLNS + "tr", new XAttribute("style", "border: 0px; padding:0px; vertical-align: top; background-color: white;")); table.Add(tr); bool first = true; foreach (Cell t in r.getCells()) { renderCell(tr, t, "td", first ? r.getIcon() : null, first ? indents : null, r.getSubRows().Any(), first ? r.getAnchor() : null); first = false; } // table.addText("\r\n"); for (int i = 0; i < r.getSubRows().Count; i++) { Row c = r.getSubRows()[i]; var ind = new List<Boolean>(); ind.AddRange(indents); if (i == r.getSubRows().Count - 1) ind.Add(true); else ind.Add(false); renderRow(table, c, indent + 1, ind); } }
private void genElement(String defPath, HierarchicalTableGenerator gen, List <Row> rows, ElementNavigator nav, Profile profile, bool showMissing, String profileUrl, String profileBaseFileName) { var element = nav.Current; if (onlyInformationIsMapping(nav.Structure.Element, element)) { return; // we don't even show it in this case } Row row = new Row(); row.setAnchor(element.Path); String s = element.GetNameFromPath(); bool hasDef = element.Definition != null; bool ext = false; if (s == "extension" || s == "modifierExtension") { row.setIcon("icon_extension_simple.png"); ext = true; } else if (!hasDef || element.Definition.Type == null || element.Definition.Type.Count == 0) { row.setIcon("icon_element.gif"); } else if (hasDef && element.Definition.Type.Count > 1) { if (allTypesAre(element.Definition.Type, "ResourceReference")) { row.setIcon("icon_reference.png"); } else { row.setIcon("icon_choice.gif"); } } else if (hasDef && element.Definition.Type[0].Code.StartsWith("@")) { //TODO: That's not a legal code, will this ever appear? //I am pretty sure this depends on ElementDefn.NameReference row.setIcon("icon_reuse.png"); } else if (hasDef && _pkp.isPrimitive(element.Definition.Type[0].Code)) { row.setIcon("icon_primitive.png"); } else if (hasDef && _pkp.isReference(element.Definition.Type[0].Code)) { row.setIcon("icon_reference.png"); } else if (hasDef && _pkp.isDataType(element.Definition.Type[0].Code)) { row.setIcon("icon_datatype.gif"); } else { row.setIcon("icon_resource.png"); } String reference = defPath == null ? null : defPath + makePathLink(element); UnusedTracker used = new UnusedTracker(); used.used = true; Cell left = new Cell(null, reference, s, !hasDef ? null : element.Definition.Formal, null); row.getCells().Add(left); if (ext) { // If this element (row) in the table is an extension... if (element.Definition != null && element.Definition.Type.Count == 1 && element.Definition.Type[0].Profile != null) { Profile.ProfileExtensionDefnComponent extDefn = _pkp.getExtensionDefinition(profile, element.Definition.Type[0].Profile); if (extDefn == null) { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); row.getCells().Add(new Cell(null, null, "?? " + element.Definition.Type[0].Profile, null, null)); generateDescription(gen, row, element, null, used.used, profileUrl, element.Definition.Type[0].Profile, profile); } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, extDefn.Definition, used), null, null)); genTypes(gen, row, extDefn.Definition, profileBaseFileName, profile); generateDescription(gen, row, element, extDefn.Definition, used.used, profileUrl, element.Definition.Type[0].Profile, profile); } } else if (element.Definition != null) { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); genTypes(gen, row, element.Definition, profileBaseFileName, profile); generateDescription(gen, row, element, null, used.used, null, null, profile); } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); row.getCells().Add(new Cell()); generateDescription(gen, row, element, null, used.used, null, null, profile); } } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); if (element.Definition != null) { genTypes(gen, row, element.Definition, profileBaseFileName, profile); } else { row.getCells().Add(new Cell()); } generateDescription(gen, row, element, null, used.used, null, null, profile); } if (element.Slicing != null) { row.setIcon("icon_slice.png"); row.getCells()[2].getPieces().Clear(); foreach (Cell cell in row.getCells()) { foreach (Piece p in cell.getPieces()) { p.addStyle("font-style: italic"); } } } if (used.used || showMissing) { rows.Add(row); } if (!used.used) { foreach (Cell cell in row.getCells()) { foreach (Piece p in cell.getPieces()) { p.setStyle("text-decoration:line-through"); p.setReference(null); } } } else { if (nav.MoveToFirstChild()) { do { genElement(defPath, gen, row.getSubRows(), nav, profile, showMissing, profileUrl, profileBaseFileName); } while (nav.MoveToNext()); nav.MoveToParent(); } } }
private void genElement(HierarchicalTableGenerator gen, List<Row> rows, ElementNavigator nav, Profile profile, bool showMissing) { var element = nav.Current; if(onlyInformationIsMapping(nav.Structure.Element, element)) return; // we don't even show it in this case Row row = new Row(); row.setAnchor(element.Path); String s = element.GetNameFromPath(); bool hasDef = element.Definition != null; bool ext = false; if (s == "extension" || s == "modifierExtension") { row.setIcon("icon_extension_simple.png"); ext = true; } else if (!hasDef || element.Definition.Type == null || element.Definition.Type.Count == 0) { row.setIcon("icon_element.gif"); } else if (hasDef && element.Definition.Type.Count > 1) { if (allTypesAre(element.Definition.Type, "ResourceReference")) row.setIcon("icon_reference.png"); else row.setIcon("icon_choice.gif"); } else if (hasDef && element.Definition.Type[0].Code.StartsWith("@")) { //TODO: That's not a legal code, will this ever appear? //I am pretty sure this depends on ElementDefn.NameReference row.setIcon("icon_reuse.png"); } else if (hasDef && _pkp.isPrimitive(element.Definition.Type[0].Code)) row.setIcon("icon_primitive.png"); else if (hasDef && _pkp.isReference(element.Definition.Type[0].Code)) row.setIcon("icon_reference.png"); else if (hasDef && _pkp.isDataType(element.Definition.Type[0].Code)) row.setIcon("icon_datatype.gif"); else row.setIcon("icon_resource.png"); var reference = _pkp.GetLinkForElementDefinition(nav.Structure, profile, element); //String reference = defPath == null ? null : defPath + makePathLink(element); UnusedTracker used = new UnusedTracker(); used.used = true; Cell left = new Cell(null, reference, s, !hasDef ? null : element.Definition.Formal, null); row.getCells().Add(left); if (ext) { // If this element (row) in the table is an extension... if (element.Definition != null && element.Definition.Type.Count == 1 && element.Definition.Type[0].Profile != null) { Profile.ProfileExtensionDefnComponent extDefn = _pkp.getExtensionDefinition(profile, element.Definition.Type[0].Profile); if (extDefn == null) { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); row.getCells().Add(new Cell(null, null, "?? "+element.Definition.Type[0].Profile, null, null)); generateDescription(gen, row, element, null, used.used, element.Definition.Type[0].Profile, profile); } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, extDefn.Definition, used), null, null)); genTypes(gen, row, extDefn.Definition, profile); generateDescription(gen, row, element, extDefn.Definition, used.used, element.Definition.Type[0].Profile, profile); } } else if (element.Definition != null) { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); genTypes(gen, row, element.Definition, profile); generateDescription(gen, row, element, null, used.used, null, profile); } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); row.getCells().Add(new Cell()); generateDescription(gen, row, element, null, used.used, null, profile); } } else { row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null)); if (element.Definition != null) genTypes(gen, row, element.Definition, profile); else row.getCells().Add(new Cell()); generateDescription(gen, row, element, null, used.used, null, profile); } if (element.Slicing != null) { row.setIcon("icon_slice.png"); row.getCells()[2].getPieces().Clear(); foreach (Cell cell in row.getCells()) foreach (Piece p in cell.getPieces()) { p.addStyle("font-style: italic"); } } if (used.used || showMissing) rows.Add(row); if (!used.used) { foreach (Cell cell in row.getCells()) foreach (Piece p in cell.getPieces()) { p.setStyle("text-decoration:line-through"); p.setReference(null); } } else { if (nav.MoveToFirstChild()) { do { genElement(gen, row.getSubRows(), nav, profile, showMissing); } while (nav.MoveToNext()); nav.MoveToParent(); } } }