@Override public void run() { ProgressHandle handle = ProgressHandleFactory.createHandle(displayName); handle.start(); handle.switchToIndeterminate(); try { ref.set(operation.run(handle)); } finally { handle.finish(); } } }, displayName, new AtomicBoolean(false), true, 0, 0);
public void finishingExtending() { String msg = NbBundle.getMessage( NewPhpProjectWizardIterator.class, "LBL_NewPhpProjectWizardIterator_WizardProgress_PreparingToOpen"); handle.progress(msg, units); } }
@Override public void beginTask(String taskName, int totalWork) { if(totalWork < 0) { this.totalWorkUnits = 0; }else { this.totalWorkUnits = F * totalWork; } this.currentWorkUnits = 0; this.currentWorkUnitsRational = 0.0; if (progressHandle == null) { progressHandle = ProgressHandleFactory.createHandle(taskName, this); progressHandle.start(this.totalWorkUnits); } else { try { progressHandle.start(this.totalWorkUnits); } catch (java.lang.IllegalStateException e) { // if already started, use fall back progressHandle.switchToDeterminate(this.totalWorkUnits); } progressHandle.setDisplayName(taskName); } }
@Override public void starting() { handle.start(10); String msg = NbBundle.getMessage( NewPhpProjectWizardIterator.class, "LBL_NewPhpProjectWizardIterator_WizardProgress_CreatingProject"); handle.progress(msg, 2); }
@Override public void operationFinish(Operation operation, Collection<TransferFile> forFiles) { operations.pollFirst(); if (operation == Operation.LIST) { progressHandle.switchToDeterminate(workUnits); progressHandle.progress(workUnit); } if (operations.isEmpty()) { progressHandle.finish(); } }
@Override public Set instantiate(ProgressHandle handle) throws IOException { handle.start(2); handle.progress(NbBundle.getMessage(JavaEESamplesWizardIterator.class, "LBL_NewSampleProjectWizardIterator_WizardProgress_CreatingProject"), 1); // NOI18N File dirF = FileUtil.normalizeFile((File) wiz.getProperty(WizardProperties.PROJ_DIR)); String name = (String)wiz.getProperty(WizardProperties.NAME); FileObject template = Templates.getTemplate(wiz); if ("web".equals(template.getAttribute("prjType"))) { // NOI18N dir = FileUtil.toFileObject(dirF); unZipFile(template.getInputStream(), dir); WebSampleProjectGenerator.configureServer(dir); for (FileObject child : dir.getChildren()) { WebSampleProjectGenerator.configureServer(child); handle.progress(NbBundle.getMessage(JavaEESamplesWizardIterator.class, "LBL_NewSampleProjectWizardIterator_WizardProgress_PreparingToOpen"), 2); // NOI18N handle.finish(); return resultSet;
private static SVGImage loadImageWithProgress(FileObject fo) throws IOException { ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(Util.class, "MSG_Loading", fo.getNameExt())); handle.start(MAX_WORKUNITS); if ( SVGDataObject.EXT_SVG.equals(fo.getExt().toLowerCase())){ //NOI18N ProgressInputStream pis = null; try { pis = new ProgressInputStream(fo.getInputStream(), fo.getSize(), handle); return (SVGImage) ScalableImage.createImage(pis, null); } finally { handle.finish(); try { if (pis != null) return (SVGImage) ScalableImage.createImage(pis, null); } finally { handle.finish(); try { if (pis != null)
handle.start(toDelete.size() + 1 /*clean*/); handle.progress(NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "LBL_Progress_Cleaning_Project")); handle.progress(++done); handle.progress(NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "LBL_Progress_Deleting_File", FileUtil.getFileDisplayName(f))); if (f != null && f.isValid()) { f.delete(); handle.progress(++done); projectFolder.refresh(); // #190983 if (!projectFolder.isValid()) { handle.finish(); String message = NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "LBL_Project_cannot_be_deleted.", displayName);
handle.progress((int) currentWorkDone); handle.progress((int) (currentWorkDone = totalWork * NOTIFY_WORK)); FileObject target = newTarget.createFolder(nueName); FileObject projectDirectory = project.getProjectDirectory(); List<FileObject> toCopyList = new ArrayList<FileObject>(); for (FileObject child : projectDirectory.getChildren()) { if (child.isValid()) { toCopyList.add(child); handle.progress((int) currentWorkDone); handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK)); ProjectOperations.notifyCopied(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueName); handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK)); handle.progress(totalWork); handle.finish(); } catch (Exception e) { Exceptions.attachLocalizedMessage(e, NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Cannot_Move", e.getLocalizedMessage())); throw e;
public void actionPerformed(ActionEvent e) { if (t != null && !t.isFinished()) { t.cancel(); } final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(ProjectAccessorImpl.class, "CTL_OpenKenaiProjectAction")); //NOI18N handle.setInitialDelay(0); handle.start(); t = RequestProcessor.getDefault().post(new Runnable() { public void run() { final KenaiProject kenaiProj = proj.getKenaiProject(); SwingUtilities.invokeLater(new Runnable() { public void run() { kenaiProjectTopComponent tc = kenaiProjectTopComponent.getInstance(kenaiProj); tc.open(); tc.requestActive(); } }); handle.finish(); } }); } };
@Override public Set<FileObject> instantiate(ProgressHandle handle) throws IOException { handle.start(4); Set<FileObject> resultSet = new LinkedHashSet<>(); File fDir = FileUtil.normalizeFile((File) wiz.getProperty("projdir")); fDir.mkdirs(); handle.progress(1); FileObject foDir = FileUtil.toFileObject(fDir); FileObject template = URLMapper.findFileObject(getClass().getResource("BasicSpringbootProject.zip")); unZipFile(template.getInputStream(), foDir); handle.progress(2); final FileObject foPom = foDir.getFileObject("pom.xml"); if (foPom != null) { resultSet.add(foPom); handle.progress(3); ProjectChooser.setProjectsFolder(parent); handle.finish(); return resultSet;
@Override public Set<FileObject> instantiate(ProgressHandle handle) throws IOException { handle.start(); handle.progress(Bundle.ClientSideProjectWizardIterator_progress_creatingProject()); Set<FileObject> files = new LinkedHashSet<FileObject>(); 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); AntProjectHelper projectHelper = ClientSideProjectUtilities.setupProject(dir, name); FileObject indexFile = siteRoot.getFileObject("index", "html"); // NOI18N if (indexFile != null) { files.add(indexFile); handle.finish(); siteTemplate != null ? siteTemplate.getId() : "NONE", // NOI18N libraryNames == null ? "" : libraryNames, !newProjWizard && siteRoot != null ? (FileUtil.isParentOf(dir, siteRoot) ? "YES" : "NO") : "" // NOI18N });
try { for (GrailsPlugin plugin : selectedPlugins) { String title = NbBundle.getMessage(GrailsPluginSupport.class, uninstall ? "Uninstallation" : "Installation"); String message = NbBundle.getMessage(GrailsPluginSupport.class, uninstall ? "PluginUninstallPleaseWait" : "PluginInstallPleaseWait", plugin.getName()); ProgressHandle handle = ProgressHandleFactory.createHandle(message); handle.start(); handle.progress(message); Exceptions.printStackTrace(ex.getCause() != null ? ex.getCause() : ex); } finally { handle.finish(); FileUtil.refreshFor(project.getBuildConfig().getProjectPluginsDir());
Project nue = null; try { handle.switchToIndeterminate(); handle.switchToDeterminate(5); int currentWorkDone = 0; FileObject projectDirectory = project.getProjectDirectory(); File projectDirectoryFile = FileUtil.toFile(project.getProjectDirectory()); close(project); handle.progress(++currentWorkDone); for (MoveOperationImplementation o : operations) { o.notifyMoving(); handle.progress(++currentWorkDone); for (MoveOperationImplementation o : operations) { o.notifyMoved(null, projectDirectoryFile, nueName); handle.progress(++currentWorkDone); assert nue != null; originalOK = false; handle.progress(++currentWorkDone); operations = nue.getLookup().lookupAll(MoveOperationImplementation.class); for (MoveOperationImplementation o : operations) { ProjectManager.getDefault().saveProject(nue); open(nue, wasMain); handle.progress(++currentWorkDone); handle.finish(); } catch (Exception e) {
@NonNull public static Future<String> download( @NonNull final URL url, @NonNull final Callable<Boolean> cancel) { return RP.submit(()-> { if (cancel.call()) { return ""; //NOI18N } final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(DocDownloader.class, "LBL_DownloadingDoc")); handle.start(); try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try(BufferedInputStream in = new BufferedInputStream(url.openStream())) { FileUtil.copy(in, out); } return cancel.call() ? "" //NOI18N : new String(out.toByteArray(),"UTF-8"); //NOI18N } finally { handle.finish(); } }); }
@Override public void run() { ProgressHandle markProgress = getProgress(); markProgress.start(tasks.size()); int workunits = 0; for (IssueImpl task : tasks) { if (canceled) { break; } markProgress.progress(NbBundle.getMessage(Actions.class, "LBL_MarkTaskProgress", task.getDisplayName())); task.setSeen(setAsSeen); workunits++; markProgress.progress(workunits); } markProgress.finish(); } });
@Override public void operationStart(Operation operation, Collection<TransferFile> forFiles) { if (operations.isEmpty()) { assert workUnits >= 0 : workUnits + " :: " + forFiles; progressHandle.start(workUnits); } operations.offerFirst(operation); if (operation == Operation.LIST) { progressHandle.progress(NbBundle.getMessage(RemoteCommand.class, "LBL_ListingFiles", forFiles.iterator().next().getName())); progressHandle.switchToIndeterminate(); } }
public Set instantiate(ProgressHandle handle) throws IOException { try { handle.start(2); handle.progress(1); RequestProcessor.getDefault().post(new Runnable() { public void run() { tryOpenProject(); } }); return Collections.EMPTY_SET; } finally { handle.finish(); } }
handle.switchToDeterminate(4); int currentWorkDone = 0; handle.progress(++currentWorkDone); for (MoveOperationImplementation o : operations) { ((MoveOrRenameOperationImplementation) o).notifyRenaming(); handle.progress(++currentWorkDone); for (MoveOperationImplementation o : operations) { ((MoveOrRenameOperationImplementation) o).notifyRenamed(nueName); handle.progress(++currentWorkDone); ProjectManager.getDefault().saveProject(project); handle.progress(++currentWorkDone); handle.finish(); } catch (Exception e) { Exceptions.attachLocalizedMessage(e, NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Cannot_Rename", e.getLocalizedMessage())); throw e;