Skip to content

Commit a3edebd

Browse files
committed
design plugin project notification with action links
1 parent d9d3cec commit a3edebd

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/util/IdeHelper.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import com.intellij.ide.util.PsiNavigationSupport;
44
import com.intellij.notification.Notification;
5+
import com.intellij.notification.NotificationAction;
56
import com.intellij.notification.NotificationGroupManager;
67
import com.intellij.notification.NotificationType;
8+
import com.intellij.openapi.actionSystem.AnActionEvent;
79
import com.intellij.openapi.application.ex.ApplicationManagerEx;
810
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
911
import com.intellij.openapi.fileTypes.FileType;
@@ -128,18 +130,17 @@ public void run() {
128130
public static void notifyEnableMessage(final Project project) {
129131
Notification notification = NotificationGroupManager.getInstance()
130132
.getNotificationGroup("Symfony Notifications")
131-
.createNotification(
132-
"Enable Symfony Plugin <a href=\"enable\">with auto configuration now</a> or <a href=\"dismiss\">dismiss</a> further messages",
133-
NotificationType.INFORMATION
134-
);
135-
136-
notification.setTitle("Symfony");
137-
notification.setIcon(Symfony2Icons.SYMFONY);
138-
notification.setListener((notification1, event) -> {
133+
.createNotification("Detected a Symfony project structure", NotificationType.INFORMATION);
134+
135+
notification.addAction(new NotificationAction("Enable plugin") {
136+
@Override
137+
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
138+
Project project1 = e.getProject();
139+
if (project1 == null) {
140+
return;
141+
}
139142

140-
// handle html click events
141-
if("enable".equals(event.getDescription())) {
142-
Collection<String> messages = enablePluginAndConfigure(project);
143+
Collection<String> messages = enablePluginAndConfigure(project1);
143144

144145
String message = "Plugin enabled for project";
145146

@@ -152,20 +153,34 @@ public static void notifyEnableMessage(final Project project) {
152153
.getNotificationGroup("Symfony Notifications")
153154
.createNotification(message, NotificationType.INFORMATION);
154155

156+
notification2.setTitle(createNotificationTitle(project1));
155157
notification2.setIcon(Symfony2Icons.SYMFONY);
156-
notification2.notify(project);
157-
} else if("dismiss".equals(event.getDescription())) {
158+
notification2.notify(project1);
159+
}
160+
});
158161

162+
notification.addAction(new NotificationAction("Dont`t show again") {
163+
@Override
164+
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
159165
// user doesnt want to show notification again
160166
Settings.getInstance(project).dismissEnableNotification = true;
161167
}
162-
163-
notification1.expire();
164168
});
165169

170+
notification.setTitle(createNotificationTitle(project));
171+
notification.setIcon(Symfony2Icons.SYMFONY);
172+
166173
notification.notify(project);
167174
}
168175

176+
private static String createNotificationTitle(@NotNull final Project project) {
177+
String title = "Symfony Support";
178+
179+
title += " (Full Version)";
180+
181+
return title;
182+
}
183+
169184
public static Collection<String> enablePluginAndConfigure(@NotNull Project project) {
170185
Settings.getInstance(project).pluginEnabled = true;
171186

0 commit comments

Comments
 (0)