use of com.intellij.notification.NotificationListener 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);
}
}
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class StudyProjectComponent method projectOpened.
@Override
public void projectOpened() {
Course course = StudyTaskManager.getInstance(myProject).getCourse();
// Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
if (StudyUtils.hasJavaFx()) {
Platform.setImplicitExit(false);
}
if (course != null && !course.isAdaptive() && !course.isUpToDate()) {
final Notification notification = new Notification("Update.course", "Course Updates", "Course is ready to <a href=\"update\">update</a>", NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
FileEditorManagerEx.getInstanceEx(myProject).closeAllFiles();
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
return execCancelable(() -> {
updateCourse();
return true;
});
}, "Updating Course", true, myProject);
EduUtils.synchronize();
course.setUpdated();
}
});
notification.notify(myProject);
}
StudyUtils.registerStudyToolWindow(course, myProject);
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater((DumbAwareRunnable) () -> ApplicationManager.getApplication().runWriteAction((DumbAwareRunnable) () -> {
Course course1 = StudyTaskManager.getInstance(myProject).getCourse();
if (course1 != null) {
UISettings instance = UISettings.getInstance();
instance.setHideToolStripes(false);
instance.fireUISettingsChanged();
registerShortcuts();
EduUsagesCollector.projectTypeOpened(course1.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
}
})));
myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
myBusConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(myProject);
if (toolWindow != null) {
toolWindow.updateFonts(myProject);
}
}
});
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class PythonSdkType method notifyRemoteSdkSkeletonsFail.
public static void notifyRemoteSdkSkeletonsFail(final InvalidSdkException e, @Nullable final Runnable restartAction) {
NotificationListener notificationListener;
String notificationMessage;
if (e.getCause() instanceof VagrantNotStartedException) {
notificationListener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final PythonRemoteInterpreterManager manager = PythonRemoteInterpreterManager.getInstance();
if (manager != null) {
try {
VagrantNotStartedException cause = (VagrantNotStartedException) e.getCause();
manager.runVagrant(cause.getVagrantFolder(), cause.getMachineName());
} catch (ExecutionException e1) {
throw new RuntimeException(e1);
}
}
if (restartAction != null) {
restartAction.run();
}
}
};
notificationMessage = e.getMessage() + "\n<a href=\"#\">Launch vagrant and refresh skeletons</a>";
} else if (ExceptionUtil.causedBy(e, ExceptionFix.class)) {
//noinspection ThrowableResultOfMethodCallIgnored
final ExceptionFix fix = ExceptionUtil.findCause(e, ExceptionFix.class);
notificationListener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
fix.apply();
if (restartAction != null) {
restartAction.run();
}
}
};
notificationMessage = fix.getNotificationMessage(e.getMessage());
} else {
notificationListener = null;
notificationMessage = e.getMessage();
}
Notifications.Bus.notify(new Notification(SKELETONS_TOPIC, "Couldn't refresh skeletons for remote interpreter", notificationMessage, NotificationType.WARNING, notificationListener));
}
use of com.intellij.notification.NotificationListener in project android by JetBrains.
the class InstantRunNotificationTask method showNotification.
public static void showNotification(@NotNull Project project, @Nullable InstantRunContext context, @NotNull String notificationText) {
if (!InstantRunSettings.isShowNotificationsEnabled()) {
return;
}
@Language("HTML") String message = String.format("<html>%1$s<br>(<a href=\"mute\">Don't show again</a>)</html>", notificationText);
NotificationListener l = (notification, event) -> {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String description = event.getDescription();
if (description != null && description.startsWith("http")) {
BrowserUtil.browse(description, project);
} else if ("mute".equals(description)) {
InstantRunSettings.setShowStatusNotifications(false);
} else if ("configure".equals(description)) {
InstantRunConfigurable configurable = new InstantRunConfigurable();
ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
} else if ("restart".equals(description)) {
assert context != null : "Notifications that include a restart activity option need to have a valid instant run context";
RestartActivityAction.restartActivity(project, context);
} else if ("learnmore".equals(description)) {
BrowserUtil.browse("http://developer.android.com/r/studio-ui/instant-run.html", project);
} else if ("updategradle".equals(description)) {
InstantRunConfigurable.updateProjectToInstantRunTools(project, null);
}
}
};
InstantRunManager.NOTIFICATION_GROUP.createNotification("", message, NotificationType.INFORMATION, l).notify(project);
}
use of com.intellij.notification.NotificationListener in project intellij-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method suggestParallelCompilationIfNeeded.
private void suggestParallelCompilationIfNeeded(final Project project, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
if (myParallelCompilationSuggested)
return;
if (CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION)
return;
if (modulesAndBCsToCompile.size() < 2)
return;
if (!independentBCsExist(modulesAndBCsToCompile))
return;
final NotificationListener listener = new NotificationListener() {
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
notification.expire();
if ("enable".equals(event.getDescription())) {
CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION = true;
final NotificationListener listener1 = new NotificationListener() {
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
notification.expire();
ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
}
};
new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.enabled"), FlexBundle.message("see.settings.compiler"), NotificationType.INFORMATION, listener1).notify(project);
} else if ("open".equals(event.getDescription())) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
}
}
};
new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.hint.title"), FlexBundle.message("parallel.compilation.hint"), NotificationType.INFORMATION, listener).notify(project);
myParallelCompilationSuggested = true;
}
Aggregations