@FXML
private void onDownloadClicked(ActionEvent downloadClickEvent) {
// create a task
geodatabaseSyncTask = new GeodatabaseSyncTask(SERVICE_URL);
// setup parameters
GenerateGeodatabaseParameters params = new GenerateGeodatabaseParameters();
// download features in visible area
params.setExtent(mapView.getVisibleArea().getExtent());
// download layer 0
params.setSyncModel(SyncModel.PER_LAYER);
params.getLayerOptions().add(new GenerateLayerOption(0));
// create job, attach listener
GenerateGeodatabaseJob downloadGeodatabaseJob = geodatabaseSyncTask.generateGeodatabaseAsync(params, geodatabaseFilePath);
downloadGeodatabaseJob.addJobDoneListener(() -> {
handleError(downloadGeodatabaseJob.getError());
progressBar.setVisible(false);
});
// execute operation
progressBar.setVisible(true);
downloadGeodatabaseJob.start();
}