예제 #1
0
 /**
  * {@inheritDoc}
  *
  * <p>Overridden - that is completely new implementation - to get first/next SortOrder from sort
  * order cycle. Does nothing if the cycle is empty.
  */
 @Override
 public void toggleSortOrder(int column) {
   checkColumn(column);
   if (!isSortable(column)) return;
   SortOrder firstInCycle = getFirstInCycle();
   // nothing to toggle through
   if (firstInCycle == null) return;
   List<SortKey> keys = new ArrayList<SortKey>(getSortKeys());
   SortKey sortKey = SortUtils.getFirstSortKeyForColumn(keys, column);
   if (keys.indexOf(sortKey) == 0) {
     //  primary key: in this case we'll use next sortorder in cylce
     keys.set(0, new SortKey(column, getNextInCycle(sortKey.getSortOrder())));
   } else {
     // all others: make primary with first sortOrder in cycle
     keys.remove(sortKey);
     keys.add(0, new SortKey(column, getFirstInCycle()));
   }
   if (keys.size() > getMaxSortKeys()) {
     keys = keys.subList(0, getMaxSortKeys());
   }
   setSortKeys(keys);
 }
예제 #2
0
 /**
  * {@inheritDoc}
  *
  * <p>
  */
 @Override
 public SortOrder getSortOrder(int column) {
   SortKey key = SortUtils.getFirstSortKeyForColumn(getSortKeys(), column);
   return key != null ? key.getSortOrder() : SortOrder.UNSORTED;
 }