use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class CodeListsVM method exportCodeList.
@Command
public void exportCodeList() throws IOException {
CollectSurvey survey = getSurvey();
CodeListExportProcess codeListExportProcess = new CodeListExportProcess(codeListManager);
File tempFile = File.createTempFile("code_list_" + editedItem.getName(), ".csv");
FileOutputStream os = new FileOutputStream(tempFile);
codeListExportProcess.exportToCSV(os, survey, editedItem.getId());
Filedownload.save(tempFile, CSV_CONTENT_TYPE);
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class CodeListsVM method batchImportFileUploaded.
@Command
public void batchImportFileUploaded(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent event) {
Media media = event.getMedia();
String fileName = media.getName();
String extension = FilenameUtils.getExtension(fileName);
File tempFile = OpenForisIOUtils.copyToTempFile(media.getStreamData(), extension);
batchImportJob = new CodeListBatchImportJob();
batchImportJob.setJobManager(jobManager);
batchImportJob.setCodeListManager(codeListManager);
batchImportJob.setSurvey(survey);
batchImportJob.setOverwriteData(true);
batchImportJob.setFile(tempFile);
jobManager.start(batchImportJob);
jobStatusPopUp = JobStatusPopUpVM.openPopUp(Labels.getLabel("survey.code_list.batch_import"), batchImportJob, true);
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class SchemaLayoutSimpleVM method addTab.
@Command
@NotifyChange({ "treeModel", "selectedTab" })
public void addTab(@BindingParam("parent") UITabSet parent) {
if (rootTabSet != null) {
if (parent == null) {
parent = rootTabSet;
treeModel.deselect();
}
CollectSurvey survey = getSurvey();
UIOptions uiOptions = survey.getUIOptions();
UITab tab = uiOptions.createTab();
String label = Labels.getLabel("survey.schema.node.layout.default_tab_label");
tab.setLabel(currentLanguageCode, label);
parent.addTab(tab);
treeModel.appendNodeToSelected(tab);
selectedTab = tab;
dispatchTabSetChangedCommand();
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class SchemaLayoutSimpleVM method removeTab.
@Command
public void removeTab() {
String confirmMessageKey = null;
if (!selectedTab.getTabs().isEmpty()) {
confirmMessageKey = "survey.layout.tab.remove.confirm.nested_tabs_present";
} else {
CollectSurvey survey = getSurvey();
UIOptions uiOpts = survey.getUIOptions();
List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(selectedTab, false);
if (!nodesPerTab.isEmpty()) {
confirmMessageKey = "survey.layout.tab.remove.confirm.associated_nodes_present";
}
}
if (confirmMessageKey != null) {
MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {
@Override
public void onOk() {
performRemoveSelectedTab();
}
}, confirmMessageKey);
params.setOkLabelKey("global.delete_item");
MessageUtil.showConfirm(params);
} else {
performRemoveSelectedTab();
}
}
use of org.zkoss.bind.annotation.Command in project collect by openforis.
the class SurveyConfigurationEditVM method applyChanges.
@Command
@NotifyChange({ "editedTabDefinition", "editedTab", "selectedTab" })
public void applyChanges() {
CollectSurvey survey = getSurvey();
UIConfiguration uiConfiguration = survey.getUIConfiguration();
if (newTab) {
if (editedTabDefinition != null) {
uiConfiguration.addTabDefinition(editedTabDefinition);
treeModel.appendToSelected(editedTabDefinition);
selectedTab = editedTabDefinition;
} else if (editedTab != null) {
selectedTab.addTab(editedTab);
treeModel.appendToSelected(editedTab);
selectedTab = editedTab;
}
} else {
String tabName = selectedTab.getName();
if (editedTabDefinition != null) {
String newName = editedTabDefinition.getName();
UITabDefinition newTabDefn = uiConfiguration.updateTabDefinition(tabName, newName);
// TODO avoid use of side effect...
// treeModel.updateSelectedNode(newTabDefn);
selectedTab = newTabDefn;
} else {
selectedTab.setName(editedTab.getName());
((UITab) selectedTab).setLabel(editedTab.getLabel());
// TODO avoid use of side effect...
// treeModel.updateSelectedNode(editedTab);
}
}
newTab = false;
HashMap<String, Object> args = new HashMap<String, Object>();
args.put("tab", selectedTab);
BindUtils.postGlobalCommand(null, null, TAB_DEFINITIONS_UPDATED_COMMAND, args);
}
Aggregations