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