Skip to content

Commit 8081d8d

Browse files
committed
Update SecuCheck notification with action to open SARIF file
1 parent 3d6fb24 commit 8081d8d

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.intellij.notification.*;
1313
import com.intellij.openapi.actionSystem.ActionManager;
1414
import com.intellij.openapi.actionSystem.ActionPopupMenu;
15+
import com.intellij.openapi.actionSystem.AnActionEvent;
1516
import com.intellij.openapi.application.ApplicationManager;
1617
import com.intellij.openapi.editor.Document;
1718
import com.intellij.openapi.fileEditor.*;
@@ -54,6 +55,7 @@
5455
import java.awt.event.KeyListener;
5556
import java.awt.event.MouseAdapter;
5657
import java.awt.event.MouseEvent;
58+
import java.io.File;
5759
import java.text.DecimalFormat;
5860
import java.util.*;
5961

@@ -389,8 +391,23 @@ public void launchSwan(HashMap<String, String> values) {
389391
bus.connect().subscribe(SecucheckNotifier.END_SECUCHECK_PROCESS_TOPIC, new SecucheckNotifier() {
390392
@Override
391393
public void launchSecuCheck() {
392-
String notificationContent = "SecuCheck results exported to "+PropertiesComponent.getInstance(project).getValue(Constants.OUTPUT_DIRECTORY);
393-
NotificationGroupManager.getInstance().getNotificationGroup("Process_Completed").createNotification(notificationContent, NotificationType.INFORMATION).notify(project);
394+
String notificationContent = "Taint analysis results exported successfully.";
395+
NotificationGroupManager.getInstance()
396+
.getNotificationGroup("Analysis Notification")
397+
.createNotification(notificationContent, NotificationType.INFORMATION)
398+
.addAction(new NotificationAction("Open Results") {
399+
@Override
400+
public void actionPerformed(@NotNull AnActionEvent anActionEvent, @NotNull Notification notification) {
401+
402+
File results = new File(Objects.requireNonNull(PropertiesComponent.getInstance(project).getValue(Constants.LAST_SARIF_FILE)));
403+
Optional<VirtualFile> file = FilenameIndex
404+
.getVirtualFilesByName(results.getName(),
405+
GlobalSearchScope.projectScope(project)).stream().findFirst();
406+
407+
file.ifPresent(virtualFile -> new OpenFileDescriptor(project, virtualFile).navigate(true));
408+
}
409+
})
410+
.notify(project);
394411
}
395412
});
396413

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<codeInsight.lineMarkerProvider language="JAVA"
2323
implementationClass="de.fraunhofer.iem.devassist.ui.markers.ErrorLineMarker"/>
2424
<toolWindow id="Dev-Assist" anchor="right" factoryClass="de.fraunhofer.iem.devassist.ui.SummaryToolWindow" icon="PluginIcons.DEV_ASSIST"/>
25-
<notificationGroup id="Process_Completed" displayType="TOOL_WINDOW"/>
2625
<notificationGroup id="SRM Notification" displayType="BALLOON"/>
26+
<notificationGroup id="Analysis Notification" displayType="STICKY_BALLOON"/>
2727
</extensions>
2828

2929
<actions>

0 commit comments

Comments
 (0)