Package com.salas.bb.updates.ui

Examples of com.salas.bb.updates.ui.DownloadsProgressDialog


     */
    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...");
        }
    }
View Full Code Here

TOP

Related Classes of com.salas.bb.updates.ui.DownloadsProgressDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.