mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 22:30:56 +00:00
Sorting event lists in drop-down select boxes in creating flexible leaderboard and AutoPlay added
This commit is contained in:
1 parent
8220714d14
commit
fbee8fb367
2 files changed
+44
-4
No files matched your search
+22
-3
@@ -1,6 +1,10 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.place.start;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
@@ -139,13 +143,28 @@ public class DesktopStartView extends Composite implements StartView {
|
||||
@Override
|
||||
public void setEvents(List<EventDTO> events) {
|
||||
this.events.clear();
|
||||
this.events.addAll(events);
|
||||
|
||||
this.events.addAll(makeSortedEvents(events));
|
||||
eventSelectionBox.addItem(StringMessages.INSTANCE.pleaseSelectAnEvent());
|
||||
for(EventDTO event: events) {
|
||||
for(EventDTO event: this.events) {
|
||||
eventSelectionBox.addItem(event.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort collection of events alphabetically
|
||||
* @param events - collection that is going to be sorted
|
||||
* @return sorted list
|
||||
*/
|
||||
private List<EventDTO> makeSortedEvents(List<EventDTO> events) {
|
||||
List<EventDTO> sortedEvents = Arrays.asList(events.toArray(new EventDTO[events.size()]));
|
||||
Collections.sort(sortedEvents, new Comparator<EventDTO>() {
|
||||
@Override
|
||||
public int compare(EventDTO firstEvent, EventDTO secondEvent) {
|
||||
return firstEvent.getName().compareTo(secondEvent.getName());
|
||||
}
|
||||
});
|
||||
return sortedEvents;
|
||||
}
|
||||
|
||||
@UiHandler("eventSelectionBox")
|
||||
void onEventSelectionChange(ChangeEvent event) {
|
||||
|
||||
+22
-1
@@ -1,6 +1,11 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
@@ -108,7 +113,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
protected ListBox createSailingEventListBox() {
|
||||
ListBox eventListBox = createListBox(false);
|
||||
eventListBox.addItem("Please select a sailing event...");
|
||||
for (EventDTO event: existingEvents) {
|
||||
for (EventDTO event: makeSortedEvents(existingEvents)) {
|
||||
eventListBox.addItem(event.getName());
|
||||
}
|
||||
eventListBox.addChangeHandler(new ChangeHandler() {
|
||||
@@ -119,6 +124,22 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
});
|
||||
return eventListBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort collection of events alphabetically
|
||||
* @param events - collection that is going to be sorted
|
||||
* @return sorted list
|
||||
*/
|
||||
private List<EventDTO> makeSortedEvents(Collection<EventDTO> events) {
|
||||
List<EventDTO> sortedEvents = Arrays.asList(events.toArray(new EventDTO[events.size()]));
|
||||
Collections.sort(sortedEvents, new Comparator<EventDTO>() {
|
||||
@Override
|
||||
public int compare(EventDTO firstEvent, EventDTO secondEvent) {
|
||||
return firstEvent.getName().compareTo(secondEvent.getName());
|
||||
}
|
||||
});
|
||||
return sortedEvents;
|
||||
}
|
||||
|
||||
protected void onEventSelectionChanged() {
|
||||
EventDTO selectedEvent = getSelectedEvent();
|
||||
|
||||
Reference in new issue
Block a user