|
11 | 11 | package com.redhat.devtools.intellij.quarkus.run.dashboard; |
12 | 12 |
|
13 | 13 | import com.intellij.execution.RunnerAndConfigurationSettings; |
| 14 | +import com.intellij.execution.dashboard.RunDashboardCustomizationBuilder; |
14 | 15 | import com.intellij.execution.dashboard.RunDashboardCustomizer; |
15 | 16 | import com.intellij.execution.dashboard.RunDashboardRunConfigurationNode; |
16 | 17 | import com.intellij.execution.process.ProcessHandler; |
17 | 18 | import com.intellij.execution.ui.RunContentDescriptor; |
18 | 19 | import com.intellij.ide.projectView.PresentationData; |
19 | 20 | import com.intellij.openapi.module.Module; |
20 | | -import com.intellij.openapi.project.Project; |
21 | 21 | import com.intellij.ui.SimpleColoredComponent; |
22 | 22 | import com.intellij.ui.SimpleTextAttributes; |
23 | 23 | import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.project.PsiMicroProfileProject; |
@@ -47,6 +47,53 @@ public boolean isApplicable(@NotNull RunnerAndConfigurationSettings settings, @N |
47 | 47 | return settings.getConfiguration() instanceof QuarkusRunConfiguration; |
48 | 48 | } |
49 | 49 |
|
| 50 | + @Override |
| 51 | + public boolean updatePresentation(@NotNull RunDashboardCustomizationBuilder customizationBuilder, |
| 52 | + @NotNull RunnerAndConfigurationSettings settings, |
| 53 | + @Nullable RunContentDescriptor descriptor) { |
| 54 | + QuarkusRunConfiguration quarkusRunConfiguration = settings.getConfiguration() instanceof QuarkusRunConfiguration config ? config : null; |
| 55 | + if (descriptor == null || quarkusRunConfiguration == null) { |
| 56 | + return false; |
| 57 | + } |
| 58 | + ProcessHandler processHandler = descriptor.getProcessHandler(); |
| 59 | + if (processHandler != null && !processHandler.isProcessTerminated()) { |
| 60 | + // The Quarkus run configuration is running |
| 61 | + Module module = quarkusRunConfiguration.getModule(); |
| 62 | + if (QuarkusModuleUtil.isQuarkusWebAppModule(module)) { |
| 63 | + PsiMicroProfileProject mpProject = PsiMicroProfileProjectManager.getInstance(module.getProject()).getMicroProfileProject(module); |
| 64 | + |
| 65 | + // It is a Web application, add links for: |
| 66 | + // - Opening quarkus application in a browser |
| 67 | + // - Opening DevUI in a browser |
| 68 | + // Add application Url as hyperlink |
| 69 | + String applicationUrl = QuarkusModuleUtil.getApplicationUrl(mpProject); |
| 70 | + customizationBuilder.addLink(applicationUrl, new SimpleColoredComponent.BrowserLauncherTag(applicationUrl) { |
| 71 | + @Override |
| 72 | + public void run() { |
| 73 | + // Open Quarkus application in a Web Browser |
| 74 | + super.run(); |
| 75 | + // Send "ui-openApplication" telemetry event |
| 76 | + TelemetryManager.instance().send(TelemetryEventName.UI_OPEN_APPLICATION); |
| 77 | + } |
| 78 | + }); |
| 79 | + |
| 80 | + // Add DevUI Url as hyperlink |
| 81 | + String devUIUrl = QuarkusModuleUtil.getDevUIUrl(mpProject); |
| 82 | + String devUILabel = "Dev UI"; |
| 83 | + customizationBuilder.addLink(devUILabel, new SimpleColoredComponent.BrowserLauncherTag(devUIUrl) { |
| 84 | + @Override |
| 85 | + public void run() { |
| 86 | + // Open DevUI in a Web Browser |
| 87 | + super.run(); |
| 88 | + // Send "ui-openDevUI" telemetry event |
| 89 | + TelemetryManager.instance().send(TelemetryEventName.UI_OPEN_DEV_UI); |
| 90 | + } |
| 91 | + }); |
| 92 | + } |
| 93 | + } |
| 94 | + return true; |
| 95 | + } |
| 96 | + |
50 | 97 | @Override |
51 | 98 | public boolean updatePresentation(@NotNull PresentationData presentation, @NotNull RunDashboardRunConfigurationNode node) { |
52 | 99 | if (!(node.getConfigurationSettings().getConfiguration() instanceof QuarkusRunConfiguration)) { |
@@ -95,7 +142,7 @@ public void run() { |
95 | 142 | TelemetryManager.instance().send(TelemetryEventName.UI_OPEN_DEV_UI); |
96 | 143 | } |
97 | 144 | }); |
98 | | - node.putUserData(RunDashboardCustomizer.NODE_LINKS, links); |
| 145 | + //node.putUserData(RunDashboardCustomizer.NODE_LINKS, links); |
99 | 146 | } |
100 | 147 | } |
101 | 148 | } |
|
0 commit comments