Search in sources :

Example 1 with ComponentSettingsBinder

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

the class ComponentSettingsRegistryImpl method isSettingsRegisteredFor.

@Override
public boolean isSettingsRegisteredFor(Class<? extends Component> componentClass) {
    Preconditions.checkNotNullArgument(componentClass);
    ComponentSettingsBinder binder = componentBinders.get(componentClass);
    return binder != null;
}
Also used : ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 2 with ComponentSettingsBinder

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

the class ComponentSettingsRegistryImpl method getSettingsBinder.

@Override
public ComponentSettingsBinder getSettingsBinder(Class<? extends Component> componentClass) {
    Preconditions.checkNotNullArgument(componentClass);
    ComponentSettingsBinder binder = componentBinders.get(componentClass);
    if (binder != null) {
        return binder;
    }
    throw new IllegalStateException(String.format("Cannot find settings binder for '%s'", componentClass));
}
Also used : ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 3 with ComponentSettingsBinder

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

the class ComponentSettingsRegistryImpl method getSettingsClass.

@Override
public Class<? extends ComponentSettings> getSettingsClass(Class<? extends Component> componentClass) {
    Preconditions.checkNotNullArgument(componentClass);
    ComponentSettingsBinder binder = componentBinders.get(componentClass);
    if (binder != null) {
        return binder.getSettingsClass();
    }
    throw new IllegalStateException(String.format("Can't find settings class for '%s'", componentClass));
}
Also used : ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 4 with ComponentSettingsBinder

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

the class PresentationsManagerImpl method setupDefaultSettings.

@Override
public void setupDefaultSettings(Collection<Component> components) {
    for (Component component : components) {
        if (Strings.isNullOrEmpty(component.getId()) || !settingsRegistry.isSettingsRegisteredFor(component.getClass()) || !(component instanceof HasTablePresentations)) {
            continue;
        }
        ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
        ComponentSettings defaultSettings = binder.getSettings(component);
        ((HasTablePresentations) component).setDefaultSettings(new SettingsWrapperImpl(defaultSettings));
    }
}
Also used : ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) Component(io.jmix.ui.component.Component) HasTablePresentations(io.jmix.ui.component.HasTablePresentations) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 5 with ComponentSettingsBinder

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

the class ScreenSettingsManagerImpl method applySettings.

@Override
public void applySettings(Collection<Component> components, ScreenSettings screenSettings) {
    Preconditions.checkNotNullArgument(components);
    Preconditions.checkNotNullArgument(screenSettings);
    for (Component component : components) {
        if (Strings.isNullOrEmpty(component.getId()) || !settingsRegistry.isSettingsRegisteredFor(component.getClass())) {
            continue;
        }
        log.trace("Applying settings for {} : {} ", getComponentPath(component), component);
        ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
        Class<? extends ComponentSettings> settingsClass = settingsRegistry.getSettingsClass(component.getClass());
        ComponentSettings settings = screenSettings.getSettingsOrCreate(component.getId(), settingsClass);
        binder.applySettings(component, new SettingsWrapperImpl(settings));
    }
}
Also used : ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) Component(io.jmix.ui.component.Component) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Aggregations

ComponentSettingsBinder (io.jmix.ui.settings.component.binder.ComponentSettingsBinder)7 Component (io.jmix.ui.component.Component)4 ComponentSettings (io.jmix.ui.settings.component.ComponentSettings)4 SettingsWrapperImpl (io.jmix.ui.settings.component.SettingsWrapperImpl)4 HasTablePresentations (io.jmix.ui.component.HasTablePresentations)1 AbstractScreenSettings (io.jmix.ui.settings.AbstractScreenSettings)1 DataLoadingSettingsBinder (io.jmix.ui.settings.component.binder.DataLoadingSettingsBinder)1