use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class SvnIntegrateChangesTask method indicatorOnStart.
private static void indicatorOnStart() {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setIndeterminate(true);
indicator.setText(SvnBundle.message("action.Subversion.integrate.changes.progress.integrating.text"));
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class HgMergeCommand method mergeWith.
public static void mergeWith(@NotNull final HgRepository repository, @NotNull final String branchName, @NotNull final UpdatedFiles updatedFiles, @Nullable final Runnable onSuccessHandler) {
final Project project = repository.getProject();
final VirtualFile repositoryRoot = repository.getRoot();
final HgMergeCommand hgMergeCommand = new HgMergeCommand(project, repository);
//there is no difference between branch or revision or bookmark as parameter to merge,
hgMergeCommand.setRevision(branchName);
// we need just a string
new Task.Backgroundable(project, "Merging Changes...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
HgCommandResult result = hgMergeCommand.mergeSynchronously();
if (HgErrorUtil.isAncestorMergeError(result)) {
//skip and notify
VcsNotifier.getInstance(project).notifyMinorWarning("Merging is skipped for " + repositoryRoot.getPresentableName(), "Merging with a working directory ancestor has no effect");
return;
}
new HgConflictResolver(project, updatedFiles).resolve(repositoryRoot);
if (!HgConflictResolver.hasConflicts(project, repositoryRoot) && onSuccessHandler != null) {
// for example commit changes
onSuccessHandler.run();
}
} catch (VcsException exception) {
if (exception.isWarning()) {
VcsNotifier.getInstance(project).notifyWarning("Warning during merge", exception.getMessage());
} else {
VcsNotifier.getInstance(project).notifyError("Exception during merge", exception.getMessage());
}
}
}
}.queue();
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class TaskManagerImpl method testConnection.
@Override
public boolean testConnection(final TaskRepository repository) {
TestConnectionTask task = new TestConnectionTask("Test connection") {
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Connecting to " + repository.getUrl() + "...");
indicator.setFraction(0);
indicator.setIndeterminate(true);
try {
myConnection = repository.createCancellableConnection();
if (myConnection != null) {
Future<Exception> future = ApplicationManager.getApplication().executeOnPooledThread(myConnection);
while (true) {
try {
myException = future.get(100, TimeUnit.MILLISECONDS);
return;
} catch (TimeoutException ignore) {
try {
indicator.checkCanceled();
} catch (ProcessCanceledException e) {
myException = e;
myConnection.cancel();
return;
}
} catch (Exception e) {
myException = e;
return;
}
}
} else {
try {
repository.testConnection();
} catch (Exception e) {
LOG.info(e);
myException = e;
}
}
} catch (Exception e) {
myException = e;
}
}
};
ProgressManager.getInstance().run(task);
Exception e = task.myException;
if (e == null) {
myBadRepositories.remove(repository);
Messages.showMessageDialog(myProject, "Connection is successful", "Connection", Messages.getInformationIcon());
} else if (!(e instanceof ProcessCanceledException)) {
String message = e.getMessage();
if (e instanceof UnknownHostException) {
message = "Unknown host: " + message;
}
if (message == null) {
LOG.error(e);
message = "Unknown error";
}
Messages.showErrorDialog(myProject, StringUtil.capitalize(message), "Error");
}
return e == null;
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class AssociationsEditor method expandTree.
private void expandTree(DefaultTreeModel newModel) {
final TreePath rootPath = new TreePath(newModel.getRoot());
final Object element = myBuilder.getTreeStructure().getRootElement();
myBuilder.batch(new Progressive() {
@Override
public void run(@NotNull ProgressIndicator indicator) {
myBuilder.expand(element, null);
myBuilder.expand(myBuilder.getTreeStructure().getChildElements(element), null);
}
});
myTree.setSelectionPath(rootPath);
myTree.scrollRectToVisible(new Rectangle(new Point(0, 0)));
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class MavenBeforeRunTasksProvider method executeTask.
public boolean executeTask(final DataContext context, RunConfiguration configuration, ExecutionEnvironment env, final MavenBeforeRunTask task) {
final Semaphore targetDone = new Semaphore();
final boolean[] result = new boolean[] { true };
try {
ApplicationManager.getApplication().invokeAndWait(() -> {
final Project project = CommonDataKeys.PROJECT.getData(context);
final MavenProject mavenProject = getMavenProject(task);
if (project == null || project.isDisposed() || mavenProject == null)
return;
FileDocumentManager.getInstance().saveAllDocuments();
final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles();
final MavenRunner mavenRunner = MavenRunner.getInstance(project);
targetDone.down();
new Task.Backgroundable(project, TasksBundle.message("maven.tasks.executing"), true) {
public void run(@NotNull ProgressIndicator indicator) {
try {
MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), ParametersListUtil.parse(task.getGoal()), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
result[0] = mavenRunner.runBatch(Collections.singletonList(params), null, null, TasksBundle.message("maven.tasks.executing"), indicator);
} finally {
targetDone.up();
}
}
@Override
public boolean shouldStartInBackground() {
return MavenRunner.getInstance(project).getSettings().isRunMavenInBackground();
}
@Override
public void processSentToBackground() {
MavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true);
}
}.queue();
}, ModalityState.NON_MODAL);
} catch (Exception e) {
MavenLog.LOG.error(e);
return false;
}
targetDone.waitFor();
return result[0];
}
Aggregations