diff --git a/plugins/performanceTesting/core/resources/META-INF/plugin.xml b/plugins/performanceTesting/core/resources/META-INF/plugin.xml index f84cc521996c..37c9f5560cfd 100644 --- a/plugins/performanceTesting/core/resources/META-INF/plugin.xml +++ b/plugins/performanceTesting/core/resources/META-INF/plugin.xml @@ -61,6 +61,9 @@ serviceInterface="com.intellij.internal.performanceTests.ProjectInitializationDiagnosticService" serviceImplementation="com.jetbrains.performancePlugin.ProjectInitializationDiagnosticServiceImpl"/> + + + diff --git a/plugins/performanceTesting/core/resources/messages/PerformanceTestingBundle.properties b/plugins/performanceTesting/core/resources/messages/PerformanceTestingBundle.properties index add0a5ada225..f24d20304ae6 100644 --- a/plugins/performanceTesting/core/resources/messages/PerformanceTestingBundle.properties +++ b/plugins/performanceTesting/core/resources/messages/PerformanceTestingBundle.properties @@ -2,7 +2,7 @@ profiling.compress.snapshot.progress=Compressing snapshot profiling.capture.snapshot.success=Captured snapshot ''{0}'' is placed in user home directory. profiling.capture.snapshot.error=Failed to capture snapshot: {0} profiling.capture.snapshot.action.showInFolder=Show in {0} -profiling.capture.snapshot.action.open=Open +profiling.capture.snapshot.action.open=Open With Intellij Profiler command.goto.finish=GoTo was executed command.inspection.extension=No files with extension: diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/LocalFileManagerSnapshotOpener.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/LocalFileManagerSnapshotOpener.kt new file mode 100644 index 000000000000..8300e585f6fd --- /dev/null +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/LocalFileManagerSnapshotOpener.kt @@ -0,0 +1,21 @@ +package com.jetbrains.performancePlugin.profilers + +import com.intellij.ide.actions.RevealFileAction +import com.intellij.idea.AppMode +import com.intellij.openapi.project.Project +import com.jetbrains.performancePlugin.PerformanceTestingBundle +import java.io.File + +internal class LocalFileManagerSnapshotOpener : SnapshotOpener { + override fun canOpen(snapshot: File, project: Project?): Boolean { + return !AppMode.isRemoteDevHost() + } + + override fun getPresentableName(): String? { + return PerformanceTestingBundle.message("profiling.capture.snapshot.action.showInFolder", RevealFileAction.getFileManagerName()) + } + + override fun open(snapshot: File, project: Project?) { + RevealFileAction.openFile(snapshot) + } +} \ No newline at end of file diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/ProfilerHandlerUtils.java b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/ProfilerHandlerUtils.java index ec2a110e5863..cb7ec1aabafa 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/ProfilerHandlerUtils.java +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/ProfilerHandlerUtils.java @@ -1,6 +1,5 @@ package com.jetbrains.performancePlugin.profilers; -import com.intellij.ide.actions.RevealFileAction; import com.intellij.notification.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -15,20 +14,19 @@ public final class ProfilerHandlerUtils { private static final NotificationGroup GROUP = NotificationGroupManager.getInstance().getNotificationGroup("PerformancePlugin"); public static void notify(@Nullable Project project, File snapshot) { + var availableSnapshotProcessors = + SnapshotOpener.EP_NAME.getExtensionList().stream().filter(it -> it.canOpen(snapshot, project)).toList(); Notification notification = GROUP.createNotification(PerformanceTestingBundle.message("profiling.capture.snapshot.success", snapshot.getName()), NotificationType.INFORMATION); - notification.addAction(NotificationAction.createSimpleExpiring( - PerformanceTestingBundle.message("profiling.capture.snapshot.action.showInFolder", RevealFileAction.getFileManagerName()), - () -> RevealFileAction.openFile(snapshot) - )); - SnapshotOpener opener = SnapshotOpener.findSnapshotOpener(snapshot); - if (opener != null && project != null) { + + for (SnapshotOpener opener : availableSnapshotProcessors) { notification.addAction(NotificationAction.createSimpleExpiring( - PerformanceTestingBundle.message("profiling.capture.snapshot.action.open"), + opener.getPresentableName(), () -> opener.open(snapshot, project) )); } + notification.notify(project); } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/SnapshotOpener.java b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/SnapshotOpener.java index 5894a7e7ee7b..e222a72b2d77 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/SnapshotOpener.java +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/profilers/SnapshotOpener.java @@ -3,6 +3,7 @@ package com.jetbrains.performancePlugin.profilers; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,12 +13,14 @@ public interface SnapshotOpener { ExtensionPointName EP_NAME = new ExtensionPointName<>("com.jetbrains.performancePlugin.snapshotOpener"); @Nullable - static SnapshotOpener findSnapshotOpener(@NotNull File snapshot) { - return ContainerUtil.find(EP_NAME.getExtensionList(), p -> p.canOpen(snapshot)); + static SnapshotOpener findSnapshotOpener(@NotNull File snapshot, @Nullable Project project) { + return ContainerUtil.find(EP_NAME.getExtensionList(), p -> p.canOpen(snapshot, project)); } - boolean canOpen(@NotNull File snapshot); + boolean canOpen(@NotNull File snapshot, @Nullable Project project); - void open(@NotNull File snapshot, @NotNull Project project); + @Nls + String getPresentableName(); + void open(@NotNull File snapshot, @Nullable Project project); }