1 package org.codehaus.redback.integration.eXc;
4 * Copyright 2005-2006 The Codehaus.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.util.Collection;
20 import java.util.Collections;
21 import java.util.List;
23 import org.codehaus.redback.integration.util.UserComparator;
24 import org.extremecomponents.table.callback.ProcessRowsCallback;
25 import org.extremecomponents.table.core.TableConstants;
26 import org.extremecomponents.table.core.TableModel;
27 import org.extremecomponents.table.limit.Sort;
30 * ProcessUserRowsCallback - Efficient and safe sort callback for user manager provided user lists.
32 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
35 public class ProcessUserRowsCallback
36 extends ProcessRowsCallback
39 @SuppressWarnings("unchecked")
40 public Collection sortRows( TableModel model, Collection rows )
43 boolean sorted = model.getLimit().isSorted();
50 Sort sort = model.getLimit().getSort();
51 String property = sort.getProperty();
52 String sortOrder = sort.getSortOrder();
54 System.out.println( "SORTING: " + property + " - " + sortOrder );
56 UserComparator comparator = new UserComparator( property, TableConstants.SORT_ASC.equals( sortOrder ) );
57 Collections.sort( (List) rows, comparator );