mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
allow filtering boats to those known by / registered with the regatta
Change-Id: I4c25a94193c1b65cd42b35565df8bf6317d72364
This commit is contained in:
1 parent
845650806d
commit
825094de81
8 files changed
+70
-21
No files matched your search
+51
-14
@@ -1,9 +1,12 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gwt.cell.client.SafeHtmlCell;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
@@ -12,6 +15,7 @@ import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.sap.sailing.domain.common.dto.BoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
@@ -19,17 +23,19 @@ import com.sap.sailing.gwt.ui.adminconsole.ColorColumn.ColorRetriever;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.common.Color;
|
||||
import com.sap.sse.common.filter.Filter;
|
||||
import com.sap.sse.common.util.NaturalComparator;
|
||||
import com.sap.sse.gwt.client.ErrorReporter;
|
||||
import com.sap.sse.gwt.client.celltable.EntityIdentityComparator;
|
||||
import com.sap.sse.gwt.client.celltable.RefreshableSelectionModel;
|
||||
import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel;
|
||||
import com.sap.sse.gwt.client.panels.CustomizableFilterablePanel;
|
||||
|
||||
public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO>> extends TableWrapper<BoatDTO, S> {
|
||||
private final LabeledAbstractFilterablePanel<BoatDTO> filterField;
|
||||
private final CustomizableFilterablePanel<BoatDTO> filterField;
|
||||
private final Set<BoatDTO> boatsRegisteredWithRegatta;
|
||||
|
||||
public CompactBoatTableWrapper(SailingServiceAsync sailingService, StringMessages stringMessages,ErrorReporter errorReporter,
|
||||
boolean multiSelection, boolean enablePager) {
|
||||
public CompactBoatTableWrapper(SailingServiceAsync sailingService, StringMessages stringMessages,
|
||||
ErrorReporter errorReporter, boolean multiSelection, boolean enablePager) {
|
||||
super(sailingService, stringMessages, errorReporter, multiSelection, enablePager,
|
||||
new EntityIdentityComparator<BoatDTO>() {
|
||||
@Override
|
||||
@@ -41,6 +47,7 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
return t.getIdAsString().hashCode();
|
||||
}
|
||||
});
|
||||
boatsRegisteredWithRegatta = new HashSet<>();
|
||||
ListHandler<BoatDTO> boatColumnListHandler = getColumnSortHandler();
|
||||
// boats table
|
||||
TextColumn<BoatDTO> boatNameColumn = new TextColumn<BoatDTO>() {
|
||||
@@ -124,8 +131,7 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
return comparator.compare(o1.getIdAsString(), o2.getIdAsString());
|
||||
}
|
||||
});
|
||||
filterField = new LabeledAbstractFilterablePanel<BoatDTO>(new Label(stringMessages.filterBoats()),
|
||||
new ArrayList<BoatDTO>(), table, dataProvider) {
|
||||
filterField = new CustomizableFilterablePanel<BoatDTO>(new ArrayList<>(), getTable(), getDataProvider()) {
|
||||
@Override
|
||||
public Iterable<String> getSearchableStrings(BoatDTO boat) {
|
||||
List<String> string = new ArrayList<String>();
|
||||
@@ -134,8 +140,22 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
string.add(boat.getIdAsString());
|
||||
string.add(boat.getBoatClass().getName());
|
||||
return string;
|
||||
}
|
||||
}
|
||||
};
|
||||
final CheckBox filterToBoatsRegisteredOnRegatta = new CheckBox(stringMessages.filterToBoatsRegisteredOnRegatta());
|
||||
filterToBoatsRegisteredOnRegatta.addValueChangeHandler(checked->filterField.filter());
|
||||
filterField.add(new Label(""), filterToBoatsRegisteredOnRegatta, new Filter<BoatDTO>() {
|
||||
@Override
|
||||
public boolean matches(BoatDTO boat) {
|
||||
return !filterToBoatsRegisteredOnRegatta.getValue() || boatsRegisteredWithRegatta.contains(boat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BoatsRegisteredWithRegatta";
|
||||
}
|
||||
});
|
||||
filterField.addDefaultTextBox();
|
||||
registerSelectionModelOnNewDataProvider(filterField.getAllListDataProvider());
|
||||
mainPanel.insert(filterField, 0);
|
||||
table.addColumnSortHandler(boatColumnListHandler);
|
||||
@@ -151,16 +171,12 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
return filterField.getAll();
|
||||
}
|
||||
|
||||
public LabeledAbstractFilterablePanel<BoatDTO> getFilterField() {
|
||||
return filterField;
|
||||
}
|
||||
|
||||
public void filterBoats(Iterable<BoatDTO> boats) {
|
||||
getFilteredBoats(boats);
|
||||
}
|
||||
|
||||
public void selectBoat(BoatDTO boatToSelect) {
|
||||
for (BoatDTO boat: getAllBoats()) {
|
||||
for (BoatDTO boat : getAllBoats()) {
|
||||
if (boat.getIdAsString().equals(boatToSelect.getIdAsString())) {
|
||||
getSelectionModel().setSelected(boat, true);
|
||||
break;
|
||||
@@ -176,7 +192,7 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
final AsyncCallback<Map<? extends CompetitorDTO, BoatDTO>> myCallback = new AsyncCallback<Map<? extends CompetitorDTO, BoatDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Remote Procedure Call refreshBoatListFromRace() - Failure: " + caught.getMessage());
|
||||
errorReporter.reportError(stringMessages.unableToObtainCompetitorsAndBoatsForRaceInFleetInLeaderboard(raceColumnName, fleetName, leaderboardName, caught.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,9 +201,29 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
}
|
||||
};
|
||||
sailingService.getCompetitorsAndBoatsOfRace(leaderboardName, raceColumnName, fleetName, myCallback);
|
||||
updateBoatRegistrationsForLeaderboard(leaderboardName);
|
||||
}
|
||||
|
||||
private void updateBoatRegistrationsForLeaderboard(String leaderboardName) {
|
||||
sailingService.getBoatRegistrationsForLeaderboard(leaderboardName, new AsyncCallback<Collection<BoatDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(stringMessages.unableToObtainBoatsRegisteredWith(leaderboardName, caught.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Collection<BoatDTO> result) {
|
||||
boatsRegisteredWithRegatta.clear();
|
||||
boatsRegisteredWithRegatta.addAll(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshBoatList() {
|
||||
/**
|
||||
* Updates the list of all boats and the set of boats registered with or used by the leaderboard named {@code leaderboardName}.
|
||||
* The latter will be used when the corresponding filter is activated.
|
||||
*/
|
||||
public void refreshBoatList(String leaderboardName) {
|
||||
sailingService.getAllBoats(new AsyncCallback<Iterable<BoatDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
@@ -199,6 +235,7 @@ public class CompactBoatTableWrapper<S extends RefreshableSelectionModel<BoatDTO
|
||||
filterBoats(result);
|
||||
}
|
||||
});
|
||||
updateBoatRegistrationsForLeaderboard(leaderboardName);
|
||||
}
|
||||
|
||||
private void getFilteredBoats(Iterable<BoatDTO> result) {
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public class CompetitorToBoatMappingsDialog extends DataEntryDialog<Map<Competit
|
||||
}
|
||||
|
||||
public CompetitorToBoatMappingsDialog(final SailingServiceAsync sailingService, final StringMessages stringMessages,
|
||||
final ErrorReporter errorReporter, Map<CompetitorDTO, BoatDTO> competitorsAndBoats, DialogCallback<Map<CompetitorDTO, BoatDTO>> callback) {
|
||||
final ErrorReporter errorReporter, String leaderboardName, Map<CompetitorDTO, BoatDTO> competitorsAndBoats, DialogCallback<Map<CompetitorDTO, BoatDTO>> callback) {
|
||||
super(stringMessages.actionEditCompetitorToBoatAssignments(), null, stringMessages.ok(), stringMessages.cancel(), new CompetitorToBoatMappingValidator(), callback);
|
||||
this.stringMessages = stringMessages;
|
||||
this.competitorToBoatMappings = new HashMap<>(competitorsAndBoats);
|
||||
@@ -141,7 +141,7 @@ public class CompetitorToBoatMappingsDialog extends DataEntryDialog<Map<Competit
|
||||
}
|
||||
});
|
||||
competitorTable.refreshCompetitorList(competitorToBoatMappings);
|
||||
boatTable.refreshBoatList();
|
||||
boatTable.refreshBoatList(leaderboardName);
|
||||
}
|
||||
|
||||
private void linkBoatToSelectedCompetitor(CompetitorDTO selectedCompetitor, BoatDTO selectedBoat) {
|
||||
|
||||
+1
-1
@@ -432,7 +432,7 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
|
||||
}
|
||||
}
|
||||
new CompetitorToBoatMappingsDialog(sailingService, stringMessages,
|
||||
errorReporter, newCompetitorToBoatMappings, new DialogCallback<Map<CompetitorDTO, BoatDTO>>() {
|
||||
errorReporter, leaderboardName, newCompetitorToBoatMappings, new DialogCallback<Map<CompetitorDTO, BoatDTO>>() {
|
||||
@Override
|
||||
public void ok(final Map<CompetitorDTO, BoatDTO> competitorToBoatMappings) {
|
||||
sailingService.setCompetitorRegistrationsInRaceLog(leaderboardName, raceColumnName,
|
||||
|
||||
+3
@@ -2161,4 +2161,7 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages,
|
||||
String errorTryingToDetermineBoatLinkedToCompetitor(String raceColumnName, String leaderboardName, String message);
|
||||
String delaysMustNotBeNegative();
|
||||
String managePlaybackMedia();
|
||||
String filterToBoatsRegisteredOnRegatta();
|
||||
String unableToObtainCompetitorsAndBoatsForRaceInFleetInLeaderboard(String raceColumnName, String fleetName, String leaderboardName, String message);
|
||||
String unableToObtainBoatsRegisteredWith(String leaderboardName, String message);
|
||||
}
|
||||
+4
-1
@@ -2149,4 +2149,7 @@ selectAtLeastOneCompetitorManeuver=To show the maneuver table, select at least o
|
||||
noDataManeuverTable=There are no maneuvers detected yet
|
||||
errorTryingToDetermineBoatLinkedToCompetitor=Error trying to determine boat linked to competitor {0} in leaderboard {1}: {2}
|
||||
delaysMustNotBeNegative=Delays must not be negative
|
||||
managePlaybackMedia=Manage Playback Media
|
||||
managePlaybackMedia=Manage Playback Media
|
||||
filterToBoatsRegisteredOnRegatta=Filter to boats registered on regatta
|
||||
unableToObtainCompetitorsAndBoatsForRaceInFleetInLeaderboard=Unable to obtain competitors and boats for race {0} in fleet {1} for leaderboard {2}: {3}
|
||||
unableToObtainBoatsRegisteredWith=Unable to obtain boats registered with {0}: {1}
|
||||
+4
-1
@@ -2145,4 +2145,7 @@ selectAtLeastOneCompetitorManeuver=Um die Manövertabelle anzuzeigen, muss minde
|
||||
noDataManeuverTable=Es wurde noch keine Manöver erkannt
|
||||
errorTryingToDetermineBoatLinkedToCompetitor=Fehler bei der Ermittlung des Bootes für Teilnehmer {0} in Ergebnisliste {1}: {2}
|
||||
delaysMustNotBeNegative=Abhängige Zeiten dürfen nicht negativ sein
|
||||
managePlaybackMedia=Abspielbare Medien verwalten
|
||||
managePlaybackMedia=Abspielbare Medien verwalten
|
||||
filterToBoatsRegisteredOnRegatta=Nach Booten filtern, die bei der Regatta regstriert sind
|
||||
unableToObtainCompetitorsAndBoatsForRaceInFleetInLeaderboard=Teilnemer der Wettfahrt {0} in Gruppe {1} der Ergebnisliste {2} konnte nicht ermittelt werden: {3}
|
||||
unableToObtainBoatsRegisteredWith=Die bei der Ergebnisliste {0} angemeldeten Boote konnten nicht ermittelt werden: {1}
|
||||
+1
-1
@@ -6816,7 +6816,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
@Override
|
||||
public Collection<BoatDTO> getBoatRegistrationsInRegattaLog(String leaderboardName) throws DoesNotHaveRegattaLogException, NotFoundException {
|
||||
Leaderboard leaderboard = getLeaderboardByName(leaderboardName);
|
||||
if (! (leaderboard instanceof HasRegattaLike)) {
|
||||
if (!(leaderboard instanceof HasRegattaLike)) {
|
||||
throw new DoesNotHaveRegattaLogException();
|
||||
}
|
||||
HasRegattaLike regattaLikeLeaderboard = ((HasRegattaLike) leaderboard);
|
||||
|
||||
+4
-1
@@ -16,7 +16,10 @@ import com.sap.sse.common.filter.Filter;
|
||||
*
|
||||
*/
|
||||
public abstract class CustomizableFilterablePanel<T> extends AbstractFilterablePanel<T> {
|
||||
|
||||
/**
|
||||
* Does not add the default filter text box yet; use {@link #addDefaultTextBox()} to do so; you may
|
||||
* add other widgets before the default text filter box.
|
||||
*/
|
||||
public CustomizableFilterablePanel(Iterable<T> all, AbstractCellTable<T> display, ListDataProvider<T> filtered) {
|
||||
super(all, display, filtered, /* show default filter text box */ false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user