fixing bug 3106: maintain ordering of leaderboard groups in event

This commit is contained in:
Axel Uhl committed 2015-07-14 11:43:19 +02:00
1 parent a13dcec533
commit 2f3da91efd
1 file changed
+11 -5
@@ -5,8 +5,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.google.gwt.dev.util.collect.HashMap;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
@@ -45,7 +47,7 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
protected TextBox sailorsInfoWebsiteURLEntryField;
protected StringListInlineEditorComposite courseAreaNameList;
protected StringConstantsListEditorComposite leaderboardGroupList;
protected List<LeaderboardGroupDTO> availableLeaderboardGroups;
protected Map<String, LeaderboardGroupDTO> availableLeaderboardGroupsByName;
protected ImagesListComposite imagesListComposite;
protected VideosListComposite videosListComposite;
@@ -120,7 +122,10 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
super(stringMessages.event(), null, stringMessages.ok(), stringMessages.cancel(), validator,
callback);
this.stringMessages = stringMessages;
this.availableLeaderboardGroups = availableLeaderboardGroups;
this.availableLeaderboardGroupsByName = new HashMap<>();
for (final LeaderboardGroupDTO lgDTO : availableLeaderboardGroups) {
availableLeaderboardGroupsByName.put(lgDTO.getName(), lgDTO);
}
getDialogBox().getWidget().setWidth("730px");
final ValueChangeHandler<Iterable<String>> valueChangeHandler = new ValueChangeHandler<Iterable<String>>() {
@Override
@@ -150,9 +155,10 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
protected EventDTO getResult() {
EventDTO result = new EventDTO();
List<String> leaderboardGroupNames = leaderboardGroupList.getValue();
for(LeaderboardGroupDTO lg: availableLeaderboardGroups) {
if(leaderboardGroupNames.contains(lg.getName())) {
result.addLeaderboardGroup(lg);
for (final String lgName : leaderboardGroupNames) {
final LeaderboardGroupDTO lgDTO = availableLeaderboardGroupsByName.get(lgName);
if (lgDTO != null) {
result.addLeaderboardGroup(lgDTO);
}
}
result.setName(nameEntryField.getText());