QChris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64305


Change subject: Harmonize color of first data row for tables
......................................................................

Harmonize color of first data row for tables

While we allow to set alternating background colors for table rows,
some table sections start the data rows on an even row
(e.g.: "Projects/List"), some start on an odd row
(e.g.: "My/Changes/Outgoing reviews"). So when using a dark trim
color, and bright and dark table row colors, one of the two examples
above starts with two dark rows (first dark row due to trimColor,
second dark row due to first data row being on odd/even row), which
looks ugly.
As for most tables the data rows begin at even row numbers (in CSS
counting), we add invisible rows prior to data rows to assure that the
first data row is on an even row number (in CSS counting).

Change-Id: I279289de5f54bfa10520cb6e16696bf7da8a8ba4
---
M gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable.java
M gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable2.java
2 files changed, 69 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/gerrit refs/changes/05/64305/1

diff --git 
a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable.java 
b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable.java
index 3a65d20..323295a 100644
--- 
a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable.java
+++ 
b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable.java
@@ -32,6 +32,7 @@
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.dom.client.KeyPressEvent;
 import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
+import com.google.gwt.user.client.ui.HTMLTable;
 import com.google.gwt.user.client.ui.HTMLTable.Cell;
 import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
 
@@ -200,9 +201,11 @@
     }
 
     s.parent = this;
+    s.parityCorrectingRow = -1;
     s.dataBegin = table.getRowCount();
     insertNoneRow(s.dataBegin);
     sections.add(s);
+    correctRowParities();
   }
 
   public void setAccountInfoCache(final AccountInfoCache aic) {
@@ -214,6 +217,9 @@
     for (final Section s : sections) {
       if (beforeRow <= s.titleRow) {
         s.titleRow++;
+      }
+      if (beforeRow <= s.parityCorrectingRow) {
+        s.parityCorrectingRow++;
       }
       if (beforeRow < s.dataBegin) {
         s.dataBegin++;
@@ -227,11 +233,33 @@
       if (row < s.titleRow) {
         s.titleRow--;
       }
+      if (row < s.parityCorrectingRow) {
+        s.parityCorrectingRow--;
+      }
       if (row < s.dataBegin) {
         s.dataBegin--;
       }
     }
     table.removeRow(row);
+  }
+
+  private void correctRowParities() {
+    for (final Section s : sections) {
+      if (s.dataBegin % 2 == 0) {
+        if (s.parityCorrectingRow == -1) {
+          insertRow(s.dataBegin);
+          s.parityCorrectingRow = s.dataBegin;
+          s.dataBegin++;
+          final FlexCellFormatter fmt = table.getFlexCellFormatter();
+          fmt.setColSpan(s.parityCorrectingRow, 0, COLUMNS);
+          final HTMLTable.RowFormatter fmtRow = table.getRowFormatter();
+          fmtRow.setVisible(s.parityCorrectingRow, false);
+        } else {
+          removeRow(s.parityCorrectingRow);
+          s.parityCorrectingRow = -1;
+        }
+      }
+    }
   }
 
   public class StarKeyCommand extends NeedsSignInKeyCommand {
@@ -263,6 +291,7 @@
     ChangeTable parent;
     final Account.Id ownerId;
     int titleRow = -1;
+    int parityCorrectingRow = -1;
     int dataBegin;
     int rows;
 
@@ -325,6 +354,7 @@
           cids.add(c.getId());
         }
       }
+      parent.correctRowParities();
     }
   }
 
diff --git 
a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable2.java 
b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable2.java
index 54dce43..9e480a0 100644
--- 
a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable2.java
+++ 
b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeTable2.java
@@ -36,6 +36,7 @@
 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;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.InlineLabel;
 import com.google.gwt.user.client.ui.UIObject;
@@ -308,15 +309,20 @@
       s.titleRow = -1;
     }
 
+    s.parityCorrectingRow = -1;
     s.dataBegin = table.getRowCount();
     insertNoneRow(s.dataBegin);
     sections.add(s);
+    correctRowParities();
   }
 
   private int insertRow(final int beforeRow) {
     for (final Section s : sections) {
       if (beforeRow <= s.titleRow) {
         s.titleRow++;
+      }
+      if (beforeRow <= s.parityCorrectingRow) {
+        s.parityCorrectingRow++;
       }
       if (beforeRow < s.dataBegin) {
         s.dataBegin++;
@@ -330,11 +336,33 @@
       if (row < s.titleRow) {
         s.titleRow--;
       }
+      if (row < s.parityCorrectingRow) {
+        s.parityCorrectingRow--;
+      }
       if (row < s.dataBegin) {
         s.dataBegin--;
       }
     }
     table.removeRow(row);
+  }
+
+  private void correctRowParities() {
+    for (final Section s : sections) {
+      if (s.dataBegin % 2 == 0) {
+        if (s.parityCorrectingRow == -1) {
+          insertRow(s.dataBegin);
+          s.parityCorrectingRow = s.dataBegin;
+          s.dataBegin++;
+          final FlexCellFormatter fmt = table.getFlexCellFormatter();
+          fmt.setColSpan(s.parityCorrectingRow, 0, columns);
+          final HTMLTable.RowFormatter fmtRow = table.getRowFormatter();
+          fmtRow.setVisible(s.parityCorrectingRow, false);
+        } else {
+          removeRow(s.parityCorrectingRow);
+          s.parityCorrectingRow = -1;
+        }
+      }
+    }
   }
 
   public class StarKeyCommand extends NeedsSignInKeyCommand {
@@ -369,6 +397,7 @@
     String titleText;
     Widget titleWidget;
     int titleRow = -1;
+    int parityCorrectingRow = -1;
     int dataBegin;
     int rows;
     private boolean highlightUnreviewed;
@@ -419,17 +448,17 @@
 
       if (sz == 0) {
         parent.insertNoneRow(dataBegin);
-        return;
+      } else {
+        while (rows < sz) {
+          parent.insertChangeRow(dataBegin + rows);
+          rows++;
+        }
+        for (int i = 0; i < sz; i++) {
+          parent.populateChangeRow(dataBegin + i, changeList.get(i),
+              highlightUnreviewed);
+        }
       }
-
-      while (rows < sz) {
-        parent.insertChangeRow(dataBegin + rows);
-        rows++;
-      }
-      for (int i = 0; i < sz; i++) {
-        parent.populateChangeRow(dataBegin + i, changeList.get(i),
-            highlightUnreviewed);
-      }
+      parent.correctRowParities();
     }
   }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/64305
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I279289de5f54bfa10520cb6e16696bf7da8a8ba4
Gerrit-PatchSet: 1
Gerrit-Project: gerrit
Gerrit-Branch: wmf
Gerrit-Owner: QChris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to