本文整理汇总了Java中com.intellij.openapi.progress.ProgressManager.runProcessWithProgressSynchronously方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressManager.runProcessWithProgressSynchronously方法的具体用法?Java ProgressManager.runProcessWithProgressSynchronously怎么用?Java ProgressManager.runProcessWithProgressSynchronously使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.progress.ProgressManager
的用法示例。
在下文中一共展示了ProgressManager.runProcessWithProgressSynchronously方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 A stdout content or null if there was error (exit code != 0 or exception during start).
*/
@Nullable
public static String doSynchronously(final GitSimpleHandler handler, final String operationTitle, @NonNls final String operationName) {
handler.addListener(new GitHandlerListenerBase(handler, operationName) {
protected String getErrorText() {
String text = handler.getStderr();
if (text.length() == 0) {
text = handler.getStdout();
}
return text;
}
});
final ProgressManager manager = ProgressManager.getInstance();
manager.runProcessWithProgressSynchronously(new Runnable() {
public void run() {
runInCurrentThread(handler, manager.getProgressIndicator(), true,
operationTitle);
}
}, operationTitle, false, handler.project());
if (!handler.isStarted() || handler.getExitCode() != 0) {
return null;
}
return handler.getStdout();
}
示例2: checkRemoteFolder
import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private static boolean checkRemoteFolder(Project project,
final SvnVcs activeVcs,
final String parent,
ProgressManager progressManager) throws VcsException {
final VcsException[] exc = new VcsException[1];
final boolean[] folderEmpty = new boolean[1];
progressManager.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
try {
folderEmpty[0] = SvnUtil.remoteFolderIsEmpty(activeVcs, parent);
}
catch (VcsException e) {
exc[0] = e;
}
}
}, "Check remote folder contents", false, project);
if (exc[0] != null) {
throw exc[0];
}
return folderEmpty[0];
}
示例3: 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());
}
}
示例4: 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");
}
}
示例5: 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);
}
}
示例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;
}
示例7: 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"));
}
}
示例8: 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);
}
}
示例9: rollbackModifiedWithoutEditing
import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private static void rollbackModifiedWithoutEditing(final Project project, final LinkedHashSet<VirtualFile> modifiedWithoutEditing) {
final String operationName = StringUtil.decapitalize(UIUtil.removeMnemonic(RollbackUtil.getRollbackOperationName(project)));
String message = (modifiedWithoutEditing.size() == 1)
? VcsBundle.message("rollback.modified.without.editing.confirm.single",
operationName, modifiedWithoutEditing.iterator().next().getPresentableUrl())
: VcsBundle.message("rollback.modified.without.editing.confirm.multiple",
operationName, modifiedWithoutEditing.size());
int rc = showYesNoDialog(project, message, VcsBundle.message("changes.action.rollback.title", operationName), getQuestionIcon());
if (rc != Messages.YES) {
return;
}
final List<VcsException> exceptions = new ArrayList<VcsException>();
final ProgressManager progressManager = ProgressManager.getInstance();
final Runnable action = new Runnable() {
public void run() {
final ProgressIndicator indicator = progressManager.getProgressIndicator();
try {
ChangesUtil.processVirtualFilesByVcs(project, modifiedWithoutEditing, new ChangesUtil.PerVcsProcessor<VirtualFile>() {
public void process(final AbstractVcs vcs, final List<VirtualFile> items) {
final RollbackEnvironment rollbackEnvironment = vcs.getRollbackEnvironment();
if (rollbackEnvironment != null) {
if (indicator != null) {
indicator.setText(vcs.getDisplayName() +
": performing " + UIUtil.removeMnemonic(rollbackEnvironment.getRollbackOperationName()).toLowerCase() + "...");
indicator.setIndeterminate(false);
}
rollbackEnvironment
.rollbackModifiedWithoutCheckout(items, exceptions, new RollbackProgressModifier(items.size(), indicator));
if (indicator != null) {
indicator.setText2("");
}
}
}
});
}
catch (ProcessCanceledException e) {
// for files refresh
}
if (!exceptions.isEmpty()) {
AbstractVcsHelper.getInstance(project).showErrors(exceptions, VcsBundle.message("rollback.modified.without.checkout.error.tab",
operationName));
}
VfsUtil.markDirty(true, false, VfsUtilCore.toVirtualFileArray(modifiedWithoutEditing));
VirtualFileManager.getInstance().asyncRefresh(new Runnable() {
public void run() {
for (VirtualFile virtualFile : modifiedWithoutEditing) {
VcsDirtyScopeManager.getInstance(project).fileDirty(virtualFile);
}
}
});
}
};
progressManager.runProcessWithProgressSynchronously(action, operationName, true, project);
}
示例10: doOKAction
import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
protected void doOKAction() {
VirtualFile root = getGitRoot();
final GitLineHandler h = handler();
final AtomicBoolean conflict = new AtomicBoolean();
h.addLineListener(new GitLineHandlerAdapter() {
public void onLineAvailable(String line, Key outputType) {
if (line.contains("Merge conflict")) {
conflict.set(true);
}
}
});
GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(root);
GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(root, MERGE);
h.addLineListener(untrackedFilesDetector);
h.addLineListener(localChangesDetector);
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
try {
final Ref<GitCommandResult> result = Ref.create();
final ProgressManager progressManager = ProgressManager.getInstance();
boolean completed = progressManager.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
h.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(progressManager.getProgressIndicator(), h, "stash", false));
Git git = ServiceManager.getService(Git.class);
result.set(git.runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(h)));
}
}, GitBundle.getString("unstash.unstashing"), true, myProject);
if (!completed) return;
ServiceManager.getService(myProject, GitPlatformFacade.class).hardRefresh(root);
GitCommandResult res = result.get();
if (conflict.get()) {
boolean conflictsResolved = new UnstashConflictResolver(myProject, root, getSelectedStash()).merge();
LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved);
} else if (untrackedFilesDetector.wasMessageDetected()) {
GitUntrackedFilesHelper.notifyUntrackedFilesOverwrittenBy(myProject, root, untrackedFilesDetector.getRelativeFilePaths(),
"unstash", null);
} else if (localChangesDetector.wasMessageDetected()) {
LocalChangesWouldBeOverwrittenHelper.showErrorDialog(myProject, root, "unstash", localChangesDetector.getRelativeFilePaths());
} else if (!res.success()) {
GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine());
}
}
finally {
DvcsUtil.workingTreeChangeFinished(myProject, token);
}
super.doOKAction();
}