fixes for version comparison

This commit is contained in:
Grahame Grieve 2020-07-26 08:17:59 +10:00
parent 04aef18307
commit 7932516b12
2 changed files with 32 additions and 9 deletions

View File

@ -94,15 +94,9 @@ public abstract class CanonicalResourceComparer extends ResourceComparer {
}
s = s + "<td><a href=\""+getId()+".html\">Comparison</a></td>";
s = s + "<td>"+outcomeSummary()+"</td>";
return "<tr style=\"background-color: "+(hasErrors() ? COLOR_DIFFERENT : COLOR_DIFFERENT_LESS)+"\">"+s+"</tr>\r\n";
return "<tr style=\"background-color: "+color()+"\">"+s+"</tr>\r\n";
}
protected boolean hasErrors() {
MessageCounts cnts = new MessageCounts();
countMessages(cnts);
return cnts.getErrors() > 0;
}
@Override
protected void countMessages(MessageCounts cnts) {

View File

@ -51,6 +51,7 @@ public class ResourceComparer {
private String id;
private String leftId;
private String rightId;
private MessageCounts cnts;
public ResourceComparison(String leftId, String rightId) {
super();
@ -85,15 +86,42 @@ public class ResourceComparer {
protected abstract String toTable();
protected String color() {
if (hasErrors()) {
return COLOR_DIFFERENT;
} else if (noChange()) {
return COLOR_NO_CHANGE;
} else {
return COLOR_DIFFERENT_LESS;
}
}
protected boolean hasErrors() {
MessageCounts cnts = getCounts();
return cnts.getErrors() > 0;
}
protected boolean noChange() {
MessageCounts cnts = getCounts();
return cnts.getErrors() + cnts.getWarnings() + cnts.getHints() == 0;
}
protected String outcomeSummary() {
MessageCounts cnts = new MessageCounts();
countMessages(cnts);
MessageCounts cnts = getCounts();
return
Integer.toString(cnts.getErrors())+" "+Utilities.pluralize("Breaking Change", cnts.getErrors())+", "+
Integer.toString(cnts.getWarnings())+" "+Utilities.pluralize("Change", cnts.getWarnings())+", "+
Integer.toString(cnts.getHints())+" "+Utilities.pluralize("Note", cnts.getHints());
}
public MessageCounts getCounts() {
if (cnts == null) {
cnts = new MessageCounts();
countMessages(cnts);
}
return cnts;
}
protected abstract void countMessages(MessageCounts cnts);
}
@ -190,6 +218,7 @@ public class ResourceComparer {
public final static String COLOR_DIFFERENT = "#f0b3ff";
public final static String COLOR_DIFFERENT_LESS = "#f8e6ff";
public final static String COLOR_ISSUE = "#ffad99";
public final static String COLOR_NO_CHANGE = "#ffffff";
protected ComparisonSession session;