Search in sources :

Example 16 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class GroupFilterConditionEdit method refreshMoveButtonsState.

protected void refreshMoveButtonsState(FilterCondition selectedCondition) {
    boolean moveUpButtonEnabled = false;
    boolean moveDownButtonEnabled = false;
    FilterCondition parent = selectedCondition.getParent();
    if (parent instanceof LogicalFilterCondition) {
        int index = ((LogicalFilterCondition) parent).getOwnFilterConditions().indexOf(selectedCondition);
        moveUpButtonEnabled = index > 0;
        moveDownButtonEnabled = index < ((LogicalFilterCondition) parent).getOwnFilterConditions().size() - 1;
    }
    moveUpButton.setEnabled(moveUpButtonEnabled);
    moveDownButton.setEnabled(moveDownButtonEnabled);
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Example 17 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class GroupFilterConditionEdit method onConditionsTreeMoveDown.

@Subscribe("conditionsTree.moveDown")
protected void onConditionsTreeMoveDown(Action.ActionPerformedEvent event) {
    FilterCondition selectedCondition = conditionsTree.getSingleSelected();
    if (selectedCondition != null) {
        FilterCondition parent = selectedCondition.getParent();
        if (parent instanceof LogicalFilterCondition) {
            List<FilterCondition> items = getCollectionContainer().getMutableItems();
            List<FilterCondition> ownConditions = ((LogicalFilterCondition) parent).getOwnFilterConditions();
            int selectedItemIndex = items.indexOf(selectedCondition);
            int selectedOwnItemIndex = ownConditions.indexOf(selectedCondition);
            FilterCondition replacedCondition = ownConditions.get(selectedOwnItemIndex + 1);
            Collections.swap(items, selectedItemIndex, items.indexOf(replacedCondition));
            Collections.swap(ownConditions, selectedOwnItemIndex, selectedOwnItemIndex + 1);
            refreshMoveButtonsState(selectedCondition);
        }
    }
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) Subscribe(io.jmix.ui.screen.Subscribe)

Example 18 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class GroupFilterConditionEdit method onConditionsTreeSelection.

@Subscribe("conditionsTree")
protected void onConditionsTreeSelection(Tree.SelectionEvent<FilterCondition> event) {
    if (!event.getSelected().isEmpty()) {
        FilterCondition selectedCondition = event.getSelected().iterator().next();
        refreshMoveButtonsState(selectedCondition);
    }
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) Subscribe(io.jmix.ui.screen.Subscribe)

Example 19 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class LogicalFilterConditionEdit method addActionSelectHandler.

protected void addActionSelectHandler(Collection<FilterCondition> selectedConditions) {
    if (getListComponent() != null) {
        if (!selectedConditions.isEmpty()) {
            for (FilterCondition selectedCondition : selectedConditions) {
                updatePropertyConditionLocalizedCaption(selectedCondition);
                LogicalFilterCondition parent;
                FilterCondition singleSelected = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), getListComponent().getSingleSelected());
                if (singleSelected != null) {
                    if (singleSelected instanceof LogicalFilterCondition) {
                        parent = (LogicalFilterCondition) singleSelected;
                    } else {
                        parent = (LogicalFilterCondition) singleSelected.getParent();
                    }
                } else {
                    parent = getEditedEntity();
                }
                parent.getOwnFilterConditions().add(selectedCondition);
                selectedCondition.setParent(parent);
                refreshChildrenConditions();
                expandItems();
            }
        }
    }
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Example 20 with FilterCondition

use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.

the class LogicalFilterConditionEdit method initEditAction.

protected void initEditAction() {
    EditAction<FilterCondition> editAction = getEditAction();
    if (getListComponent() != null && editAction != null) {
        editAction.setIcon(null);
        editAction.setScreenConfigurer(this::editActionScreenConfigurer);
        editAction.setAfterCloseHandler(this::editActionAfterCloseHandler);
        getCollectionContainer().addItemChangeListener(event -> {
            FilterCondition item = event.getItem();
            if (item != null) {
                editAction.setScreenId(filterComponents.getEditScreenId(item.getClass()));
            }
        });
    }
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Aggregations

FilterCondition (io.jmix.ui.entity.FilterCondition)25 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)14 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)13 ArrayList (java.util.ArrayList)8 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)6 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)6 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)6 AbstractSingleFilterCondition (io.jmix.ui.entity.AbstractSingleFilterCondition)4 JpqlFilterCondition (io.jmix.ui.entity.JpqlFilterCondition)4 FilterComponent (io.jmix.ui.component.FilterComponent)3 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)3 Subscribe (io.jmix.ui.screen.Subscribe)3 Filter (io.jmix.ui.component.Filter)2 FilterValueComponent (io.jmix.ui.entity.FilterValueComponent)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 AddConditionScreen (io.jmix.ui.app.filter.condition.AddConditionScreen)1 GroupFilter (io.jmix.ui.component.GroupFilter)1 HasValue (io.jmix.ui.component.HasValue)1 PropertyFilter (io.jmix.ui.component.PropertyFilter)1