Skip to content

Commit

Permalink
gwt: Sort courses by name.
Browse files Browse the repository at this point in the history
  • Loading branch information
calin-iorgulescu committed Mar 30, 2015
1 parent 500c326 commit 4914e2e
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Collections;
import java.util.Comparator;

import ro.pub.cs.vmchecker.client.event.AuthenticationEvent;
import ro.pub.cs.vmchecker.client.event.AuthenticationEventHandler;
Expand All @@ -22,6 +24,7 @@
import ro.pub.cs.vmchecker.client.ui.HeaderWidget;
import ro.pub.cs.vmchecker.client.ui.LoginWidget;
import ro.pub.cs.vmchecker.client.util.CookieManager;
import ro.pub.cs.vmchecker.client.util.AlphanumComparator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
Expand Down Expand Up @@ -57,7 +60,16 @@ public AppController(EventBus eventBus, HTTPService service) {
listenCourseChange();
listenAuthenticationEvents();
}


private class CourseComparator implements Comparator<Course> {
AlphanumComparator stringComparator = new AlphanumComparator();
@Override
public int compare(Course c1, Course c2) {
return stringComparator.compare(c1.title, c2.title);
}
}


private void listenAuthenticationEvents() {
eventBus.addHandler(AuthenticationEvent.TYPE, new AuthenticationEventHandler() {

Expand Down Expand Up @@ -138,6 +150,8 @@ public void onSuccess(Course[] result) {
courses.add(course);
}

Collections.sort(courses, new CourseComparator());

/* initialize header presenter */
headerPresenter = new HeaderPresenter(eventBus, service,
new HeaderWidget(CookieManager.getUser()));
Expand Down

0 comments on commit 4914e2e

Please sign in to comment.