Live races ui - Show/hide fleet details dynamically

This commit is contained in:
Benjamin Barth committed 2015-05-18 14:52:34 +02:00
1 parent 944a3c3b0f
commit beb0564168
3 files changed
+27 -12

No files matched your search

@@ -27,7 +27,7 @@ public class RacesListLive extends Composite implements RefreshableWidget<LiveRa
@Override
public void setData(LiveRacesDTO data, long nextUpdate, int updateNo) {
this.raceList.setTableData(data.getRaces());
this.raceList.setListData(data);
}
}
@@ -21,6 +21,7 @@ import com.google.gwt.user.cellview.client.Header;
import com.google.gwt.user.cellview.client.RowStyles;
import com.google.gwt.user.cellview.client.TextHeader;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.sap.sailing.domain.common.InvertibleComparator;
import com.sap.sailing.domain.common.SortingOrder;
import com.sap.sailing.domain.common.impl.NaturalComparator;
@@ -69,24 +70,27 @@ public abstract class AbstractRaceList<T extends RaceMetadataDTO> extends Compos
SafeHtml windDirection(SafeStyles rotation);
}
private final SortedCellTable<T> cellTable = new SortedCellTable<T>(0, CleanCellTableResources.INSTANCE);
private final SimplePanel cellTableContainer = new SimplePanel();
private final EventView.Presenter presenter;
private SortedCellTable<T> cellTable;
protected AbstractRaceList(EventView.Presenter presenter) {
CSS.ensureInjected();
this.presenter = presenter;
this.initTableStyle();
this.initTableColumns();
this.initWidget(cellTable);
this.initWidget(cellTableContainer);
}
public void setTableData(List<T> data) {
protected void setTableData(List<T> data) {
this.cellTable = new SortedCellTable<T>(data.size(), CleanCellTableResources.INSTANCE);
this.cellTableContainer.setWidget(this.cellTable);
this.initTableStyle();
this.initTableColumns();
this.cellTable.setList(data);
this.cellTable.setPageSize(data.size());
this.cellTable.sort();
}
private void initTableStyle() {
CSS.ensureInjected();
this.cellTable.addStyleName(CSS.raceslist());
this.cellTable.setHeaderBuilder(new StyledHeaderOrFooterBuilder<T>(cellTable, false, CSS.raceslist_head()));
this.cellTable.setRowStyles(new RowStyles<T>() {
@@ -96,7 +100,7 @@ public abstract class AbstractRaceList<T extends RaceMetadataDTO> extends Compos
}
});
}
protected abstract void initTableColumns();
protected void addFleetCornerColumn() {
@@ -10,6 +10,7 @@ import com.sap.sailing.gwt.home.client.place.event.partials.raceListLive.RacesLi
import com.sap.sailing.gwt.home.client.place.event.partials.raceListLive.RacesListLiveResources.LocalCss;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.dispatch.event.LiveRaceDTO;
import com.sap.sailing.gwt.ui.shared.dispatch.event.LiveRacesDTO;
import com.sap.sailing.gwt.ui.shared.race.FlagStateDTO;
import com.sap.sailing.gwt.ui.shared.race.SimpleWindDTO;
import com.sap.sailing.gwt.ui.shared.util.NullSafeComparableComparator;
@@ -21,15 +22,23 @@ public class RaceList extends AbstractRaceList<LiveRaceDTO> {
private static final StringMessages I18N = StringMessages.INSTANCE;
private final boolean showRegattaDetails;
private boolean showFleetDetails;
public RaceList(EventView.Presenter presenter, boolean showRegattaDetails) {
super(presenter);
this.showRegattaDetails = showRegattaDetails;
}
public void setListData(LiveRacesDTO data) {
this.showFleetDetails = data.hasFleets();
setTableData(data.getRaces());
}
@Override
protected void initTableColumns() {
addFleetCornerColumn();
if (showFleetDetails) {
addFleetCornerColumn();
}
if (showRegattaDetails) {
add(new SortableRaceListColumn<String>(I18N.regatta(), new TextCell()) {
@@ -61,7 +70,9 @@ public class RaceList extends AbstractRaceList<LiveRaceDTO> {
}
addRaceNameColumn();
addFleetNameColumn();
if (showFleetDetails) {
addFleetNameColumn();
}
addStartTimeColumn();
add(new RaceListColumn<FlagStateDTO>(I18N.flags(), new FlagsCell()) {