Refactor type dependent unified diff displaying into separate functions
Thereby we can better see the overall flow of control. Change-Id: I7c49da641cca2b5ec1fd85026f7e9df5a87ba32d
This commit is contained in:
@@ -228,6 +228,52 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
|||||||
final ArrayList<PatchLine> lines = new ArrayList<PatchLine>();
|
final ArrayList<PatchLine> lines = new ArrayList<PatchLine>();
|
||||||
if (script.getDisplayMethodA() == DisplayMethod.IMG
|
if (script.getDisplayMethodA() == DisplayMethod.IMG
|
||||||
|| script.getDisplayMethodB() == DisplayMethod.IMG) {
|
|| script.getDisplayMethodB() == DisplayMethod.IMG) {
|
||||||
|
appendImageDifferences(script, nc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isDisplayBinary) {
|
||||||
|
if (hasDifferences(script)) {
|
||||||
|
appendTextDifferences(script, nc, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasDifferences(script)) {
|
||||||
|
appendNoDifferences(nc);
|
||||||
|
}
|
||||||
|
resetHtml(nc);
|
||||||
|
populateTableHeader(script, detail);
|
||||||
|
if (hasDifferences(script)) {
|
||||||
|
initScript(script);
|
||||||
|
if (!isDisplayBinary) {
|
||||||
|
int row = script.getPatchHeader().size();
|
||||||
|
final CellFormatter fmt = table.getCellFormatter();
|
||||||
|
final Iterator<PatchLine> iLine = lines.iterator();
|
||||||
|
while (iLine.hasNext()) {
|
||||||
|
final PatchLine l = iLine.next();
|
||||||
|
final String n;
|
||||||
|
switch (l.getType()) {
|
||||||
|
case CONTEXT:
|
||||||
|
n = Gerrit.RESOURCES.css().diffTextCONTEXT();
|
||||||
|
break;
|
||||||
|
case DELETE:
|
||||||
|
n = Gerrit.RESOURCES.css().diffTextDELETE();
|
||||||
|
break;
|
||||||
|
case INSERT:
|
||||||
|
n = Gerrit.RESOURCES.css().diffTextINSERT();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while (!fmt.getStyleName(row, PC).contains(n)) {
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
setRowItem(row++, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendImageDifferences(final PatchScript script,
|
||||||
|
final SafeHtmlBuilder nc) {
|
||||||
final String rawBase = GWT.getHostPageBaseURL() + "cat/";
|
final String rawBase = GWT.getHostPageBaseURL() + "cat/";
|
||||||
|
|
||||||
nc.openTr();
|
nc.openTr();
|
||||||
@@ -263,10 +309,10 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
|||||||
nc.closeTr();
|
nc.closeTr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDisplayBinary) {
|
private void appendTextDifferences(final PatchScript script,
|
||||||
|
final SafeHtmlBuilder nc, final ArrayList<PatchLine> lines) {
|
||||||
final SparseHtmlFile a = getSparseHtmlFileA(script);
|
final SparseHtmlFile a = getSparseHtmlFileA(script);
|
||||||
final SparseHtmlFile b = getSparseHtmlFileB(script);
|
final SparseHtmlFile b = getSparseHtmlFileB(script);
|
||||||
if (hasDifferences(script)) {
|
|
||||||
final boolean syntaxHighlighting =
|
final boolean syntaxHighlighting =
|
||||||
script.getDiffPrefs().isSyntaxHighlighting();
|
script.getDiffPrefs().isSyntaxHighlighting();
|
||||||
for (final EditList.Hunk hunk : script.getHunks()) {
|
for (final EditList.Hunk hunk : script.getHunks()) {
|
||||||
@@ -310,42 +356,6 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!hasDifferences(script)) {
|
|
||||||
appendNoDifferences(nc);
|
|
||||||
}
|
|
||||||
resetHtml(nc);
|
|
||||||
populateTableHeader(script, detail);
|
|
||||||
if (hasDifferences(script)) {
|
|
||||||
initScript(script);
|
|
||||||
if (!isDisplayBinary) {
|
|
||||||
int row = script.getPatchHeader().size();
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
final Iterator<PatchLine> iLine = lines.iterator();
|
|
||||||
while (iLine.hasNext()) {
|
|
||||||
final PatchLine l = iLine.next();
|
|
||||||
final String n;
|
|
||||||
switch (l.getType()) {
|
|
||||||
case CONTEXT:
|
|
||||||
n = Gerrit.RESOURCES.css().diffTextCONTEXT();
|
|
||||||
break;
|
|
||||||
case DELETE:
|
|
||||||
n = Gerrit.RESOURCES.css().diffTextDELETE();
|
|
||||||
break;
|
|
||||||
case INSERT:
|
|
||||||
n = Gerrit.RESOURCES.css().diffTextINSERT();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
while (!fmt.getStyleName(row, PC).contains(n)) {
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
setRowItem(row++, l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void display(final CommentDetail cd, boolean expandComments) {
|
public void display(final CommentDetail cd, boolean expandComments) {
|
||||||
|
Reference in New Issue
Block a user