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) { 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 ContentViewerHtmlStyles.getIndentedClassName())); //NON-NLS
} }

View File

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

View File

@ -207,11 +207,10 @@ public class Annotations {
Element sourceFileSection = appendSection(parent, Bundle.Annotations_sourceFile_title()); Element sourceFileSection = appendSection(parent, Bundle.Annotations_sourceFile_title());
sourceFileSection.attr("class", ContentViewerHtmlStyles.getSpacedSectionClassName()); sourceFileSection.attr("class", ContentViewerHtmlStyles.getSpacedSectionClassName());
Element sourceFileContainer = sourceFileSection.appendElement("div"); Element sourceFileContainer = sourceFileSection.appendElement("div");
sourceFileContainer.attr("class", ContentViewerHtmlStyles.getIndentedClassName()); sourceFileContainer.attr("class", ContentViewerHtmlStyles.getIndentedClassName());
boolean sourceFileRendered = renderContent(sourceFileContainer, sourceContent, true); boolean sourceFileRendered = renderContent(sourceFileContainer, sourceContent, true);
if (!sourceFileRendered) { if (!sourceFileRendered) {
@ -239,7 +238,7 @@ public class Annotations {
if (CentralRepository.isEnabled()) { if (CentralRepository.isEnabled()) {
List<CorrelationAttributeInstance> centralRepoComments = getCentralRepositoryData(sourceFile); List<CorrelationAttributeInstance> centralRepoComments = getCentralRepositoryData(sourceFile);
boolean crRendered = appendEntries(parent, CR_COMMENTS_CONFIG, centralRepoComments, isSubheader, boolean crRendered = appendEntries(parent, CR_COMMENTS_CONFIG, centralRepoComments, isSubheader,
!contentRendered); !contentRendered);
contentRendered = contentRendered || crRendered; contentRendered = contentRendered || crRendered;
} }
@ -475,13 +474,13 @@ public class Annotations {
if (!isFirstSection) { if (!isFirstSection) {
sectionDiv.attr("class", ContentViewerHtmlStyles.getSpacedSectionClassName()); sectionDiv.attr("class", ContentViewerHtmlStyles.getSpacedSectionClassName());
} }
Element sectionContainer = sectionDiv.appendElement("div"); Element sectionContainer = sectionDiv.appendElement("div");
if (!isSubsection) { if (!isSubsection) {
sectionContainer.attr("class", ContentViewerHtmlStyles.getIndentedClassName()); sectionContainer.attr("class", ContentViewerHtmlStyles.getIndentedClassName());
} }
appendVerticalEntryTables(sectionContainer, items, config.getAttributes()); appendVerticalEntryTables(sectionContainer, items, config.getAttributes());
return true; return true;
} }
@ -532,7 +531,10 @@ public class Annotations {
* @return The created table. * @return The created table.
*/ */
private static Element appendTable(Element parent, int columnNumber, List<List<String>> content, List<String> columnHeaders) { 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()) { if (columnHeaders != null && !columnHeaders.isEmpty()) {
Element header = table.appendElement("thead"); Element header = table.appendElement("thead");
appendRow(header, columnHeaders, columnNumber, true); appendRow(header, columnHeaders, columnNumber, true);
@ -559,9 +561,15 @@ public class Annotations {
Element row = rowParent.appendElement("tr"); Element row = rowParent.appendElement("tr");
for (int i = 0; i < columnNumber; i++) { for (int i = 0; i < columnNumber; i++) {
Element cell = row.appendElement(cellType); Element cell = row.appendElement(cellType);
cell.attr("class", ContentViewerHtmlStyles.getTextClassName());
if (i == 0) {
cell.attr("class", ContentViewerHtmlStyles.getKeyColumnClassName());
}
if (data != null && i < data.size()) { 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; return row;

View File

@ -65,7 +65,7 @@ public class ContentViewerHtmlStyles {
INDENTED_CLASSNAME, pxToPt(ContentViewerDefaults.getSectionIndent())) INDENTED_CLASSNAME, pxToPt(ContentViewerDefaults.getSectionIndent()))
+ String.format(" .%s { padding-top: %dpt } ", + String.format(" .%s { padding-top: %dpt } ",
SPACED_SECTION_CLASSNAME, pxToPt(ContentViewerDefaults.getSectionSpacing())) 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())); KEY_COLUMN_TD_CLASSNAME, pxToPt(ContentViewerDefaults.getColumnSpacing()));
private static final StyleSheet STYLE_SHEET = new StyleSheet(); private static final StyleSheet STYLE_SHEET = new StyleSheet();