/* (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException { int count = 0; if (repoNames.length > 0) { BundlesManager bm = new BundlesManager(this.telosysToolsCfg); // count = total number of work units into which the main task is been subdivided int totalWorkTasks = repoNames.length; // if ( bInstall ) { // totalWorkTasks = repoNames.length * 2; // } progressMonitor.beginTask("Download in progress", totalWorkTasks + 1); progressMonitor.worked(1); loggerTextArea.setText(""); for (String githubRepoName : repoNames) { // String sFileURL = buildFileURL(githubRepoName, sGitHubUrlPattern); // if ( sFileURL != null ) { // String sZipFileName = buildDestinationFileName(githubRepoName, this.sDownloadFolder); count++; progressMonitor.subTask("Download #" + count + " '" + githubRepoName + "'"); // loggerTextArea.append("-> Download #" + count + " '" + githubRepoName + "' ... \n"); // loggerTextArea.append(" " + sFileURL + "\n"); // loggerTextArea.append(" " + sZipFileName + "\n"); // long r = 0; // try { // // //--- Download the file // r = HttpDownloader.download(sFileURL, sZipFileName); // loggerTextArea.append(" done (" + r + " bytes).\n"); // EclipseWksUtil.refresh( new File(sZipFileName) ); // //--- One TARGET done // // Notifies that a given number of work unit of the main task has been completed. // // Note that this amount represents an installment, as opposed to a cumulative // amount of work done to date. // progressMonitor.worked(1); // One unit done (not cumulative) // // //--- Unzip the downloaded file // if ( bInstall ) { // installBundle( sZipFileName, githubRepoName ); // bm.installBundle(arg0, arg1) // progressMonitor.worked(1); // One unit done (not cumulative) // } // } // catch (Exception e) { // String msg = "Cannot download file \n" // + sFileURL + "\n\n" // + ( e.getCause() != null ? e.getCause().getMessage() : "") ; // //MsgBox.error(msg ); // loggerTextArea.append("ERROR \n"); // loggerTextArea.append(msg); // } BundleStatus status; if (bInstall) { loggerTextArea.append( "-> #" + count + " Download & Install '" + githubRepoName + "' ... \n"); status = bm.downloadAndInstallBundle(this.user, githubRepoName); } else { loggerTextArea.append("-> #" + count + " Download '" + githubRepoName + "' ... \n"); status = bm.downloadBundle(this.user, githubRepoName); } if (status.isDone()) { loggerTextArea.append("OK, done. \n"); } else { loggerTextArea.append(status.getMessage() + "\n"); if (status.getException() != null) { loggerTextArea.append("Exception : " + status.getException() + "\n"); } } EclipseWksUtil.refresh(new File(bm.getDownloadsFolderFullPath())); if (bInstall) { EclipseWksUtil.refresh(new File(bm.getBundlesFolderFullPath())); } progressMonitor.worked(1); // One unit done (not cumulative) loggerTextArea.append("\n"); } } // --- Notifies that the work is done; that is, either the main task is completed or the user // canceled it. progressMonitor.done(); if (progressMonitor .isCanceled()) // Returns whether cancellation of current operation has been requested { throw new InterruptedException("The download was cancelled"); } _result = count; // } // else { // MsgBox.error("Selection is void !"); // _result = 0 ; // } }