Added new notifications and the time slider is now only expanded if the selected mark needs it

This commit is contained in:
Jonas Dann committed 2016-02-12 14:50:53 +01:00
1 parent 700db4a4ef
commit 335ebef7d6
6 files changed
+108 -52

No files matched your search

+5 -4
View File
@@ -778,7 +778,7 @@ img.openColumn {
font-weight: bold;
padding: 15px 25px;
background-color: #efab00;
border: 1px solid #e5e5e5;
border: 1px solid gray;
}
.EditMarkPositionConfirmCancelButtons .gwt-MenuItem:hover {
@@ -792,11 +792,12 @@ img.openColumn {
.EditMarkPositionNotification > div {
margin: 80px;
color: #f33;
font-weight: bold;
font-size: 15px;
padding: 20px;
max-width: 500px;
text-align: center;
background-color: #fff;
line-height: 130%;
}
.EditMarkPositionMarkTable {
@@ -810,7 +811,7 @@ img.openColumn {
width: 100%;
font-size: 12px;
font-weight: bold;
border: 1px solid #e5e5e5;
border: 1px solid gray;
background-color: #efab00;
padding: 7px;
color: #fff;
@@ -428,10 +428,10 @@ public class TimePanel<T extends TimePanelSettings> extends SimplePanel implemen
assert min != null && max != null;
boolean changed = false;
if (!max.equals(timeRangeProvider.getToTime()) || !min.equals(timeRangeProvider.getFromTime())) {
//if (!max.equals(timeRangeProvider.getToTime()) || !min.equals(timeRangeProvider.getFromTime())) {
changed = true;
timeSlider.setMinAndMaxValue(new Double(min.getTime()),new Double(max.getTime()), fireEvent);
}
//}
if (changed) {
if (!timeRangeProvider.isZoomed()) {
timeRangeProvider.setTimeRange(min, max, this);
@@ -529,6 +529,7 @@ public class TimePanel<T extends TimePanelSettings> extends SimplePanel implemen
@Override
public void onTimeRangeChanged(Date fromTime, Date toTime) {
setMinMax(fromTime, toTime, true);
}
protected boolean isLiveModeToBeMadePossible() {
@@ -179,20 +179,22 @@ public abstract class AbstractRaceChart extends AbsolutePanel implements TimeLis
}
protected void changeMinMaxAndExtremesInterval(Date minTimepoint, Date maxTimepoint, boolean redraw) {
XAxis xAxis = chart.getXAxis();
if (minTimepoint != null) {
xAxis.setMin(minTimepoint.getTime());
}
if (maxTimepoint != null) {
xAxis.setMax(maxTimepoint.getTime());
}
if (minTimepoint != null && maxTimepoint != null) {
xAxis.setExtremes(minTimepoint.getTime(), maxTimepoint.getTime(), false, false);
long tickInterval = (maxTimepoint.getTime() - minTimepoint.getTime()) / TICKCOUNT;
xAxis.setTickInterval(tickInterval);
}
if (redraw) {
chart.redraw();
if (chart != null) {
XAxis xAxis = chart.getXAxis();
if (minTimepoint != null) {
xAxis.setMin(minTimepoint.getTime());
}
if (maxTimepoint != null) {
xAxis.setMax(maxTimepoint.getTime());
}
if (minTimepoint != null && maxTimepoint != null) {
xAxis.setExtremes(minTimepoint.getTime(), maxTimepoint.getTime(), false, false);
long tickInterval = (maxTimepoint.getTime() - minTimepoint.getTime()) / TICKCOUNT;
xAxis.setTickInterval(tickInterval);
}
if (redraw) {
chart.redraw();
}
}
}
@@ -39,6 +39,8 @@ import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.base.LatLng;
import com.google.gwt.maps.client.base.LatLngBounds;
import com.google.gwt.maps.client.controls.ControlPosition;
import com.google.gwt.maps.client.events.click.ClickMapEvent;
import com.google.gwt.maps.client.events.click.ClickMapHandler;
import com.google.gwt.maps.client.events.mousedown.MouseDownMapEvent;
import com.google.gwt.maps.client.events.mousedown.MouseDownMapHandler;
import com.google.gwt.maps.client.events.mousemove.MouseMoveMapEvent;
@@ -77,6 +79,7 @@ import com.sap.sailing.gwt.ui.raceboard.SideBySideComponentViewer;
import com.sap.sailing.gwt.ui.shared.GPSFixDTO;
import com.sap.sailing.gwt.ui.shared.MarkDTO;
import com.sap.sailing.gwt.ui.shared.WindDTO;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.settings.AbstractSettings;
import com.sap.sse.gwt.client.ErrorReporter;
import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
@@ -95,6 +98,11 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
private final Label noMarkSelectedLabel;
private MapWidget map;
private boolean visible;
private List<HandlerRegistration> courseMarkClickHandlers;
private Map<MarkDTO, Pair<Date, Date>> marksFromToTimes;
private Date raceFromTime;
private Date raceToTime;
private Map<MarkDTO, SortedMap<GPSFixDTO, FixOverlay>> marks;
private MarkDTO selectedMark;
@@ -105,8 +113,6 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
private FixPositionChooser currentFixPositionChooser;
private List<OverlayClickHandler> overlayClickHandlers;
//TODO: Extend timeslider when there are fixes outside the current slider
//TODO: Select mark in table when it is clicked on on the map
public EditMarkPositionPanel(final RaceMap raceMap, final LeaderboardPanel leaderboardPanel,
RegattaAndRaceIdentifier selectedRaceIdentifier, String leaderboardName, final StringMessages stringMessages,
SailingServiceAsync sailingService, Timer timer, TimeRangeWithZoomProvider timeRangeWithZoomProvider,
@@ -114,12 +120,14 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
super(sailingService, timer, timeRangeWithZoomProvider, stringMessages, asyncActionsExecutor, errorReporter);
this.raceMap = raceMap;
this.leaderboardPanel = leaderboardPanel;
this.polylines = new HashMap<MarkDTO, Polyline>();
this.polylines = new HashMap<>();
this.markDataProvider = new ListDataProvider<>();
this.marksPanel = new MarksPanel(this, markDataProvider, stringMessages);
this.noMarkSelectedLabel = new Label("Please select a mark from the list on the left.");
this.noMarkSelectedLabel.setStyleName("abstractChartPanel-importantMessageOfChart");
this.selectedRaceIdentifier = selectedRaceIdentifier;
this.courseMarkClickHandlers = new ArrayList<>();
this.marksFromToTimes = new HashMap<>();
this.getEntryWidget().setTitle(stringMessages.editMarkPositions());
this.setVisible(false);
@@ -198,10 +206,11 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
MarkDTO mark = new MarkDTO("test1", "Three Fixes");
mark.color = "#0f0";
List<GPSFixDTO> fixes = new ArrayList<>();
fixes.add(new GPSFixDTO(new Date(1453140600000l), new DegreePosition(53.54, 9.98), null, new WindDTO(), null, null, false));
fixes.add(new GPSFixDTO(new Date(1453110600000l), new DegreePosition(53.54, 9.98), null, new WindDTO(), null, null, false));
fixes.add(new GPSFixDTO(new Date(1453141600000l), new DegreePosition(53.531, 9.99), null, new WindDTO(), null, null, false));
fixes.add(new GPSFixDTO(new Date(1453142600000l), new DegreePosition(53.5323, 10), null, new WindDTO(), null, null, false));
fixes.add(new GPSFixDTO(new Date(1453142400000l), new DegreePosition(53.54, 10.01), null, new WindDTO(), null, null, false));
fixes.add(new GPSFixDTO(new Date(1453144400000l), new DegreePosition(53.53, 10.01), null, new WindDTO(), null, null, false));
//final double COUNT = 1000;
//for (double i = 0; i < COUNT; i++) {
// fixes.add(new GPSFixDTO(new Date(1453141600000l + (long)(i * 1000000d / COUNT)), new DegreePosition(53.531 + i * 1d / COUNT, 9.99), null, new WindDTO(), null, null, false));
@@ -245,7 +254,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
private MarkPositionService serviceMock = new MarkPositionServiceMock();
private boolean canRemoveMarkFix(MarkDTO mark, GPSFixDTO fix) {
return serviceMock.canRemoveMarkFix("", "", "", mark, fix); //TODO: Readd code for leaderBoardname, ...
return serviceMock.canRemoveMarkFix("", "", "", mark, fix);
}
private static class Pixel extends JavaScriptObject {
@@ -362,7 +371,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
overlay.setVisible(false);
if (currentFixPositionChooser == null) {
OverlayClickHandler.this.unregisterAll();
currentFixPositionChooser = new FixPositionChooser(map, getIndexOfFixInPolyline(mark, fix), polyline.getPath(), overlay, new Callback<Position, Exception>() {
currentFixPositionChooser = new FixPositionChooser(EditMarkPositionPanel.this, map, getIndexOfFixInPolyline(mark, fix), polyline.getPath(), overlay, new Callback<Position, Exception>() {
@Override
public void onFailure(Exception reason) {
overlay.setVisible(true);
@@ -479,7 +488,11 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
showLoading("Loading mark fixes...");
Map<MarkDTO, List<GPSFixDTO>> result = serviceMock.getMarkTracks("", "", "");
marks = new HashMap<MarkDTO, SortedMap<GPSFixDTO, FixOverlay>>();
raceFromTime = timeRangeWithZoomProvider.getFromTime();
raceToTime = timeRangeWithZoomProvider.getToTime();
for (final Map.Entry<MarkDTO, List<GPSFixDTO>> fixes : result.entrySet()) {
Date fromTime = raceFromTime;
Date toTime = raceToTime;
PolylineOptions options = PolylineOptions.newInstance();
if (map != null) {
options.setMap(map);
@@ -505,14 +518,15 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
overlay.setVisible(false);
overlayClickHandlers.add(new OverlayClickHandler(fixes.getKey(), fix, overlay).register());
if (fix.timepoint.before(timeRangeWithZoomProvider.getFromTime())) {
timeRangeWithZoomProvider.setTimeRange(fix.timepoint, timeRangeWithZoomProvider.getToTime());
} else if (fix.timepoint.after(timeRangeWithZoomProvider.getToTime())) {
timeRangeWithZoomProvider.setTimeRange(timeRangeWithZoomProvider.getFromTime(), fix.timepoint);
if (fromTime.after(fix.timepoint)) {
fromTime = fix.timepoint;
} else if (toTime.before(fix.timepoint)) {
toTime = fix.timepoint;
}
}
marks.put(fixes.getKey(), fixOverlayMap);
updatePolylinePoints(fixes.getKey());
marksFromToTimes.put(fixes.getKey(), new Pair<Date, Date>(fromTime, toTime));
}
List<MarkDTO> markList = new ArrayList<MarkDTO>();
markList.addAll(marks.keySet());
@@ -532,6 +546,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
updatePolylinePoints(mark);
setSeriesPoints(mark);
onResize();
showNotification("Fix successfully added.", NotificationType.SUCCESS);
}
private void editMarkFix(MarkDTO mark, GPSFixDTO fix, Position newPosition) {
@@ -541,6 +556,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
updatePolylinePoints(mark);
setSeriesPoints(mark);
onResize();
showNotification("Fix position successfully edited.", NotificationType.SUCCESS);
}
private void removeMarkFix(MarkDTO mark, GPSFixDTO fix) {
@@ -550,6 +566,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
updatePolylinePoints(mark);
setSeriesPoints(mark);
onResize();
showNotification("Fix successfully removed.", NotificationType.SUCCESS);
}
private void updatePolylinePoints(MarkDTO mark) {
@@ -592,6 +609,14 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
sideBySideComponentViewer.setLeftComponent(marksPanel);
sideBySideComponentViewer.setLeftComponentToggleButtonVisible(false);
}
for (final CourseMarkOverlay overlay : raceMap.getCourseMarkOverlays().values()) {
courseMarkClickHandlers.add(overlay.addClickHandler(new ClickMapHandler() {
@Override
public void onEvent(ClickMapEvent event) {
marksPanel.select(overlay.getMark());
}
}));
}
raceMap.unregisterAllCourseMarkInfoWindowClickHandlers();
} else {
marksPanel.deselectMarks();
@@ -600,6 +625,9 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
sideBySideComponentViewer.setLeftComponent(leaderboardPanel);
sideBySideComponentViewer.setLeftComponentToggleButtonVisible(true);
}
for (HandlerRegistration registration : courseMarkClickHandlers) {
registration.removeHandler();
}
raceMap.unregisterAllCourseMarkInfoWindowClickHandlers();
raceMap.registerAllCourseMarkInfoWindowClickHandlers();
}
@@ -701,10 +729,14 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
hideAllFixOverlays();
hideAllPolylines();
selected = marksPanel.getSelectedMarks();
setWidget(noMarkSelectedLabel);
} else if (selectedMark == selected.get(0)) {
return;
}
selectedMark = selected.get(0);
if (marksFromToTimes.get(selectedMark) != null) {
timeRangeWithZoomProvider.setTimeRange(marksFromToTimes.get(selectedMark).getA(), marksFromToTimes.get(selectedMark).getB());
}
setWidget(chart);
markSeries.remove();
markSeries.setPlotOptions(markSeriesPlotOptions.setMarker(
@@ -721,6 +753,9 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
polylines.get(selectedMark).setVisible(true);
} else {
selectedMark = null;
if (raceFromTime != null && raceToTime != null) {
timeRangeWithZoomProvider.setTimeRange(raceFromTime, raceToTime);
}
setWidget(noMarkSelectedLabel);
showAllCourseMarkOverlays();
raceMap.showAllHelplinesToShow();
@@ -735,7 +770,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
}
}
public void hideAllCourseMarkOverlaysExceptSelected() {
public void hideAllCourseMarkOverlaysExceptSelected() {
for (Map.Entry<String, CourseMarkOverlay> overlay : raceMap.getCourseMarkOverlays().entrySet()) {
if (!overlay.getKey().equals(selectedMark.getName())) {
overlay.getValue().setVisible(false);
@@ -775,7 +810,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
index++;
}
Polyline polyline = polylines.get(mark);
currentFixPositionChooser = new FixPositionChooser(map, index, polyline != null ? polyline.getPath() : null, map.getCenter(), raceMap.getCoordinateSystem(), callback);
currentFixPositionChooser = new FixPositionChooser(this, map, index, polyline != null ? polyline.getPath() : null, map.getCenter(), raceMap.getCoordinateSystem(), callback);
return currentFixPositionChooser;
}
@@ -785,20 +820,31 @@ public class EditMarkPositionPanel extends AbstractRaceChart implements Componen
private com.google.gwt.user.client.Timer notificationTimer;
public enum NotificationType {
INFO,
ERROR,
SUCCESS
}
public void showNotification(String message) {
if (notificationTimer == null || !notificationTimer.isRunning()) {
final HTMLPanel text = new HTMLPanel("<div>" + message + "</div>");
text.setStyleName("EditMarkPositionNotification");
map.setControls(ControlPosition.TOP_CENTER, text);
notificationTimer = new com.google.gwt.user.client.Timer(){
@Override
public void run() {
text.removeFromParent();
}
};
notificationTimer.schedule(8000);
showNotification(message, NotificationType.INFO);
}
public void showNotification(String message, NotificationType type) {
if (notificationTimer != null && notificationTimer.isRunning()) {
notificationTimer.run();
}
final HTMLPanel text = new HTMLPanel("<div style = \" color: " + (type == NotificationType.ERROR ? "#c00" : type == NotificationType.SUCCESS ? "#0c0" : "#000") + "\">" + message + "</div>");
text.setStyleName("EditMarkPositionNotification");
map.setControls(ControlPosition.TOP_CENTER, text);
notificationTimer = new com.google.gwt.user.client.Timer(){
@Override
public void run() {
text.removeFromParent();
}
};
notificationTimer.schedule(5000);
}
public boolean hasFixAtTimePoint(MarkDTO mark) {
@@ -44,9 +44,9 @@ public class FixPositionChooser {
* @param overlay
* @param callback
*/
public FixPositionChooser(final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath, final FixOverlay overlay,
public FixPositionChooser(final EditMarkPositionPanel editMarkPositionPanel, final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath, final FixOverlay overlay,
final Callback<Position, Exception> callback) {
this(false, map, polylineFixIndex, polylinePath, overlay, overlay.getLatLngPosition(), overlay.getCoordinateSystem(),
this(editMarkPositionPanel, false, map, polylineFixIndex, polylinePath, overlay, overlay.getLatLngPosition(), overlay.getCoordinateSystem(),
"Confirm Move", callback);
}
@@ -60,17 +60,17 @@ public class FixPositionChooser {
* @param coordinateSystem
* @param callback
*/
public FixPositionChooser(final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath, final LatLng startPos,
public FixPositionChooser(final EditMarkPositionPanel editMarkPositionPanel, final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath, final LatLng startPos,
final CoordinateSystem coordinateSystem, final Callback<Position, Exception> callback) {
this(true, map, polylineFixIndex, polylinePath, null, startPos, coordinateSystem,
this(editMarkPositionPanel, true, map, polylineFixIndex, polylinePath, null, startPos, coordinateSystem,
"Confirm New", callback);
}
// TODO: Differentiate touch and mouse somehow
// TODO: Disable time slider
// TODO: Red dot in chart - PointOptions
// TODO: Show info bubble on what to do
private FixPositionChooser(final boolean newFix, final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath,
// The problem of not knowing if it is a touchscreen or mouse the user is currently using, applies to this class too.
// Both input methods are implemented.
private FixPositionChooser(final EditMarkPositionPanel editMarkPositionPanel, final boolean newFix, final MapWidget map, final int polylineFixIndex, final MVCArray<LatLng> polylinePath,
final FixOverlay overlay, final LatLng startPos, final CoordinateSystem coordinateSystem, final String confirmButtonText,
final Callback<Position, Exception> callback) {
this.callback = callback;
@@ -81,6 +81,7 @@ public class FixPositionChooser {
this.overlay = overlay;
this.startPos = startPos;
this.coordinateSystem = coordinateSystem;
editMarkPositionPanel.showNotification("Select a fix position by dragging the red dot or the map. Then confirm or cancel with the buttons below.");
setupUIOverlay(confirmButtonText);
}
@@ -16,6 +16,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.shared.charts.EditMarkPositionPanel.NotificationType;
import com.sap.sailing.gwt.ui.client.shared.controls.FlushableSortedCellTableWithStylableHeaders;
import com.sap.sailing.gwt.ui.client.shared.controls.SelectionCheckboxColumn;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardTableResources;
@@ -71,7 +72,7 @@ public class MarksPanel extends SimplePanel implements Component<AbstractSetting
@Override
public void update(int index, final MarkDTO mark, String value) {
if (parent.hasFixAtTimePoint(mark)) {
parent.showNotification("Please select another timepoint. There already is a fix at the timepoint of the timeslider.");
parent.showNotification("Please select another timepoint. There already is a fix at the timepoint of the timeslider.", NotificationType.ERROR);
} else {
try {
parent.createFixPositionChooserToAddFixToMark(mark, new Callback<Position, Exception>() {
@@ -150,4 +151,8 @@ public class MarksPanel extends SimplePanel implements Component<AbstractSetting
deselectMark(mark);
}
}
public void select(MarkDTO mark) {
markTable.getSelectionModel().setSelected(mark, true);
}
}