Search in sources :

Example 1 with FilterSettings

use of io.jmix.ui.settings.component.FilterSettings in project jmix by jmix-framework.

the class FilterSettingsBinder method getSettings.

@Override
public FilterSettings getSettings(Filter component) {
    FilterSettings settings = createSettings();
    settings.setId(component.getId());
    return settings;
}
Also used : FilterSettings(io.jmix.ui.settings.component.FilterSettings)

Example 2 with FilterSettings

use of io.jmix.ui.settings.component.FilterSettings in project jmix by jmix-framework.

the class UiDataFilterSupport method saveFilterSettings.

protected void saveFilterSettings(ScreenSettingsFacet screenSettingsFacet, String filterId, FilterConfiguration configurationModel) {
    ScreenSettings settings = screenSettingsFacet.getSettings();
    if (settings == null) {
        throw new IllegalStateException("ScreenSettingsFacet is not attached to the frame");
    }
    FilterSettings filterSettings = settings.getSettingsOrCreate(filterId, FilterSettings.class);
    if (Objects.equals(filterSettings.getDefaultConfigurationId(), configurationModel.getConfigurationId()) && !configurationModel.getDefaultForMe()) {
        filterSettings.setDefaultConfigurationId(null);
    }
    if (configurationModel.getDefaultForMe()) {
        filterSettings.setDefaultConfigurationId(configurationModel.getConfigurationId());
    }
    settings.put(filterSettings);
}
Also used : ScreenSettings(io.jmix.ui.settings.ScreenSettings) FilterSettings(io.jmix.ui.settings.component.FilterSettings)

Example 3 with FilterSettings

use of io.jmix.ui.settings.component.FilterSettings in project jmix by jmix-framework.

the class FilterMakeDefaultAction method execute.

@Override
public void execute() {
    if (filter.getFrame() == null) {
        throw new IllegalStateException("Filter component is not attached to the Frame");
    }
    ScreenSettingsFacet screenSettingsFacet = UiControllerUtils.getFacet(filter.getFrame(), ScreenSettingsFacet.class);
    if (screenSettingsFacet == null) {
        throw new IllegalStateException("The Frame does no contain ScreenSettingsFacet");
    }
    ScreenSettings settings = screenSettingsFacet.getSettings();
    if (settings == null) {
        throw new IllegalStateException("ScreenSettingsFacet is not attached to the frame");
    }
    FilterSettings filterSettings = new FilterSettings();
    filterSettings.setId(filter.getId());
    filterSettings.setDefaultConfigurationId(filter.getCurrentConfiguration().getId());
    settings.put(filterSettings);
}
Also used : ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) ScreenSettings(io.jmix.ui.settings.ScreenSettings) FilterSettings(io.jmix.ui.settings.component.FilterSettings)

Example 4 with FilterSettings

use of io.jmix.ui.settings.component.FilterSettings in project jmix by jmix-framework.

the class UiDataFilterSupport method isDefaultForMeFieldVisible.

protected boolean isDefaultForMeFieldVisible(Filter.Configuration currentConfiguration, FilterConfiguration configurationModel) {
    Frame filterFrame = currentConfiguration.getOwner().getFrame();
    if (currentConfiguration.getOwner().getId() != null && filterFrame != null) {
        ScreenSettingsFacet settingsFacet = UiControllerUtils.getFacet(filterFrame, ScreenSettingsFacet.class);
        if (settingsFacet != null) {
            ScreenSettings settings = settingsFacet.getSettings();
            if (settings != null) {
                settings.getSettings(currentConfiguration.getOwner().getId(), FilterSettings.class).ifPresent(filterSettings -> {
                    String defaultConfigurationId = filterSettings.getDefaultConfigurationId();
                    if (defaultConfigurationId != null) {
                        boolean defaultForMe = defaultConfigurationId.equals(configurationModel.getConfigurationId());
                        configurationModel.setDefaultForMe(defaultForMe);
                    }
                });
            }
            return true;
        }
    }
    return false;
}
Also used : Frame(io.jmix.ui.component.Frame) ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) ScreenSettings(io.jmix.ui.settings.ScreenSettings) FilterSettings(io.jmix.ui.settings.component.FilterSettings)

Aggregations

FilterSettings (io.jmix.ui.settings.component.FilterSettings)4 ScreenSettings (io.jmix.ui.settings.ScreenSettings)3 ScreenSettingsFacet (io.jmix.ui.settings.facet.ScreenSettingsFacet)2 Frame (io.jmix.ui.component.Frame)1