org.netbeans.api.progress.ProgressHandle Java Examples
The following examples show how to use
org.netbeans.api.progress.ProgressHandle.
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: OnlineSampleWizardIterator.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({ "# {0} - template name", "OnlineSampleWizardIterator.error.applyingSiteTemplate=Cannot apply template \"{0}\"." }) private void applySiteTemplate( final FileObject projectDir, final CreateProjectProperties props, final OnlineSiteTemplate siteTemplate, final ProgressHandle handle) { assert !EventQueue.isDispatchThread(); final String templateName = siteTemplate.getName(); try { siteTemplate.apply(projectDir, props, handle); } catch (IOException ex) { errorOccured(Bundle.OnlineSampleWizardIterator_error_applyingSiteTemplate(templateName)); } }
Example #2
Source File: DBScriptWizard.java From netbeans with Apache License 2.0 | 6 votes |
@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 #3
Source File: GoogleSearchProviderImpl.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
private List<MavenDependencyInfo> downloadGoogleIndex(int connectTimeout, int readTimeout) { ProgressHandle handle = ProgressHandle.createHandle("Goodle index download"); List<MavenDependencyInfo> tmp = new ArrayList<>(); handle.start(); GoogleMasterIndex googleMasterIndex = readGoogleMasterIndex(connectTimeout, readTimeout); if (googleMasterIndex != null) { handle.switchToDeterminate(googleMasterIndex.getGroups().size()); int step = 0; Map<String, String> groups = googleMasterIndex.getGroups(); for (Map.Entry<String, String> entry : groups.entrySet()) { final String group = entry.getKey(); final String url = entry.getValue(); GoogleGroupIndex googleGroupIndex = readGoogleGroupIndex(group, url, connectTimeout, readTimeout); tmp.addAll(googleGroupIndex.getArtifacts()); handle.progress(step++); } } handle.finish(); return tmp; }
Example #4
Source File: JaxWsClientCreator.java From netbeans with Apache License 2.0 | 6 votes |
public void createClient() throws IOException { WSStackUtils stackUtils = new WSStackUtils(project); final boolean isJsr109Supported = stackUtils.isJsr109Supported(); //final boolean isJWSDPSupported = isJWSDPSupported(); // Use Progress API to display generator messages. final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JaxWsClientCreator.class, "MSG_WizCreateClient")); //NOI18N task = new Task(new Runnable() { public void run() { try { handle.start(); generate15Client((isJsr109Supported /*|| isJWSDPSupported*/), handle); } catch (IOException exc) { //finish progress bar handle.finish(); ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, exc); } } }); RequestProcessor.getDefault().post(task); }
Example #5
Source File: TagTagAction.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({ "# {0} - tag", "MSG_Tagging=Tagging {0}" }) private void perform(final DockerTag source, final String repository, final String tag, final boolean force) { RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { ProgressHandle handle = ProgressHandle.createHandle(Bundle.MSG_Tagging(source.getTag())); handle.start(); try { DockerAction facade = new DockerAction(source.getImage().getInstance()); facade.tag(source, repository, tag, force); } catch (DockerException ex) { LOGGER.log(Level.INFO, null, ex); String msg = ex.getLocalizedMessage(); NotifyDescriptor desc = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(desc); } finally { handle.finish(); } } }); }
Example #6
Source File: NetworkSupport.java From netbeans with Apache License 2.0 | 6 votes |
/** * Download the given URL to the target file with showing its progress. * <p> * This method must be called only in a background thread. To cancel the download, interrupt the current thread. * @param url URL to be downloaded * @param target target file * @param displayName display name of the progress * @throws NetworkException if any network error occurs * @throws IOException if any error occurs * @throws InterruptedException if the download is cancelled * @see #download(java.lang.String, java.io.File) * @see #downloadWithProgress(java.lang.String, java.io.File, org.netbeans.api.progress.ProgressHandle) * @since 1.25 */ public static void downloadWithProgress(@NonNull String url, @NonNull File target, @NonNull String displayName) throws NetworkException, IOException, InterruptedException { Parameters.notNull("displayName", displayName); final Thread downloadThread = Thread.currentThread(); ProgressHandle progressHandle = ProgressHandle.createHandle(displayName, new Cancellable() { @Override public boolean cancel() { downloadThread.interrupt(); return true; } }); progressHandle.start(); try { downloadInternal(url, target, progressHandle); } finally { progressHandle.finish(); } }
Example #7
Source File: XMLMinify.java From minifierbeans with Apache License 2.0 | 6 votes |
public static void execute(final DataObject context, final String content, final boolean notify) { Runnable runnable = new Runnable() { @Override public void run() { xmlMinify(context, content, notify); } }; final RequestProcessor.Task theTask = RP.create(runnable); final ProgressHandle ph = ProgressHandleFactory.createHandle("Minifying XML " + context.getPrimaryFile().getName(), theTask); theTask.addTaskListener(new TaskListener() { @Override public void taskFinished(org.openide.util.Task task) { ph.finish(); } }); ph.start(); theTask.schedule(0); }
Example #8
Source File: OperationSupportImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public synchronized Boolean doOperation(ProgressHandle progress, OperationContainer container) throws OperationException { OperationContainer<InstallSupport> containerForUpdate = OperationContainer.createForUpdate(); List<? extends OperationInfo> infos = container.listAll(); for (OperationInfo info : infos) { containerForUpdate.add(info.getUpdateUnit(), info.getUpdateElement()); } assert containerForUpdate.listInvalid().isEmpty(); Validator v = containerForUpdate.getSupport().doDownload(ProgressHandleFactory.createHandle(OperationSupportImpl.class.getName()), null, false); Installer i = containerForUpdate.getSupport().doValidate(v, ProgressHandleFactory.createHandle(OperationSupportImpl.class.getName())); InstallSupportImpl installSupportImpl = Trampoline.API.impl(containerForUpdate.getSupport()); Boolean needRestart = installSupportImpl.doInstall(i, ProgressHandleFactory.createHandle(OperationSupportImpl.class.getName()), true); return needRestart; }
Example #9
Source File: AutoupdateCheckScheduler.java From netbeans with Apache License 2.0 | 6 votes |
/** * @param progress * @return collection of strings with description of problems in update process */ private static Collection<String> refreshUpdateCenters (ProgressHandle progress) { final long startTime = System.currentTimeMillis (); Collection<String> problems = new HashSet<String> (); assert ! SwingUtilities.isEventDispatchThread () : "Cannot run refreshProviders in EQ!"; Collection<RequestProcessor.Task> refreshTasks = new HashSet<RequestProcessor.Task> (); List <UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault ().getUpdateUnitProviders (true); RequestProcessor rp = new RequestProcessor("autoupdate-refresh-providers", providers.size(), false); for (UpdateUnitProvider p : providers) { RequestProcessor.Task t = rp.post (getRefresher (p, problems, progress)); refreshTasks.add (t); } err.log (Level.FINEST, "Waiting for all refreshTasks..."); for (RequestProcessor.Task t : refreshTasks) { t.waitFinished (); } err.log (Level.FINEST, "Waiting for all refreshTasks is done."); long time = (System.currentTimeMillis () - startTime) / 1000; if (time > 0) { Utilities.putTimeOfRefreshUpdateCenters (time); } return problems; }
Example #10
Source File: InterceptorIterator.java From netbeans with Apache License 2.0 | 6 votes |
@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 #11
Source File: StopModuleCookieImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Task stop() { final WildflyDeploymentManager dm = (WildflyDeploymentManager) lookup.lookup(WildflyDeploymentManager.class); final String nameWoExt = fileName.substring(0, fileName.lastIndexOf('.')); final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(StopModuleCookieImpl.class, "LBL_StopProgress", nameWoExt)); Runnable r = new Runnable() { @Override public void run() { isRunning = true; try { dm.getClient().stopModule(fileName); } catch (IOException ex) { Logger.getLogger(StopModuleCookieImpl.class.getName()).log(Level.INFO, null, ex); } handle.finish(); isRunning = false; } }; handle.start(); return PROCESSOR.post(r); }
Example #12
Source File: DefaultProjectOperationsImplementationTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCopyWithInnerProjectComplex() throws Exception { TestUtil.createFileFromContent(DefaultProjectOperationsImplementationTest.class.getResource("data/test.txt"), projdir, "lib/test.txt"); FileObject projdir2 = projdir.getFileObject("lib").createFolder("proj2"); createProject(projdir2); ProgressHandle handle = ProgressHandleFactory.createHandle("test-handle"); handle.start(DefaultProjectOperationsImplementation.MAX_WORK); FileObject newTarget = prj.getProjectDirectory().getParent(); DefaultProjectOperationsImplementation.doCopyProject(handle, prj, "projCopy", newTarget); File newProject = new File(FileUtil.toFile(newTarget), "projCopy"); assertTrue(newProject.isDirectory()); assertTrue(new File(newProject, "nbproject").isDirectory()); assertTrue(new File(newProject, "src").isDirectory()); assertTrue(new File(newProject, "lib").isDirectory()); assertFalse(new File(new File(newProject, "lib"), "proj2").exists()); }
Example #13
Source File: DefaultProjectOperationsImplementationTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMainProjectFlagNotMovedWhenCopying() throws Exception { OpenProjects.getDefault().close(OpenProjects.getDefault().getOpenProjects()); OpenProjects.getDefault().open(new Project[] {prj}, false); //set the project to be copied as main. OpenProjects.getDefault().setMainProject(prj); assertTrue(prj.getProjectDirectory().equals(OpenProjects.getDefault().getMainProject().getProjectDirectory())); ProgressHandle handle = ProgressHandleFactory.createHandle("test-handle"); handle.start(DefaultProjectOperationsImplementation.MAX_WORK); FileObject oldProject = prj.getProjectDirectory(); File oldProjectFile = FileUtil.toFile(oldProject); FileObject newTarget = oldProject.getParent(); DefaultProjectOperationsImplementation.doCopyProject(handle, prj, "projCopy", newTarget); //test that after copying the main project is still the original one. Project main = OpenProjects.getDefault().getMainProject(); assertTrue(main != null && main.getProjectDirectory().equals(prj.getProjectDirectory())); }
Example #14
Source File: ImageCompress.java From minifierbeans with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent ev) { Runnable runnable = new Runnable() { @Override public void run() { compress(); } }; final RequestProcessor.Task theTask = RP.create(runnable); final ProgressHandle ph = ProgressHandleFactory.createHandle("Compressing Image " + context.getPrimaryFile().getName(), theTask); theTask.addTaskListener(new TaskListener() { @Override public void taskFinished(org.openide.util.Task task) { NotificationDisplayer.getDefault().notify("Image compressed successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The compression of the image was successful.", null); ph.finish(); } }); ph.start(); theTask.schedule(0); }
Example #15
Source File: AttachmentsPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void applyPatch() { String progressFormat = NbBundle.getMessage(AttachmentsPanel.class,"Attachment.applyPatch.progress"); //NOI18N String progressMessage = MessageFormat.format(progressFormat, getFilename()); final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage); handle.start(); handle.switchToIndeterminate(); Support.getInstance().getParallelRP().post( new Runnable() { @Override public void run() { IDEServices ideServices = Support.getInstance().getIDEServices(); if(ideServices != null) { try { ideServices.applyPatch(saveToTempFile()); } catch (IOException ex) { LOG.log(Level.WARNING, ex.getMessage(), ex); } finally { handle.finish(); } } } }); }
Example #16
Source File: DerbyActivator.java From netbeans with Apache License 2.0 | 6 votes |
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 #17
Source File: ApplicationSnapshotProvider.java From visualvm with GNU General Public License v2.0 | 6 votes |
void createSnapshot(final Application application, final boolean openSnapshot) { VisualVM.getInstance().runTask(new Runnable() { public void run() { ProgressHandle pHandle = null; try { pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(ApplicationSnapshotProvider.class, "MSG_Saving_snapshot", DataSourceDescriptorFactory.getDescriptor(application).getName())); // NOI18N pHandle.setInitialDelay(0); pHandle.start(); createSnapshotImpl(application, openSnapshot); } finally { final ProgressHandle pHandleF = pHandle; SwingUtilities.invokeLater(new Runnable() { public void run() { if (pHandleF != null) pHandleF.finish(); } }); } } }); }
Example #18
Source File: InstanceNode.java From netbeans with Apache License 2.0 | 6 votes |
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 #19
Source File: AnalyzerTopComponent.java From netbeans with Apache License 2.0 | 6 votes |
@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 #20
Source File: WebSocketEndpointIterator.java From netbeans with Apache License 2.0 | 6 votes |
@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 #21
Source File: AttachmentsPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void saveToFile() { final File file = new FileChooserBuilder(AttachmentsPanel.class) .setFilesOnly(true).showSaveDialog(); if (file != null) { String progressFormat = NbBundle.getMessage( SaveAttachmentAction.class, "Attachment.saveToFile.progress"); //NOI18N String progressMessage = MessageFormat.format(progressFormat, getFilename()); final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage); handle.start(); handle.switchToIndeterminate(); Support.getInstance().getParallelRP().post(new Runnable() { @Override public void run() { try { getAttachmentData(file); } catch (IOException ioex) { LOG.log(Level.INFO, ioex.getMessage(), ioex); } finally { handle.finish(); } } }); } }
Example #22
Source File: ProgressAPICompatTest.java From netbeans with Apache License 2.0 | 6 votes |
/** * Check that if a Swing component is extracted, the progress * reports 'customPlaced' = true. * @throws Exception */ public void testHandleIsCustomPlaced() throws Exception { C c = new C(); A a = new A(); Constructor ctor = InternalHandle.class.getConstructor( String.class, Cancellable.class, Boolean.TYPE, Action.class ); InternalHandle h = (InternalHandle)ctor.newInstance("Foobar", c, true, a); ProgressHandle p = h.createProgressHandle(); Method m = InternalHandle.class.getMethod("extractComponent"); JComponent comp = (JComponent)m.invoke(h); assertTrue(h.isCustomPlaced()); }
Example #23
Source File: ConvertModel.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void actionPerformed(ActionEvent ev) { Runnable run = new Runnable() { public void run() { ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Converting Model"); progressHandle.start(); for (SpatialAssetDataObject spatialAssetDataObject : context) { if (!(spatialAssetDataObject instanceof BinaryModelDataObject)) { try { spatialAssetDataObject.loadAsset(); spatialAssetDataObject.saveAsset(); } catch (Exception ex) { Exceptions.printStackTrace(ex); Confirmation msg = new NotifyDescriptor.Confirmation( "Error converting " + spatialAssetDataObject.getName() + "\n" + ex.toString(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(msg); } } } progressHandle.finish(); } }; new Thread(run).start(); }
Example #24
Source File: RetrieverEngineImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void run() { ProgressHandle ph = ProgressHandleFactory.createHandle( NbBundle.getMessage(RetrieverEngineImpl.class,"LBL_PROGRESSBAR_Retrieve_XML"), new Cancellable(){ public boolean cancel() { synchronized(RetrieverEngineImpl.this){ if(!RetrieverEngineImpl.this.STOP_PULL){ RetrieverEngineImpl.this.STOP_PULL = true; //taskThread.interrupt(); } } return true; } }, new AbstractAction(){ public void actionPerformed(ActionEvent e) { getOPWindow().setOutputVisible(true); getOPWindow().select(); } }); ph.start(); ph.switchToIndeterminate(); try{ pullRecursively(); }finally{ ph.finish(); } }
Example #25
Source File: RepositoryRegistry.java From netbeans with Apache License 2.0 | 5 votes |
private RepositoryRegistry() { lockRepositories(); final long t = System.currentTimeMillis(); new RequestProcessor(RepositoryRegistry.class.getName()).post(new Runnable() { @Override public void run() { final ProgressHandle[] ph = new ProgressHandle[1]; final Timer timer[] = new Timer[1]; timer[0] = new Timer(800, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(repositories == null) { timer[0].stop(); ph[0] = ProgressHandleFactory.createSystemHandle("Initializing Bugtracking repositories"); ph[0].start(); } } }); timer[0].start(); try { loadRepositories(); } finally { releaseRepositoriesLock(); if(ph[0] != null) { ph[0].finish(); } timer[0].stop(); BugtrackingManager.LOG.log(Level.INFO, "Loading stored repositories took {0} millis.", (System.currentTimeMillis() - t)); } } }); }
Example #26
Source File: DefaultProjectOperationsImplementationTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testCopyWithLib() throws Exception { TestUtil.createFileFromContent(DefaultProjectOperationsImplementationTest.class.getResource("data/test.txt"), projdir, "lib/test.txt"); ProgressHandle handle = ProgressHandleFactory.createHandle("test-handle"); handle.start(DefaultProjectOperationsImplementation.MAX_WORK); FileObject newTarget = prj.getProjectDirectory().getParent(); DefaultProjectOperationsImplementation.doCopyProject(handle, prj, "projCopy", newTarget); File newProject = new File(FileUtil.toFile(newTarget), "projCopy"); assertTrue(newProject.isDirectory()); assertTrue(new File(newProject, "nbproject").isDirectory()); assertTrue(new File(newProject, "src").isDirectory()); assertTrue(new File(newProject, "lib").isDirectory()); }
Example #27
Source File: DummyBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties, Set<? extends String> concealedProperties, int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) { err.println(NbBundle.getMessage(DummyBridgeImpl.class, "ERR_cannot_run_target")); problem.printStackTrace(err); return false; }
Example #28
Source File: STSWizardCreator.java From netbeans with Apache License 2.0 | 5 votes |
public void createSTS() { final ProgressHandle handle = ProgressHandleFactory.createHandle( NbBundle.getMessage(STSWizardCreator.class, "TXT_StsGeneration")); //NOI18N initProjectInfo(project); Runnable r = new Runnable() { public void run() { try { handle.start(100); generateWsFromWsdl15(handle); } catch (Exception e) { //finish progress bar handle.finish(); String message = e.getLocalizedMessage(); if(message != null) { logger.log(Level.INFO, null, e); NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(nd); } else { logger.log(Level.INFO, null, e); } } } }; RequestProcessor.getDefault().post(r); }
Example #29
Source File: HeapWalker.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void computeRetainedSizes() { List<JavaClass> classes = mainHeapWalker.getHeapFragment().getAllClasses(); if (classes.size() > 0) { ProgressHandle pd = ProgressHandle.createHandle(Bundle.HeapFragmentWalker_ComputingRetainedMsg()); pd.start(); classes.get(0).getRetainedSizeByClass(); pd.finish(); } }
Example #30
Source File: ApplicationSnapshot.java From visualvm with GNU General Public License v2.0 | 5 votes |
public void saveAs() { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle(NbBundle.getMessage(ApplicationSnapshot.class, "LBL_Save_Application_Snapshot_As")); // NOI18N chooser.setSelectedFile(new File(getFile().getName())); chooser.setAcceptAllFileFilterUsed(false); chooser.setFileFilter(getCategory().getFileFilter()); if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) { String categorySuffix = ApplicationSnapshotCategory.SUFFIX; String filePath = chooser.getSelectedFile().getAbsolutePath(); if (!filePath.endsWith(categorySuffix)) filePath += categorySuffix; final File file = new File(filePath); VisualVM.getInstance().runTask(new Runnable() { public void run() { ProgressHandle pHandle = null; try { pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(ApplicationSnapshot.class, "MSG_Saving", DataSourceDescriptorFactory.getDescriptor(ApplicationSnapshot.this).getName())); // NOI18N pHandle.setInitialDelay(0); pHandle.start(); saveArchive(file); } finally { final ProgressHandle pHandleF = pHandle; SwingUtilities.invokeLater(new Runnable() { public void run() { if (pHandleF != null) pHandleF.finish(); } }); } } }); } }