return;
}
IPageableComponent<E> component = getTable();
IDataProvider<E> dataProvider = component.getDataProvider();
if(dataProvider instanceof ISortStateLocator) {
ISortStateLocator locator = (ISortStateLocator)dataProvider;
ISortState sortState = locator.getSortState();
if(sortState != null) {
int sortOrder = sortState.getPropertySortOrder(columnModel.getSortProperty());
if(sortOrder == ISortState.DESCENDING)
sortState.setPropertySortOrder(columnModel.getSortProperty(), ISortState.ASCENDING);
else if(sortOrder == ISortState.ASCENDING)
sortState.setPropertySortOrder(columnModel.getSortProperty(), ISortState.DESCENDING);
else
sortState.setPropertySortOrder(columnModel.getSortProperty(), ISortState.ASCENDING);
}
component.reset();
}
target.addComponent((Component)component);
}
}
});
}
draggableTarget .setOutputMarkupId(true);
add(draggableTarget);
Label title = new Label("title", titleModel);
title.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
IColumn<E> columnModel = DefaultHeaderCell.this.getColumnModel();
if(!columnModel.isSortable()) {
return "headerTitle";
}
IPageableComponent<E> component = getTable();
IDataProvider<E> dataProvider = component.getDataProvider();
if(dataProvider instanceof ISortStateLocator) {
ISortStateLocator locator = (ISortStateLocator)dataProvider;
ISortState sortState = locator.getSortState();
if(sortState != null) {
int sortOrder = sortState.getPropertySortOrder(columnModel.getSortProperty());
if(sortOrder == ISortState.DESCENDING)
return "headerTitleDesc";
else if(sortOrder == ISortState.ASCENDING)
return "headerTitleAsc";
}
}
return "headerTitle";
}
}));
draggableTarget.add(title);
WebMarkupContainer dragTd = new WebMarkupContainer("dragTd");
dragTd.add(new AttributeModifier("id", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if(!DefaultHeaderCell.this.getTable().isColumnsResizable())
return DefaultHeaderCell.this.getTable().getMarkupId()+"_cND_"+DefaultHeaderCell.this.getColumn();
if(columnModel.isResizable() )
return DefaultHeaderCell.this.getTable().getMarkupId()+"_c_"+DefaultHeaderCell.this.getColumn();
// this naming does the trick of making the column non re-sizable
return DefaultHeaderCell.this.getTable().getMarkupId()+"_cND_"+DefaultHeaderCell.this.getColumn();
}
}));
dragTd.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if(!DefaultHeaderCell.this.getTable().isColumnsResizable())
return "noResCol";
if(columnModel.isResizable() )
return "resCol";
return "noResCol";
}
}));
add(dragTd);
WebMarkupContainer sortInfo = new WebMarkupContainer("sortInfo");
sortInfo.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
IColumn<E> columnModel = DefaultHeaderCell.this.getColumnModel();
if(!columnModel.isSortable()) {
return "";
}
IPageableComponent<E> component = getTable();
IDataProvider<E> dataProvider = component.getDataProvider();
if(dataProvider instanceof ISortStateLocator) {
ISortStateLocator locator = (ISortStateLocator)dataProvider;
ISortState sortState = locator.getSortState();
if(sortState != null) {
int sortOrder = sortState.getPropertySortOrder(columnModel.getSortProperty());
if(sortOrder == ISortState.DESCENDING)
return "ui-icon ui-icon-triangle-1-s";
else if(sortOrder == ISortState.ASCENDING)