@Override public String getConfirmationMessage() { if (hasDefaultRole) return getMessage("dialogs.Confirmation.RemoveDefaultRole"); else return super.getConfirmationMessage(); }
protected void confirmAndRemove(Set<Entity> selected) { Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs(); dialogs.createOptionDialog() .withCaption(getConfirmationTitle()) .withMessage(getConfirmationMessage()) .withActions( new DialogAction(Type.OK, Status.PRIMARY).withHandler(event -> { try { remove(selected); } finally { if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } Set<Entity> filtered = new HashSet<>(selected); filtered.retainAll(target.getDatasource().getItems()); //noinspection unchecked target.setSelected(filtered); } }), new DialogAction(Type.CANCEL).withHandler(event -> { // move focus to owner if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } })) .show(); }