Merge "Change Screen: Allow to configure display of size details in file list"
diff --git a/Documentation/user-review-ui.txt b/Documentation/user-review-ui.txt
index ab1070a..b36792f 100644
--- a/Documentation/user-review-ui.txt
+++ b/Documentation/user-review-ui.txt
@@ -350,21 +350,26 @@
image::images/user-review-ui-change-screen-file-list-comments.png[width=800, link="images/user-review-ui-change-screen-file-list-comments.png"]
[[size]]
-The size of the modifications in the files can be seen in the `Size`
-column. The footer row shows the total size of the change.
-
-For files, the `Size` column shows the sum of inserted and deleted
-lines as one number. For the total size, inserted and deleted lines are
-shown separately. In addition, the number of insertions and deletions
-is shown as a bar. The size of the bar indicates the amount of changed
-lines, and its coloring in green and red shows the proportion of
-insertions to deletions.
+The size of the modifications in the files can be seen in the `Size` column. The
+footer row shows the total size of the change.
The size information is useful to easily spot the files that contain
the most modifications; these files are likely to be the most relevant
files for this change. The total change size gives an estimate of how
long a review of this change may take.
+When the "Show Change Sizes As Colored Bars" user preference is enabled, the
+`Size` column shows the sum of inserted and deleted lines as one number. In
+addition, the change size is shown as a bar. The size of the bar indicates the
+amount of changed lines, and its coloring shows the proportion of insertions
+(green) to deletions (red).
+
+When the "Show Change Sizes As Colored Bars" user preference is disabled, the
+colored bar is not shown. For added and renamed files, the `Size` column
+shows the number of inserted and deleted lines. For new files, the column only
+shows the total number of lines in the new file. No size is shown for binary
+files and deleted files.
+
image::images/user-review-ui-change-screen-file-list-size.png[width=800, link="images/user-review-ui-change-screen-file-list-size.png"]
[[diff-against]]
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
index 5596ace..36cb765 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties
@@ -21,7 +21,7 @@
contextWholeFile = Whole File
buttonSaveChanges = Save Changes
showRelativeDateInChangeTable = Show Relative Dates In Changes Table
-showSizeBarInChangeTable = Show Change Sizes As Colored Bars In Changes Table
+showSizeBarInChangeTable = Show Change Sizes As Colored Bars
showLegacycidInChangeTable = Show Change Number In Changes Table
muteCommonPathPrefixes = Mute Common Path Prefixes In File List
myMenu = My Menu
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/FileTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/FileTable.java
index d0038e3..fc62c46 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/FileTable.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/FileTable.java
@@ -442,6 +442,7 @@
private final NativeMap<JsArray<CommentInfo>> comments;
private final NativeMap<JsArray<CommentInfo>> drafts;
private final boolean hasUser;
+ private final boolean showChangeSizeBars;
private boolean attached;
private int row;
private double start;
@@ -462,6 +463,8 @@
this.comments = comments;
this.drafts = drafts;
this.hasUser = Gerrit.isSignedIn();
+ this.showChangeSizeBars = !hasUser
+ || Gerrit.getUserAccount().getGeneralPreferences().isSizeBarInChangeTable();
myTable.addStyleName(R.css().table());
}
@@ -721,14 +724,27 @@
private void columnDelta1(SafeHtmlBuilder sb, FileInfo info) {
sb.openTd().setStyleName(R.css().deltaColumn1());
if (!Patch.COMMIT_MSG.equals(info.path()) && !info.binary()) {
- sb.append(info.lines_inserted() + info.lines_deleted());
+ if (showChangeSizeBars) {
+ sb.append(info.lines_inserted() + info.lines_deleted());
+ } else if (!ChangeType.DELETED.matches(info.status())) {
+ if (ChangeType.ADDED.matches(info.status())) {
+ sb.append(info.lines_inserted())
+ .append(" lines");
+ } else {
+ sb.append("+")
+ .append(info.lines_inserted())
+ .append(", -")
+ .append(info.lines_deleted());
+ }
+ }
}
sb.closeTd();
}
private void columnDelta2(SafeHtmlBuilder sb, FileInfo info) {
sb.openTd().setStyleName(R.css().deltaColumn2());
- if (!Patch.COMMIT_MSG.equals(info.path()) && !info.binary()
+ if (showChangeSizeBars
+ && !Patch.COMMIT_MSG.equals(info.path()) && !info.binary()
&& (info.lines_inserted() != 0 || info.lines_deleted() != 0)) {
int w = 80;
int t = inserted + deleted;
@@ -775,26 +791,28 @@
// delta2
sb.openTh().setStyleName(R.css().deltaColumn2());
- int w = 80;
- int t = inserted + deleted;
- int i = Math.max(1, (int) (((double) w) * inserted / t));
- int d = Math.max(1, (int) (((double) w) * deleted / t));
- if (i + d > w && i > d) {
- i = w - d;
- } else if (i + d > w && d > i) {
- d = w - i;
- }
- if (0 < inserted) {
- sb.openDiv()
- .setStyleName(R.css().inserted())
- .setAttribute("style", "width:" + i + "px")
- .closeDiv();
- }
- if (0 < deleted) {
- sb.openDiv()
- .setStyleName(R.css().deleted())
- .setAttribute("style", "width:" + d + "px")
+ if (showChangeSizeBars) {
+ int w = 80;
+ int t = inserted + deleted;
+ int i = Math.max(1, (int) (((double) w) * inserted / t));
+ int d = Math.max(1, (int) (((double) w) * deleted / t));
+ if (i + d > w && i > d) {
+ i = w - d;
+ } else if (i + d > w && d > i) {
+ d = w - i;
+ }
+ if (0 < inserted) {
+ sb.openDiv()
+ .setStyleName(R.css().inserted())
+ .setAttribute("style", "width:" + i + "px")
.closeDiv();
+ }
+ if (0 < deleted) {
+ sb.openDiv()
+ .setStyleName(R.css().deleted())
+ .setAttribute("style", "width:" + d + "px")
+ .closeDiv();
+ }
}
sb.closeTh();