content viewer html layout

This commit is contained in:
Greg DiCristofaro 2021-07-01 09:18:37 -04:00
parent c6c1869f07
commit fa967f81d3
4 changed files with 27 additions and 16 deletions

View File

@ -136,7 +136,7 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer {
}
private void startTable(StringBuilder sb) {
sb.append(MessageFormat.format("<table class=\"{0}\"><tbody>",
sb.append(MessageFormat.format("<table class=\"{0}\" valign=\"top\" align=\"left\"><tbody>",
ContentViewerHtmlStyles.getIndentedClassName())); //NON-NLS
}

View File

@ -184,7 +184,10 @@ public class AnalysisResultsContentPanel extends javax.swing.JPanel {
Optional.ofNullable(getAnchor(attrs.getAnalysisResult())));
// create a table
Element table = sectionDiv.appendElement("table");
Element table = sectionDiv.appendElement("table")
.attr("valign", "top")
.attr("align", "left");
table.attr("class", ContentViewerHtmlStyles.getIndentedClassName());
Element tableBody = table.appendElement("tbody");
@ -194,11 +197,11 @@ public class AnalysisResultsContentPanel extends javax.swing.JPanel {
Element row = tableBody.appendElement("tr");
String keyString = keyVal.getKey() == null ? "" : keyVal.getKey() + ":";
Element keyTd = row.appendElement("td")
.attr("class", ContentViewerHtmlStyles.getTextClassName());
.attr("class", ContentViewerHtmlStyles.getKeyColumnClassName());
keyTd.appendElement("span")
.text(keyString)
.attr("class", ContentViewerHtmlStyles.getKeyColumnClassName());
.attr("class", ContentViewerHtmlStyles.getTextClassName());
String valueString = keyVal.getValue() == null ? "" : keyVal.getValue();
row.appendElement("td")

View File

@ -211,7 +211,6 @@ public class Annotations {
Element sourceFileContainer = sourceFileSection.appendElement("div");
sourceFileContainer.attr("class", ContentViewerHtmlStyles.getIndentedClassName());
boolean sourceFileRendered = renderContent(sourceFileContainer, sourceContent, true);
if (!sourceFileRendered) {
@ -532,7 +531,10 @@ public class Annotations {
* @return The created table.
*/
private static Element appendTable(Element parent, int columnNumber, List<List<String>> content, List<String> columnHeaders) {
Element table = parent.appendElement("table");
Element table = parent.appendElement("table")
.attr("valign", "top")
.attr("align", "left");
if (columnHeaders != null && !columnHeaders.isEmpty()) {
Element header = table.appendElement("thead");
appendRow(header, columnHeaders, columnNumber, true);
@ -559,9 +561,15 @@ public class Annotations {
Element row = rowParent.appendElement("tr");
for (int i = 0; i < columnNumber; i++) {
Element cell = row.appendElement(cellType);
cell.attr("class", ContentViewerHtmlStyles.getTextClassName());
if (i == 0) {
cell.attr("class", ContentViewerHtmlStyles.getKeyColumnClassName());
}
if (data != null && i < data.size()) {
cell.text(StringUtils.isEmpty(data.get(i)) ? "" : data.get(i));
cell.appendElement("span")
.attr("class", ContentViewerHtmlStyles.getTextClassName())
.text(StringUtils.isEmpty(data.get(i)) ? "" : data.get(i));
}
}
return row;

View File

@ -65,7 +65,7 @@ public class ContentViewerHtmlStyles {
INDENTED_CLASSNAME, pxToPt(ContentViewerDefaults.getSectionIndent()))
+ String.format(" .%s { padding-top: %dpt } ",
SPACED_SECTION_CLASSNAME, pxToPt(ContentViewerDefaults.getSectionSpacing()))
+ String.format(" .%s { padding-right: %dpt } ",
+ String.format(" .%s { padding-right: %dpt; white-space: nowrap; } ",
KEY_COLUMN_TD_CLASSNAME, pxToPt(ContentViewerDefaults.getColumnSpacing()));
private static final StyleSheet STYLE_SHEET = new StyleSheet();