use of org.zkoss.bind.annotation.GlobalCommand in project collect by openforis.
the class CodeListsVM method jobFailed.
@GlobalCommand
public void jobFailed(@BindingParam("job") Job job) {
closeJobStatusPopUp();
if (job instanceof CodeListBatchImportJob && job.getCurrentTask() != null) {
CodeListImportTask lastTask = (CodeListImportTask) ((CodeListBatchImportJob) job).getCurrentTask();
dataImportErrorPopUp = ReferenceDataImportErrorPopUpVM.showPopUp(lastTask.getErrors(), Labels.getLabel("survey.code_list.import_data.error_popup.title", new String[] { lastTask.getEntryName() }));
} else {
String errorMessageKey = job.getErrorMessage();
String errorMessage = StringUtils.defaultIfBlank(Labels.getLabel(errorMessageKey), errorMessageKey);
MessageUtil.showError("global.job_status.failed.message", errorMessage);
}
clearJob(job);
}
use of org.zkoss.bind.annotation.GlobalCommand in project collect by openforis.
the class CodeListsVM method closeCodeListImportPopUp.
@GlobalCommand
public void closeCodeListImportPopUp() {
closePopUp(codeListImportPopUp);
codeListImportPopUp = null;
if (editedItem != null) {
boolean hasMultipleLevels = editedItem.getHierarchy().size() > 1;
Type type = hasMultipleLevels ? Type.HIERARCHICAL : Type.FLAT;
CodeListFormObject fo = (CodeListFormObject) formObject;
fo.setType(type.name());
selectedItemsPerLevel = new ArrayList<CodeListItem>();
initItemsPerLevel();
notifyChange("formObject", "listLevels", "selectedItemsPerLevel");
}
}
use of org.zkoss.bind.annotation.GlobalCommand in project collect by openforis.
the class CodeListsVM method closeCodeListItemPopUp.
@GlobalCommand
public void closeCodeListItemPopUp(@BindingParam("undoChanges") boolean undoChanges, @BindingParam("imageModified") boolean imageModified, @BindingParam("imageFileWrapper") FileWrapper imageFileWrapper) {
if (codeListItemPopUp == null) {
// handling code list from node editor form?
return;
}
closePopUp(codeListItemPopUp);
codeListItemPopUp = null;
if (undoChanges) {
dispatchCurrentFormValidatedCommand(true);
} else {
if (newChildItem) {
addChildItemToCodeList();
} else {
dispatchSurveySaveCommand();
if (editedChildItem instanceof PersistedCodeListItem) {
codeListManager.save((PersistedCodeListItem) editedChildItem);
}
BindUtils.postNotifyChange(null, null, editedChildItem, "*");
}
if (imageModified) {
PersistedCodeListItem persistedItem;
if (editedChildItem instanceof PersistedCodeListItem) {
persistedItem = (PersistedCodeListItem) editedChildItem;
} else {
CodeList codeList = editedChildItem.getCodeList();
codeListManager.persistCodeListItems(codeList);
reloadSelectedItems();
initItemsPerLevel();
persistedItem = codeListManager.loadItem(codeList, editedChildItem.getId());
}
if (imageFileWrapper == null) {
codeListManager.deleteImageContent(persistedItem);
} else {
codeListManager.saveImageContent(persistedItem, imageFileWrapper);
}
}
}
}
use of org.zkoss.bind.annotation.GlobalCommand in project collect by openforis.
the class SurveyEditVM method openCodeListsManagerPopUp.
@GlobalCommand
public void openCodeListsManagerPopUp(@BindingParam(EDITING_ATTRIBUTE_PARAM) Boolean editingAttribute, @BindingParam(SELECTED_CODE_LIST_PARAM) CodeList selectedCodeList) {
if (codeListsPopUp == null) {
dispatchCurrentFormValidatedCommand(true);
Map<String, Object> args = new HashMap<String, Object>();
args.put(EDITING_ATTRIBUTE_PARAM, editingAttribute);
CodeList selectedCodeListInPopUp = selectedCodeList == survey.getSamplingDesignCodeList() ? null : selectedCodeList;
args.put(SELECTED_CODE_LIST_PARAM, selectedCodeListInPopUp);
codeListsPopUp = openPopUp(Resources.Component.CODE_LISTS_POPUP.getLocation(), true, args);
}
}
use of org.zkoss.bind.annotation.GlobalCommand in project collect by openforis.
the class SurveyEditVM method jobCompleted.
@GlobalCommand
public void jobCompleted(@BindingParam("job") Job job) {
closeJobStatusPopUp();
if (job instanceof SchemaSummaryCSVExportJob) {
File file = ((SchemaSummaryCSVExportJob) job).getOutputFile();
String surveyName = survey.getName();
String dateStr = Dates.formatLocalDateTime(new Date());
String fileName = String.format(SCHEMA_SUMMARY_FILE_NAME_PATTERN, surveyName, dateStr, "csv");
String contentType = URLConnection.guessContentTypeFromName(fileName);
try {
FileInputStream is = new FileInputStream(file);
Filedownload.save(is, contentType, fileName);
} catch (FileNotFoundException e) {
log.error(e);
MessageUtil.showError("survey.schema.export_summary.error", e.getMessage());
}
}
}
Aggregations