Search in sources :

Example 6 with Fragment

use of io.jmix.ui.component.Fragment 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)

Aggregations

Fragment (io.jmix.ui.component.Fragment)6 ScreenFragment (io.jmix.ui.screen.ScreenFragment)5 FragmentImplementation (io.jmix.ui.component.impl.FragmentImplementation)3 FrameImplementation (io.jmix.ui.component.impl.FrameImplementation)3 ScreenData (io.jmix.ui.model.ScreenData)3 UiMonitoring.createScreenTimer (io.jmix.ui.monitoring.UiMonitoring.createScreenTimer)3 WindowInfo (io.jmix.ui.WindowInfo)2 Component (io.jmix.ui.component.Component)2 FrameOwner (io.jmix.ui.screen.FrameOwner)2 FragmentHelper (io.jmix.ui.sys.FragmentHelper)2 FragmentLoaderInjectTask (io.jmix.ui.sys.FragmentHelper.FragmentLoaderInjectTask)2 Timer (io.micrometer.core.instrument.Timer)2 Element (org.dom4j.Element)2 UiComponents (com.haulmont.cuba.gui.UiComponents)1 FrameHelper (com.haulmont.cuba.gui.sys.FrameHelper)1 Messages (io.jmix.core.Messages)1 ParamsMap (io.jmix.core.common.util.ParamsMap)1 Widget (io.jmix.dashboards.model.Widget)1 io.jmix.dashboards.model.visualmodel (io.jmix.dashboards.model.visualmodel)1 CanvasLayout (io.jmix.dashboardsui.component.CanvasLayout)1