Revert "Change Size column to show +X, -Y instead of a bar"
This reverts commit d2fc715327.
Change-Id: I800e54d037d9872ce2665ce398c5dec84c8d71f4
This commit is contained in:
committed by
Edwin Kempin
parent
4863b97fad
commit
6c0cae6972
@@ -38,6 +38,7 @@ 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.Image;
|
||||
import com.google.gwt.user.client.ui.InlineLabel;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
@@ -236,8 +237,10 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
}
|
||||
int col = C_SIZE;
|
||||
if (useNewFeatures) {
|
||||
table.setText(row, col++,
|
||||
table.setWidget(row, col, getSizeWidget(c));
|
||||
fmt.getElement(row, col).setTitle(
|
||||
Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
|
||||
col++;
|
||||
}
|
||||
|
||||
boolean displayName = Gerrit.isSignedIn() && Gerrit.getUserAccount()
|
||||
@@ -314,6 +317,31 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
setRowItem(row, c);
|
||||
}
|
||||
|
||||
private static Widget getSizeWidget(ChangeInfo c) {
|
||||
int largeChangeSize = Gerrit.getConfig().getLargeChangeSize();
|
||||
int changedLines = c.insertions() + c.deletions();
|
||||
int p = 100;
|
||||
if (changedLines < largeChangeSize) {
|
||||
p = Math.round(changedLines * 100 / largeChangeSize);
|
||||
}
|
||||
|
||||
int width = Math.max(2, 70 * p / 100);
|
||||
int red = p > 50 ? 255 : (int) Math.round((p) * 5.12);
|
||||
int green = p < 50 ? 255 : (int) Math.round(256 - (p - 50) * 5.12);
|
||||
String bg = "#" + toHex(red) + toHex(green) + "00";
|
||||
|
||||
SimplePanel panel = new SimplePanel();
|
||||
panel.setStyleName(Gerrit.RESOURCES.css().changeSize());
|
||||
panel.setWidth(width + "px");
|
||||
panel.getElement().getStyle().setBackgroundColor(bg);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private static String toHex(int i) {
|
||||
String hex = Integer.toHexString(i);
|
||||
return hex.length() == 1 ? "0" + hex : hex;
|
||||
}
|
||||
|
||||
public void addSection(final Section s) {
|
||||
assert s.parent == null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user