Search in sources :

Example 1 with CubaFilterSettings

use of com.haulmont.cuba.settings.component.CubaFilterSettings in project jmix by jmix-framework.

the class CubaFilterSettingsBinder method getSettings.

@Override
public CubaFilterSettings getSettings(Filter component) {
    CubaFilterSettings settings = createSettings();
    settings.setId(component.getId());
    settings.setGroupBoxExpanded(component.isExpanded());
    FilterDelegate delegate = getFilterDelegate(component);
    if (isMaxResultsLayoutVisible(delegate)) {
        settings.setMaxResults(getMaxResultsValue(delegate));
    }
    FilterEntity defaultFilter = getDefaultFilter(delegate);
    if (defaultFilter != null) {
        settings.setDefaultFilterId(defaultFilter.getId().toString());
        settings.setApplyDefault(defaultFilter.getApplyDefault());
    }
    return settings;
}
Also used : FilterDelegate(com.haulmont.cuba.gui.components.filter.FilterDelegate) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings)

Example 2 with CubaFilterSettings

use of com.haulmont.cuba.settings.component.CubaFilterSettings in project jmix by jmix-framework.

the class CubaFilterSettingsBinder method applyDataLoadingSettings.

@Override
public void applyDataLoadingSettings(Filter component, SettingsWrapper wrapper) {
    CubaFilterSettings settings = wrapper.getSettings();
    FilterDelegate delegate = getFilterDelegate(component);
    if (applyMaxResultsSettingsBeforeLoad(delegate) && settings.getMaxResults() != null) {
        applyMaxResultsSettings(delegate, settings.getMaxResults());
    }
}
Also used : FilterDelegate(com.haulmont.cuba.gui.components.filter.FilterDelegate) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings)

Example 3 with CubaFilterSettings

use of com.haulmont.cuba.settings.component.CubaFilterSettings in project jmix by jmix-framework.

the class CubaFilterSettingsBinder method applySettings.

@Override
public void applySettings(Filter component, SettingsWrapper wrapper) {
    CubaFilterSettings settings = wrapper.getSettings();
    if (settings.getGroupBoxExpanded() != null) {
        component.setExpanded(settings.getGroupBoxExpanded());
    }
    FilterDelegate delegate = getFilterDelegate(component);
    if (!applyMaxResultsSettingsBeforeLoad(delegate) && settings.getMaxResults() != null) {
        applyMaxResultsSettings(delegate, settings.getMaxResults());
    }
}
Also used : FilterDelegate(com.haulmont.cuba.gui.components.filter.FilterDelegate) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings)

Example 4 with CubaFilterSettings

use of com.haulmont.cuba.settings.component.CubaFilterSettings in project jmix by jmix-framework.

the class FilterDelegateImpl method getDefaultFilterFromScreenSettings.

@Nullable
protected FilterEntity getDefaultFilterFromScreenSettings(List<FilterEntity> filters) {
    if (filter.getFrame() == null || StringUtils.isBlank(filter.getId())) {
        return null;
    }
    ScreenSettingsFacet settingsFacet = UiControllerUtils.getFacet(filter.getFrame(), ScreenSettingsFacet.class);
    if (settingsFacet == null || settingsFacet.getSettings() == null) {
        return null;
    }
    CubaFilterSettings cubaFilterSettings = settingsFacet.getSettings().getSettings(filter.getId(), CubaFilterSettings.class).orElse(null);
    if (cubaFilterSettings == null) {
        return null;
    }
    String settingsDefaultId = cubaFilterSettings.getDefaultFilterId();
    if (StringUtils.isBlank(settingsDefaultId)) {
        return null;
    }
    UUID defaultId = null;
    try {
        defaultId = UUID.fromString(settingsDefaultId);
    } catch (IllegalArgumentException ex) {
    // do nothing
    }
    if (defaultId != null) {
        for (FilterEntity filter : filters) {
            if (defaultId.equals(filter.getId())) {
                filter.setIsDefault(true);
                filter.setApplyDefault(cubaFilterSettings.getApplyDefault());
                return filter;
            }
        }
    }
    return null;
}
Also used : ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings) Nullable(javax.annotation.Nullable)

Example 5 with CubaFilterSettings

use of com.haulmont.cuba.settings.component.CubaFilterSettings in project jmix by jmix-framework.

the class CubaFilterSettingsBinder method saveSettings.

@Override
public boolean saveSettings(Filter component, SettingsWrapper wrapper) {
    CubaFilterSettings settings = wrapper.getSettings();
    if (!isSettingsChanged(component, settings)) {
        return false;
    }
    FilterDelegate delegate = getFilterDelegate(component);
    if (isMaxResultsLayoutVisible(delegate)) {
        settings.setMaxResults(getMaxResultsValue(delegate));
    }
    settings.setGroupBoxExpanded(component.isExpanded());
    FilterEntity defaultFilter = getDefaultFilter(delegate);
    if (defaultFilter == null) {
        settings.setDefaultFilterId(null);
        settings.setApplyDefault(null);
    } else {
        settings.setDefaultFilterId(defaultFilter.getId().toString());
        settings.setApplyDefault(defaultFilter.getApplyDefault());
    }
    return true;
}
Also used : FilterDelegate(com.haulmont.cuba.gui.components.filter.FilterDelegate) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) CubaFilterSettings(com.haulmont.cuba.settings.component.CubaFilterSettings)

Aggregations

CubaFilterSettings (com.haulmont.cuba.settings.component.CubaFilterSettings)5 FilterDelegate (com.haulmont.cuba.gui.components.filter.FilterDelegate)4 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)3 ScreenSettingsFacet (io.jmix.ui.settings.facet.ScreenSettingsFacet)1 Nullable (javax.annotation.Nullable)1