Java Code Examples for org.apache.wicket.extensions.markup.html.repeater.util.SortParam#isAscending()
The following examples show how to use
org.apache.wicket.extensions.markup.html.repeater.util.SortParam#isAscending() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatisticableSitesDataProvider.java From sakai with Educational Community License v2.0 | 6 votes |
private SortType getSSSortType() { SortParam sp = getSort(); if(sp.getProperty().equals(COL_TITLE)){ if(sp.isAscending()) { return SortType.TITLE_ASC; }else{ return SortType.TITLE_DESC; } }else if(sp.getProperty().equals(COL_TYPE)){ if(sp.isAscending()){ return SortType.TYPE_ASC; }else{ return SortType.TYPE_DESC; } }else if(sp.getProperty().equals(COL_STATUS)){ if(sp.isAscending()){ return SortType.PUBLISHED_ASC; }else{ return SortType.PUBLISHED_DESC; } }else{ return SortType.TITLE_ASC; } }
Example 2
Source File: BaseRestClient.java From syncope with Apache License 2.0 | 6 votes |
protected static String toOrderBy(final SortParam<String> sort) { OrderByClauseBuilder builder = SyncopeClient.getOrderByClauseBuilder(); String property = sort.getProperty(); if (property.indexOf('#') != -1) { property = property.substring(property.indexOf('#') + 1); } if (sort.isAscending()) { builder.asc(property); } else { builder.desc(property); } return builder.build(); }
Example 3
Source File: BaseRestClient.java From syncope with Apache License 2.0 | 6 votes |
public static String toOrderBy(final SortParam<String> sort) { OrderByClauseBuilder builder = SyncopeClient.getOrderByClauseBuilder(); String property = sort.getProperty(); if (property.indexOf('#') != -1) { property = property.substring(property.indexOf('#') + 1); } if (sort.isAscending()) { builder.asc(property); } else { builder.desc(property); } return builder.build(); }
Example 4
Source File: StatisticableSitesDataProvider.java From sakai with Educational Community License v2.0 | 6 votes |
private SortType getSSSortType() { SortParam sp = getSort(); if(sp.getProperty().equals(COL_TITLE)){ if(sp.isAscending()) { return SortType.TITLE_ASC; }else{ return SortType.TITLE_DESC; } }else if(sp.getProperty().equals(COL_TYPE)){ if(sp.isAscending()){ return SortType.TYPE_ASC; }else{ return SortType.TYPE_DESC; } }else if(sp.getProperty().equals(COL_STATUS)){ if(sp.isAscending()){ return SortType.PUBLISHED_ASC; }else{ return SortType.PUBLISHED_DESC; } }else{ return SortType.TITLE_ASC; } }
Example 5
Source File: AbstractJavaSortableDataProvider.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public Iterator<? extends T> iterator(long first, long count) { Collection<T> data =dataModel.getObject(); if(data==null || data.size()==0) return Collections.emptyIterator(); if(filterPredicate!=null) data = Collections2.filter(data, filterPredicate); Iterator<T> it; final SortParam<S> sortParam = getSort(); if(sortParam!=null && sortParam.getProperty()!=null) { Ordering<T> ordering = Ordering.natural().nullsFirst().onResultOf(new Function<T, Comparable<?>>() { @Override public Comparable<?> apply(T input) { return comparableValue(input, sortParam.getProperty()); } }); if(!sortParam.isAscending()) ordering = ordering.reverse(); it=ordering.sortedCopy(data).iterator(); } else { it=data.iterator(); } if(filterPredicate!=null) it = Iterators.filter(it, filterPredicate); if(first>0) Iterators.advance(it, (int)first); return count>=0?Iterators.limit(it, (int)count):it; }
Example 6
Source File: MyListPageSortableDataProvider.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
protected Comparator<T> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<T>(sortProperty, ascending, secondSortProperty, secondAscending); }
Example 7
Source File: TimesheetMassUpdatePage.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
public TimesheetMassUpdatePage(final AbstractSecuredPage callerPage, final List<TimesheetDO> timesheets) { super(new PageParameters(), callerPage); this.timesheets = timesheets; form = new TimesheetMassUpdateForm(this); Integer taskId = null; for (final TimesheetDO sheet : timesheets) { if (taskId == null) { taskId = sheet.getTaskId(); } else if (taskId.equals(sheet.getTaskId()) == false) { taskId = null; break; } } if (taskId != null) { // All time sheets have the same task, so pre-select this task. timesheetDao.setTask(form.data, taskId); } body.add(form); form.init(); final List<IColumn<TimesheetDO, String>> columns = TimesheetListPage.createColumns(this, false, true, null, taskTree, userFormatter, dateTimeFormatter); @SuppressWarnings("serial") final SortableDataProvider<TimesheetDO, String> sortableDataProvider = new SortableDataProvider<TimesheetDO, String>() { public Iterator<TimesheetDO> iterator(final long first, final long count) { final SortParam sp = getSort(); final Comparator<TimesheetDO> comp = new MyBeanComparator<TimesheetDO>(sp.getProperty().toString(), sp.isAscending()); Collections.sort(timesheets, comp); return timesheets.subList((int)first, (int)(first + count)).iterator(); } public long size() { return timesheets != null ? timesheets.size() : 0; } public IModel<TimesheetDO> model(final TimesheetDO object) { return new Model<TimesheetDO>() { @Override public TimesheetDO getObject() { return object; } }; } }; sortableDataProvider.setSort("startTime", SortOrder.DESCENDING); final DefaultDataTable<TimesheetDO, String> dataTable = new DefaultDataTable<TimesheetDO, String>("table", columns, sortableDataProvider, 1000); body.add(dataTable); }
Example 8
Source File: TimesheetListPage.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * Avoid LazyInitializationException user.fullname. * @see org.projectforge.web.wicket.AbstractListPage#createSortableDataProvider(java.lang.String, boolean) */ @SuppressWarnings("serial") @Override protected ISortableDataProvider<TimesheetDO, String> createSortableDataProvider(final SortParam<String> sortParam) { this.listPageSortableDataProvider = new MyListPageSortableDataProvider<TimesheetDO>(sortParam, null, this) { @Override protected Comparator<TimesheetDO> getComparator(final SortParam<String> sortParam, final SortParam<String> secondSortParam) { final String sortProperty = sortParam != null ? sortParam.getProperty() : null; final boolean ascending = sortParam != null ? sortParam.isAscending() : true; final String secondSortProperty = secondSortParam != null ? secondSortParam.getProperty() : null; final boolean secondAscending = secondSortParam != null ? secondSortParam.isAscending() : true; return new MyBeanComparator<TimesheetDO>(sortProperty, ascending, secondSortProperty, secondAscending) { @Override public int compare(final TimesheetDO t1, final TimesheetDO t2) { if ("user.fullname".equals(sortProperty) == true) { PFUserDO user = t1.getUser(); if (user != null && Hibernate.isInitialized(user) == false) { t1.setUser(userGroupCache.getUser(user.getId())); } user = t2.getUser(); if (user != null && Hibernate.isInitialized(user) == false) { t2.setUser(userGroupCache.getUser(user.getId())); } } else if ("task.title".equals(sortProperty) == true) { TaskDO task = t1.getTask(); if (task != null && Hibernate.isInitialized(task) == false) { t1.setTask(taskTree.getTaskById(task.getId())); } task = t2.getTask(); if (task != null && Hibernate.isInitialized(task) == false) { t2.setTask(taskTree.getTaskById(task.getId())); } } return super.compare(t1, t2); } }; } }; return this.listPageSortableDataProvider; }
Example 9
Source File: AddressCampaignValueMassUpdatePage.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
public AddressCampaignValueMassUpdatePage(final AbstractSecuredPage callerPage, final List<AddressDO> addresses, final AddressCampaignDO addressCampaign, final Map<Integer, PersonalAddressDO> personalAddressMap, final Map<Integer, AddressCampaignValueDO> addressCampaignValueMap) { super(new PageParameters(), callerPage); this.addresses = addresses; form = new AddressCampaignValueMassUpdateForm(this, addressCampaign); body.add(form); form.init(); final List<IColumn<AddressDO, String>> columns = AddressCampaignValueListPage.createColumns(this, false, true, null, personalAddressMap, addressCampaignValueMap); @SuppressWarnings("serial") final SortableDataProvider<AddressDO, String> sortableDataProvider = new SortableDataProvider<AddressDO, String>() { @Override public Iterator< ? extends AddressDO> iterator(final long first, final long count) { final SortParam sp = getSort(); if (addresses == null) { return null; } final Comparator<AddressDO> comp = new MyBeanComparator<AddressDO>(sp.getProperty().toString(), sp.isAscending()); Collections.sort(addresses, comp); return addresses.subList((int)first, (int)(first + count)).iterator(); } public long size() { return addresses != null ? addresses.size() : 0; } public IModel<AddressDO> model(final AddressDO object) { return new Model<AddressDO>() { @Override public AddressDO getObject() { return object; } }; } }; sortableDataProvider.setSort("name", SortOrder.DESCENDING); final DefaultDataTable<AddressDO, String> dataTable = new DefaultDataTable<AddressDO, String>("table", columns, sortableDataProvider, 1000); body.add(dataTable); }