protected void checkGlobalDefaultAndCloseEditor() {
List<FilterEntity> otherDefaultFilters = dataManager.loadList(LoadContext.create(FilterEntity.class)
.setQuery(LoadContext.createQuery("select f from sec$Filter f where f.globalDefault = true and " +
"f.componentId = :componentId and " +
"f.id <> :currentId ")
.setParameter("componentId", filterEntity.getComponentId())
.setParameter("currentId", filterEntity.getId())));
if (!otherDefaultFilters.isEmpty()) {
String otherFilterNamesStr = otherDefaultFilters.stream()
.map(FilterEntity::getName)
.collect(Collectors.joining(", "));
showOptionDialog(getMessage("filter.editor.anotherGlobalDefaultFilterFound.dialogTitle"),
formatMessage("filter.editor.anotherGlobalDefaultFilterFound.dialogMessage", otherFilterNamesStr),
MessageType.WARNING,
new Action[]{
new DialogAction(DialogAction.Type.YES, Action.Status.PRIMARY).withHandler(e -> {
otherDefaultFilters.forEach(otherDefaultFilter -> otherDefaultFilter.setGlobalDefault(false));
modifiedGlobalDefaultFilters = dataManager.commit(new CommitContext(otherDefaultFilters));
close(COMMIT_ACTION_ID, true);
}),
new DialogAction(DialogAction.Type.NO, Action.Status.NORMAL).withHandler(e -> {
filterEntity.setGlobalDefault(false);
close(COMMIT_ACTION_ID, true);
}),
});
} else {
close(COMMIT_ACTION_ID, true);
}
}