Search in sources :

Example 6 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListItemVM method onImageUpload.

@Command("imageUpload")
public void onImageUpload(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
    UploadEvent upEvent = null;
    Object objUploadEvent = ctx.getTriggerEvent();
    if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
        upEvent = (UploadEvent) objUploadEvent;
    }
    if (checkValidImage(upEvent)) {
        Media media = upEvent.getMedia();
        // Initialize the bind object to
        image = (AImage) media;
        // show image in zul page and
        // Notify it also
        newImageFileWrapper = new FileWrapper(media.getByteData(), media.getName());
        imageModified = true;
        notifyChange("image", "imageModified");
    }
}
Also used : Media(org.zkoss.util.media.Media) FileWrapper(org.openforis.collect.model.FileWrapper) FormObject(org.openforis.collect.designer.form.FormObject) CodeListItemFormObject(org.openforis.collect.designer.form.CodeListItemFormObject) UploadEvent(org.zkoss.zk.ui.event.UploadEvent) Command(org.zkoss.bind.annotation.Command)

Example 7 with Command

use of org.zkoss.bind.annotation.Command 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 8 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListsVM method deleteCodeListItem.

@Command
@NotifyChange({ "itemsPerLevel" })
public void deleteCodeListItem(@BindingParam("item") final CodeListItem item) {
    if (isSurveyPublished() && isEnumeratingCodeList()) {
        MessageUtil.showWarning("survey.code_list.cannot_delete_enumerating_code_list_items");
    } else {
        String messageKey;
        if (codeListManager.hasChildItems(item)) {
            messageKey = "survey.code_list.confirm.delete_non_empty_item";
        } else {
            messageKey = "survey.code_list.confirm.delete_item";
        }
        MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {

            @Override
            public void onOk() {
                performDeleteCodeListItem(item);
            }
        }, messageKey);
        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) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 9 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListsVM method moveChildItem.

@Command
public void moveChildItem(@ContextParam(ContextType.TRIGGER_EVENT) DropEvent event) {
    Listitem dragged = (Listitem) event.getDragged();
    Listitem dropped = (Listitem) event.getTarget();
    CodeListItem draggedItem = dragged.getValue();
    CodeListItem droppedItem = dropped.getValue();
    int indexTo = getItemIndex(droppedItem);
    moveChildItem(draggedItem, indexTo);
}
Also used : Listitem(org.zkoss.zul.Listitem) PersistedCodeListItem(org.openforis.idm.metamodel.PersistedCodeListItem) CodeListItem(org.openforis.idm.metamodel.CodeListItem) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 10 with Command

use of org.zkoss.bind.annotation.Command in project collect by openforis.

the class CodeListsVM method batchExport.

@Command
public void batchExport() {
    batchExportJob = new CodeListBatchExportJob();
    batchExportJob.setJobManager(jobManager);
    batchExportJob.setCodeListManager(codeListManager);
    batchExportJob.setSurvey(survey);
    jobManager.start(batchExportJob);
    jobStatusPopUp = JobStatusPopUpVM.openPopUp(Labels.getLabel("survey.code_list.batch_export"), batchExportJob, true);
}
Also used : CodeListBatchExportJob(org.openforis.collect.io.metadata.codelist.CodeListBatchExportJob) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

Command (org.zkoss.bind.annotation.Command)62 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)44 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 File (java.io.File)12 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 MessageUtil (org.openforis.collect.designer.util.MessageUtil)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 FileInputStream (java.io.FileInputStream)5 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)5 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 Media (org.zkoss.util.media.Media)5 Window (org.zkoss.zul.Window)5 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 IOException (java.io.IOException)4 Date (java.util.Date)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)3 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)3