use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class GitUntrackedFilesHelper method notifyUntrackedFilesOverwrittenBy.
/**
* Displays notification about {@code untracked files would be overwritten by checkout} error.
* Clicking on the link in the notification opens a simple dialog with the list of these files.
* @param root
* @param relativePaths
* @param operation the name of the Git operation that caused the error: {@code rebase, merge, checkout}.
* @param description the content of the notification or null if the default content is to be used.
*/
public static void notifyUntrackedFilesOverwrittenBy(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull Collection<String> relativePaths, @NotNull final String operation, @Nullable String description) {
final String notificationTitle = StringUtil.capitalize(operation) + " failed";
final String notificationDesc = description == null ? createUntrackedFilesOverwrittenDescription(operation, true) : description;
final Collection<String> absolutePaths = GitUtil.toAbsolute(root, relativePaths);
final List<VirtualFile> untrackedFiles = ContainerUtil.mapNotNull(absolutePaths, new Function<String, VirtualFile>() {
@Override
public VirtualFile fun(String absolutePath) {
return GitUtil.findRefreshFileOrLog(absolutePath);
}
});
VcsNotifier.getInstance(project).notifyError(notificationTitle, notificationDesc, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
final String dialogDesc = createUntrackedFilesOverwrittenDescription(operation, false);
String title = "Untracked Files Preventing " + StringUtil.capitalize(operation);
if (untrackedFiles.isEmpty()) {
GitUtil.showPathsInDialog(project, absolutePaths, title, dialogDesc);
} else {
DialogWrapper dialog;
dialog = new UntrackedFilesDialog(project, untrackedFiles, dialogDesc);
dialog.setTitle(title);
dialog.show();
}
}
}
});
}
use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.
the class ConfigurationErrorEvent method process.
@Override
public void process(@NotNull final TestEventXmlView xml) throws TestEventXmlView.XmlParserException {
final String errorTitle = xml.getEventTitle();
final String configurationErrorMsg = xml.getEventMessage();
final boolean openSettings = xml.isEventOpenSettings();
final Project project = getProject();
assert project != null;
final String message = openSettings ? String.format("<br>\n%s<br><br>\n\n<a href=\"Gradle settings\">Open gradle settings</a>", configurationErrorMsg) : String.format("<br>\n%s", configurationErrorMsg);
GradleNotification.getInstance(project).showBalloon(errorTitle, message, NotificationType.WARNING, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
notification.expire();
if ("Gradle settings".equals(event.getDescription())) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
assert manager instanceof GradleManager;
GradleManager gradleManager = (GradleManager) manager;
Configurable configurable = gradleManager.getConfigurable(project);
ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
} else {
BrowserUtil.browse(event.getDescription());
}
}
});
}
use of com.intellij.notification.NotificationListener in project android by JetBrains.
the class InstantRunNotificationTask method showIrBrokenForSecondaryUsersNotification.
private static void showIrBrokenForSecondaryUsersNotification(@NotNull Project project) {
NotificationListener l = (notification, event) -> {
if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
return;
}
String description = event.getDescription();
if ("learnmore".equals(description)) {
BrowserUtil.browse("http://developers.android.com/r/studio-ui/run-with-work-profile.html", project);
}
};
InstantRunManager.NOTIFICATION_GROUP.createNotification("", AndroidBundle.message("instant.run.notification.ir.broken.for.secondary.user"), NotificationType.INFORMATION, l).notify(project);
}
use of com.intellij.notification.NotificationListener in project android by JetBrains.
the class AndroidGradleNotification method showBalloon.
public void showBalloon(@NotNull String title, @NotNull String text, @NotNull NotificationType type, @NotNull NotificationGroup group, @NotNull NotificationHyperlink... hyperlinks) {
NotificationListener notificationListener = new CustomNotificationListener(myProject, hyperlinks);
String newText = addHyperlinksToText(text, hyperlinks);
showBalloon(title, newText, type, group, notificationListener);
}
use of com.intellij.notification.NotificationListener in project intellij-plugins by JetBrains.
the class FlexmojosImporter method doShowFlexConfigWarning.
private synchronized void doShowFlexConfigWarning(final Project project) {
final NotificationListener listener = new NotificationListener() {
public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
Messages.showWarningDialog(project, FlexBundle.message("flexmojos.warning.detailed"), FlexBundle.message("flexmojos.project.import"));
notification.expire();
}
};
myFlexConfigNotification = new Notification("Maven", FlexBundle.message("flexmojos.project.import"), FlexBundle.message("flexmojos.warning.short"), NotificationType.WARNING, listener);
myFlexConfigNotification.notify(project);
}
Aggregations