mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 02:13:55 +00:00
Refactored the RaceMap to a SimplePanel and implemented the
RequiresDataInitialization methods
This commit is contained in:
1 parent
0a2cc4950e
commit
d123b97a4b
3 files changed
+12
-8
No files matched your search
+10
-6
@@ -37,7 +37,7 @@ import com.google.gwt.maps.client.overlay.Polyline;
|
||||
import com.google.gwt.maps.client.overlay.PolylineOptions;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.Panel;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.ManeuverType;
|
||||
@@ -66,7 +66,7 @@ import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.components.Component;
|
||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class RaceMap implements TimeListener, CompetitorSelectionChangeListener, RaceSelectionChangeListener,
|
||||
public class RaceMap extends SimplePanel implements TimeListener, CompetitorSelectionChangeListener, RaceSelectionChangeListener,
|
||||
Component<RaceMapSettings>, RequiresDataInitialization {
|
||||
protected MapWidget map;
|
||||
|
||||
@@ -169,6 +169,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
|
||||
public RaceMap(SailingServiceAsync sailingService, ErrorReporter errorReporter, Timer timer,
|
||||
CompetitorSelectionProvider competitorSelection, StringMessages stringMessages) {
|
||||
this.setSize("100%", "100%");
|
||||
this.stringMessages = stringMessages;
|
||||
this.sailingService = sailingService;
|
||||
this.errorReporter = errorReporter;
|
||||
@@ -185,6 +186,8 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
competitorSelection.addCompetitorSelectionChangeListener(this);
|
||||
settings = new RaceMapSettings();
|
||||
lastTimeChangeBeforeInitialization = null;
|
||||
dataInitialized = false;
|
||||
initializeData();
|
||||
}
|
||||
|
||||
public double calculateDistance(double lat1, double lng1, double lat2, double lng2) {
|
||||
@@ -201,7 +204,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
return dist;
|
||||
}
|
||||
|
||||
public void loadMapsAPI(final Panel parentPanel) {
|
||||
private void loadMapsAPI() {
|
||||
Maps.loadMapsApi(mapsAPIKey, "2", false, new Runnable() {
|
||||
public void run() {
|
||||
map = new MapWidget();
|
||||
@@ -212,7 +215,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
// Add the map to the HTML host page
|
||||
map.setScrollWheelZoomEnabled(true);
|
||||
map.setContinuousZoom(true);
|
||||
parentPanel.add(map);
|
||||
RaceMap.this.add(map);
|
||||
map.setSize("100%", "100%");
|
||||
map.addMapZoomEndHandler(new MapZoomEndHandler() {
|
||||
@Override
|
||||
@@ -248,6 +251,8 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
timeChanged(lastTimeChangeBeforeInitialization);
|
||||
lastTimeChangeBeforeInitialization = null;
|
||||
}
|
||||
//Data has been initialized
|
||||
RaceMap.this.dataInitialized = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1207,8 +1212,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
|
||||
@Override
|
||||
public void initializeData() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
loadMapsAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
|
||||
mapPanel.setSize("100%", "100%");
|
||||
grid.setWidget(2, 1, mapPanel);
|
||||
raceMap = new RaceMap(sailingService, errorReporter, timer, competitorSelectionProvider, stringMessages);
|
||||
raceMap.loadMapsAPI(mapPanel);
|
||||
mapPanel.add(raceMap);
|
||||
raceSelectionModel = new RaceSelectionModel();
|
||||
raceListBox = new RacesListBoxPanel(eventRefresher, raceSelectionModel, stringMessages);
|
||||
raceSelectionModel.addRaceSelectionChangeListener(this);
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public class RaceBoardPanel extends FormPanel implements EventDisplayer, RaceSel
|
||||
CollapsableComponentViewer<RaceMapSettings> raceMapViewer = new CollapsableComponentViewer<RaceMapSettings>(
|
||||
raceMap, "auto", "500px", stringMessages);
|
||||
|
||||
raceMap.loadMapsAPI((Panel) raceMapViewer.getViewerWidget().getContent());
|
||||
((Panel) raceMapViewer.getViewerWidget().getContent()).add(raceMap);
|
||||
raceMap.onRaceSelectionChange(Collections.singletonList(selectedRaceIdentifier));
|
||||
collapsableViewers.add(raceMapViewer);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user