Search in sources :

Example 66 with Component

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

the class ScreenSettingsManagerImpl method saveSettings.

@Override
public void saveSettings(Collection<Component> components, ScreenSettings screenSettings) {
    Preconditions.checkNotNullArgument(components);
    Preconditions.checkNotNullArgument(screenSettings);
    boolean isModified = false;
    for (Component component : components) {
        if (!settingsRegistry.isSettingsRegisteredFor(component.getClass()) || component.getId() == null) {
            continue;
        }
        log.trace("Saving settings for {} : {}", getComponentPath(component), component);
        Class<? extends ComponentSettings> settingsClass = settingsRegistry.getSettingsClass(component.getClass());
        ComponentSettings settings = screenSettings.getSettingsOrCreate(component.getId(), settingsClass);
        ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
        boolean settingsChanged = binder.saveSettings(component, new SettingsWrapperImpl(settings));
        if (settingsChanged) {
            isModified = true;
            screenSettings.put(settings);
        }
    }
    if (isModified || screenSettings.isModified()) {
        if (screenSettings instanceof AbstractScreenSettings) {
            ((AbstractScreenSettings) screenSettings).commit();
        }
    }
}
Also used : ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) AbstractScreenSettings(io.jmix.ui.settings.AbstractScreenSettings) Component(io.jmix.ui.component.Component) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 67 with Component

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

the class ScreenSettingsManagerImpl method applyDataLoadingSettings.

@Override
public void applyDataLoadingSettings(Collection<Component> components, ScreenSettings screenSettings) {
    Preconditions.checkNotNullArgument(components);
    Preconditions.checkNotNullArgument(screenSettings);
    for (Component component : components) {
        if (!settingsRegistry.isSettingsRegisteredFor(component.getClass()) || component.getId() == null) {
            continue;
        }
        log.trace("Applying settings for {} : {} ", getComponentPath(component), component);
        Class<? extends ComponentSettings> settingsClass = settingsRegistry.getSettingsClass(component.getClass());
        ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
        if (binder instanceof DataLoadingSettingsBinder) {
            ComponentSettings settings = screenSettings.getSettingsOrCreate(component.getId(), settingsClass);
            ((DataLoadingSettingsBinder) binder).applyDataLoadingSettings(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) DataLoadingSettingsBinder(io.jmix.ui.settings.component.binder.DataLoadingSettingsBinder) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 68 with Component

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

the class FilterEditAction method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void execute() {
    if (filter.getFrame() == null) {
        throw new IllegalStateException("Filter component is not attached to the Frame");
    }
    Filter.Configuration currentConfiguration = filter.getCurrentConfiguration();
    boolean isNewConfiguration = Objects.equals(currentConfiguration.getId(), filter.getEmptyConfiguration().getId());
    LogicalFilterComponent rootComponent = currentConfiguration.getRootLogicalFilterComponent();
    Class modelClass = filterComponents.getModelClass(rootComponent.getClass());
    FilterConverter converter = filterComponents.getConverterByComponentClass(rootComponent.getClass(), filter);
    Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(currentConfiguration);
    LogicalFilterCondition model = (LogicalFilterCondition) converter.convertToModel(rootComponent);
    Screen editScreen = createEditScreen(modelClass, model);
    applyScreenConfigurer(editScreen);
    ScreenFragment screenFragment = filterSupport.createFilterConfigurationFragment(editScreen.getWindow().getFrameOwner(), isNewConfiguration, currentConfiguration);
    Fragment fragment = screenFragment.getFragment();
    fragment.setWidthFull();
    editScreen.getWindow().add(fragment, 0);
    editScreen.getWindow().setCaption(messages.getMessage(FilterEditAction.class, "configurationEdit.caption"));
    if (editScreen instanceof GroupFilterConditionEdit) {
        Component groupConditionBox = editScreen.getWindow().getComponent("groupConditionBox");
        if (groupConditionBox instanceof Component.HasCaption) {
            ((Component.HasCaption) groupConditionBox).setCaption(messages.getMessage(FilterEditAction.class, "configurationEdit.rootGroupCondition"));
        }
    }
    editScreen.addAfterCloseListener(afterCloseEvent -> {
        if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
            LogicalFilterCondition filterCondition = (LogicalFilterCondition) ((FilterConditionEdit) afterCloseEvent.getSource()).getInstanceContainer().getItem();
            onEditScreenAfterCommit(screenFragment, filterCondition, converter, isNewConfiguration, currentConfiguration, valuesMap);
        } else {
            filterSupport.resetConfigurationValuesMap(currentConfiguration, valuesMap);
        }
    });
    editScreen.show();
}
Also used : Screen(io.jmix.ui.screen.Screen) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) GroupFilterConditionEdit(io.jmix.ui.app.filter.condition.GroupFilterConditionEdit) FilterConditionEdit(io.jmix.ui.app.filter.condition.FilterConditionEdit) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Fragment(io.jmix.ui.component.Fragment) GroupFilterConditionEdit(io.jmix.ui.app.filter.condition.GroupFilterConditionEdit) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Filter(io.jmix.ui.component.Filter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) Component(io.jmix.ui.component.Component) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 69 with Component

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

the class AbstractAction method setEnabled.

@Override
public void setEnabled(boolean enabled) {
    boolean oldValue = this.enabled;
    if (oldValue != enabled) {
        this.enabled = enabled;
        for (ActionOwner owner : owners) {
            if (owner instanceof Component) {
                ((Component) owner).setEnabled(enabled);
            }
        }
        firePropertyChange(PROP_ENABLED, oldValue, enabled);
    }
}
Also used : ActionOwner(io.jmix.ui.component.ActionOwner) Component(io.jmix.ui.component.Component)

Example 70 with Component

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

the class AbstractAction method setVisible.

@Override
public void setVisible(boolean visible) {
    boolean oldValue = this.visible;
    if (oldValue != visible) {
        this.visible = visible;
        for (ActionOwner owner : owners) {
            if (owner instanceof Component) {
                ((Component) owner).setVisible(visible);
            }
        }
        firePropertyChange(PROP_VISIBLE, oldValue, visible);
    }
}
Also used : ActionOwner(io.jmix.ui.component.ActionOwner) Component(io.jmix.ui.component.Component)

Aggregations

Component (io.jmix.ui.component.Component)81 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)16 Datasource (com.haulmont.cuba.gui.data.Datasource)12 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)11 Test (org.junit.jupiter.api.Test)11 Element (org.dom4j.Element)10 Consumer (java.util.function.Consumer)9 ListComponent (com.haulmont.cuba.gui.components.ListComponent)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)7 Action (io.jmix.ui.action.Action)7 HasValue (io.jmix.ui.component.HasValue)7 FrameOwner (io.jmix.ui.screen.FrameOwner)7 ArrayList (java.util.ArrayList)7 DatasourceImpl (com.haulmont.cuba.gui.data.impl.DatasourceImpl)6 FetchPlan (io.jmix.core.FetchPlan)6 UUID (java.util.UUID)6 Nullable (javax.annotation.Nullable)6 User (com.haulmont.cuba.core.model.common.User)5 DsBuilder (com.haulmont.cuba.gui.data.DsBuilder)5 Entity (io.jmix.core.Entity)5