Skip to content

Commit 8e2790f

Browse files
committed
migrate project notification
1 parent d758d32 commit 8e2790f

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.intellij.ide.util.PsiNavigationSupport;
44
import com.intellij.notification.Notification;
5+
import com.intellij.notification.NotificationGroupManager;
56
import com.intellij.notification.NotificationType;
6-
import com.intellij.notification.Notifications;
77
import com.intellij.openapi.application.ex.ApplicationManagerEx;
88
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
99
import com.intellij.openapi.fileTypes.FileType;
@@ -16,15 +16,17 @@
1616
import com.intellij.psi.codeStyle.CodeStyleManager;
1717
import com.intellij.util.ui.UIUtil;
1818
import fr.adrienbrault.idea.symfony2plugin.Settings;
19-
import fr.adrienbrault.idea.symfony2plugin.SettingsForm;
19+
import fr.adrienbrault.idea.symfony2plugin.Symfony2Icons;
2020
import org.apache.commons.lang.StringUtils;
2121
import org.jetbrains.annotations.NotNull;
2222
import org.jetbrains.annotations.Nullable;
2323

2424
import java.awt.*;
2525
import java.io.IOException;
2626
import java.net.URISyntaxException;
27-
import java.util.*;
27+
import java.util.ArrayList;
28+
import java.util.Arrays;
29+
import java.util.Collection;
2830
import java.util.List;
2931
import java.util.stream.Collectors;
3032

@@ -124,25 +126,34 @@ public void run() {
124126
}
125127

126128
public static void notifyEnableMessage(final Project project) {
129+
Notification notification = NotificationGroupManager.getInstance()
130+
.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+
);
127135

128-
Notification notification = new Notification("Symfony Support", "Symfony", "Enable the Symfony Plugin <a href=\"enable\">with auto configuration now</a>, open <a href=\"config\">Project Settings</a> or <a href=\"dismiss\">dismiss</a> further messages", NotificationType.INFORMATION, (notification1, event) -> {
136+
notification.setTitle("Symfony");
137+
notification.setIcon(Symfony2Icons.SYMFONY);
138+
notification.setListener((notification1, event) -> {
129139

130140
// handle html click events
131-
if("config".equals(event.getDescription())) {
132-
133-
// open settings dialog and show panel
134-
SettingsForm.show(project);
135-
} else if("enable".equals(event.getDescription())) {
141+
if("enable".equals(event.getDescription())) {
136142
Collection<String> messages = enablePluginAndConfigure(project);
137143

138-
String message = "Plugin enabled";
144+
String message = "Plugin enabled for project";
139145

140146
if (!messages.isEmpty()) {
141147
List<String> collect = messages.stream().map(s -> "<br> - " + s).collect(Collectors.toList());
142148
message += StringUtils.join(collect, "");
143149
}
144150

145-
Notifications.Bus.notify(new Notification("Symfony Support", "Symfony", message, NotificationType.INFORMATION), project);
151+
Notification notification2 = NotificationGroupManager.getInstance()
152+
.getNotificationGroup("Symfony Notifications")
153+
.createNotification(message, NotificationType.INFORMATION);
154+
155+
notification2.setIcon(Symfony2Icons.SYMFONY);
156+
notification2.notify(project);
146157
} else if("dismiss".equals(event.getDescription())) {
147158

148159
// user doesnt want to show notification again
@@ -152,7 +163,7 @@ public static void notifyEnableMessage(final Project project) {
152163
notification1.expire();
153164
});
154165

155-
Notifications.Bus.notify(notification, project);
166+
notification.notify(project);
156167
}
157168

158169
public static Collection<String> enablePluginAndConfigure(@NotNull Project project) {

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
<projectService
257257
serviceImplementation="fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent$ProjectCloseService"/>
258258

259+
<notificationGroup id="Symfony Notifications" displayType="STICKY_BALLOON"/>
259260

260261
<localInspection groupPath="Symfony" shortName="PhpRouteMissingInspection" displayName="Route Missing"
261262
groupName="Route"

0 commit comments

Comments
 (0)