Java Code Examples for com.intellij.openapi.progress.ProgressIndicator#setText2()
The following examples show how to use
com.intellij.openapi.progress.ProgressIndicator#setText2() .
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: ActionManager.java From markdown-image-kit with MIT License | 6 votes |
/** * Invoke. * * @param indicator the indicator */ public void invoke(ProgressIndicator indicator) { int totalProcessed = 0; data.setIndicator(indicator); data.setSize(handlersChain.size()); int index = 0; for (IActionHandler handler : handlersChain) { data.setIndex(index++); if (handler.isEnabled(data)) { log.trace("invoke {}", handler.getName()); indicator.setText2(handler.getName()); if (!handler.execute(data)) { break; } } indicator.setFraction(++totalProcessed * 1.0 / handlersChain.size()); } }
Example 2
Source File: ActionHandlerAdapter.java From markdown-image-kit with MIT License | 6 votes |
@Override public boolean execute(EventData data) { ProgressIndicator indicator = data.getIndicator(); int size = data.getSize(); int totalProcessed = 0; for (Map.Entry<Document, List<MarkdownImage>> imageEntry : data.getWaitingProcessMap().entrySet()) { int totalCount = imageEntry.getValue().size(); Iterator<MarkdownImage> imageIterator = imageEntry.getValue().iterator(); while (imageIterator.hasNext()) { MarkdownImage markdownImage = imageIterator.next(); indicator.setText2("Processing " + markdownImage.getImageName()); indicator.setFraction(((++totalProcessed * 1.0) + data.getIndex() * size) / totalCount * size); invoke(data, imageIterator, markdownImage); } } return true; }
Example 3
Source File: InsertToClipboardHandler.java From markdown-image-kit with MIT License | 6 votes |
@Override public boolean execute(EventData data) { ProgressIndicator indicator = data.getIndicator(); int size = data.getSize(); int totalProcessed = 0; StringBuilder marks = new StringBuilder(); for (Map.Entry<Document, List<MarkdownImage>> imageEntry : data.getWaitingProcessMap().entrySet()) { int totalCount = imageEntry.getValue().size(); for (MarkdownImage markdownImage : imageEntry.getValue()) { String imageName = markdownImage.getImageName(); indicator.setText2("Processing " + imageName); marks.append(markdownImage.getFinalMark()).append(ImageContents.LINE_BREAK); indicator.setFraction(((++totalProcessed * 1.0) + data.getIndex() * size) / totalCount * size); } } ImageUtils.setStringToClipboard(marks.toString()); return true; }
Example 4
Source File: MuleSdkSelectionDialog.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
private boolean download(ProgressIndicator progressIndicator, URL url, File outputFile, String version) { try { HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection()); long completeFileSize = httpConnection.getContentLength(); java.io.BufferedInputStream in = new java.io.BufferedInputStream(httpConnection.getInputStream()); java.io.FileOutputStream fos = new java.io.FileOutputStream(outputFile); java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, BUFFER_SIZE); byte[] data = new byte[BUFFER_SIZE]; long downloadedFileSize = 0; int x; while (!progressIndicator.isCanceled() && (x = in.read(data, 0, BUFFER_SIZE)) >= 0) { downloadedFileSize += x; // calculate progress final double currentProgress = ((double) downloadedFileSize) / ((double) completeFileSize); progressIndicator.setFraction(currentProgress); progressIndicator.setText2(Math.ceil(downloadedFileSize / (1024 * 1024)) + "/" + (Math.ceil(completeFileSize / (1024 * 1024)) + " MB")); bout.write(data, 0, x); } bout.close(); in.close(); } catch (IOException e) { Messages.showErrorDialog("An error occurred while trying to download " + version + ".\n" + e.getMessage(), "Mule SDK Download Error"); return false; } return !progressIndicator.isCanceled(); }
Example 5
Source File: PluginDownloader.java From consulo with Apache License 2.0 | 6 votes |
private File downloadPlugin(final ProgressIndicator indicator) throws IOException { File pluginsTemp = new File(ContainerPathManager.get().getPluginTempPath()); if (!pluginsTemp.exists() && !pluginsTemp.mkdirs()) { throw new IOException(IdeBundle.message("error.cannot.create.temp.dir", pluginsTemp)); } final File file = FileUtil.createTempFile(pluginsTemp, "plugin_", "_download", true, false); indicator.checkCanceled(); if (myIsPlatform) { indicator.setText2(IdeBundle.message("progress.downloading.platform")); } else { indicator.setText2(IdeBundle.message("progress.downloading.plugin", getPluginName())); } return HttpRequests.request(myPluginUrl).gzip(false).connect(request -> { request.saveToFile(file, indicator); String fileName = getFileName(); File newFile = new File(file.getParentFile(), fileName); FileUtil.rename(file, newFile); return newFile; }); }
Example 6
Source File: ReplaceToDocument.java From markdown-image-kit with MIT License | 5 votes |
@Override public boolean execute(EventData data) { ProgressIndicator indicator = data.getIndicator(); int size = data.getSize(); int totalProcessed = 0; for (Map.Entry<Document, List<MarkdownImage>> imageEntry : data.getWaitingProcessMap().entrySet()) { Document document = imageEntry.getKey(); int totalCount = imageEntry.getValue().size(); for (MarkdownImage markdownImage : imageEntry.getValue()) { String imageName = markdownImage.getImageName(); indicator.setFraction(((++totalProcessed * 1.0) + data.getIndex() * size) / totalCount * size); indicator.setText2("Processing " + imageName); String finalMark = markdownImage.getFinalMark(); if(StringUtils.isBlank(finalMark)){ continue; } String newLineText = markdownImage.getOriginalLineText().replace(markdownImage.getOriginalMark(), finalMark); WriteCommandAction.runWriteCommandAction(data.getProject(), () -> document .replaceString(document.getLineStartOffset(markdownImage.getLineNumber()), document.getLineEndOffset(markdownImage.getLineNumber()), newLineText)); } } return true; }
Example 7
Source File: SourceJarGenerator.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private static File generateSourceJar(ProgressIndicator progress, String target, String sourceJarPath, PsiFile psiFile) throws IOException, URISyntaxException { Project project = psiFile.getProject(); progress.setText("Getting source paths for target " + target); List<String> sources = getSourcesForTarget(project, target); progress.setText("Finding Pants build root"); Path buildRoot = findBuildRoot(project); progress.setText("Preparing source jar"); Path targetPath = Paths.get(sourceJarPath); Optional<String> packageName = findPackageName(psiFile); try (FileSystem zipFileSystem = createZipFileSystem(targetPath)) { for (String source : sources) { progress.setText2("Processing " + source); String sourceRoot = findSourceRoot(source, packageName); Path pathInZip = zipFileSystem.getPath(source.substring(sourceRoot.length())); Files.createDirectories(pathInZip.getParent()); Path absoluteSourcePath = buildRoot.resolve(source); Files.copy(absoluteSourcePath, pathInZip, StandardCopyOption.REPLACE_EXISTING); } } return targetPath.toFile(); }
Example 8
Source File: AnalysisScope.java From consulo with Apache License 2.0 | 5 votes |
public int getFileCount() { if (myFilesSet == null) initFilesSet(); final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { //clear text after building analysis scope set indicator.setText(""); indicator.setText2(""); } return myFilesSet.size(); }
Example 9
Source File: ProjectImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void notifyAboutInitialization(float percentOfLoad, Object component) { ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { indicator.setText2(getComponentName(component)); } if (component instanceof ProjectComponent) { myProjectComponents.add((ProjectComponent)component); } }
Example 10
Source File: Waiter.java From consulo with Apache License 2.0 | 5 votes |
public void run(@Nonnull ProgressIndicator indicator) { indicator.setIndeterminate(true); indicator.setText2(VcsBundle.message("commit.wait.util.synched.text")); if (!myStarted.compareAndSet(false, true)) { LOG.error("Waiter running under progress being started again."); } else { while (!mySemaphore.waitFor(500)) { indicator.checkCanceled(); } } }
Example 11
Source File: BackgroundTaskByVfsChangeManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public void call(final ProgressIndicator indicator, final VirtualFile file, final List<BackgroundTaskByVfsChangeTask> tasks, final int index) { if (index == tasks.size()) { file.putUserData(PROCESSING_BACKGROUND_TASK, null); return; } BackgroundTaskByVfsChangeTaskImpl task = (BackgroundTaskByVfsChangeTaskImpl)tasks.get(index); ActionCallback callback = new ActionCallback(); callback.doWhenProcessed(() -> call(indicator, file, tasks, index + 1)); indicator.setText2("Task: " + task.getName()); task.run(callback); }
Example 12
Source File: TFSProgressUtil.java From azure-devops-intellij with MIT License | 4 votes |
public static void setProgressText2(final @Nullable ProgressIndicator progressIndicator, @Nullable String text) { if (progressIndicator != null && text != null) { progressIndicator.setText2(text); } }
Example 13
Source File: ModuleManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private Module loadModuleInternal(@Nonnull ModuleLoadItem item, boolean firstLoad, @Nullable ProgressIndicator progressIndicator) throws ModuleWithNameAlreadyExistsException, ModuleDirIsNotExistsException, StateStorageException { final String moduleName = item.getName(); if (progressIndicator != null) { progressIndicator.setText2(moduleName); } if (firstLoad) { for (Module module : myModules) { if (module.getName().equals(moduleName)) { throw new ModuleWithNameAlreadyExistsException(ProjectBundle.message("module.already.exists.error", moduleName), moduleName); } } } ModuleEx oldModule = null; String dirUrl = item.getDirUrl(); if (dirUrl != null) { Ref<VirtualFile> ref = Ref.create(); ApplicationManager.getApplication().invokeAndWait(() -> ref.set(VirtualFileManager.getInstance().refreshAndFindFileByUrl(dirUrl))); VirtualFile moduleDir = ref.get(); if (moduleDir == null || !moduleDir.exists() || !moduleDir.isDirectory()) { throw new ModuleDirIsNotExistsException(ProjectBundle.message("module.dir.does.not.exist.error", FileUtil.toSystemDependentName(VirtualFileManager.extractPath(dirUrl)))); } oldModule = getModuleByDirUrl(moduleDir.getUrl()); } if (oldModule == null) { oldModule = createAndLoadModule(item, this, progressIndicator); } else { collapseOrExpandMacros(oldModule, item.getElement(), false); final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(oldModule); ApplicationManager.getApplication().runReadAction(() -> moduleRootManager.loadState(item.getElement(), progressIndicator)); } return oldModule; }
Example 14
Source File: UpdateCopyrightProcessor.java From consulo with Apache License 2.0 | 4 votes |
@Override protected Runnable preprocessFile(final PsiFile file) throws IncorrectOperationException { VirtualFile vfile = file.getVirtualFile(); if (vfile == null) { return EmptyRunnable.getInstance(); } final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText2(vfile.getPresentableUrl()); } Module mod = module; if (module == null) { mod = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vfile); } if (mod == null) { return EmptyRunnable.getInstance(); } UpdateCopyrightsProvider updateCopyrightsProvider = CopyrightUpdaters.INSTANCE.forFileType(file.getFileType()); if(updateCopyrightsProvider == null) { return EmptyRunnable.getInstance(); } CopyrightProfile copyrightProfile = CopyrightManager.getInstance(project).getCopyrightOptions(file); if (copyrightProfile != null && CopyrightUpdaters.hasExtension(file)) { logger.debug("process " + file); final UpdatePsiFileCopyright<?> updateCopyright = updateCopyrightsProvider.createInstance(file, copyrightProfile); return new Runnable() { @Override public void run() { try { updateCopyright.process(); } catch (Exception e) { logger.error(e); } } }; } else { return EmptyRunnable.getInstance(); } }