Improve the side-by-side viewer table
Move the line number column for the right side to be on the far right of the table, giving us the layout: 1 | foo | bar | 1 2 | hello | hello | 2 This looks nicer when reading a lot of code, as the line numbers are less relevant entities than the code itself which is now in the center of the UI. Line numbers are still links to create comment editors, but they use a light shade of gray and skip the underline decoration, making them less visually distracting. Skip lines now use a paler shade of blue and also hide the fact they contain anchors, until you hover over them and the anchor shows up. The expand before and after are changed to be arrows showing in which direction the lines will appear above or below the skip line. This makes it easier for people like myself who get confused and always hit the wrong link, the arrow shows to which side the lines will appear. Change-Id: I7108733358db23dca6f7d5b90cd4b7e8712cf2b2
This commit is contained in:
parent
282c102ec4
commit
412150cf8b
@ -662,11 +662,17 @@
|
|||||||
white-space: pre;
|
white-space: pre;
|
||||||
width: 3.5em;
|
width: 3.5em;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
border-right: thin solid #b0bdcc;
|
|
||||||
padding-right: 0.2em;
|
padding-right: 0.2em;
|
||||||
background: white;
|
background: white;
|
||||||
border-bottom: 1px solid white;
|
border-bottom: 1px solid white;
|
||||||
}
|
}
|
||||||
|
.lineNumber.rightmost {
|
||||||
|
border-left: thin solid #b0bdcc;
|
||||||
|
}
|
||||||
|
.lineNumber a {
|
||||||
|
color: #888;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
.patchContentTable td.fileColumnHeader {
|
.patchContentTable td.fileColumnHeader {
|
||||||
background: trimColor;
|
background: trimColor;
|
||||||
font-family: norm-font;
|
font-family: norm-font;
|
||||||
@ -689,6 +695,7 @@
|
|||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
|
border-left: thin solid #b0bdcc;
|
||||||
}
|
}
|
||||||
.fileLineNone {
|
.fileLineNone {
|
||||||
background: #eeeeee;
|
background: #eeeeee;
|
||||||
@ -723,11 +730,21 @@
|
|||||||
font-family: norm-font;
|
font-family: norm-font;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
background: lightblue;
|
background: #def;
|
||||||
|
color: grey;
|
||||||
}
|
}
|
||||||
.patchContentTable .skipLine div {
|
.patchContentTable .skipLine div {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
.patchContentTable a.skipLine {
|
||||||
|
color: grey;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.patchContentTable a:hover.skipLine {
|
||||||
|
background: white;
|
||||||
|
color: #00A;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.patchContentTable .activeRow .iconCell,
|
.patchContentTable .activeRow .iconCell,
|
||||||
.patchContentTable .activeRow .lineNumber {
|
.patchContentTable .activeRow .lineNumber {
|
||||||
|
@ -516,22 +516,6 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
|||||||
Gerrit.RESOURCES.css().iconCell());
|
Gerrit.RESOURCES.css().iconCell());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addStyle(final int row, final int col, final String style) {
|
|
||||||
table.getCellFormatter().addStyleName(row, col, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeRow(final int row) {
|
|
||||||
table.removeRow(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setHtml(final int row, final int col, final String html) {
|
|
||||||
table.setHTML(row, col, html);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setWidget(final int row, final int col, final Widget widget) {
|
|
||||||
table.setWidget(row, col, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onOpenRow(final int row) {
|
protected void onOpenRow(final int row) {
|
||||||
final Object item = getRowItem(row);
|
final Object item = getRowItem(row);
|
||||||
|
@ -48,5 +48,5 @@ download = (Download)
|
|||||||
fileTypeSymlink = Type: Symbolic Link
|
fileTypeSymlink = Type: Symbolic Link
|
||||||
fileTypeGitlink = Type: Git Commit in Subproject
|
fileTypeGitlink = Type: Git Commit in Subproject
|
||||||
|
|
||||||
patchSkipRegionStart = (... skipping
|
patchSkipRegionStart = ... skipped
|
||||||
patchSkipRegionEnd = common lines ...)
|
patchSkipRegionEnd = common lines ...
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
expandBefore = Expand {0} before
|
expandBefore = +{0}⇧
|
||||||
expandAfter = Expand {0} after
|
expandAfter = +{0}⇩
|
||||||
|
|
||||||
draftSaved = Draft saved at {0,time,short}
|
draftSaved = Draft saved at {0,time,short}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
expandBefore = Expand {0} before
|
expandBefore = +{0}⇧
|
||||||
expandAfter = Expand {0} after
|
expandAfter = +{0}⇩
|
||||||
|
@ -26,16 +26,15 @@ import com.google.gerrit.common.data.PatchScript.FileMode;
|
|||||||
import com.google.gerrit.prettify.common.EditList;
|
import com.google.gerrit.prettify.common.EditList;
|
||||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
import com.google.gerrit.reviewdb.client.Patch;
|
||||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
||||||
|
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.InlineLabel;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||||
import com.google.gwtorm.client.KeyUtil;
|
import com.google.gwtorm.client.KeyUtil;
|
||||||
@ -47,9 +46,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SideBySideTable extends AbstractPatchContentTable {
|
public class SideBySideTable extends AbstractPatchContentTable {
|
||||||
private static final int COL_A = 2;
|
private static final int A = 2;
|
||||||
private static final int COL_B = 4;
|
private static final int B = 3;
|
||||||
|
|
||||||
private static final int NUM_ROWS_TO_EXPAND = 10;
|
private static final int NUM_ROWS_TO_EXPAND = 10;
|
||||||
|
|
||||||
private SparseHtmlFile a;
|
private SparseHtmlFile a;
|
||||||
@ -59,24 +57,17 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
protected void onCellDoubleClick(final int row, int column) {
|
protected void onCellDoubleClick(final int row, int column) {
|
||||||
if (column > 0 && getRowItem(row) instanceof PatchLine) {
|
if (column > 0 && getRowItem(row) instanceof PatchLine) {
|
||||||
final PatchLine line = (PatchLine) getRowItem(row);
|
final PatchLine line = (PatchLine) getRowItem(row);
|
||||||
final short file = (short) ((column - 1) / 2);
|
if (column == 1 || column == A) {
|
||||||
if (column < (1 + file * 2 + 1)) {
|
createCommentEditor(row + 1, A, line.getLineA(), (short) 0);
|
||||||
column++;
|
} else if (column == B || column == 4) {
|
||||||
}
|
createCommentEditor(row + 1, B, line.getLineB(), (short) 1);
|
||||||
switch (file) {
|
|
||||||
case 0:
|
|
||||||
createCommentEditor(row + 1, column, line.getLineA(), file);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
createCommentEditor(row + 1, column, line.getLineB(), file);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCellSingleClick(int row, int column) {
|
protected void onCellSingleClick(int row, int column) {
|
||||||
if (column == 1 || column == 3) {
|
if (column == 1 || column == 4) {
|
||||||
onCellDoubleClick(row, column);
|
onCellDoubleClick(row, column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +75,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
@Override
|
@Override
|
||||||
protected void onInsertComment(final PatchLine line) {
|
protected void onInsertComment(final PatchLine line) {
|
||||||
final int row = getCurrentRow();
|
final int row = getCurrentRow();
|
||||||
createCommentEditor(row + 1, 4, line.getLineB(), (short) 1);
|
createCommentEditor(row + 1, B, line.getLineB(), (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +91,8 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
appendHeader(script, nc);
|
appendHeader(script, nc);
|
||||||
lines.add(null);
|
lines.add(null);
|
||||||
|
|
||||||
if(script.getFileModeA()!=FileMode.FILE||script.getFileModeB()!=FileMode.FILE){
|
if (script.getFileModeA() != FileMode.FILE
|
||||||
|
|| script.getFileModeB() != FileMode.FILE) {
|
||||||
openLine(nc);
|
openLine(nc);
|
||||||
appendModeLine(nc, script.getFileModeA());
|
appendModeLine(nc, script.getFileModeA());
|
||||||
appendModeLine(nc, script.getFileModeB());
|
appendModeLine(nc, script.getFileModeB());
|
||||||
@ -121,13 +113,14 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
if (hunk.isContextLine()) {
|
if (hunk.isContextLine()) {
|
||||||
openLine(nc);
|
openLine(nc);
|
||||||
final SafeHtml ctx = a.getSafeHtmlLine(hunk.getCurA());
|
final SafeHtml ctx = a.getSafeHtmlLine(hunk.getCurA());
|
||||||
appendLineText(nc, hunk.getCurA(), CONTEXT, ctx, false, false);
|
appendLineNumber(nc, hunk.getCurA(), false);
|
||||||
|
appendLineText(nc, CONTEXT, ctx, false, false);
|
||||||
if (ignoreWS && b.contains(hunk.getCurB())) {
|
if (ignoreWS && b.contains(hunk.getCurB())) {
|
||||||
appendLineText(nc, hunk.getCurB(), CONTEXT, b, hunk.getCurB(),
|
appendLineText(nc, CONTEXT, b, hunk.getCurB(), false);
|
||||||
false);
|
|
||||||
} else {
|
} else {
|
||||||
appendLineText(nc, hunk.getCurB(), CONTEXT, ctx, false, false);
|
appendLineText(nc, CONTEXT, ctx, false, false);
|
||||||
}
|
}
|
||||||
|
appendLineNumber(nc, hunk.getCurB(), true);
|
||||||
closeLine(nc);
|
closeLine(nc);
|
||||||
hunk.incBoth();
|
hunk.incBoth();
|
||||||
lines.add(new PatchLine(CONTEXT, hunk.getCurA(), hunk.getCurB()));
|
lines.add(new PatchLine(CONTEXT, hunk.getCurA(), hunk.getCurB()));
|
||||||
@ -140,21 +133,27 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
openLine(nc);
|
openLine(nc);
|
||||||
|
|
||||||
if (del) {
|
if (del) {
|
||||||
appendLineText(nc, hunk.getCurA(), DELETE, a, hunk.getCurA(), full);
|
appendLineNumber(nc, hunk.getCurA(), false);
|
||||||
|
appendLineText(nc, DELETE, a, hunk.getCurA(), full);
|
||||||
hunk.incA();
|
hunk.incA();
|
||||||
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
||||||
|
appendLineNumber(nc, false);
|
||||||
appendLineNone(nc, DELETE);
|
appendLineNone(nc, DELETE);
|
||||||
} else {
|
} else {
|
||||||
|
appendLineNumber(nc, false);
|
||||||
appendLineNone(nc, CONTEXT);
|
appendLineNone(nc, CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ins) {
|
if (ins) {
|
||||||
appendLineText(nc, hunk.getCurB(), INSERT, b, hunk.getCurB(), full);
|
appendLineText(nc, INSERT, b, hunk.getCurB(), full);
|
||||||
|
appendLineNumber(nc, hunk.getCurB(), true);
|
||||||
hunk.incB();
|
hunk.incB();
|
||||||
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
||||||
appendLineNone(nc, INSERT);
|
appendLineNone(nc, INSERT);
|
||||||
|
appendLineNumber(nc, true);
|
||||||
} else {
|
} else {
|
||||||
appendLineNone(nc, CONTEXT);
|
appendLineNone(nc, CONTEXT);
|
||||||
|
appendLineNumber(nc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeLine(nc);
|
closeLine(nc);
|
||||||
@ -229,13 +228,13 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
final PatchLineComment ac = ai.next();
|
final PatchLineComment ac = ai.next();
|
||||||
final PatchLineComment bc = bi.next();
|
final PatchLineComment bc = bi.next();
|
||||||
insertRow(row);
|
insertRow(row);
|
||||||
bindComment(row, COL_A, ac, !ai.hasNext(), expandComments);
|
bindComment(row, A, ac, !ai.hasNext(), expandComments);
|
||||||
bindComment(row, COL_B, bc, !bi.hasNext(), expandComments);
|
bindComment(row, B, bc, !bi.hasNext(), expandComments);
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
row = finish(ai, row, COL_A, expandComments);
|
row = finish(ai, row, A, expandComments);
|
||||||
row = finish(bi, row, COL_B, expandComments);
|
row = finish(bi, row, B, expandComments);
|
||||||
} else {
|
} else {
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
@ -246,10 +245,10 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
protected void insertRow(final int row) {
|
protected void insertRow(final int row) {
|
||||||
super.insertRow(row);
|
super.insertRow(row);
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
final CellFormatter fmt = table.getCellFormatter();
|
||||||
fmt.addStyleName(row, COL_A - 1, Gerrit.RESOURCES.css().lineNumber());
|
fmt.addStyleName(row, A - 1, Gerrit.RESOURCES.css().lineNumber());
|
||||||
fmt.addStyleName(row, COL_A, Gerrit.RESOURCES.css().diffText());
|
fmt.addStyleName(row, A, Gerrit.RESOURCES.css().diffText());
|
||||||
fmt.addStyleName(row, COL_B - 1, Gerrit.RESOURCES.css().lineNumber());
|
fmt.addStyleName(row, B, Gerrit.RESOURCES.css().diffText());
|
||||||
fmt.addStyleName(row, COL_B, Gerrit.RESOURCES.css().diffText());
|
fmt.addStyleName(row, B + 1, Gerrit.RESOURCES.css().lineNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int finish(final Iterator<PatchLineComment> i, int row, final int col, boolean expandComment) {
|
private int finish(final Iterator<PatchLineComment> i, int row, final int col, boolean expandComment) {
|
||||||
@ -294,11 +293,6 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
}
|
}
|
||||||
m.closeTd();
|
m.closeTd();
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
m.openTd();
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
m.setStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
||||||
m.setAttribute("width", "50%");
|
m.setAttribute("width", "50%");
|
||||||
@ -309,6 +303,11 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
}
|
}
|
||||||
m.closeTd();
|
m.closeTd();
|
||||||
|
|
||||||
|
m.openTd();
|
||||||
|
m.addStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
||||||
|
m.addStyleName(Gerrit.RESOURCES.css().lineNumber());
|
||||||
|
m.closeTd();
|
||||||
|
|
||||||
m.closeTr();
|
m.closeTr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,21 +335,21 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
m.closeTr();
|
m.closeTr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickHandler expandAllListener = new ClickHandler() {
|
private ClickHandler expandAllListener = new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
expand(event, 0);
|
expand(event, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClickHandler expandBeforeListener = new ClickHandler() {
|
private ClickHandler expandBeforeListener = new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
expand(event, NUM_ROWS_TO_EXPAND);
|
expand(event, NUM_ROWS_TO_EXPAND);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClickHandler expandAfterListener = new ClickHandler() {
|
private ClickHandler expandAfterListener = new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
expand(event, -NUM_ROWS_TO_EXPAND);
|
expand(event, -NUM_ROWS_TO_EXPAND);
|
||||||
@ -358,11 +357,11 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void expand(ClickEvent event, final int numRows) {
|
private void expand(ClickEvent event, final int numRows) {
|
||||||
Cell cell = table.getCellForEvent(event);
|
int row = table.getCellForEvent(event).getRowIndex();
|
||||||
int row = cell.getRowIndex();
|
|
||||||
if (!(getRowItem(row) instanceof SkippedLine)) {
|
if (!(getRowItem(row) instanceof SkippedLine)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkippedLine line = (SkippedLine) getRowItem(row);
|
SkippedLine line = (SkippedLine) getRowItem(row);
|
||||||
int loopTo = numRows;
|
int loopTo = numRows;
|
||||||
if (numRows == 0) {
|
if (numRows == 0) {
|
||||||
@ -374,6 +373,8 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
if (numRows < 0) {
|
if (numRows < 0) {
|
||||||
offset = 1;
|
offset = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CellFormatter fmt = table.getCellFormatter();
|
||||||
for (int i = 0 + offset; i < loopTo + offset; i++) {
|
for (int i = 0 + offset; i < loopTo + offset; i++) {
|
||||||
insertRow(row + i);
|
insertRow(row + i);
|
||||||
int lineA = line.getStartA() + i;
|
int lineA = line.getStartA() + i;
|
||||||
@ -382,21 +383,20 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
lineA = line.getStartA() + line.getSize() + numRows + i - offset;
|
lineA = line.getStartA() + line.getSize() + numRows + i - offset;
|
||||||
lineB = line.getStartB() + line.getSize() + numRows + i - offset;
|
lineB = line.getStartB() + line.getSize() + numRows + i - offset;
|
||||||
}
|
}
|
||||||
setHtml(row + i, 1, "<a href=\"javascript:void(0)\">" + (lineA + 1)
|
|
||||||
+ "</a>");
|
|
||||||
addStyle(row + i, 1, Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
|
|
||||||
setHtml(row + i, 2, a.getSafeHtmlLine(lineA).asString());
|
table.setHTML(row + i, A - 1, "<a href=\"javascript:;\">" + (lineA + 1) + "</a>");
|
||||||
addStyle(row + i, 2, Gerrit.RESOURCES.css().fileLine());
|
fmt.addStyleName(row + i, A - 1, Gerrit.RESOURCES.css().lineNumber());
|
||||||
addStyle(row + i, 2, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
|
||||||
|
|
||||||
setHtml(row + i, 3, "<a href=\"javascript:void(0)\">" + (lineB + 1)
|
table.setHTML(row + i, A, a.getSafeHtmlLine(lineA).asString());
|
||||||
+ "</a>");
|
fmt.addStyleName(row + i, A, Gerrit.RESOURCES.css().fileLine());
|
||||||
addStyle(row + i, 3, Gerrit.RESOURCES.css().lineNumber());
|
fmt.addStyleName(row + i, A, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
||||||
|
|
||||||
setHtml(row + i, 4, b.getSafeHtmlLine(lineB).asString());
|
table.setHTML(row + i, B, b.getSafeHtmlLine(lineB).asString());
|
||||||
addStyle(row + i, 4, Gerrit.RESOURCES.css().fileLine());
|
fmt.addStyleName(row + i, B, Gerrit.RESOURCES.css().fileLine());
|
||||||
addStyle(row + i, 4, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
fmt.addStyleName(row + i, B, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
||||||
|
|
||||||
|
table.setHTML(row + i, B + 1, "<a href=\"javascript:;\">" + (lineB + 1) + "</a>");
|
||||||
|
fmt.addStyleName(row + i, B + 1, Gerrit.RESOURCES.css().lineNumber());
|
||||||
|
|
||||||
setRowItem(row + i, new PatchLine(CONTEXT, lineA, lineB));
|
setRowItem(row + i, new PatchLine(CONTEXT, lineA, lineB));
|
||||||
}
|
}
|
||||||
@ -408,34 +408,41 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
line.reduceSize(-numRows);
|
line.reduceSize(-numRows);
|
||||||
createSkipLine(row, line);
|
createSkipLine(row, line);
|
||||||
} else {
|
} else {
|
||||||
removeRow(row + loopTo);
|
table.removeRow(row + loopTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSkipLine(int row, SkippedLine line) {
|
private void createSkipLine(int row, SkippedLine line) {
|
||||||
FlowPanel p = new FlowPanel();
|
FlowPanel p = new FlowPanel();
|
||||||
Label l1 = new Label(" " + PatchUtil.C.patchSkipRegionStart() + " ");
|
InlineLabel l1 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionStart() + " ");
|
||||||
|
InlineLabel l2 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionEnd() + " ");
|
||||||
|
|
||||||
Anchor all = new Anchor(String.valueOf(line.getSize()));
|
Anchor all = new Anchor(String.valueOf(line.getSize()));
|
||||||
Label l2 = new Label(" " + PatchUtil.C.patchSkipRegionEnd() + " ");
|
|
||||||
all.addClickHandler(expandAllListener);
|
all.addClickHandler(expandAllListener);
|
||||||
|
all.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
||||||
|
|
||||||
if (line.getSize() > 30) {
|
if (line.getSize() > 30) {
|
||||||
// We only show the expand before & after links if we skip more than
|
// Only show the expand before/after if skipped more than 30 lines.
|
||||||
// 30 lines.
|
Anchor b = new Anchor(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND), true);
|
||||||
Anchor before = new Anchor(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND));
|
Anchor a = new Anchor(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND), true);
|
||||||
before.addClickHandler(expandBeforeListener);
|
|
||||||
Anchor after = new Anchor(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND));
|
b.addClickHandler(expandBeforeListener);
|
||||||
after.addClickHandler(expandAfterListener);
|
a.addClickHandler(expandAfterListener);
|
||||||
p.add(before);
|
|
||||||
|
b.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
||||||
|
a.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
||||||
|
|
||||||
|
p.add(b);
|
||||||
p.add(l1);
|
p.add(l1);
|
||||||
p.add(all);
|
p.add(all);
|
||||||
p.add(l2);
|
p.add(l2);
|
||||||
p.add(after);
|
p.add(a);
|
||||||
} else {
|
} else {
|
||||||
p.add(l1);
|
p.add(l1);
|
||||||
p.add(all);
|
p.add(all);
|
||||||
p.add(l2);
|
p.add(l2);
|
||||||
}
|
}
|
||||||
setWidget(row, 1, p);
|
table.setWidget(row, 1, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openLine(final SafeHtmlBuilder m) {
|
private void openLine(final SafeHtmlBuilder m) {
|
||||||
@ -447,22 +454,34 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
m.closeTd();
|
m.closeTd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendLineText(final SafeHtmlBuilder m,
|
private void appendLineNumber(SafeHtmlBuilder m, boolean right) {
|
||||||
final int lineNumberMinusOne, final PatchLine.Type type,
|
m.openTd();
|
||||||
final SparseHtmlFile src, final int i, final boolean fullBlock) {
|
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
||||||
appendLineText(m, lineNumberMinusOne, type, //
|
if (right) {
|
||||||
src.getSafeHtmlLine(i), src.hasTrailingEdit(i), fullBlock);
|
m.addStyleName(Gerrit.RESOURCES.css().rightmost());
|
||||||
|
}
|
||||||
|
m.closeTd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendLineNumber(SafeHtmlBuilder m, int lineNumberMinusOne, boolean right) {
|
||||||
|
m.openTd();
|
||||||
|
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
||||||
|
if (right) {
|
||||||
|
m.addStyleName(Gerrit.RESOURCES.css().rightmost());
|
||||||
|
}
|
||||||
|
m.append(SafeHtml.asis("<a href=\"javascript:;\">"+ (lineNumberMinusOne + 1) + "</a>"));
|
||||||
|
m.closeTd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendLineText(final SafeHtmlBuilder m,
|
private void appendLineText(final SafeHtmlBuilder m,
|
||||||
final int lineNumberMinusOne, final PatchLine.Type type,
|
final PatchLine.Type type, final SparseHtmlFile src, final int i,
|
||||||
final SafeHtml lineHtml, final boolean trailingEdit,
|
|
||||||
final boolean fullBlock) {
|
final boolean fullBlock) {
|
||||||
m.openTd();
|
appendLineText(m, type, src.getSafeHtmlLine(i), src.hasTrailingEdit(i), fullBlock);
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
}
|
||||||
m.append(SafeHtml.asis("<a href=\"javascript:void(0)\">"+ (lineNumberMinusOne + 1) + "</a>"));
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
|
private void appendLineText(final SafeHtmlBuilder m,
|
||||||
|
final PatchLine.Type type, final SafeHtml lineHtml,
|
||||||
|
final boolean trailingEdit, final boolean fullBlock) {
|
||||||
m.openTd();
|
m.openTd();
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -487,10 +506,6 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void appendLineNone(final SafeHtmlBuilder m, final PatchLine.Type type) {
|
private void appendLineNone(final SafeHtmlBuilder m, final PatchLine.Type type) {
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
m.openTd();
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
||||||
switch (type != null ? type : PatchLine.Type.CONTEXT) {
|
switch (type != null ? type : PatchLine.Type.CONTEXT) {
|
||||||
|
Loading…
Reference in New Issue
Block a user