use of com.vaadin.data.provider.GridSortOrder in project SORMAS-Project by hzi-braunschweig.
the class ShareRequestGrid method initGridColumns.
private void initGridColumns() {
addShowColumn((request) -> {
ControllerProvider.getSormasToSormasController().showRequestDetails(request);
});
addComponentColumn(indexDto -> createActionButtons(indexDto)).setId(COLUMN_ACTIONS);
setColumns(SHOW_MESSAGE, SormasToSormasShareRequestIndexDto.UUID, SormasToSormasShareRequestIndexDto.CREATION_DATE, SormasToSormasShareRequestIndexDto.DATA_TYPE, SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME, SormasToSormasShareRequestIndexDto.SENDER_NAME, SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER, SormasToSormasShareRequestIndexDto.STATUS, SormasToSormasShareRequestIndexDto.COMMENT, COLUMN_ACTIONS);
getColumn(COLUMN_ACTIONS).setMinimumWidth(260);
((Column<SormasToSormasShareRequestIndexDto, String>) getColumn(LabMessageIndexDto.UUID)).setRenderer(new UuidRenderer());
((Column<SormasToSormasShareRequestIndexDto, Date>) getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE)).setRenderer(new DateRenderer(DateHelper.getLocalDateTimeFormat(I18nProperties.getUserLanguage())));
getColumn(SormasToSormasShareRequestIndexDto.ORGANIZATION_NAME).setSortable(false);
getColumn(SormasToSormasShareRequestIndexDto.OWNERSHIP_HANDED_OVER).setRenderer(new BooleanRenderer());
for (Column<?, ?> column : getColumns()) {
column.setCaption(I18nProperties.getPrefixCaption(SormasToSormasShareRequestIndexDto.I18N_PREFIX, column.getId(), column.getCaption()));
}
setSortOrder(Collections.singletonList(new GridSortOrder<>(getColumn(SormasToSormasShareRequestIndexDto.CREATION_DATE), SortDirection.DESCENDING)));
}
use of com.vaadin.data.provider.GridSortOrder in project cuba by cuba-platform.
the class WebAbstractDataGrid method saveSettings.
@Override
public boolean saveSettings(Element element) {
if (!isSettingsEnabled()) {
return false;
}
Element columnsElem = element.element("columns");
String sortColumnId = null;
String sortDirection = null;
if (columnsElem != null) {
sortColumnId = columnsElem.attributeValue("sortColumnId");
sortDirection = columnsElem.attributeValue("sortDirection");
}
boolean commonSettingsChanged = isCommonDataGridSettingsChanged(columnsElem);
boolean sortChanged = isSortPropertySettingsChanged(sortColumnId, sortDirection);
boolean settingsChanged = commonSettingsChanged || sortChanged;
if (settingsChanged) {
if (columnsElem != null) {
element.remove(columnsElem);
}
columnsElem = element.addElement("columns");
List<Column<E>> visibleColumns = getVisibleColumns();
for (Column<E> column : visibleColumns) {
Element colElem = columnsElem.addElement("columns");
colElem.addAttribute("id", column.toString());
double width = column.getWidth();
if (width > -1) {
colElem.addAttribute("width", String.valueOf(width));
}
colElem.addAttribute("collapsed", Boolean.toString(column.isCollapsed()));
}
List<GridSortOrder<E>> sortOrders = component.getSortOrder();
if (!sortOrders.isEmpty()) {
GridSortOrder<E> sortOrder = sortOrders.get(0);
columnsElem.addAttribute("sortColumnId", sortOrder.getSorted().getId());
columnsElem.addAttribute("sortDirection", sortOrder.getDirection().toString());
}
}
return settingsChanged;
}
use of com.vaadin.data.provider.GridSortOrder in project jmix by jmix-framework.
the class AbstractDataGridSettingsBinder method saveSettings.
@Override
public boolean saveSettings(DataGrid dataGrid, SettingsWrapper wrapper) {
DataGridSettings settings = wrapper.getSettings();
String sortColumnId = null;
DataGrid.SortDirection sortDirection = null;
if (settings.getColumns() != null) {
sortColumnId = settings.getSortColumnId();
sortDirection = settings.getSortDirection();
}
boolean commonSettingsChanged = isCommonDataGridSettingsChanged(dataGrid, settings);
boolean sortChanged = isSortPropertySettingsChanged(dataGrid, sortColumnId, sortDirection);
boolean settingsChanged = commonSettingsChanged || sortChanged;
if (settingsChanged) {
settings.setColumns(getColumnsSettings(dataGrid));
List<GridSortOrder> sortOrders = getGrid(dataGrid).getSortOrder();
// so we don't save null sorting
if (!sortOrders.isEmpty()) {
GridSortOrder sortOrder = sortOrders.get(0);
settings.setSortColumnId(sortOrder.getSorted().getId());
settings.setSortDirection(WrapperUtils.convertToDataGridSortDirection(sortOrder.getDirection()));
}
}
return settingsChanged;
}
use of com.vaadin.data.provider.GridSortOrder in project jmix by jmix-framework.
the class AbstractDataGridSettingsBinder method getSettings.
@Override
public DataGridSettings getSettings(DataGrid dataGrid) {
DataGridSettings settings = createSettings();
settings.setId(dataGrid.getId());
settings.setColumns(getColumnsSettings(dataGrid));
List<GridSortOrder> sortOrders = getGrid(dataGrid).getSortOrder();
if (!sortOrders.isEmpty()) {
GridSortOrder sortOrder = sortOrders.get(0);
settings.setSortColumnId(sortOrder.getSorted().getId());
settings.setSortDirection(WrapperUtils.convertToDataGridSortDirection(sortOrder.getDirection()));
}
return settings;
}
use of com.vaadin.data.provider.GridSortOrder in project jmix by jmix-framework.
the class AbstractDataGridSettingsBinder method isSortPropertySettingsChanged.
protected boolean isSortPropertySettingsChanged(DataGrid dataGrid, @Nullable String settingsSortColumnId, @Nullable DataGrid.SortDirection settingsSort) {
List<GridSortOrder> sortOrders = getGrid(dataGrid).getSortOrder();
String columnId = null;
com.vaadin.shared.data.sort.SortDirection sort = null;
if (!sortOrders.isEmpty()) {
GridSortOrder sortOrder = sortOrders.get(0);
columnId = sortOrder.getSorted().getId();
sort = sortOrder.getDirection();
}
com.vaadin.shared.data.sort.SortDirection settingsGridSort = settingsSort != null ? WrapperUtils.convertToGridSortDirection(settingsSort) : null;
return !Objects.equals(columnId, settingsSortColumnId) || !Objects.equals(sort, settingsGridSort);
}
Aggregations