Java Code Examples for org.netbeans.api.progress.ProgressHandle#finish()

The following examples show how to use org.netbeans.api.progress.ProgressHandle#finish() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Installer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static URL uploadLogs(URL postURL, String id, Map<String,String> attrs,
        List<LogRecord> recs, DataType dataType, boolean isErrorReport,
        SlownessData slownData, boolean isOOM, boolean isAfterRestart) throws IOException {
    ProgressHandle h = null;
    //Do not show progress UI for metrics upload
    if (dataType != DataType.DATA_METRICS) {
        h = ProgressHandleFactory.createHandle(NbBundle.getMessage(Installer.class, "MSG_UploadProgressHandle"));
    }
    try {
        return uLogs(h, postURL, id, attrs, recs, dataType, isErrorReport, slownData, isOOM, isAfterRestart);
    } finally {
        if (h != null) {
            h.finish();
        }
    }
}
 
Example 2
Source File: InterceptorIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set<?> instantiate( ProgressHandle handle ) throws IOException {
    handle.start();
    
    handle.progress(NbBundle.getMessage(InterceptorIterator.class, 
            "TXT_GenerateInterceptorFile"));                            // NOI18N
    
    FileObject targetFolder = Templates.getTargetFolder(getWizard());
    String name = Templates.getTargetName(getWizard());
    FileObject interceptorClass = GenerationUtils.createClass(targetFolder,
            name, null );
    
    implementInterceptors(interceptorClass);
    
    handle.finish();
    return Collections.singleton(interceptorClass);
}
 
Example 3
Source File: InstanceNode.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected List getReferences() {
    if (hasInstance()) {
        ProgressHandle pHandle = null;
        ChangeListener cl = null;
        
        try {
            pHandle = ProgressHandle.createHandle(Bundle.InstanceNode_References());
            pHandle.setInitialDelay(200);
            pHandle.start(HeapProgress.PROGRESS_MAX);

            cl = setProgress(pHandle);
            return getInstance().getReferences();
        } finally {
            if (pHandle != null) {
                pHandle.finish();
            }
            if (cl != null) {
                HeapProgress.getProgress().removeChangeListener(cl);
            }
        }
    }
    return Collections.EMPTY_LIST;
}
 
Example 4
Source File: DerbyActivator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void doActivate() {
    if (!helper.canBundleDerby()) {
        LOGGER.fine("Default platform cannot bundle Derby"); // NOI18N
        return;
    }

    ProgressHandle handle = ProgressHandleFactory.createSystemHandle(NbBundle.getMessage(DerbyActivator.class, "MSG_RegisterJavaDB"));
    handle.start();
    try {
        if (registerDerby()) {
            registerSampleDatabase();
        }
    } finally {
        handle.finish();
    }
}
 
Example 5
Source File: ContextAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void finnishProgress() {
    // TODO add failed and restart texts                
    if (isCanceled()) {
        getLogger().logCommandLine("==[IDE]== " + DateFormat.getDateTimeInstance().format(new Date()) + " " + runningName + " " + NbBundle.getMessage(ContextAction.class, "MSG_Progress_Canceled")); // NOI18N
    } else {
        final ProgressHandle progress = getProgressHandle();
        progress.switchToDeterminate(100);
        progress.progress(NbBundle.getMessage(ContextAction.class, "MSG_Progress_Done"), 100); // NOI18N
        if (System.currentTimeMillis() > progressStamp) {
            Subversion.getInstance().getParallelRequestProcessor().post(new Runnable() {
                @Override
                public void run() {
                    progress.finish();
                }
            }, 15 * 1000);
        } else {
            progress.finish();
        }
        getLogger().logCommandLine("==[IDE]== " + DateFormat.getDateTimeInstance().format(new Date()) + " " + runningName + " " + NbBundle.getMessage(ContextAction.class, "MSG_Progress_Finished")); // NOI18N
    }
}
 
Example 6
Source File: AnalyzerTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void run(ProgressHandle handle) {
    handle.switchToDeterminate(fixes.size());

    int clock = 0;

    for (FixDescription f : fixes) {
        if (cancel.get()) break;
        
        try {
            f.implement();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            handle.progress(++clock);
        }
    }

    handle.finish();

    return null;
}
 
Example 7
Source File: WebSocketEndpointIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set<?> instantiate( ProgressHandle handle ) throws IOException {
    handle.start();
    
    handle.progress(NbBundle.getMessage(WebSocketEndpointIterator.class, 
            "TXT_GenerateEndpoint"));                       // NOI18N
    
    FileObject targetFolder = Templates.getTargetFolder(getWizard());
    String name = Templates.getTargetName(getWizard());
    FileObject endpoint = GenerationUtils.createClass(targetFolder,
            name, null );
    
    generateEndpoint(endpoint);
    
    handle.finish();
    return Collections.singleton(endpoint);
}
 
Example 8
Source File: StartModuleCookieImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Task start() {
    final WildflyDeploymentManager dm = (WildflyDeploymentManager) lookup.lookup(WildflyDeploymentManager.class);
    final String nameWoExt = fileName.substring(0, fileName.lastIndexOf('.'));
    final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(StartModuleCookieImpl.class,
            "LBL_StartProgress", nameWoExt));

    Runnable r = new Runnable() {
        @Override
        public void run() {
            isRunning = true;
            try {
                dm.getClient().startModule(fileName);
            } catch (IOException ex) {
                Logger.getLogger(StartModuleCookieImpl.class.getName()).log(Level.INFO, null, ex);
            }
            handle.finish();
            isRunning = false;
        }
    };
    handle.start();
    return PROCESSOR.post(r);
}
 
Example 9
Source File: DBScriptWizard.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set instantiate(ProgressHandle handle) throws IOException {
    Project project = Templates.getProject(wiz);
    FileObject tFolder = Templates.getTargetFolder(wiz);
    try {
        handle.start(100);
        handle.progress(NbBundle.getMessage(DBScriptWizard.class, "MSG_CreateFile"),5);
        FileObject sqlFile = tFolder.createData(Templates.getTargetName(wiz), EXTENSION);//NOI18N
        PersistenceEnvironment pe = project.getLookup().lookup(PersistenceEnvironment.class);
        if (sqlFile != null) {
            //execution
            run(project, sqlFile, pe, handle, false);
        }
        return Collections.singleton(sqlFile);
    } finally {
        handle.finish();
    }
}
 
Example 10
Source File: DBSchemaTablesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void invokeHandlers(final List<Handler> handlers, final Parameters params) {
    final ProgressPanel progressPanel = new ProgressPanel();
    
    ProgressHandle progressHandle = ProgressHandleFactory.createHandle(null);
    JComponent progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
    
    progressHandle.start();
    progressHandle.switchToIndeterminate();
    
    final int[] index = new int[1];
    
    try {
        RequestProcessor.Task task = RequestProcessor.getDefault().create(new Runnable() {
            public void run() {
                index[0] = invokeHandlers(handlers, index[0], params, progressPanel);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        progressPanel.close();
                    }
                });
            }
        });
        
        while (index[0] < handlers.size()) {
            index[0] = invokeHandlers(handlers, index[0], params, null);
            if (index[0] < handlers.size()) {
                task.schedule(0);
                progressPanel.open(progressComponent);
            }
        }
    } finally {
        progressHandle.finish();
    }
}
 
Example 11
Source File: JaxWsServiceCreator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void createServiceFromWsdl() throws IOException {

    //initProjectInfo(project);

    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JaxWsServiceCreator.class, "TXT_WebServiceGeneration")); //NOI18N

    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                handle.start(100);
                generateWsFromWsdl15(handle);
            } catch (IOException e) {
                //finish progress bar
                handle.finish();
                String message = e.getLocalizedMessage();
                if (message != null) {
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                    NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
                    DialogDisplayer.getDefault().notify(nd);
                } else {
                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
                }
            }
        }
    };
    RequestProcessor.getDefault().post(r);
}
 
Example 12
Source File: RegisterDerby.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean waitStart(final ExecSupport execSupport, int waitTime) {
    boolean started = false;
    final boolean[] forceExit = new boolean[1];
    String waitMessage = NbBundle.getMessage(RegisterDerby.class, "MSG_StartingDerby");
    ProgressHandle progress = ProgressHandleFactory.createHandle(waitMessage, new Cancellable() {
        @Override
        public boolean cancel() {
            forceExit[0] = true;
            return execSupport.interruptWaiting();
        }
    });
    progress.start();
    try {
        while (!started) {
            started = execSupport.waitForMessage(waitTime * 1000);
            if (!started) {
                if (waitTime > 0 && (!forceExit[0])) {
                    String title = NbBundle.getMessage(RegisterDerby.class, "LBL_DerbyDatabase");
                    String message = NbBundle.getMessage(RegisterDerby.class, "MSG_WaitStart", waitTime);
                    NotifyDescriptor waitConfirmation = new NotifyDescriptor.Confirmation(message, title, NotifyDescriptor.YES_NO_OPTION);
                    if (DialogDisplayer.getDefault().notify(waitConfirmation)
                            != NotifyDescriptor.YES_OPTION) {
                        break;
                    }
                } else {
                    break;
                }
            }
        }
        if (!started) {
            execSupport.terminate();
            LOGGER.log(Level.WARNING, "Derby server failed to start"); // NOI18N
        }
    } finally {
        progress.finish();
    }
    return started;
}
 
Example 13
Source File: EjbFacadeWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Set instantiate(ProgressHandle handle) throws IOException {
    try {
        EjbFacadeWizardPanel2.afterFinishAction.set(true);
        return instantiateWProgress(handle);
    } finally {
        handle.finish();
    }
}
 
Example 14
Source File: HeapFragmentWalker.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public final int computeRetainedSizes(boolean masterAction, boolean interactive) {
    
    synchronized(this) {
       if (retainedSizesStatus == RETAINED_SIZES_UNSUPPORTED ||
           retainedSizesStatus == RETAINED_SIZES_COMPUTED)
           return retainedSizesStatus;
    }

    if (interactive && !ProfilerDialogs.displayConfirmationDNSA(
            Bundle.HeapFragmentWalker_ComputeRetainedMsg(), 
            Bundle.HeapFragmentWalker_ComputeRetainedCaption(),
            null, "HeapFragmentWalker.computeRetainedSizes", false)) { //NOI18N
        return changeState(RETAINED_SIZES_CANCELLED, masterAction);
    } else {
        changeState(RETAINED_SIZES_COMPUTING, masterAction);
        List<JavaClass> classes = heapFragment.getAllClasses();
        if (classes.size() > 0) {
            ProgressHandle pd = interactive ? ProgressHandle.createHandle(Bundle.HeapFragmentWalker_ComputingRetainedMsg()) : null;
            if (pd != null) {
                pd.start();
            }
            classes.get(0).getRetainedSizeByClass();
            if (pd != null) pd.finish();
        }
        
        return changeState(RETAINED_SIZES_COMPUTED, masterAction);
    }
}
 
Example 15
Source File: ExecuteGoal.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    cancellation.set(false);
    cancellationReference.set(new DefaultBuildCancellationToken());
    GradleConnector connector = GradleConnector.newConnector();
    connector.useInstallation(gradleHome);
    connector.forProjectDirectory(FileUtil.toFile(project.getProjectDirectory()));
    try (ProjectConnection connection = connector.connect()) {
        BuildLauncher buildLauncher = connection.newBuild();
        buildLauncher.forTasks(taskInfo.getName());
        buildLauncher.withCancellationToken(this);
        ProjectConfigurationProvider pcp = project.getLookup().lookup(ProjectConfigurationProvider.class);
        if (pcp != null && pcp.getActiveConfiguration() != null) {
            buildLauncher.addArguments("-Pandroid.profile=" + pcp.getActiveConfiguration());
        }
        if (argsConfiguration != null) {
            buildLauncher.addArguments(argsConfiguration.getJvmArguments());
        }
        if (jvmConfiguration == null) {
            buildLauncher.addJvmArguments("-Xms800m", "-Xmx2000m");
        } else {
            buildLauncher.addJvmArguments(jvmConfiguration.getJvmArguments());
        }
        InputOutput io = project.getLookup().lookup(InputOutput.class);
        if (io != null) {
            io.show(ImmutableSet.of(ShowOperation.OPEN, ShowOperation.MAKE_VISIBLE));
            io.getOut().print("\n\r");
            io.getOut().print("\n\r");
            io.getOut().print("\n\r");
            io.getOut().print("\n\r");
            io.getOut().println(BLUE + "Executing task: " + taskInfo.getName() + BLACK);
            io.getOut().print("\n\r");
            io.getOut().print("\n\r");
            CustomWriterOutputStream cwos = new CustomWriterOutputStream(io.getOut(), "UTF-8");
            buildLauncher.setStandardOutput(cwos);
            buildLauncher.setStandardError(cwos);
            buildLauncher.setColorOutput(true);
        }
        final ProgressHandle progressHandle = ProgressHandleFactory.createSystemHandle(project.getProjectDirectory().getName() + " : " + taskInfo.getDescription(), this);
        progressHandle.start();
        buildLauncher.addProgressListener(new ProgressListener() {
            @Override
            public void statusChanged(ProgressEvent event) {
                progressHandle.progress(event.getDisplayName());
            }
        });
        try {
            buildLauncher.run();
        } catch (GradleConnectionException | IllegalStateException gradleConnectionException) {
            if (!(gradleConnectionException instanceof BuildCancelledException)) {
                Exceptions.printStackTrace(gradleConnectionException);
            }
        }
        progressHandle.finish();
        ModelRefresh modelRefresh = project.getLookup().lookup(ModelRefresh.class);
        if (modelRefresh != null) {
            modelRefresh.refreshModels();
        }
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
    }
}
 
Example 16
Source File: UndeployModuleCookieImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Task undeploy() {
    final WildflyDeploymentManager dm = (WildflyDeploymentManager) lookup.lookup(WildflyDeploymentManager.class);

    final String nameWoExt;
    if(fileName.indexOf('.') > 0) {
        nameWoExt = fileName.substring(0, fileName.lastIndexOf('.'));
    } else {
        nameWoExt = fileName;
    }
    final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(UndeployModuleCookieImpl.class,
            "LBL_UndeployProgress", nameWoExt));

    Runnable r = new Runnable() {
        public void run() {
            isRunning = true;
            try {
                switch(type) {
                    case EJB:
                    case EAR:
                    case CAR:
                    case RAR:
                    case WAR:
                        dm.getClient().undeploy(fileName);
                        break;
                    case QUEUE:
                        dm.getClient().removeMessageDestination(new WildflyMessageDestination(fileName, MessageDestination.Type.QUEUE));
                        break;
                    case TOPIC:
                        dm.getClient().removeMessageDestination(new WildflyMessageDestination(fileName, MessageDestination.Type.TOPIC));
                        break;
                    case DATASOURCE:
                        dm.getClient().removeDatasource(fileName);
                        break;

                }
            } catch (IOException ex) {
                Logger.getLogger(UndeployModuleCookieImpl.class.getName()).log(Level.INFO, null, ex);
            }
            handle.finish();
            isRunning = false;
        }
    };
    handle.start();
    return PROCESSOR.post(r);
}
 
Example 17
Source File: ClientSideProjectWizardIterator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
    "ClientSideProjectWizardIterator.progress.creatingProject=Creating project",
    "ClientSideProjectWizardIterator.error.noSources=<html>Source folder cannot be created.<br><br>Use <i>Resolve Project Problems...</i> action to repair the project.",
    "ClientSideProjectWizardIterator.error.noSiteRoot=<html>Site Root folder cannot be created.<br><br>Use <i>Resolve Project Problems...</i> action to repair the project.",
})
@Override
public Set<FileObject> instantiate(ProgressHandle handle) throws IOException {
    handle.start();
    handle.progress(Bundle.ClientSideProjectWizardIterator_progress_creatingProject());
    Set<FileObject> files = new LinkedHashSet<>();
    File projectDirectory = FileUtil.normalizeFile((File) wizardDescriptor.getProperty(Wizard.PROJECT_DIRECTORY));
    String name = (String) wizardDescriptor.getProperty(Wizard.NAME);
    if (!projectDirectory.isDirectory() && !projectDirectory.mkdirs()) {
        throw new IOException("Cannot create project directory"); //NOI18N
    }
    FileObject dir = FileUtil.toFileObject(projectDirectory);
    CommonProjectHelper projectHelper = ClientSideProjectUtilities.setupProject(dir, name);
    // Always open top dir as a project:
    files.add(dir);

    ClientSideProject project = (ClientSideProject) FileOwnerQuery.getOwner(projectHelper.getProjectDirectory());
    Pair<FileObject, FileObject> folders = wizard.instantiate(files, handle, wizardDescriptor, project);
    FileObject sources = folders.first();
    FileObject siteRoot = folders.second();

    if (sources != null) {
        // main file
        FileObject mainFile = sources.getFileObject("main.js"); // NOI18N
        if (mainFile != null) {
            files.add(mainFile);
        }
    } else if (wizard.hasSources()) {
        errorOccured(Bundle.ClientSideProjectWizardIterator_error_noSources());
    }
    if (siteRoot != null) {
        // index file
        FileObject indexFile = siteRoot.getFileObject("index", "html"); // NOI18N
        if (indexFile != null) {
            files.add(indexFile);
        }
    } else if (wizard.hasSiteRoot()) {
        errorOccured(Bundle.ClientSideProjectWizardIterator_error_noSiteRoot());
    }

    File parent = projectDirectory.getParentFile();
    if (parent != null && parent.exists()) {
        ProjectChooser.setProjectsFolder(parent);
    }

    handle.finish();

    wizard.logUsage(wizardDescriptor, dir, sources, siteRoot);

    return files;
}
 
Example 18
Source File: ExportZIP.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@org.netbeans.api.annotations.common.SuppressWarnings("OS_OPEN_STREAM")
@Messages({
    "# {0} - ZIP file", "MSG_building=Building {0}",
    "# {0} - ZIP entry name", "MSG_packed=Packed: {0}"
})
private static boolean build(File root, File zip) throws IOException {
    final AtomicBoolean canceled = new AtomicBoolean();
    ProgressHandle handle = ProgressHandleFactory.createHandle(MSG_building(zip.getName()), new Cancellable() {
        @Override public boolean cancel() {
            return canceled.compareAndSet(false, true);
        }
    });
    handle.start();
    try {
        List<String> files = new ArrayList<String>();
        scanForFiles(root, files, "", handle, canceled, true);
        if (canceled.get()) {
            return false;
        }
        handle.switchToDeterminate(files.size());
        OutputStream os = new FileOutputStream(zip);
        try {
            ZipOutputStream zos = new ZipOutputStream(os);
            Set<String> written = new HashSet<String>();
            String prefix = root.getName() + '/';
            for (int i = 0; i < files.size(); i++) {
                if (canceled.get()) {
                    return false;
                }
                String name = files.get(i);
                writeEntry(prefix + name, written, zos, new File(root, name));
                handle.progress(MSG_packed(name), i);
            }
            zos.finish();
            zos.close();
        } finally {
            os.close();
        }
    } finally {
        handle.finish();
    }
    return true;
}
 
Example 19
Source File: NetBeansProfiler.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Connects to an application started using the specified sessionSettings, and will start its profiling
 * with the provided profilingSettings.
 *
 * @param profilingSettings Settings to use for profiling
 * @param sessionSettings   Session settings for profiling
 * @param cancel shared cancel flag
 * @return true if connected successfully, false otherwise
 */
public boolean connectToStartedApp(final ProfilingSettings profilingSettings, final SessionSettings sessionSettings, final AtomicBoolean cancel) {
    profilingMode = MODE_PROFILE;

    lastProfilingSettings = profilingSettings;
    lastSessionSettings = sessionSettings;
    lastMode = MODE_PROFILE;

    ProgressHandle ph = ProgressHandle.createHandle(Bundle.NetBeansProfiler_StartingSession());
    try {
        ph.setInitialDelay(500);
        ph.start();
        
        if (getTargetAppRunner().targetJVMIsAlive()) {
            getTargetAppRunner().terminateTargetJVM();
        }
        
        final ProfilerEngineSettings sSettings = getTargetAppRunner().getProfilerEngineSettings();
        
        sessionSettings.applySettings(sSettings);
        profilingSettings.applySettings(sSettings); // can override the session settings
        sSettings.setInstrumentObjectInit(false); // clear instrument object.<init>
        //sSettings.setRemoteHost(""); // NOI18N // clear remote profiling host

        //getThreadsManager().setSupportsSleepingStateMonitoring(
        // Platform.supportsThreadSleepingStateMonitoring(sharedSettings.getTargetJDKVersionString()));
        logActionConfig("connectToStartedApp", profilingSettings, sessionSettings, null, sSettings.getInstrumentationFilter()); // NOI18N
        
        if (prepareProfilingSession(profilingSettings, sessionSettings)) {
            RequestProcessor.getDefault().post(new Runnable() {
                
                @Override
                public void run() {
                    // should propagate the result of the following operation somehow; current workflow doesn't allow it
                    if (tryInitiateSession(sessionSettings, cancel)) {
                        connectToApp();
                    }
                }
            });
            
            return true;
        }
        
        return false;
    } finally {
        ph.finish();
    }
}
 
Example 20
Source File: Installer.java    From minifierbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Downloads a file from a URL
 *
 * @param fileURL HTTP URL of the file to be downloaded
 * @param saveDir path of the directory to save the file
 * @throws IOException
 */
private void downloadFile(String fileURL, String saveDir)
        throws IOException {
    final ProgressHandle handle = ProgressHandle.createHandle("Downloading minifierbeans archive");
    handle.start(0);

    URL url = new URL(fileURL);
    HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
    int responseCode = httpConn.getResponseCode();

    // always check HTTP response code first
    if (responseCode == HttpURLConnection.HTTP_OK) {
        String fileName = "custom-packages.zip";

        // opens input stream from the HTTP connection
        InputStream inputStream = httpConn.getInputStream();

        final File theFile = new File(saveDir + "/.netbeans/minifierbeans");
        theFile.mkdirs();

        final String saveFilePath = saveDir + "/.netbeans/minifierbeans/" + fileName;

        // opens an output stream to save into file
        FileOutputStream outputStream = new FileOutputStream(saveFilePath);

        int bytesRead = -1;
        byte[] buffer = new byte[BUFFER_SIZE];
        while ((bytesRead = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, bytesRead);
        }

        outputStream.close();
        inputStream.close();
        handle.finish();

        RP.post(new Runnable() {
            @Override
            public void run() {
                try {
                    extractArchive(saveFilePath, theFile.getAbsolutePath() + "/");
                } catch (IOException ex) {
                    handle.finish();
                    Exceptions.printStackTrace(ex);
                }
            }
        });
    } else {
        handle.finish();
        NotificationDisplayer.getDefault().notify("Error while downloading", NotificationDisplayer.Priority.HIGH.getIcon(), "No file to download. Server replied HTTP code: " + responseCode, null);
    }

    httpConn.disconnect();
}