use of io.jmix.ui.settings.ScreenSettings 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);
}
use of io.jmix.ui.settings.ScreenSettings in project jmix by jmix-framework.
the class ScreenSettingsFacetResolver method resolveLazyTabSelectEvent.
/**
* Resolves applying settings and presentations for components in a lazy tab e.g. {@link TabSheet} or
* {@link Accordion}.
*
* @param window screen window
* @param source component source
* @param components tab content
*/
public void resolveLazyTabSelectEvent(Window window, Component source, Collection<Component> components) {
List<PresentationsFacet> presentationsFacet = window.getFacets().filter(facet -> facet instanceof PresentationsFacet).map(facet -> (PresentationsFacet) facet).collect(Collectors.toList());
boolean isPresentationsAdded = presentationsFacet.size() > 0;
Collection<Component> managedComponents = getManagedComponents(presentationsFacet, components);
if (isPresentationsAdded) {
for (Component component : managedComponents) {
if (component instanceof HasTablePresentations) {
((HasTablePresentations) component).loadPresentations();
}
}
if (presentationsManager != null) {
presentationsManager.setupDefaultSettings(managedComponents);
}
}
window.getFacets().forEach(facet -> {
if (facet instanceof ScreenSettingsFacet) {
ScreenSettingsFacet settingsFacet = (ScreenSettingsFacet) facet;
Consumer<ScreenSettingsFacet.SettingsContext> applyHandler = settingsFacet.getApplySettingsDelegate();
ScreenSettings settings = settingsFacet.getSettings();
if (settings == null) {
throw new IllegalStateException("ScreenSettingsFacet is not attached to the frame");
}
if (applyHandler != null) {
applyHandler.accept(new ScreenSettingsFacet.SettingsContext(source, components, settings));
} else {
settingsFacet.applySettings(components);
}
}
});
if (isPresentationsAdded && presentationsManager != null) {
presentationsManager.applyDefaultPresentation(managedComponents);
}
}
use of io.jmix.ui.settings.ScreenSettings 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);
}
use of io.jmix.ui.settings.ScreenSettings 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;
}
Aggregations