Search in sources :

Example 1 with ConfirmHandler

use of org.openforis.collect.designer.util.MessageUtil.ConfirmHandler in project collect by openforis.

the class CodeListsVM method removeLevel.

@Command
public void removeLevel() {
    final List<CodeListLevel> levels = editedItem.getHierarchy();
    if (!levels.isEmpty()) {
        final int levelIndex = levels.size() - 1;
        if (codeListManager.hasChildItemsInLevel(editedItem, levelIndex + 1)) {
            ConfirmHandler handler = new ConfirmHandler() {

                @Override
                public void onOk() {
                    performRemoveLevel(levelIndex);
                }
            };
            MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(handler, "survey.code_list.alert.cannot_delete_non_empty_level");
            params.setOkLabelKey("global.delete_item");
            MessageUtil.showConfirm(params);
        } else {
            performRemoveLevel(levelIndex);
        }
    }
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) ConfirmHandler(org.openforis.collect.designer.util.MessageUtil.ConfirmHandler) MessageUtil(org.openforis.collect.designer.util.MessageUtil) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 2 with ConfirmHandler

use of org.openforis.collect.designer.util.MessageUtil.ConfirmHandler in project collect by openforis.

the class SurveyObjectBaseVM method deleteItem.

@Command
public void deleteItem(@BindingParam("item") final T item) {
    MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(new ConfirmHandler() {

        @Override
        public void onOk() {
            performDeleteItem(item);
        }
    }, getConfirmDeleteMessageKey());
    params.setOkLabelKey("global.delete_item");
    MessageUtil.showConfirm(params);
}
Also used : MessageUtil(org.openforis.collect.designer.util.MessageUtil) ConfirmHandler(org.openforis.collect.designer.util.MessageUtil.ConfirmHandler) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Aggregations

MessageUtil (org.openforis.collect.designer.util.MessageUtil)2 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)2 Command (org.zkoss.bind.annotation.Command)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 CodeListLevel (org.openforis.idm.metamodel.CodeListLevel)1