Search in sources :

Example 1 with SortOrder

use of org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder in project midpoint by Evolveum.

the class TableHeadersToolbar method newSortableHeader.

@Override
protected WebMarkupContainer newSortableHeader(String headerId, final String property, final ISortStateLocator locator) {
    IDataProvider provider = getTable().getDataProvider();
    if (provider instanceof BaseSortableDataProvider) {
        BaseSortableDataProvider sortableDataProvider = (BaseSortableDataProvider) provider;
        if (sortableDataProvider.isOrderingDisabled()) {
            return new WebMarkupContainer(headerId);
        }
    }
    return new AjaxFallbackOrderByBorder(headerId, property, locator) {

        @Override
        protected void onSortChanged() {
            getTable().setCurrentPage(0);
        }

        @Override
        protected void onAjaxClick(AjaxRequestTarget target) {
            refreshTable(target);
        }

        @Override
        public void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            ISortState sortState = locator.getSortState();
            SortOrder dir = sortState.getPropertySortOrder(property);
            String cssClass;
            if (dir == SortOrder.ASCENDING) {
                cssClass = "sortable asc";
            } else if (dir == SortOrder.DESCENDING) {
                cssClass = "sortable desc";
            } else {
                cssClass = "sortable";
            }
            if (!Strings.isEmpty(cssClass)) {
                tag.append("class", cssClass, " ");
            }
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) SortOrder(org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) AjaxFallbackOrderByBorder(org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ISortState(org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFallbackOrderByBorder (org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder)1 ISortState (org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)1 SortOrder (org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder)1 ComponentTag (org.apache.wicket.markup.ComponentTag)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 IDataProvider (org.apache.wicket.markup.repeater.data.IDataProvider)1