当前位置: 首页>>代码示例>>Java>>正文


Java ProgressManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.progress.ProgressManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressManager.getInstance方法的具体用法?Java ProgressManager.getInstance怎么用?Java ProgressManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.progress.ProgressManager的用法示例。


在下文中一共展示了ProgressManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: implementersHaveOnlyPrivateConstructors

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private boolean implementersHaveOnlyPrivateConstructors(final PsiClass aClass) {
  final GlobalSearchScope scope = GlobalSearchScope.allScope(aClass.getProject());
  final PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit(6);
  final ProgressManager progressManager = ProgressManager.getInstance();
  progressManager.runProcess(new Runnable() {
    @Override
    public void run() {
      ClassInheritorsSearch.search(aClass, scope, true, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
    }
  }, null);
  if (processor.isOverflow()) {
    return false;
  }
  final Collection<PsiClass> implementers = processor.getCollection();
  for (PsiClass implementer : implementers) {
    if (!implementer.isInterface() && !implementer.hasModifierProperty(PsiModifier.ABSTRACT)) {
      if (!hasOnlyPrivateConstructors(implementer)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ObjectEqualityInspection.java

示例2: onOk

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public void onOk(@Nonnull NewClassDialog dialog) {
    final PsiDirectory directory = ideView.getOrChooseDirectory();
    if (directory == null) {
        dialog.cancel();
        return;
    }

    try {
        final CommandActionFactory actionFactory = commandActionFactoryProvider.get();
        final JavaConverterFactory converterFactory = javaConverterFactoryProvider.get();
        final NewClassCommandAction command = actionFactory.create(
                dialog.getClassName(),
                dialog.getJson(),
                directory,
                converterFactory.create(settings)
        );

        final ProgressManager progressManager = ProgressManager.getInstance();
        progressManager.runProcessWithProgressSynchronously(() -> {
            final ProgressIndicator indicator = progressManager.getProgressIndicator();
            if (indicator != null) {
                indicator.setIndeterminate(true);
                indicator.setText(bundle.message("progress.text", dialog.getClassName()));
            }

            final RunResult<PsiFile> result = command.execute();
            return result.getResultObject();
        }, bundle.message("progress.title"), false, project);
        dialog.close();
    } catch (RuntimeException e) {
        LOGGER.warn("Unable to create a class", e);
        onError(dialog, e.getCause());
    }
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:36,代码来源:NewClassAction.java

示例3: downloadVersionWithProgress

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private void downloadVersionWithProgress(String version, String destinationDir) {

        Messages.showInfoMessage(contentPane, "Download Is Going to Take Some Time. Good time for a coffee.", "Mule Distribution Download");
        final Optional<MuleUrl> first = MuleUrl.getVERSIONS().stream().filter((url) -> url.getName().equals(version)).findFirst();
        final MuleUrl muleUrl = first.get();
        try {
            final ProgressManager instance = ProgressManager.getInstance();
            final File distro = instance.runProcessWithProgressSynchronously(() -> {
                final URL artifactUrl = new URL(muleUrl.getUrl());
                final File sourceFile = FileUtil.createTempFile("mule" + version, ".zip");
                if (download(instance.getProgressIndicator(), artifactUrl, sourceFile, version)) {
                    final File destDir = new File(destinationDir);
                    destDir.mkdirs();
                    ZipUtil.extract(sourceFile, destDir, null);
                    try (ZipFile zipFile = new ZipFile(sourceFile)) {
                        String rootName = zipFile.entries().nextElement().getName();
                        return new File(destDir, rootName);
                    }
                } else {
                    return null;
                }
            }, "Downloading Mule Distribution " + muleUrl.getName(), true, null);
            if (distro != null) {
                final MuleSdk muleSdk = new MuleSdk(distro.getAbsolutePath());
                MuleSdkManagerImpl.getInstance().addSdk(muleSdk);
                myTableModel.addRow(muleSdk);
                final int rowIndex = myTableModel.getRowCount() - 1;
                myInputsTable.getSelectionModel().setSelectionInterval(rowIndex, rowIndex);
                onOK();
            }
        } catch (Exception e) {
            Messages.showErrorDialog("An error occurred while trying to download " + version + ".\n" + e.getMessage(),
                    "Mule SDK Download Error");
        }

    }
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:37,代码来源:MuleSdkSelectionDialog.java

示例4: actionPerformed

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final List<FilePath> files = e.getData(ChangesListView.MISSING_FILES_DATA_KEY);
  if (files == null) return;

  final ProgressManager progressManager = ProgressManager.getInstance();
  final Runnable action = new Runnable() {
    public void run() {
      final List<VcsException> allExceptions = new ArrayList<VcsException>();
      ChangesUtil.processFilePathsByVcs(project, files, new ChangesUtil.PerVcsProcessor<FilePath>() {
        public void process(final AbstractVcs vcs, final List<FilePath> items) {
          final List<VcsException> exceptions = processFiles(vcs, files);
          if (exceptions != null) {
            allExceptions.addAll(exceptions);
          }
        }
      });

      for (FilePath file : files) {
        VcsDirtyScopeManager.getInstance(project).fileDirty(file);
      }
      ChangesViewManager.getInstance(project).scheduleRefresh();
      if (allExceptions.size() > 0) {
        AbstractVcsHelper.getInstance(project).showErrors(allExceptions, "VCS Errors");
      }
    }
  };
  if (synchronously()) {
    action.run();
  } else {
    progressManager.runProcessWithProgressSynchronously(new Runnable() {
      @Override
      public void run() {
        DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, action);
      }
    }, getName(), true, project);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:AbstractMissingFilesAction.java

示例5: initOccurrencesNumber

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
protected static int initOccurrencesNumber(PsiNameIdentifierOwner nameIdentifierOwner) {
  final ProgressManager progressManager = ProgressManager.getInstance();
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(nameIdentifierOwner.getProject());
  final GlobalSearchScope scope = GlobalSearchScope.projectScope(nameIdentifierOwner.getProject());
  final String name = nameIdentifierOwner.getName();
  final boolean isCheapToSearch =
   name != null && searchHelper.isCheapEnoughToSearch(name, scope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
  return isCheapToSearch ? ReferencesSearch.search(nameIdentifierOwner).findAll().size() : - 1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:InlineOptionsDialog.java

示例6: findModulesInScope

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private static Map<Module, PsiFile> findModulesInScope(@NotNull final Project project,
                                                       @NotNull final AnalysisScope scope,
                                                       @NotNull final int[] fileCount) {
  final ProgressManager progressManager = ProgressManager.getInstance();
  final Map<Module, PsiFile> modules = new HashMap<Module, PsiFile>();
  boolean completed = progressManager.runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      scope.accept(new PsiElementVisitor() {
        @Override
        public void visitFile(PsiFile file) {
          fileCount[0]++;
          final ProgressIndicator progressIndicator = progressManager.getProgressIndicator();
          if (progressIndicator != null) {
            final VirtualFile virtualFile = file.getVirtualFile();
            if (virtualFile != null) {
              progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project));
            }
            progressIndicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title"));
          }
          final Module module = ModuleUtilCore.findModuleForPsiElement(file);
          if (module != null && !modules.containsKey(module)) {
            modules.put(module, file);
          }
        }
      });
    }
  }, "Check applicability...", true, project);
  return completed ? modules : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:AndroidInferNullityAnnotationAction.java

示例7: checkCancelled

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public void checkCancelled() throws SVNCancelException {
  final ProgressManager pm = ProgressManager.getInstance();
  final ProgressIndicator pi = pm.getProgressIndicator();
  if (pi != null) {
    if (pi.isCanceled()) throw new SVNCancelException();
  }
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null && indicator.isCanceled()) {
    throw new SVNCancelException();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PrimitivePool.java

示例8: doSynchronously

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
/**
 * Execute simple process synchronously with progress
 *
 * @param handler        a handler
 * @param operationTitle an operation title shown in progress dialog
 * @param operationName  an operation name shown in failure dialog
 * @return An exit code
 */
public static int doSynchronously(final GitLineHandler handler, final String operationTitle, @NonNls final String operationName) {
  final ProgressManager manager = ProgressManager.getInstance();
  manager.run(new Task.Modal(handler.project(), operationTitle, true) {
    public void run(@NotNull final ProgressIndicator indicator) {
      handler.addLineListener(new GitLineHandlerListenerProgress(indicator, handler, operationName, true));
      runInCurrentThread(handler, indicator, true, operationTitle);
    }
  });
  if (!handler.isStarted()) {
    return -1;
  }
  return handler.getExitCode();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GitHandlerUtil.java

示例9: getInheritors

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public Collection<PsiClass> getInheritors() {
  final ProgressManager progressManager =
    ProgressManager.getInstance();
  // do not display progress
  progressManager.runProcess(this, null);
  return inheritors;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AbstractMethodWithMissingImplementationsInspection.java

示例10: isOnlyAccessedFromInnerClass

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public boolean isOnlyAccessedFromInnerClass() {
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
  final ProgressManager progressManager = ProgressManager.getInstance();
  final ProgressIndicator progressIndicator = progressManager.getProgressIndicator();
  final PsiSearchHelper.SearchCostResult searchCost =
    searchHelper.isCheapEnoughToSearch(method.getName(), method.getResolveScope(), null, progressIndicator);
  if (searchCost == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES ||
      searchCost == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES) {
    return onlyAccessedFromInnerClass;
  }
  final Query<PsiReference> query = ReferencesSearch.search(method);
  query.forEach(this);
  return onlyAccessedFromInnerClass;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MethodOnlyUsedFromInnerClassInspection.java

示例11: isCheapEnoughToSearch

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private boolean isCheapEnoughToSearch(PsiNamedElement element) {
  final String name = element.getName();
  if (name == null) {
    return false;
  }
  final ProgressManager progressManager =
    ProgressManager.getInstance();
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
  final SearchScope useScope = element.getUseScope();
  if (useScope instanceof GlobalSearchScope) {
    return searchHelper.isCheapEnoughToSearch(name, (GlobalSearchScope)useScope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:DeclareCollectionAsInterfaceInspection.java

示例12: loadBranches

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Nullable
private void loadBranches(final String selectedBranchesHolder, final Runnable runnable) {
  final ProgressManager pm = ProgressManager.getInstance();
  pm.run(new ModalityIgnorantBackgroundableTask(myProject, SvnBundle.message("compare.with.branch.progress.loading.branches")) {
    @Override
    protected void doInAwtIfFail(Exception e) {
      runnable.run();
    }

    @Override
    protected void doInAwtIfCancel() {
      runnable.run();
    }

    @Override
    protected void doInAwtIfSuccess() {
      runnable.run();
    }

    @Override
    protected void runImpl(@NotNull ProgressIndicator indicator) {
      final NewRootBunch manager = SvnBranchConfigurationManager.getInstance(myProject).getSvnBranchConfigManager();

      manager.reloadBranches(myVcsRoot, selectedBranchesHolder, InfoReliability.setByUser, false);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:SelectBranchPopup.java

示例13: execute

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public void execute(final String url) {
  Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.text"),
                           SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.title"));
  if(! applyImpl()) {
    return;
  }
  final Ref<Exception> excRef = new Ref<Exception>();
  final ProgressManager pm = ProgressManager.getInstance();
  pm.runProcessWithProgressSynchronously(new Runnable() {
    public void run() {
      final ProgressIndicator pi = pm.getProgressIndicator();
      if (pi != null) {
        pi.setText("Connecting to " + url);
      }
      try {
        SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD);
      }
      catch (SvnBindException e) {
        excRef.set(e);
      }
    }
  }, "Test connection", true, myProject);
  if (! excRef.isNull()) {
    Messages.showErrorDialog(myProject, excRef.get().getMessage(),
                             SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.error.title"));
  } else {
    Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.text"),
                             SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.title"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:SvnConfigureProxiesDialog.java

示例14: analyze

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) {
  PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, myAnnotateLocalVariablesCb.isSelected());

  final ProgressManager progressManager = ProgressManager.getInstance();
  final Set<Module> modulesWithoutAnnotations = new HashSet<Module>();
  final Set<Module> modulesWithLL = new HashSet<Module>();
  final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
  final String defaultNullable = NullableNotNullManager.getInstance(project).getDefaultNullable();
  final int[] fileCount = new int[] {0};
  if (!progressManager.runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      scope.accept(new PsiElementVisitor() {
        final private Set<Module> processed = new HashSet<Module>();

        @Override
        public void visitFile(PsiFile file) {
          fileCount[0]++;
          final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
          if (progressIndicator != null) {
            final VirtualFile virtualFile = file.getVirtualFile();
            if (virtualFile != null) {
              progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project));
            }
            progressIndicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title"));
          }
          final Module module = ModuleUtilCore.findModuleForPsiElement(file);
          if (module != null && processed.add(module)) {
            if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_5) < 0) {
              modulesWithLL.add(module);
            }
            else if (javaPsiFacade.findClass(defaultNullable, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) == null) {
              modulesWithoutAnnotations.add(module);
            }
          }
        }
      });
    }
  }, "Check Applicability...", true, project)) {
    return;
  }
  if (!modulesWithLL.isEmpty()) {
    Messages.showErrorDialog(project, "Infer Nullity Annotations requires the project language level be set to 1.5 or greater.",
                             INFER_NULLITY_ANNOTATIONS);
    return;
  }
  if (!modulesWithoutAnnotations.isEmpty()) {
    if (addAnnotationsDependency(project, modulesWithoutAnnotations, defaultNullable, INFER_NULLITY_ANNOTATIONS)) {
      restartAnalysis(project, scope);
    }
    return;
  }
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  final UsageInfo[] usageInfos = findUsages(project, scope, fileCount[0]);
  if (usageInfos == null) return;

  if (usageInfos.length < 5) {
    SwingUtilities.invokeLater(applyRunnable(project, new Computable<UsageInfo[]>() {
      @Override
      public UsageInfo[] compute() {
        return usageInfos;
      }
    }));
  }
  else {
    showUsageView(project, usageInfos, scope);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:70,代码来源:InferNullityAnnotationsAction.java

示例15: loadAndShowCommittedChangesDetails

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public void loadAndShowCommittedChangesDetails(@NotNull final Project project,
                                               @NotNull final VcsRevisionNumber revision,
                                               @NotNull final VirtualFile virtualFile,
                                               @NotNull VcsKey vcsKey,
                                               @Nullable final RepositoryLocation location,
                                               final boolean isNonLocal) {
  final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
  if (vcs == null) return;
  final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
  if (provider == null) return;
  if (isNonLocal && provider.getForNonLocal(virtualFile) == null) return;

  final String title = VcsBundle.message("paths.affected.in.revision",
                                         revision instanceof ShortVcsRevisionNumber
                                         ? ((ShortVcsRevisionNumber)revision).toShortString()
                                         : revision.asString());
  final CommittedChangeList[] list = new CommittedChangeList[1];
  final FilePath[] targetPath = new FilePath[1];
  final VcsException[] exc = new VcsException[1];
  Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      try {
        if (!isNonLocal) {
          final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
          if (pair != null) {
            list[0] = pair.getFirst();
            targetPath[0] = pair.getSecond();
          }
        }
        else {
          if (location != null) {
            final ChangeBrowserSettings settings = provider.createDefaultSettings();
            settings.USE_CHANGE_BEFORE_FILTER = true;
            settings.CHANGE_BEFORE = revision.asString();
            final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
            if (changes != null && changes.size() == 1) {
              list[0] = changes.get(0);
            }
          }
          else {
            list[0] = getRemoteList(vcs, revision, virtualFile);
          }
        }
      }
      catch (VcsException e) {
        exc[0] = e;
      }
    }

    @Override
    public void onSuccess() {
      if (exc[0] != null) {
        showError(exc[0], failedText(virtualFile, revision));
      }
      else if (list[0] == null) {
        Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
      }
      else {
        VirtualFile navigateToFile = targetPath[0] != null ?
                                     new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) :
                                     virtualFile;
        showChangesListBrowser(list[0], navigateToFile, title);
      }
    }
  };

  CoreProgressManager progressManager = (CoreProgressManager)ProgressManager.getInstance();
  progressManager.runProcessWithProgressAsynchronously(task, new EmptyProgressIndicator(), null, ModalityState.current());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:72,代码来源:AbstractVcsHelperImpl.java


注:本文中的com.intellij.openapi.progress.ProgressManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。