use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class MavenProjectsProcessor method doProcessPendingTasks.
private void doProcessPendingTasks(MavenProgressIndicator indicator, MavenProjectsProcessorTask task) throws MavenProcessCanceledException {
int counter = 0;
try {
while (true) {
indicator.checkCanceled();
counter++;
int remained;
synchronized (myQueue) {
remained = myQueue.size();
}
indicator.setFraction(counter / (double) (counter + remained));
try {
final MavenGeneralSettings mavenGeneralSettings = MavenProjectsManager.getInstance(myProject).getGeneralSettings();
task.perform(myProject, myEmbeddersManager, new SoutMavenConsole(mavenGeneralSettings.getOutputLevel(), mavenGeneralSettings.isPrintErrorStackTraces()), indicator);
} catch (MavenProcessCanceledException e) {
throw e;
} catch (Throwable e) {
MavenLog.LOG.error(e);
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Unable to import maven project", "See logs for details", NotificationType.ERROR).notify(myProject);
}
synchronized (myQueue) {
task = myQueue.poll();
if (task == null) {
isProcessing = false;
return;
}
}
}
} catch (MavenProcessCanceledException e) {
synchronized (myQueue) {
myQueue.clear();
isProcessing = false;
}
throw e;
}
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class MavenShowEffectivePom method actionPerformed.
public static void actionPerformed(@NotNull final Project project, @NotNull final VirtualFile file) {
final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
final MavenProject mavenProject = manager.findProject(file);
assert mavenProject != null;
manager.evaluateEffectivePom(mavenProject, s -> ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
if (s == null) {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Error", "Failed to evaluate effective pom.", NotificationType.ERROR).notify(project);
return;
}
String fileName = mavenProject.getMavenId().getArtifactId() + "-effective-pom.xml";
PsiFile file1 = PsiFileFactory.getInstance(project).createFileFromText(fileName, XMLLanguage.INSTANCE, s);
try {
file1.getVirtualFile().setWritable(false);
} catch (IOException e) {
LOG.error(e);
}
file1.navigate(true);
}));
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class MavenUtil method showError.
public static void showError(Project project, String title, Throwable e) {
MavenLog.LOG.warn(title, e);
Notifications.Bus.notify(new Notification(MAVEN_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR), project);
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class GithubTest method checkNotification.
protected void checkNotification(@NotNull NotificationType type, @Nullable String title, @Nullable String content) {
Notification actualNotification = myVcsNotifier.getLastNotification();
assertNotNull("No notification was shown", actualNotification);
if (title != null) {
assertEquals("Notification has wrong title (content: " + actualNotification.getContent() + ")", title, actualNotification.getTitle());
}
if (content != null) {
assertEquals("Notification has wrong content", content, actualNotification.getContent());
}
assertEquals("Notification has wrong type", type, actualNotification.getType());
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class HgVcs method checkVersion.
/**
* Checks Hg version and updates the myVersion variable.
* In the case of nullable or unsupported version reports the problem.
*/
public void checkVersion() {
final String executable = getGlobalSettings().getHgExecutable();
VcsNotifier vcsNotifier = VcsNotifier.getInstance(myProject);
final String SETTINGS_LINK = "settings";
final String UPDATE_LINK = "update";
NotificationListener linkAdapter = new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
if (SETTINGS_LINK.equals(e.getDescription())) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, getConfigurable().getDisplayName());
} else if (UPDATE_LINK.equals(e.getDescription())) {
BrowserUtil.browse("http://mercurial.selenic.com");
}
}
};
try {
myVersion = HgVersion.identifyVersion(executable);
//if version is not supported, but have valid hg executable
if (!myVersion.isSupported()) {
LOG.info("Unsupported Hg version: " + myVersion);
String message = String.format("The <a href='" + SETTINGS_LINK + "'>configured</a> version of Hg is not supported: %s.<br/> " + "The minimal supported version is %s. Please <a href='" + UPDATE_LINK + "'>update</a>.", myVersion, HgVersion.MIN);
vcsNotifier.notifyError("Unsupported Hg version", message, linkAdapter);
} else if (myVersion.hasUnsupportedExtensions()) {
String unsupportedExtensionsAsString = myVersion.getUnsupportedExtensions().toString();
LOG.warn("Unsupported Hg extensions: " + unsupportedExtensionsAsString);
String message = String.format("Some hg extensions %s are not found or not supported by your hg version and will be ignored.\n" + "Please, update your hgrc or Mercurial.ini file", unsupportedExtensionsAsString);
vcsNotifier.notifyWarning("Unsupported Hg version", message);
}
} catch (Exception e) {
if (getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
//sometimes not hg application has version command, but we couldn't parse an answer as valid hg,
// so parse(output) throw ParseException, but hg and git executable seems to be valid in this case
final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
String message = HgVcsMessages.message("hg4idea.unable.to.run.hg", executable);
vcsNotifier.notifyError(message, reason + "<br/> Please check your hg executable path in <a href='" + SETTINGS_LINK + "'> settings </a>", linkAdapter);
}
}
}
Aggregations