*/
public void download(Location[] locations)
{
if (locations == null || locations.length == 0) return;
final DownloadsProgressDialog dialog;
// Create progress dialog
JFrame frame = Application.getDefaultParentFrame();
dialog = new DownloadsProgressDialog(frame, locations);
// Create downloader component
IStreamProgressListener progressListener = dialog.getProgressListener();
Downloader downloader = new Downloader(progressListener);
// Initialize target directory
File targetDirectory = getTargetDirectory();
List successful = new ArrayList();
List failed = new ArrayList();
// Open progress dialog and start downloading packages
openProgressDialog(dialog, downloader, locations, targetDirectory);
try
{
for (int i = 0; i < locations.length; i++)
{
Location location = locations[i];
try
{
URL locationURL = new URL(location.getLink());
downloader.download(locationURL, targetDirectory);
successful.add(location);
} catch (IOException e)
{
LOG.log(Level.SEVERE, MessageFormat.format(
Strings.error("invalid.url"),
new Object[] { location.getLink() }), e);
failed.add(location);
} finally
{
dialog.nextDownload();
}
}
dialog.allDone(successful, failed);
} catch (InterruptedException e)
{
LOG.info("Downloading canceled...");
}
}