|
1 | | -import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions } from "vscode"; |
2 | | -import * as vscode from "vscode"; |
| 1 | +import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions, window, ProgressLocation, Progress } from "vscode"; |
3 | 2 | import { serverTasks } from "./serverTasks"; |
4 | 3 | import { Disposable } from "vscode-languageclient"; |
5 | 4 | import { ProgressReport } from "./protocol"; |
| 5 | +import { Commands } from "./commands"; |
| 6 | +import { getJavaConfiguration } from "./utils"; |
6 | 7 |
|
7 | 8 | const JAVA_SERVER_TASK_PRESENTER_TASK_NAME = "Java Build Status"; |
8 | 9 |
|
9 | 10 | export namespace serverTaskPresenter { |
10 | 11 | export async function presentServerTaskView() { |
11 | 12 | const execution = await getPresenterTaskExecution(); |
12 | | - const terminals = vscode.window.terminals; |
| 13 | + const terminals = window.terminals; |
13 | 14 | const presenterTerminals = terminals.filter(terminal => terminal.name.indexOf(execution.task.name) >= 0); |
14 | 15 | if (presenterTerminals.length > 0) { |
15 | 16 | presenterTerminals[0].show(); |
16 | 17 | } |
| 18 | + activationProgressNotification.hide(); |
17 | 19 | } |
18 | 20 | } |
19 | 21 |
|
@@ -57,7 +59,7 @@ async function killExistingExecutions() { |
57 | 59 | execs.forEach(exec => exec.terminate()); |
58 | 60 | await new Promise(resolve => setTimeout(resolve, 0)); |
59 | 61 |
|
60 | | - let terminals = vscode.window.terminals; |
| 62 | + let terminals = window.terminals; |
61 | 63 | terminals = terminals.filter(terminal => terminal.name.indexOf(JAVA_SERVER_TASK_PRESENTER_TASK_NAME) >= 0); |
62 | 64 | terminals.forEach(terminal => terminal.dispose()); |
63 | 65 | await new Promise(resolve => setTimeout(resolve, 0)); |
@@ -112,3 +114,48 @@ class ServerTaskTerminal implements Pseudoterminal { |
112 | 114 | serverTasks.suggestTaskEntrySize(dimensions.rows - 1); |
113 | 115 | } |
114 | 116 | } |
| 117 | + |
| 118 | +export class ActivationProgressNotification { |
| 119 | + private hideEmitter = new EventEmitter<void>(); |
| 120 | + private onHide = this.hideEmitter.event; |
| 121 | + private disposables: Disposable[] = []; |
| 122 | + private lastJobId: string; |
| 123 | + |
| 124 | + public showProgress() { |
| 125 | + const showBuildStatusEnabled = getJavaConfiguration().get("showBuildStatusOnStart.enabled"); |
| 126 | + if (typeof showBuildStatusEnabled === "string" || showBuildStatusEnabled instanceof String) { |
| 127 | + if (showBuildStatusEnabled !== "notification") { |
| 128 | + return; |
| 129 | + } |
| 130 | + } else if (!showBuildStatusEnabled) { |
| 131 | + return; |
| 132 | + } |
| 133 | + const isProgressReportEnabled: boolean = getJavaConfiguration().get("progressReports.enabled"); |
| 134 | + const title = isProgressReportEnabled ? "Opening Java Projects" : "Opening Java Projects..."; |
| 135 | + window.withProgress({ |
| 136 | + location: ProgressLocation.Notification, |
| 137 | + title, |
| 138 | + cancellable: false, |
| 139 | + }, (progress: Progress<{ message?: string; increment?: number }>) => { |
| 140 | + return new Promise<void>((resolve) => { |
| 141 | + if (isProgressReportEnabled) { |
| 142 | + progress.report({ |
| 143 | + message: `[check details](command:${Commands.SHOW_SERVER_TASK_STATUS})` |
| 144 | + }); |
| 145 | + } |
| 146 | + this.onHide(() => { |
| 147 | + for (const disposable of this.disposables) { |
| 148 | + disposable.dispose(); |
| 149 | + } |
| 150 | + return resolve(); |
| 151 | + }); |
| 152 | + }); |
| 153 | + }); |
| 154 | + } |
| 155 | + |
| 156 | + public hide() { |
| 157 | + this.hideEmitter.fire(); |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +export const activationProgressNotification = new ActivationProgressNotification(); |
0 commit comments