Reimplemented the busy indicator to the leaderboard charts

This commit is contained in:
Lennart Hensler committed 2012-02-16 10:00:40 +01:00
1 parent 80fc3da396
commit 22d327651f
1 file changed
+23 -20
@@ -23,12 +23,13 @@ import org.moxieapps.gwt.highcharts.client.plotOptions.Marker;
import org.moxieapps.gwt.highcharts.client.plotOptions.ScatterPlotOptions;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.domain.common.DetailType;
@@ -49,6 +50,8 @@ import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
import com.sap.sailing.gwt.ui.shared.CompetitorInRaceDTO;
import com.sap.sailing.gwt.ui.shared.CompetitorsAndTimePointsDTO;
import com.sap.sailing.gwt.ui.shared.components.Component;
import com.sap.sailing.gwt.ui.shared.panels.BusyIndicator;
import com.sap.sailing.gwt.ui.shared.panels.SimpleBusyIndicator;
/**
* ChartPanel is a GWT panel that can show one sort of competitor data (e.g. current speed over ground, windward distance to
@@ -70,9 +73,9 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
protected final SailingServiceAsync sailingService;
protected final ErrorReporter errorReporter;
protected Chart chart;
protected final AbsolutePanel busyIndicatorPanel;
protected final Map<CompetitorDTO, Series> seriesByCompetitor;
protected final Map<CompetitorDTO, Series> markPassingSeriesByCompetitor;
protected final DeckPanel chartAndBusyIndicatorPanel;
protected final RaceSelectionProvider raceSelectionProvider;
protected long stepSize = 5000;
protected final StringMessages stringMessages;
@@ -80,7 +83,6 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
protected final Timer timer;
protected final DateTimeFormat dateFormat = DateTimeFormat.getFormat("HH:mm:ss");
protected DetailType dataToShow;
protected AbsolutePanel loadingPanel;
protected final CompetitorSelectionProvider competitorSelectionProvider;
public AbstractChartPanel(SailingServiceAsync sailingService,
@@ -95,22 +97,26 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
this.errorReporter = errorReporter;
chartData = new CompetitorInRaceDTO();
this.dataToShow = dataToShow;
chart = createChart(dataToShow);
seriesIsUsed = new HashSet<Series>();
this.sailingService = sailingService;
this.raceSelectionProvider = raceSelectionProvider;
raceSelectionProvider.addRaceSelectionChangeListener(this);
setWidget(chart);
loadingPanel = new AbsolutePanel();
loadingPanel.setSize("100%", "100%");
// BusyIndicator busyIndicator = new SimpleBusyIndicator(true, 1);
// loadingPanel.add(busyIndicator, width / 2 - 32 / 2, height / 2 - 32 - 2);
chartAndBusyIndicatorPanel = new DeckPanel();
// chartAndBusyIndicatorPanel.add(loadingPanel);
// chartAndBusyIndicatorPanel.add(chart);
// chartAndBusyIndicatorPanel.showWidget(0);
chart = createChart(dataToShow);
busyIndicatorPanel = new AbsolutePanel();
busyIndicatorPanel.setSize("100%", "100%");
final BusyIndicator busyIndicator = new SimpleBusyIndicator(/*busy*/ true, /*scale*/ 1);
//Adding the busyIndicator with an scheduler, to be sure that the busyIndicatorPanel has a width and a height
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
busyIndicatorPanel.add(busyIndicator, busyIndicatorPanel.getOffsetWidth() / 2,
busyIndicatorPanel.getOffsetHeight() / 2 - 40); //Adjusting the indictator to place it more in the middle
}
});
setWidget(busyIndicatorPanel);
List<RaceIdentifier> selectedRaces = raceSelectionProvider.getSelectedRaces();
if(!selectedRaces.isEmpty()) {
loadData();
@@ -158,7 +164,7 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
protected abstract Component<SettingsType> getComponent();
protected void loadData() {
// chartAndBusyIndicatorPanel.showWidget(0);
setWidget(busyIndicatorPanel);
if (getCompetitorsAndTimePointsDTO() != null) {
doLoadData();
} else {
@@ -211,7 +217,7 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
chartData.setMarkPassingData(competitor, result.getMarkPassings(competitor));
}
updateTableData(competitorsAndTimePointsToLoad.getCompetitors());
// chartAndBusyIndicatorPanel.showWidget(1);
setWidget(chart);
}
});
}
@@ -244,7 +250,7 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
private synchronized void updateTableData(CompetitorDTO[] competitorDTOs) {
//Make sure the busy indicator is removed at this point, or plotting the data results in an exception
// chartAndBusyIndicatorPanel.showWidget(1);
setWidget(chart);
if (getCompetitorsAndTimePointsDTO() != null && chartData != null) {
for (CompetitorDTO competitor : competitorDTOs) {
Series compSeries = getCompetitorSeries(competitor);
@@ -440,9 +446,6 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
if (dataToShow != this.dataToShow) {
this.dataToShow = dataToShow;
chart = createChart(dataToShow);
// if (chartAndBusyIndicatorPanel.getWidgetCount() > 1) {
// chartAndBusyIndicatorPanel.remove(1);
// }
this.setWidget(chart);
}
}