Skip to content

Commit 2a96297

Browse files
committed
Update plugin notifications
1 parent 4f90843 commit 2a96297

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

swan-assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/ExportAction.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
package de.fraunhofer.iem.swan.assist.actions;
99

10-
import com.intellij.notification.Notification;
11-
import com.intellij.notification.NotificationType;
12-
import com.intellij.notification.Notifications;
10+
import com.intellij.notification.*;
1311
import com.intellij.openapi.actionSystem.AnAction;
1412
import com.intellij.openapi.actionSystem.AnActionEvent;
1513
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -31,8 +29,11 @@
3129

3230
public class ExportAction extends AnAction {
3331

32+
private static final NotificationGroup TOOL_GROUP = new NotificationGroup(Constants.PLUGIN_GROUP_DISPLAY_ID,
33+
NotificationDisplayType.TOOL_WINDOW, true);
3434
/**
3535
* Obtains list of methods and creates new JSON file in the location specified by the user.
36+
*
3637
* @param anActionEvent source event
3738
*/
3839
@Override
@@ -71,8 +72,8 @@ public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
7172
try {
7273
exportFile.writeToJsonFile(JSONFileLoader.getMethods(), filePath);
7374

74-
Notifications.Bus.notify(
75-
new Notification(Constants.PLUGIN_GROUP_DISPLAY_ID, "", JSONFileLoader.getMethods().size()+ " methods exported to: "+filePath, NotificationType.INFORMATION));
75+
Notification analysisCompleted = TOOL_GROUP.createNotification("", JSONFileLoader.getMethods().size() + " methods exported to: " + filePath, NotificationType.INFORMATION);
76+
Notifications.Bus.notify(analysisCompleted, project);
7677

7778
} catch (IOException e) {
7879
e.printStackTrace();
@@ -82,6 +83,7 @@ public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
8283

8384
/**
8485
* Controls whether the action is enabled or disabled
86+
*
8587
* @param event source event
8688
*/
8789
@Override

swan-assist/src/main/java/de/fraunhofer/iem/swan/assist/ui/MethodListTree.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
1111
import com.intellij.ide.util.PropertiesComponent;
12-
import com.intellij.notification.Notification;
13-
import com.intellij.notification.NotificationListener;
14-
import com.intellij.notification.NotificationType;
15-
import com.intellij.notification.Notifications;
12+
import com.intellij.notification.*;
1613
import com.intellij.openapi.actionSystem.ActionManager;
1714
import com.intellij.openapi.actionSystem.ActionPopupMenu;
1815
import com.intellij.openapi.application.ApplicationManager;
@@ -74,6 +71,9 @@ public class MethodListTree extends Tree {
7471
private ResourceBundle resource;
7572
public static boolean TREE_EXPANDED;
7673

74+
private static final NotificationGroup TOOL_GROUP= new NotificationGroup(Constants.PLUGIN_GROUP_DISPLAY_ID,
75+
NotificationDisplayType.TOOL_WINDOW, true);;
76+
7777
/**
7878
* Initialises method list tree
7979
*
@@ -297,7 +297,6 @@ public void addNewExistingMethod(MethodWrapper newMethod) {
297297

298298
break;
299299
case JSONFileLoader.NEW_METHOD:
300-
301300
addNode(newMethod);
302301
break;
303302
}
@@ -378,10 +377,9 @@ public void launchSwan(HashMap<String, String> values) {
378377
public void launchSwan(HashMap<String, String> values) {
379378

380379
JSONFileLoader.setReloading(false);
381-
NotificationType notificationType = NotificationType.INFORMATION;
382380

383-
String message = "<html>"
384-
+ values.get(Constants.ANALYSIS_RESULT);
381+
Notification analysisCompleted = TOOL_GROUP.createNotification("", "SRM List updated", NotificationType.INFORMATION);
382+
Notifications.Bus.notify(analysisCompleted, project);
385383

386384
ConfigurationFileNotifier fileNotifier = bus.syncPublisher(ConfigurationFileNotifier.FILE_NOTIFIER_TOPIC);
387385
fileNotifier.loadUpdatedFile(values.get(Constants.OUTPUT_FILE));
@@ -569,7 +567,7 @@ private void loadMethods() {
569567

570568
DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(new Pair<>(classname, methodCount));
571569

572-
ArrayList<MethodWrapper> sortedList = methods.get(classname);
570+
ArrayList<MethodWrapper> sortedList = methods.get(classname);
573571
Collections.sort(sortedList);
574572
for (MethodWrapper method : sortedList) {
575573

@@ -581,7 +579,7 @@ private void loadMethods() {
581579
String pattern = "###,###";
582580
DecimalFormat decimalFormat = new DecimalFormat(pattern);
583581

584-
root.setUserObject("<html><b>SRMs</b> <font color='gray'>(" + decimalFormat.format(totalMethods) + " in "+ decimalFormat.format(methods.size())+" classes)</font></html>");
582+
root.setUserObject("<html><b>SRMs</b> <font color='gray'>(" + decimalFormat.format(totalMethods) + " in " + decimalFormat.format(methods.size()) + " classes)</font></html>");
585583

586584
treeModel.setRoot(root);
587585
TREE_EXPANDED = false;

0 commit comments

Comments
 (0)