2
2
3
3
import com .intellij .ide .util .PsiNavigationSupport ;
4
4
import com .intellij .notification .Notification ;
5
+ import com .intellij .notification .NotificationAction ;
5
6
import com .intellij .notification .NotificationGroupManager ;
6
7
import com .intellij .notification .NotificationType ;
8
+ import com .intellij .openapi .actionSystem .AnActionEvent ;
7
9
import com .intellij .openapi .application .ex .ApplicationManagerEx ;
8
10
import com .intellij .openapi .fileEditor .OpenFileDescriptor ;
9
11
import com .intellij .openapi .fileTypes .FileType ;
@@ -128,18 +130,17 @@ public void run() {
128
130
public static void notifyEnableMessage (final Project project ) {
129
131
Notification notification = NotificationGroupManager .getInstance ()
130
132
.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
+ }
139
142
140
- // handle html click events
141
- if ("enable" .equals (event .getDescription ())) {
142
- Collection <String > messages = enablePluginAndConfigure (project );
143
+ Collection <String > messages = enablePluginAndConfigure (project1 );
143
144
144
145
String message = "Plugin enabled for project" ;
145
146
@@ -152,20 +153,34 @@ public static void notifyEnableMessage(final Project project) {
152
153
.getNotificationGroup ("Symfony Notifications" )
153
154
.createNotification (message , NotificationType .INFORMATION );
154
155
156
+ notification2 .setTitle (createNotificationTitle (project1 ));
155
157
notification2 .setIcon (Symfony2Icons .SYMFONY );
156
- notification2 .notify (project );
157
- } else if ("dismiss" .equals (event .getDescription ())) {
158
+ notification2 .notify (project1 );
159
+ }
160
+ });
158
161
162
+ notification .addAction (new NotificationAction ("Dont`t show again" ) {
163
+ @ Override
164
+ public void actionPerformed (@ NotNull AnActionEvent e , @ NotNull Notification notification ) {
159
165
// user doesnt want to show notification again
160
166
Settings .getInstance (project ).dismissEnableNotification = true ;
161
167
}
162
-
163
- notification1 .expire ();
164
168
});
165
169
170
+ notification .setTitle (createNotificationTitle (project ));
171
+ notification .setIcon (Symfony2Icons .SYMFONY );
172
+
166
173
notification .notify (project );
167
174
}
168
175
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
+
169
184
public static Collection <String > enablePluginAndConfigure (@ NotNull Project project ) {
170
185
Settings .getInstance (project ).pluginEnabled = true ;
171
186
0 commit comments