mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[performance plugin] IJPL-165636 Refactor existing code: split snapshot openers into separate extensions to make notiication actions list context-aware
GitOrigin-RevId: fab71c6618593d8bbe0f66b2284c973af8da8e6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2e51595d3c
commit
89c2180c33
@@ -61,6 +61,9 @@
|
||||
serviceInterface="com.intellij.internal.performanceTests.ProjectInitializationDiagnosticService"
|
||||
serviceImplementation="com.jetbrains.performancePlugin.ProjectInitializationDiagnosticServiceImpl"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="com.jetbrains">
|
||||
<performancePlugin.snapshotOpener implementation="com.jetbrains.performancePlugin.profilers.LocalFileManagerSnapshotOpener"/>
|
||||
</extensions>
|
||||
|
||||
<applicationListeners>
|
||||
<listener class="com.jetbrains.performancePlugin.ProjectLoaded$MyAppLifecycleListener" topic="com.intellij.ide.AppLifecycleListener"/>
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
+21
@@ -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)
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -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<SnapshotOpener> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user