Search in sources :

Example 6 with GridSortOrder

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)));
}
Also used : UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) ShareRequestCriteria(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestCriteria) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LabMessageIndexDto(de.symeda.sormas.api.labmessage.LabMessageIndexDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) SortDirection(com.vaadin.shared.data.sort.SortDirection) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GridSortOrder(com.vaadin.data.provider.GridSortOrder) VaadinIcons(com.vaadin.icons.VaadinIcons) DataProvider(com.vaadin.data.provider.DataProvider) DateRenderer(com.vaadin.ui.renderers.DateRenderer) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) ListDataProvider(com.vaadin.data.provider.ListDataProvider) FilteredGrid(de.symeda.sormas.ui.utils.FilteredGrid) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) ShareRequestStatus(de.symeda.sormas.api.sormastosormas.sharerequest.ShareRequestStatus) SortProperty(de.symeda.sormas.api.utils.SortProperty) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) SormasToSormasShareRequestIndexDto(de.symeda.sormas.api.sormastosormas.sharerequest.SormasToSormasShareRequestIndexDto) Consumer(java.util.function.Consumer) ShowDetailsListener(de.symeda.sormas.ui.utils.ShowDetailsListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) Collections(java.util.Collections) Component(com.vaadin.ui.Component) GridSortOrder(com.vaadin.data.provider.GridSortOrder) BooleanRenderer(de.symeda.sormas.ui.utils.BooleanRenderer) UuidRenderer(de.symeda.sormas.ui.utils.UuidRenderer) DateRenderer(com.vaadin.ui.renderers.DateRenderer)

Example 7 with GridSortOrder

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;
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder) Element(org.dom4j.Element)

Example 8 with GridSortOrder

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;
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder) DataGrid(io.jmix.ui.component.DataGrid) DataGridSettings(io.jmix.ui.settings.component.DataGridSettings)

Example 9 with GridSortOrder

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;
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder) DataGridSettings(io.jmix.ui.settings.component.DataGridSettings)

Example 10 with GridSortOrder

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);
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder)

Aggregations

GridSortOrder (com.vaadin.data.provider.GridSortOrder)11 DataGridSettings (io.jmix.ui.settings.component.DataGridSettings)4 DataGrid (io.jmix.ui.component.DataGrid)3 Element (org.dom4j.Element)3 CubaEnhancedGrid (com.haulmont.cuba.web.widgets.CubaEnhancedGrid)2 Grid (com.vaadin.ui.Grid)2 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 SortableDataProvider (com.haulmont.cuba.web.widgets.data.SortableDataProvider)1 DataProvider (com.vaadin.data.provider.DataProvider)1 ListDataProvider (com.vaadin.data.provider.ListDataProvider)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 SortDirection (com.vaadin.shared.data.sort.SortDirection)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 DateRenderer (com.vaadin.ui.renderers.DateRenderer)1 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1