Make dashboard section headers link to their searches
This link enables a section to be expanded fully when a search is limited. It also makes it easier to debug or copy a section's query. Change-Id: Iac9dd6c834e8c67d595abd4ae1198f4b18101a5d
This commit is contained in:
@@ -38,6 +38,7 @@ 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.UIObject;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -292,9 +293,9 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
public void addSection(final Section s) {
|
||||
assert s.parent == null;
|
||||
|
||||
if (s.titleText != null) {
|
||||
s.titleRow = table.getRowCount();
|
||||
table.setText(s.titleRow, 0, s.titleText);
|
||||
s.parent = this;
|
||||
s.titleRow = table.getRowCount();
|
||||
if (s.displayTitle()) {
|
||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||
fmt.setColSpan(s.titleRow, 0, columns);
|
||||
fmt.addStyleName(s.titleRow, 0, Gerrit.RESOURCES.css().sectionHeader());
|
||||
@@ -302,7 +303,6 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
s.titleRow = -1;
|
||||
}
|
||||
|
||||
s.parent = this;
|
||||
s.dataBegin = table.getRowCount();
|
||||
insertNoneRow(s.dataBegin);
|
||||
sections.add(s);
|
||||
@@ -362,6 +362,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
public static class Section {
|
||||
ChangeTable2 parent;
|
||||
String titleText;
|
||||
Widget titleWidget;
|
||||
int titleRow = -1;
|
||||
int dataBegin;
|
||||
int rows;
|
||||
@@ -373,11 +374,31 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
|
||||
|
||||
public void setTitleText(final String text) {
|
||||
titleText = text;
|
||||
titleWidget = null;
|
||||
if (titleRow >= 0) {
|
||||
parent.table.setText(titleRow, 0, titleText);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitleWidget(final Widget title) {
|
||||
titleWidget = title;
|
||||
titleText = null;
|
||||
if (titleRow >= 0) {
|
||||
parent.table.setWidget(titleRow, 0, title);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean displayTitle() {
|
||||
if (titleText != null) {
|
||||
setTitleText(titleText);
|
||||
return true;
|
||||
} else if(titleWidget != null) {
|
||||
setTitleWidget(titleWidget);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void display(ChangeList changeList) {
|
||||
final int sz = changeList != null ? changeList.size() : 0;
|
||||
final boolean hadData = rows > 0;
|
||||
|
||||
@@ -17,7 +17,9 @@ package com.google.gerrit.client.changes;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.rpc.NativeList;
|
||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gwt.http.client.URL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -61,9 +63,10 @@ public class CustomDashboardScreen extends Screen implements ChangeListScreen {
|
||||
table.addStyleName(Gerrit.RESOURCES.css().accountDashboard());
|
||||
|
||||
sections = new ArrayList<ChangeTable2.Section>();
|
||||
int i = 0;
|
||||
for (String title : titles) {
|
||||
ChangeTable2.Section s = new ChangeTable2.Section();
|
||||
s.setTitleText(title);
|
||||
s.setTitleWidget(new InlineHyperlink(title, PageLinks.toChangeQuery(queries.get(i++))));
|
||||
table.addSection(s);
|
||||
sections.add(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user