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);
}
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);
}
}
}
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);
}
}
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();
}
}
}
}
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()));
}
});
}
}
Aggregations