mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 18:33:54 +00:00
added regatta selection when we want to start a race tracking
This commit is contained in:
1 parent
5c26817d2e
commit
929c27d6e4
5 files changed
+91
-48
No files matched your search
+6
-4
@@ -35,9 +35,12 @@ public class AdminConsoleEntryPoint extends AbstractEntryPoint implements Regatt
|
||||
tabPanel.setAnimationEnabled(true);
|
||||
rootPanel.add(tabPanel); //, 10, 10);
|
||||
tabPanel.setSize("95%", "95%");
|
||||
|
||||
tabPanel.add(new EventStructureManagementPanel(sailingService, this, stringMessages), stringMessages.regattas());
|
||||
|
||||
regattaDisplayers = new HashSet<RegattaDisplayer>();
|
||||
|
||||
EventStructureManagementPanel eventStructureManagementPanel = new EventStructureManagementPanel(sailingService, this, stringMessages, this);
|
||||
tabPanel.add(eventStructureManagementPanel, stringMessages.regattas());
|
||||
regattaDisplayers.add(eventStructureManagementPanel);
|
||||
TracTracEventManagementPanel tractracEventManagementPanel = new TracTracEventManagementPanel(sailingService, this, this, stringMessages);
|
||||
regattaDisplayers.add(tractracEventManagementPanel);
|
||||
tractracEventManagementPanel.setSize("90%", "90%");
|
||||
@@ -101,9 +104,8 @@ public class AdminConsoleEntryPoint extends AbstractEntryPoint implements Regatt
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
reportError("Remote Procedure Call listEvents() - Failure");
|
||||
reportError("Remote Procedure Call getRegattas() - Failure");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+21
-30
@@ -34,6 +34,8 @@ import com.sap.sailing.domain.common.Color;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaDisplayer;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
@@ -48,7 +50,7 @@ import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
* @author Frank Mittag (C5163974)
|
||||
*
|
||||
*/
|
||||
public class EventStructureManagementPanel extends SimplePanel {
|
||||
public class EventStructureManagementPanel extends SimplePanel implements RegattaDisplayer {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final ErrorReporter errorReporter;
|
||||
private final StringMessages stringMessages;
|
||||
@@ -63,15 +65,17 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
private CellTable<RegattaDTO> regattaTable;
|
||||
private SingleSelectionModel<RegattaDTO> regattaSelectionModel;
|
||||
private ListDataProvider<RegattaDTO> regattaProvider;
|
||||
private final RegattaRefresher regattaRefresher;
|
||||
|
||||
private final AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class);
|
||||
private boolean supportEvents = false;
|
||||
|
||||
public EventStructureManagementPanel(SailingServiceAsync sailingService, ErrorReporter errorReporter,
|
||||
StringMessages stringMessages) {
|
||||
StringMessages stringMessages, RegattaRefresher regattaRefresher) {
|
||||
this.sailingService = sailingService;
|
||||
this.stringMessages = stringMessages;
|
||||
this.errorReporter = errorReporter;
|
||||
this.regattaRefresher = regattaRefresher;
|
||||
|
||||
events = new ArrayList<EventDTO>();
|
||||
selectedEvent = null;
|
||||
@@ -115,8 +119,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
} else {
|
||||
createEventDetailsPanel();
|
||||
mainPanel.add(eventDetailsCaptionPanel);
|
||||
|
||||
fillRegattas();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +137,15 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
}
|
||||
|
||||
private void createRegattaDetails(Panel parentPanel) {
|
||||
Button addRegattaBtn = new Button("Add regatta");
|
||||
parentPanel.add(addRegattaBtn);
|
||||
addRegattaBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openCreateRegattaDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// regatta table
|
||||
TextColumn<RegattaDTO> regattaNameColumn = new TextColumn<RegattaDTO>() {
|
||||
@Override
|
||||
@@ -223,15 +234,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
regattaProvider = new ListDataProvider<RegattaDTO>();
|
||||
regattaProvider.addDataDisplay(regattaTable);
|
||||
parentPanel.add(regattaTable);
|
||||
|
||||
Button addRegattaBtn = new Button("Add regatta");
|
||||
parentPanel.add(addRegattaBtn);
|
||||
addRegattaBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openCreateRegattaDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onEventSelectionChanged() {
|
||||
@@ -306,22 +308,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillRegattas() {
|
||||
// load the regattas for this event
|
||||
sailingService.getRegattas(new AsyncCallback<List<RegattaDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to read regattas of event " + selectedEvent.name + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<RegattaDTO> regattas) {
|
||||
regattaProvider.getList().clear();
|
||||
regattaProvider.getList().addAll(regattas);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createNewEvent(final EventDTO newEvent) {
|
||||
sailingService.createEvent(newEvent.name, newEvent.venue.name, new AsyncCallback<EventDTO>() {
|
||||
@Override
|
||||
@@ -358,7 +344,7 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
|
||||
@Override
|
||||
public void onSuccess(RegattaDTO regatta) {
|
||||
regattaProvider.getList().add(regatta);
|
||||
regattaRefresher.fillRegattas();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -393,4 +379,9 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillRegattas(List<RegattaDTO> regattas) {
|
||||
regattaProvider.getList().clear();
|
||||
regattaProvider.getList().addAll(regattas);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -264,7 +264,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
fleetsGrid.setCellSpacing(4);
|
||||
|
||||
fleetsGrid.setHTML(0, 0, stringConstants.name());
|
||||
fleetsGrid.setHTML(0, 1, stringConstants.no());
|
||||
fleetsGrid.setHTML(0, 1, stringConstants.rank());
|
||||
fleetsGrid.setHTML(0, 2, stringConstants.color());
|
||||
|
||||
for(int i = 0; i < fleetCount; i++) {
|
||||
|
||||
+10
-3
@@ -34,10 +34,12 @@ import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaName;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
@@ -453,10 +455,15 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
private void trackSelectedRaces(boolean trackWind, boolean correctWindByDeclination) {
|
||||
String liveURI = liveURIBox.getValue();
|
||||
String storedURI = storedURIBox.getValue();
|
||||
RegattaDTO selectedRegatta = trackedRacesListComposite.getSelectedRegatta();
|
||||
RegattaIdentifier regattaIdentifier = null;
|
||||
if(selectedRegatta != null) {
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.name);
|
||||
}
|
||||
for (final TracTracRaceRecordDTO rr : raceList.getList()) {
|
||||
if (raceTable.getSelectionModel().isSelected(rr)) {
|
||||
sailingService.trackWithTracTrac(/* regattaToAddTo */ null, // TODO allow user to optionally select a pre-defined regatta
|
||||
rr, liveURI, storedURI, trackWind, correctWindByDeclination, new AsyncCallback<Void>() {
|
||||
sailingService.trackWithTracTrac(regattaIdentifier, rr, liveURI, storedURI, trackWind,
|
||||
correctWindByDeclination, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to register race " + rr.name + " for tracking: "
|
||||
|
||||
+53
-10
@@ -33,6 +33,7 @@ import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
@@ -82,6 +83,10 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
|
||||
private Iterable<RaceDTO> allRaces;
|
||||
|
||||
private Iterable<RegattaDTO> allRegattas;
|
||||
|
||||
private ListBox regattaListBox;
|
||||
|
||||
private final VerticalPanel panel;
|
||||
|
||||
private DateTimeFormatRenderer dateFormatter = new DateTimeFormatRenderer(
|
||||
@@ -124,9 +129,6 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
public TrackedRacesListComposite(final SailingServiceAsync sailingService, final ErrorReporter errorReporter,
|
||||
final RegattaRefresher regattaRefresher, RaceSelectionProvider raceSelectionProvider,
|
||||
StringMessages stringMessages, boolean hasMultiSelection) {
|
||||
if (regattaRefresher == null) {
|
||||
throw new IllegalArgumentException("regattaRefresher must not be null");
|
||||
}
|
||||
this.sailingService = sailingService;
|
||||
this.errorReporter = errorReporter;
|
||||
this.regattaRefresher = regattaRefresher;
|
||||
@@ -141,13 +143,26 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
settings.setDelayToLiveInSeconds(DEFAULT_LIVE_DELAY_IN_MILLISECONDS / 1000l);
|
||||
panel = new VerticalPanel();
|
||||
setWidget(panel);
|
||||
|
||||
// the regatta selection for a tracked race
|
||||
HorizontalPanel regattaPanel = new HorizontalPanel();
|
||||
panel.add(regattaPanel);
|
||||
Label lblRegattas = new Label("Regatta used for the tracked race:");
|
||||
lblRegattas.setWordWrap(false);
|
||||
regattaPanel.setCellVerticalAlignment(lblRegattas, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
regattaPanel.setSpacing(5);
|
||||
regattaPanel.add(lblRegattas);
|
||||
regattaListBox = new ListBox();
|
||||
regattaPanel.add(regattaListBox);
|
||||
regattaPanel.setCellVerticalAlignment(regattaListBox, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
|
||||
HorizontalPanel filterPanel = new HorizontalPanel();
|
||||
panel.add(filterPanel);
|
||||
Label lblFilterEvents = new Label(stringMessages.filterRacesByName() + ":");
|
||||
lblFilterEvents.setWordWrap(false);
|
||||
Label lblFilterRaces = new Label(stringMessages.filterRacesByName() + ":");
|
||||
lblFilterRaces.setWordWrap(false);
|
||||
filterPanel.setSpacing(5);
|
||||
filterPanel.add(lblFilterEvents);
|
||||
filterPanel.setCellVerticalAlignment(lblFilterEvents, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
filterPanel.add(lblFilterRaces);
|
||||
filterPanel.setCellVerticalAlignment(lblFilterRaces, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
filterRacesTextbox = new TextBox();
|
||||
filterRacesTextbox.addKeyUpHandler(new KeyUpHandler() {
|
||||
@Override
|
||||
@@ -438,8 +453,11 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillRegattas(List<RegattaDTO> events) {
|
||||
if (events.isEmpty()) {
|
||||
public void fillRegattas(List<RegattaDTO> regattas) {
|
||||
RegattaDTO oldRegattaSelection = getSelectedRegatta();
|
||||
regattaListBox.clear();
|
||||
if (regattas.isEmpty()) {
|
||||
regattaListBox.addItem("No regatta");
|
||||
raceTable.setVisible(false);
|
||||
btnUntrack.setVisible(false);
|
||||
btnRemoveRace.setVisible(false);
|
||||
@@ -453,10 +471,19 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
btnRemoveRace.setEnabled(false);
|
||||
noTrackedRacesLabel.setVisible(false);
|
||||
btnSetDelayToLive.setVisible(true);
|
||||
regattaListBox.addItem("No regatta");
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
regattaListBox.addItem(regatta.name);
|
||||
if(oldRegattaSelection != null && oldRegattaSelection.name.equals(regatta.name)) {
|
||||
regattaListBox.setSelectedIndex(regattaListBox.getItemCount()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<RaceDTO> newAllRaces = new ArrayList<RaceDTO>();
|
||||
List<RegattaDTO> newAllRegattas = new ArrayList<RegattaDTO>();
|
||||
List<RegattaAndRaceIdentifier> newAllRaceIdentifiers = new ArrayList<RegattaAndRaceIdentifier>();
|
||||
for (RegattaDTO regatta : events) {
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
newAllRegattas.add(regatta);
|
||||
for (RaceDTO race : regatta.races) {
|
||||
if (race != null) {
|
||||
newAllRaces.add(race);
|
||||
@@ -465,6 +492,7 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
}
|
||||
}
|
||||
allRaces = newAllRaces;
|
||||
allRegattas = newAllRegattas;
|
||||
fillRaceListFromAvailableRacesApplyingFilter();
|
||||
raceSelectionProvider.setAllRaces(newAllRaceIdentifiers); // have this object be notified; triggers onRaceSelectionChange
|
||||
}
|
||||
@@ -516,6 +544,21 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
});
|
||||
}
|
||||
|
||||
public RegattaDTO getSelectedRegatta() {
|
||||
RegattaDTO result = null;
|
||||
int selIndex = regattaListBox.getSelectedIndex();
|
||||
if(selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = regattaListBox.getItemText(selIndex);
|
||||
for(RegattaDTO regattaDTO: allRegattas) {
|
||||
if(regattaDTO.name.equals(itemText)) {
|
||||
result = regattaDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void fillRaceListFromAvailableRacesApplyingFilter() {
|
||||
String text = filterRacesTextbox.getText();
|
||||
List<String> wordsToFilter = Arrays.asList(text.split(" "));
|
||||
|
||||
Reference in new issue
Block a user