Softly grey the common part of paths in ChangeScreen2
When displaying the table of file paths, grey out the part that is common with the prior row. This makes changes in packages more visible as the uncommon prefix on the next row will be black rather than the softer grey color. For example the common prefix in () would be grey: gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java gerrit-server/src/main/java/com/google/gerrit/server/ change/GetContent.java (gerrit-server/src/main/java/com/google/gerrit/server/)project/GarbageCollect.java Change-Id: Ia63d79fe56c023838dc091fcfe5db8d30337616e
This commit is contained in:
@@ -71,6 +71,7 @@ class FileTable extends FlowPanel {
|
||||
String commentColumn();
|
||||
String deltaColumn1();
|
||||
String deltaColumn2();
|
||||
String commonPrefix();
|
||||
String inserted();
|
||||
String deleted();
|
||||
}
|
||||
@@ -323,6 +324,7 @@ class FileTable extends FlowPanel {
|
||||
private int row;
|
||||
private double start;
|
||||
private ProgressBar meter;
|
||||
private String lastPath = "";
|
||||
|
||||
private int inserted;
|
||||
private int deleted;
|
||||
@@ -448,14 +450,42 @@ class FileTable extends FlowPanel {
|
||||
.setStyleName(R.css().pathColumn())
|
||||
.openAnchor()
|
||||
.setAttribute("href", "#" + url(info))
|
||||
.setAttribute("onclick", OPEN + "(event," + info._row() + ")")
|
||||
.append(Patch.COMMIT_MSG.equals(info.path())
|
||||
? Util.C.commitMessage()
|
||||
: info.path())
|
||||
.closeAnchor()
|
||||
.setAttribute("onclick", OPEN + "(event," + info._row() + ")");
|
||||
|
||||
String path = info.path();
|
||||
if (Patch.COMMIT_MSG.equals(path)) {
|
||||
sb.append(Util.C.commitMessage());
|
||||
} else {
|
||||
int commonPrefixLen = commonPrefix(path);
|
||||
if (commonPrefixLen > 0) {
|
||||
sb.openSpan().setStyleName(R.css().commonPrefix())
|
||||
.append(path.substring(0, commonPrefixLen))
|
||||
.closeSpan();
|
||||
}
|
||||
sb.append(path.substring(commonPrefixLen));
|
||||
lastPath = path;
|
||||
}
|
||||
|
||||
sb.closeAnchor()
|
||||
.closeTd();
|
||||
}
|
||||
|
||||
private int commonPrefix(String path) {
|
||||
for (int n = path.length(); n > 0;) {
|
||||
int s = path.lastIndexOf('/', n);
|
||||
if (s < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String p = path.substring(0, s + 1);
|
||||
if (lastPath.startsWith(p)) {
|
||||
return s + 1;
|
||||
}
|
||||
n = s - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void columnComments(SafeHtmlBuilder sb, FileInfo info) {
|
||||
JsArray<CommentInfo> cList = get(info.path(), comments);
|
||||
JsArray<CommentInfo> dList = get(info.path(), drafts);
|
||||
|
@@ -23,6 +23,12 @@
|
||||
white-space: nowrap;
|
||||
min-width: 600px;
|
||||
}
|
||||
.pathColumn a {
|
||||
color: #000;
|
||||
}
|
||||
.commonPrefix {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.draftColumn,
|
||||
.newColumn,
|
||||
|
Reference in New Issue
Block a user