NIHVIVO-1306 code fix for sorting properties in dropdown.
This commit is contained in:
parent
dcb358d4c8
commit
dc73f0bedb
1 changed files with 37 additions and 0 deletions
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -64,6 +69,8 @@ public class RefactorRetryController extends BaseEditController {
|
||||||
Collections.sort(dpList);
|
Collections.sort(dpList);
|
||||||
newPropertyOpts = FormUtils.makeOptionListFromBeans(dpList,"URI","Name", null, null);
|
newPropertyOpts = FormUtils.makeOptionListFromBeans(dpList,"URI","Name", null, null);
|
||||||
}
|
}
|
||||||
|
HashMap<String,Option> hashMap = new HashMap<String,Option>();
|
||||||
|
newPropertyOpts = getSortedList(hashMap,newPropertyOpts);
|
||||||
newPropertyOpts.add(new Option("","(move to trash)"));
|
newPropertyOpts.add(new Option("","(move to trash)"));
|
||||||
optMap.put("NewPropertyURI", newPropertyOpts);
|
optMap.put("NewPropertyURI", newPropertyOpts);
|
||||||
|
|
||||||
|
@ -136,4 +143,34 @@ public class RefactorRetryController extends BaseEditController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Option> getSortedList(HashMap<String,Option> hashMap, List<Option> optionList){
|
||||||
|
|
||||||
|
class ListComparator implements Comparator<String>{
|
||||||
|
@Override
|
||||||
|
public int compare(String str1, String str2) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
Collator collator = Collator.getInstance();
|
||||||
|
return collator.compare(str1, str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bodyVal = new ArrayList<String>();
|
||||||
|
List<Option> options = new ArrayList<Option>();
|
||||||
|
Iterator<Option> itr = optionList.iterator();
|
||||||
|
while(itr.hasNext()){
|
||||||
|
Option option = itr.next();
|
||||||
|
hashMap.put(option.getBody(),option);
|
||||||
|
bodyVal.add(option.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Collections.sort(bodyVal, new ListComparator());
|
||||||
|
ListIterator<String> itrStr = bodyVal.listIterator();
|
||||||
|
while(itrStr.hasNext()){
|
||||||
|
options.add(hashMap.get(itrStr.next()));
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue