Java Code Examples for com.intellij.openapi.progress.ProgressManager
The following examples show how to use
com.intellij.openapi.progress.ProgressManager. These examples are extracted from open source projects.
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 Project: intellij-demandware Source File: DWCleanAction.java License: MIT License | 6 votes |
public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); if (project != null) { for (Module module : ModuleManager.getInstance(project).getModules()) { if (ModuleType.get(module) instanceof DWModuleType) { ModuleServiceManager.getService(module, DWServerConnection.class); ProgressManager.getInstance().run( new DWCleanTask(project, module, "Cleaning cartridges...", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) ); } } } }
Example 2
Source Project: consulo Source File: FileHistoryPanelImpl.java License: Apache License 2.0 | 6 votes |
private void refreshFile(VcsFileRevision revision) { Runnable refresh = null; final VirtualFile vf = getVirtualFile(); if (vf == null) { final LocalHistoryAction action = startLocalHistoryAction(revision); final VirtualFile vp = myFilePath.getVirtualFileParent(); if (vp != null) { refresh = () -> vp.refresh(false, true, action::finish); } } else { refresh = () -> vf.refresh(false, false); } if (refresh != null) { ProgressManager.getInstance().runProcessWithProgressSynchronously(refresh, "Refreshing Files...", false, myVcs.getProject()); } }
Example 3
Source Project: consulo Source File: AnalysisScope.java License: Apache License 2.0 | 6 votes |
private static boolean processFile(@Nonnull final VirtualFile vFile, @Nonnull final PsiElementVisitor visitor, @Nonnull final PsiManager psiManager, final boolean needReadAction, final boolean clearResolveCache) { final Runnable runnable = new Runnable() { @Override public void run() { doProcessFile(visitor, psiManager, vFile, clearResolveCache); } }; if (needReadAction && !ApplicationManager.getApplication().isDispatchThread()) { commitAndRunInSmartMode(runnable, psiManager.getProject()); } else { runnable.run(); } final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); return indicator == null || !indicator.isCanceled(); }
Example 4
Source Project: consulo Source File: WolfTheProblemSolverImpl.java License: Apache License 2.0 | 6 votes |
private boolean isToBeHighlighted(@Nullable VirtualFile virtualFile) { if (virtualFile == null) return false; synchronized (myFilters) { if (!myFiltersLoaded) { myFiltersLoaded = true; myFilters.addAll(Arrays.asList(FILTER_EP_NAME.getExtensions(myProject))); } } for (final Condition<VirtualFile> filter : myFilters) { ProgressManager.checkCanceled(); if (filter.value(virtualFile)) { return true; } } return false; }
Example 5
Source Project: consulo Source File: FindInProjectUtil.java License: Apache License 2.0 | 6 votes |
static int processUsagesInFile(@Nonnull final PsiFile psiFile, @Nonnull final VirtualFile virtualFile, @Nonnull final FindModel findModel, @Nonnull final Processor<? super UsageInfo> consumer) { if (findModel.getStringToFind().isEmpty()) { if (!ReadAction.compute(() -> consumer.process(new UsageInfo(psiFile)))) { throw new ProcessCanceledException(); } return 1; } if (virtualFile.getFileType().isBinary()) return 0; // do not decompile .class files final Document document = ReadAction.compute(() -> virtualFile.isValid() ? FileDocumentManager.getInstance().getDocument(virtualFile) : null); if (document == null) return 0; final int[] offset = {0}; int count = 0; int found; ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator()); TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator); do { tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); // wait for user out of read action found = ReadAction.compute(() -> { if (!psiFile.isValid()) return 0; return addToUsages(document, findModel, psiFile, offset, USAGES_PER_READ_ACTION, consumer); }); count += found; } while (found != 0); return count; }
Example 6
Source Project: consulo Source File: CompilerPathsEx.java License: Apache License 2.0 | 6 votes |
protected void acceptDirectory(final VirtualFile file, final String fileRoot, final String filePath) { ProgressManager.checkCanceled(); final VirtualFile[] children = file.getChildren(); for (final VirtualFile child : children) { final String name = child.getName(); final String _filePath; final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { buf.append(filePath).append("/").append(name); _filePath = buf.toString(); } finally { StringBuilderSpinAllocator.dispose(buf); } accept(child, fileRoot, _filePath); } }
Example 7
Source Project: consulo Source File: ProgressIndicatorUtils.java License: Apache License 2.0 | 6 votes |
/** * Run the given computation with its execution time restricted to the given amount of time in milliseconds.<p></p> * <p> * Internally, it creates a new {@link ProgressIndicator}, runs the computation with that indicator and cancels it after the the timeout. * The computation should call {@link ProgressManager#checkCanceled()} frequently enough, so that after the timeout has been exceeded * it can stop the execution by throwing {@link ProcessCanceledException}, which will be caught by this {@code withTimeout}.<p></p> * <p> * If a {@link ProcessCanceledException} happens due to any other reason (e.g. a thread's progress indicator got canceled), * it'll be thrown out of this method. * * @return the computation result or {@code null} if timeout has been exceeded. */ @Nullable public static <T> T withTimeout(long timeoutMs, @Nonnull Computable<T> computation) { ProgressManager.checkCanceled(); ProgressIndicator outer = ProgressIndicatorProvider.getGlobalProgressIndicator(); ProgressIndicator inner = outer != null ? new SensitiveProgressWrapper(outer) : new ProgressIndicatorBase(false, false); AtomicBoolean canceledByTimeout = new AtomicBoolean(); ScheduledFuture<?> cancelProgress = AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> { canceledByTimeout.set(true); inner.cancel(); }, timeoutMs, TimeUnit.MILLISECONDS); try { return ProgressManager.getInstance().runProcess(computation, inner); } catch (ProcessCanceledException e) { if (canceledByTimeout.get()) { return null; } throw e; // canceled not by timeout } finally { cancelProgress.cancel(false); } }
Example 8
Source Project: GsonFormat Source File: DataWriter.java License: Apache License 2.0 | 6 votes |
public void execute(ClassEntity targetClass) { this.targetClass = targetClass; ProgressManager.getInstance().run(new Task.Backgroundable(project, "GsonFormat") { @Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); long currentTimeMillis = System.currentTimeMillis(); execute(); progressIndicator.setIndeterminate(false); progressIndicator.setFraction(1.0); StringBuffer sb = new StringBuffer(); sb.append("GsonFormat [" + (System.currentTimeMillis() - currentTimeMillis) + " ms]\n"); // sb.append("generate class : ( "+generateClassList.size()+" )\n"); // for (String item: generateClassList) { // sb.append(" at "+item+"\n"); // } // sb.append(" \n"); // NotificationCenter.info(sb.toString()); Toast.make(project, MessageType.INFO, sb.toString()); } }); }
Example 9
Source Project: intellij-haxe Source File: HaxeUtil.java License: Apache License 2.0 | 6 votes |
public static void reparseProjectFiles(@NotNull final Project project) { Task.Backgroundable task = new Task.Backgroundable(project, HaxeBundle.message("haxe.project.reparsing"), false) { public void run(@NotNull ProgressIndicator indicator) { final Collection<VirtualFile> haxeFiles = new ArrayList<VirtualFile>(); final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) { FileBasedIndex.getInstance().iterateIndexableFiles(new ContentIterator() { public boolean processFile(VirtualFile file) { if (HaxeFileType.HAXE_FILE_TYPE == file.getFileType()) { haxeFiles.add(file); } return true; } }, project, indicator); } ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { FileContentUtil.reparseFiles(project, haxeFiles, !project.isDefault()); } }, ModalityState.NON_MODAL); } }; ProgressManager.getInstance().run(task); }
Example 10
Source Project: consulo Source File: ExtractMethodHelper.java License: Apache License 2.0 | 6 votes |
/** * Finds duplicates of the code fragment specified in the finder in given scopes. * Note that in contrast to {@link #processDuplicates} the search is performed synchronously because normally you need the results in * order to complete the refactoring. If user cancels it, empty list will be returned. * * @param finder finder object to seek for duplicates * @param searchScopes scopes where to look them in * @param generatedMethod new method that should be excluded from the search * @return list of discovered duplicate code fragments or empty list if user interrupted the search * @see #replaceDuplicates(PsiElement, Editor, Consumer, List) */ @Nonnull public static List<SimpleMatch> collectDuplicates(@Nonnull SimpleDuplicatesFinder finder, @Nonnull List<PsiElement> searchScopes, @Nonnull PsiElement generatedMethod) { final Project project = generatedMethod.getProject(); try { //noinspection RedundantCast return ProgressManager.getInstance().runProcessWithProgressSynchronously( (ThrowableComputable<List<SimpleMatch>, RuntimeException>)() -> { ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true); ThrowableComputable<List<SimpleMatch>, RuntimeException> action = () -> finder.findDuplicates(searchScopes, generatedMethod); return AccessRule.read(action); }, RefactoringBundle.message("searching.for.duplicates"), true, project); } catch (ProcessCanceledException e) { return Collections.emptyList(); } }
Example 11
Source Project: intellij Source File: AddSourceToProjectHelper.java License: Apache License 2.0 | 6 votes |
@Nullable private static WorkspacePath findBlazePackagePath(Project project, WorkspacePath source) { WorkspacePathResolver pathResolver = WorkspacePathResolverProvider.getInstance(project).getPathResolver(); if (pathResolver == null) { return null; } BuildSystemProvider provider = Blaze.getBuildSystemProvider(project); while (source != null) { ProgressManager.checkCanceled(); if (provider.findBuildFileInDirectory(pathResolver.resolveToFile(source)) != null) { return source; } source = source.getParent(); } return null; }
Example 12
Source Project: consulo Source File: JarHandler.java License: Apache License 2.0 | 6 votes |
@Nonnull private File copyToMirror(@Nonnull File original, @Nonnull File mirror) { ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); if (progress != null) { progress.pushState(); progress.setText(VfsBundle.message("jar.copy.progress", original.getPath())); progress.setFraction(0); } try { FileUtil.copy(original, mirror); } catch (final IOException e) { reportIOErrorWithJars(original, mirror, e); return original; } finally { if (progress != null) { progress.popState(); } } return mirror; }
Example 13
Source Project: consulo Source File: VcsSynchronousProgressWrapper.java License: Apache License 2.0 | 6 votes |
public static boolean wrap(final ThrowableRunnable<VcsException> runnable, final Project project, final String title) { final VcsException[] exc = new VcsException[1]; final Runnable process = new Runnable() { @Override public void run() { try { runnable.run(); } catch (VcsException e) { exc[0] = e; } } }; final boolean notCanceled; if (ApplicationManager.getApplication().isDispatchThread()) { notCanceled = ProgressManager.getInstance().runProcessWithProgressSynchronously(process, title, true, project); } else { process.run(); notCanceled = true; } if (exc[0] != null) { AbstractVcsHelper.getInstance(project).showError(exc[0], title); return false; } return notCanceled; }
Example 14
Source Project: consulo Source File: ShelveChangesManager.java License: Apache License 2.0 | 6 votes |
public void unshelveSilentlyAsynchronously(@Nonnull final Project project, @Nonnull final List<ShelvedChangeList> selectedChangeLists, @Nonnull final List<ShelvedChange> selectedChanges, @Nonnull final List<ShelvedBinaryFile> selectedBinaryChanges, @Nullable final LocalChangeList forcePredefinedOneChangelist) { ProgressManager.getInstance().run(new Task.Backgroundable(project, VcsBundle.message("unshelve.changes.progress.title"), true) { @Override public void run(@Nonnull ProgressIndicator indicator) { for (ShelvedChangeList changeList : selectedChangeLists) { List<ShelvedChange> changesForChangelist = ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getChanges(myProject), selectedChanges)); List<ShelvedBinaryFile> binariesForChangelist = ContainerUtil.newArrayList(ContainerUtil.intersection(changeList.getBinaryFiles(), selectedBinaryChanges)); boolean shouldUnshelveAllList = changesForChangelist.isEmpty() && binariesForChangelist.isEmpty(); unshelveChangeList(changeList, shouldUnshelveAllList ? null : changesForChangelist, shouldUnshelveAllList ? null : binariesForChangelist, forcePredefinedOneChangelist != null ? forcePredefinedOneChangelist : getChangeListUnshelveTo(changeList), true); } } }); }
Example 15
Source Project: consulo Source File: ImplementationSearcher.java License: Apache License 2.0 | 6 votes |
/** * * @param element * @param editor * @return For the case the search has been cancelled */ @Nullable protected PsiElement[] searchDefinitions(PsiElement element, Editor editor) { PsiElement[][] result = new PsiElement[1][]; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { try { result[0] = search(element, editor).toArray(PsiElement.EMPTY_ARRAY); } catch (IndexNotReadyException e) { dumbModeNotification(element); result[0] = null; } }, SEARCHING_FOR_IMPLEMENTATIONS, true, element.getProject())) { return null; } return result[0]; }
Example 16
Source Project: consulo Source File: ModuleManagerComponent.java License: Apache License 2.0 | 6 votes |
@Override protected void fireModulesAdded() { Runnable runnableWithProgress = () -> { for (final Module module : myModuleModel.getModules()) { final Application app = ApplicationManager.getApplication(); final Runnable swingRunnable = () -> fireModuleAddedInWriteAction(module); if (app.isDispatchThread() || app.isHeadlessEnvironment()) { swingRunnable.run(); } else { ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator(); app.invokeAndWait(swingRunnable, pi.getModalityState()); } } }; ProgressIndicator progressIndicator = myProgressManager.getProgressIndicator(); if (progressIndicator == null) { myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Loading modules", false, myProject); } else { runnableWithProgress.run(); } }
Example 17
Source Project: consulo Source File: SingleTargetRequestResultProcessor.java License: Apache License 2.0 | 6 votes |
@Override public boolean processTextOccurrence(@Nonnull PsiElement element, int offsetInElement, @Nonnull final Processor<? super PsiReference> consumer) { if (!myTarget.isValid()) { return false; } final List<PsiReference> references = ourReferenceService.getReferences(element, new PsiReferenceService.Hints(myTarget, offsetInElement)); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < references.size(); i++) { PsiReference ref = references.get(i); ProgressManager.checkCanceled(); if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) { return false; } } return true; }
Example 18
Source Project: netbeans-mmd-plugin Source File: IdeaMMDPrintPanelAdaptor.java License: Apache License 2.0 | 6 votes |
@Override public void startBackgroundTask(@Nonnull final MMDPrintPanel source, @Nonnull final String taskName, @Nonnull final Runnable task) { final Task.Backgroundable backgroundTask = new Task.Backgroundable(this.project, taskName) { @Override public void run(@Nonnull final ProgressIndicator indicator) { try { indicator.setIndeterminate(true); task.run(); IdeaUtils.showPopup(String.format("%s has been sent to the printer", taskName), MessageType.INFO); } catch (Exception ex) { LOGGER.error("Print error", ex); IdeaUtils.showPopup("Print error! See the log!", MessageType.ERROR); } finally { indicator.stop(); } } }; ProgressManager.getInstance().run(backgroundTask); }
Example 19
Source Project: consulo Source File: CompletionThreadingBase.java License: Apache License 2.0 | 6 votes |
public static void withBatchUpdate(Runnable runnable, CompletionProcess process) { if (ourIsInBatchUpdate.get().booleanValue() || !(process instanceof CompletionProgressIndicator)) { runnable.run(); return; } try { ourIsInBatchUpdate.set(Boolean.TRUE); runnable.run(); ProgressManager.checkCanceled(); CompletionProgressIndicator currentIndicator = (CompletionProgressIndicator)process; CompletionThreadingBase threading = Objects.requireNonNull(currentIndicator.getCompletionThreading()); threading.flushBatchResult(currentIndicator); } finally { ourIsInBatchUpdate.set(Boolean.FALSE); } }
Example 20
Source Project: IntelliJDeodorant Source File: AbstractRefactoringPanel.java License: MIT License | 5 votes |
public static void runAfterCompilationCheck(Task.Backgroundable afterCompilationBackgroundable, Project project, ProjectInfo projectInfo) { final Task.Backgroundable compilationBackgroundable = new Task.Backgroundable(project, IntelliJDeodorantBundle.message("project.compiling.indicator.text"), true) { @Override public void run(@NotNull ProgressIndicator indicator) { runAfterCompilationCheck(projectInfo, afterCompilationBackgroundable); } }; ProgressManager.getInstance().run(compilationBackgroundable); }
Example 21
Source Project: consulo Source File: CommitHelper.java License: Apache License 2.0 | 5 votes |
private void delegateCommitToVcsThread(final GeneralCommitProcessor processor) { final ProgressIndicator indicator = new DelegatingProgressIndicator(); final Semaphore endSemaphore = new Semaphore(); endSemaphore.down(); ChangeListManagerImpl.getInstanceImpl(myProject).executeOnUpdaterThread(new Runnable() { @Override public void run() { indicator.setText("Performing VCS commit..."); try { ProgressManager.getInstance().runProcess(new Runnable() { @Override public void run() { indicator.checkCanceled(); generalCommit(processor); } }, indicator); } finally { endSemaphore.up(); } } }); indicator.setText("Waiting for VCS background tasks to finish..."); while (!endSemaphore.waitFor(20)) { indicator.checkCanceled(); } }
Example 22
Source Project: consulo Source File: CallbackData.java License: Apache License 2.0 | 5 votes |
@Nonnull private static CallbackData createInteractive(@Nonnull Project project, @Nonnull InvokeAfterUpdateMode mode, @Nonnull Runnable afterUpdate, String title, @Nullable ModalityState state) { Task task = mode.isSynchronous() ? new Waiter(project, afterUpdate, title, mode.isCancellable()) : new FictiveBackgroundable(project, afterUpdate, title, mode.isCancellable(), state); Runnable callback = () -> { logUpdateFinished(project, mode); setDone(task); }; return new CallbackData(callback, () -> ProgressManager.getInstance().run(task)); }
Example 23
Source Project: consulo Source File: JobUtilTest.java License: Apache License 2.0 | 5 votes |
private static void checkProgressAndReadAction(final List<Object> objects, final DaemonProgressIndicator progress, final boolean runInReadAction) throws Throwable { final AtomicReference<Throwable> exception = new AtomicReference<Throwable>(); JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, progress, runInReadAction, new Processor<Object>() { @Override public boolean process(Object o) { try { if (objects.size() <= 1 || JobSchedulerImpl.getCPUCoresCount() <= 2) { assertTrue(ApplicationManager.getApplication().isDispatchThread()); } else { // generally we know nothing about current thread since FJP can help others task to execute while in current context } ProgressIndicator actualIndicator = ProgressManager.getInstance().getProgressIndicator(); assertTrue(actualIndicator instanceof SensitiveProgressWrapper); actualIndicator = ((SensitiveProgressWrapper)actualIndicator).getOriginalProgressIndicator(); if (progress != null) { assertSame(progress, actualIndicator); } else { assertNotNull(actualIndicator); } // there can be read access even if we didn't ask for it (e.g. when task under read action steals others work) assertTrue(!runInReadAction || ApplicationManager.getApplication().isReadAccessAllowed()); } catch (Throwable e) { exception.set(e); } return true; } }); if (exception.get() != null) throw exception.get(); }
Example 24
Source Project: idea-php-shopware-plugin Source File: ShopwareInstallerProjectGenerator.java License: MIT License | 5 votes |
@Override public void generateProject(@NotNull final Project project, final @NotNull VirtualFile baseDir, final @NotNull ShopwareInstallerSettings settings, @NotNull Module module) { String downloadPath = settings.getVersion().getUrl(); String toDir = baseDir.getPath(); VirtualFile zipFile = PhpConfigurationUtil.downloadFile(project, null, toDir, downloadPath, "shopware.zip"); if (zipFile == null) { showErrorNotification(project, "Cannot download Shopware.zip file"); return; } // Convert files File zip = VfsUtil.virtualToIoFile(zipFile); File base = VfsUtil.virtualToIoFile(baseDir); Task.Backgroundable task = new Task.Backgroundable(project, "Extracting", true) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { try { // unzip file ZipUtil.extract(zip, base, null); // Delete TMP File FileUtil.delete(zip); // Activate Plugin IdeHelper.enablePluginAndConfigure(project); } catch (IOException e) { showErrorNotification(project, "There is a error occurred"); } } }; ProgressManager.getInstance().run(task); }
Example 25
Source Project: litho Source File: ComponentsCacheService.java License: Apache License 2.0 | 5 votes |
void invalidate() { final List<String> componentNames = new ArrayList<>(componentNameToClass.keySet()); LOG.debug("Invalidating " + componentNames); if (componentNames.isEmpty()) return; IntervalLogger logger = new IntervalLogger(LOG); ProgressManager.getInstance() .run( new Task.Backgroundable(project, "Invalidating In-Memory Files") { @Override public void run(ProgressIndicator indicator) { indicator.setIndeterminate(false); for (int i = 0, size = componentNames.size(); i < size; i++) { indicator.setFraction(((double) i + 1) / size); indicator.setText2(i + 1 + "/" + size); String clsName = componentNames.get(i); AtomicBoolean found = new AtomicBoolean(false); ReadAction.run( () -> { final boolean foundCls = Arrays.stream(PsiSearchUtils.findClasses(project, clsName)) .anyMatch(cls -> !ComponentScope.contains(cls.getContainingFile())); found.set(foundCls); }); if (found.get()) { logger.logStep("removing " + clsName); componentNameToClass.remove(clsName); } else { logger.logStep("keeping " + clsName); } } } }); }
Example 26
Source Project: consulo Source File: CustomRegionStructureUtil.java License: Apache License 2.0 | 5 votes |
@RequiredReadAction private static Collection<CustomRegionTreeElement> collectCustomRegions(@Nonnull PsiElement rootElement, @Nonnull Set<? extends TextRange> ranges) { TextRange rootRange = getTextRange(rootElement); Iterator<PsiElement> iterator = SyntaxTraverser.psiTraverser(rootElement).filter(element -> isCustomRegionCommentCandidate(element) && rootRange.contains(element.getTextRange()) && !isInsideRanges(element, ranges)).iterator(); List<CustomRegionTreeElement> customRegions = new SmartList<>(); CustomRegionTreeElement currRegionElement = null; CustomFoldingProvider provider = null; while (iterator.hasNext()) { ProgressManager.checkCanceled(); PsiElement child = iterator.next(); if (provider == null) provider = getProvider(child); if (provider != null) { String commentText = child.getText(); if (provider.isCustomRegionStart(commentText)) { if (currRegionElement == null) { currRegionElement = new CustomRegionTreeElement(child, provider); customRegions.add(currRegionElement); } else { currRegionElement = currRegionElement.createNestedRegion(child); } } else if (provider.isCustomRegionEnd(commentText) && currRegionElement != null) { currRegionElement = currRegionElement.endRegion(child); } } } return customRegions; }
Example 27
Source Project: consulo Source File: InspectionProfileWrapper.java License: Apache License 2.0 | 5 votes |
public static void checkInspectionsDuplicates(@Nonnull InspectionToolWrapper[] toolWrappers) { if (alreadyChecked) return; alreadyChecked = true; Set<InspectionProfileEntry> uniqTools = new THashSet<InspectionProfileEntry>(toolWrappers.length); for (InspectionToolWrapper toolWrapper : toolWrappers) { ProgressManager.checkCanceled(); if (!uniqTools.add(toolWrapper.getTool())) { LOG.error("Inspection " + toolWrapper.getDisplayName() + " (" + toolWrapper.getTool().getClass() + ") already registered"); } } }
Example 28
Source Project: consulo Source File: DumpDirectoryInfoAction.java License: Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final DirectoryIndex index = DirectoryIndex.getInstance(project); if (project != null) { final VirtualFile root = e.getData(PlatformDataKeys.VIRTUAL_FILE); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { final ContentIterator contentIterator = new ContentIterator() { @Override public boolean processFile(VirtualFile fileOrDir) { LOG.info(fileOrDir.getPath()); final DirectoryInfo directoryInfo = index.getInfoForDirectory(fileOrDir); if (directoryInfo != null) { LOG.info(directoryInfo.toString()); } return true; } }; if (root != null) { ProjectRootManager.getInstance(project).getFileIndex().iterateContentUnderDirectory(root, contentIterator); } else { ProjectRootManager.getInstance(project).getFileIndex().iterateContent(contentIterator); } } }, "Dumping directory index", true, project); } }
Example 29
Source Project: AndroidGodEye Source File: OpenAction.java License: Apache License 2.0 | 5 votes |
private String parsePortByLogcatWithTimeout(Project project, String adbPath) { final String[] parsedPort = new String[1]; ProgressManager.getInstance(). runProcessWithProgressSynchronously(new Runnable() { public void run() { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); progressIndicator.setIndeterminate(false); progressIndicator.setFraction(0.3); mLogger.info("parsePortByLogcatWithTimeout start parsing"); Future<String> result = mExecutorService.submit(new Callable<String>() { @Override public String call() throws Exception { return parsePortByLogcat(adbPath, progressIndicator); } }); mLogger.info("parsePortByLogcatWithTimeout wait parsing"); try { parsedPort[0] = result.get(5, TimeUnit.SECONDS); mLogger.info("parsePortByLogcatWithTimeout wait end,get parsed port:" + parsedPort[0]); } catch (Throwable e) { e.printStackTrace(); mLogger.info("parsePortByLogcatWithTimeout wait end, timeout."); } progressIndicator.setFraction(1.0); } }, "Parsing Port, Wait For 5 Seconds...", true, project); mLogger.info("parsePortByLogcatWithTimeout return"); return parsedPort[0]; }
Example 30
Source Project: consulo Source File: FileTreeModelBuilder.java License: Apache License 2.0 | 5 votes |
private void counting() { myTotalFileCount++; ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { update(indicator, true, -1); } }