Java Code Examples for org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder#DESCENDING

The following examples show how to use org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder#DESCENDING . 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: SemesterPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public Iterator<? extends Semester> iterator(long first, long count) {			
	List<Semester>myList = getData();
	if (needToSortList) {
		log.debug("sorting the collection");
		String prop = getSort().getProperty();
		SortOrder order =  getSortState().getPropertySortOrder(prop);			
		Comparator<Semester> comp = ComparatorFactory.createComparator(prop);
		Collections.sort(myList, comp);
		if (order == SortOrder.DESCENDING) {
			Collections.reverse(myList);
		}
		needToSortList = false;
	}
	else {
		log.debug("skipped sorting because the sort order should be the same as before..");
	}
	
	int fint = (int)first;
	int fcount = (int)count;
	return myList.subList(fint, fint + fcount).iterator();
}
 
Example 2
Source File: SemesterPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public Iterator<? extends Semester> iterator(long first, long count) {			
	List<Semester>myList = getData();
	if (needToSortList) {
		log.debug("sorting the collection");
		String prop = getSort().getProperty();
		SortOrder order =  getSortState().getPropertySortOrder(prop);			
		Comparator<Semester> comp = ComparatorFactory.createComparator(prop);
		Collections.sort(myList, comp);
		if (order == SortOrder.DESCENDING) {
			Collections.reverse(myList);
		}
		needToSortList = false;
	}
	else {
		log.debug("skipped sorting because the sort order should be the same as before..");
	}
	
	int fint = (int)first;
	int fcount = (int)count;
	return myList.subList(fint, fint + fcount).iterator();
}
 
Example 3
Source File: OrienteerHeadersToolbar.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private WebMarkupContainer newIconContainer(String id, final S property, final ISortStateLocator<S> locator) {
    return new WebMarkupContainer(id) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            ISortState<S> sortState = locator.getSortState();
            SortOrder sortOrder = sortState.getPropertySortOrder(property);
            String iconClass;
            if (sortOrder == SortOrder.ASCENDING) {
                iconClass = FAIconType.sort_asc.getCssClass();
            } else if (sortOrder == SortOrder.DESCENDING) {
                iconClass = FAIconType.sort_desc.getCssClass();
            } else {
                iconClass = FAIconType.sort.getCssClass();
            }
            if (!Strings.isEmpty(iconClass)) {
                tag.append("class", iconClass, " ");
            }
        }
    };
}
 
Example 4
Source File: OQueryDataProvider.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Set sort
 * @param property property to sort on
 * @param order order to apply: true is for ascending, false is for descending
 */
public void setSort(String property, Boolean order) {
	SortOrder sortOrder = order==null?SortOrder.ASCENDING:(order?SortOrder.ASCENDING:SortOrder.DESCENDING);
	if(property==null) {
		if(order==null) setSort(null);
		else setSort("@rid", sortOrder);
	} else {
		super.setSort(property, sortOrder);
	}
}
 
Example 5
Source File: OClassIntrospector.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void defineDefaultSorting(SortableDataProvider<ODocument, String> provider, OClass oClass) {
	if(oClass==null) return;
	OProperty property = CustomAttribute.SORT_BY.getValue(oClass);
	Boolean order = CustomAttribute.SORT_ORDER.getValue(oClass);
	SortOrder sortOrder = order==null?SortOrder.ASCENDING:(order?SortOrder.ASCENDING:SortOrder.DESCENDING);
   	if(property==null) {
   		if(order==null) provider.setSort(null);
   		else provider.setSort("@rid", sortOrder);
   	} else {
   		provider.setSort(property.getName(), sortOrder);
   	}
}
 
Example 6
Source File: AnalysisDataProvider.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AnalysisDataProvider(IModel<Analysis> model) {
	this.analysis = model.getObject();
	if ((analysis != null) && (analysis.getSortProperty() != null) && !analysis.getSortProperty().isEmpty()) {
		SortOrder order = analysis.getAscending().get(0) ? SortOrder.ASCENDING : SortOrder.DESCENDING;
		setSort(analysis.getSortProperty().get(0), order);
	}		
	Injector.get().inject(this);
}