Skip to content

Commit

Permalink
Update Notifications usages in AddSourceToProjectHelper
Browse files Browse the repository at this point in the history
Removes some "slated for removal" deprecation warnings.

PiperOrigin-RevId: 587099887
  • Loading branch information
Googler authored and copybara-github committed Dec 1, 2023
1 parent 31a3800 commit 82c1dbd
Showing 1 changed file with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@
import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverProvider;
import com.google.idea.blaze.base.targetmaps.SourceToTargetMap;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
Expand All @@ -71,10 +70,6 @@

class AddSourceToProjectHelper {

private static final NotificationGroup NOTIFICATION_GROUP =
new NotificationGroup(
"Add source to project", NotificationDisplayType.BALLOON, /* logByDefault= */ true);

static boolean autoDeriveTargets(Project project) {
return ProjectViewManager.getInstance(project)
.getProjectViewSet()
Expand Down Expand Up @@ -189,13 +184,13 @@ private static void addTargets(
}

private static void notifyFailed(Project project, String message) {
Notification notification =
NOTIFICATION_GROUP.createNotification(
Notifications.Bus.notify(
new Notification(
"AddToProject",
"Failed to add source file to project",
message,
NotificationType.WARNING,
/* listener= */ null);
notification.notify(project);
NotificationType.WARNING),
project);
}

private static void notifySuccess(
Expand All @@ -214,19 +209,22 @@ private static void notifySuccess(
targets.forEach(t -> builder.append(" ").append(t).append("\n"));
}
builder.append("<a href='open'>Open project view file</a>");
Notification notification =
NOTIFICATION_GROUP.createNotification(
"Updated project view file",
builder.toString(),
NotificationType.INFORMATION,
new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(Notification notification, HyperlinkEvent e) {
notification.expire();
OpenProjectViewAction.openLocalProjectViewFile(project);
}
});
notification.notify(project);

Notifications.Bus.notify(
new Notification(
"AddToProject",
"Updated project view file",
builder.toString(),
NotificationType.INFORMATION)
.setListener(
new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(Notification notification, HyperlinkEvent e) {
notification.expire();
OpenProjectViewAction.openLocalProjectViewFile(project);
}
}),
project);
}

/**
Expand Down

0 comments on commit 82c1dbd

Please sign in to comment.