Example usage for org.springframework.beans.support MutableSortDefinition getProperty

List of usage examples for org.springframework.beans.support MutableSortDefinition getProperty

Introduction

In this page you can find the example usage for org.springframework.beans.support MutableSortDefinition getProperty.

Prototype

@Override
    public String getProperty() 

Source Link

Usage

From source file:de.iteratec.iteraplan.presentation.dialog.GuiSearchController.java

/**
 *    Get/create SortDefinition for active dialog and store it in DialogMemory for this request.
 *    When a sort action happened, toggles the appropriate column in the sort definition.  
 *    If no sorting is defined, it sorts the first column ascending.
 */// w  ww .  ja  v  a 2  s. c  o m
@SuppressWarnings("boxing")
private void initColumnSortDefinition(T dialogMemory) {
    TableActionParams params = dialogMemory.getTableActionParameter();

    // Get/create SortDefinition for this Dialog and store it in DialogMemory for this request
    MutableSortDefinition sortDefinition = dialogMemory.getTableState().getSortDefinition();

    // check, if sorting is toggled
    List<ColumnDefinition> visibleColumnDefinitions = dialogMemory.getTableState()
            .getVisibleColumnDefinitions();
    if (params != null && params.getColSortIndex() != null) {
        int sortIndex = params.getColSortIndex();

        if (sortIndex < 0) {
            sortIndex = 0;
        }

        if (sortIndex > (visibleColumnDefinitions.size() - 1)) {
            sortIndex = visibleColumnDefinitions.size() - 1;
        }

        ColumnDefinition sortColumnDefinition = visibleColumnDefinitions.get(sortIndex);
        sortDefinition.setProperty(sortColumnDefinition.getBeanPropertyPath());
        params.setColSortIndex(null);
    } else if (params != null && params.getSortByPosition() != null && params.getSortByPosition().booleanValue()
            && dialogMemory.isTreeView()) {
        sortDefinition.setProperty("position");
        sortDefinition.setAscending(true);
        params.setSortByPosition(null);
    } else {

        if (sortDefinition.getProperty() != null && "".equals(sortDefinition.getProperty())
                && visibleColumnDefinitions != null && visibleColumnDefinitions.size() > 0) {

            // set sort definition to first column's property
            sortDefinition.setProperty(visibleColumnDefinitions.get(0).getModelPath());
        }
    }
}