|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -import { StatusBarItem, window, StatusBarAlignment, version } from "vscode"; |
| 3 | +import { StatusBarItem, window, StatusBarAlignment } from "vscode"; |
4 | 4 | import { Commands } from "./commands"; |
5 | 5 | import { Disposable } from "vscode-languageclient"; |
6 | | -import * as semver from "semver"; |
7 | | -import { ServerStatusItemFactory, StatusCommands, supportsLanguageStatus } from "./languageStatusItemFactory"; |
| 6 | +import { StatusCommands } from "./languageStatusItemFactory"; |
8 | 7 |
|
9 | 8 | class ServerStatusBarProvider implements Disposable { |
10 | 9 | private statusBarItem: StatusBarItem; |
11 | | - private languageStatusItem: any; |
12 | | - // Adopt new API for status bar item, meanwhile keep the compatibility with Theia. |
13 | | - // See: https://github.com/redhat-developer/vscode-java/issues/1982 |
14 | | - private isAdvancedStatusBarItem: boolean; |
15 | 10 |
|
16 | 11 | constructor() { |
17 | | - this.isAdvancedStatusBarItem = semver.gte(version, "1.57.0"); |
18 | | - } |
19 | | - |
20 | | - public initialize(): void { |
21 | | - if (supportsLanguageStatus()) { |
22 | | - this.languageStatusItem = ServerStatusItemFactory.create(); |
23 | | - } else { |
24 | | - if (this.isAdvancedStatusBarItem) { |
25 | | - this.statusBarItem = (window.createStatusBarItem as any)("java.serverStatus", StatusBarAlignment.Right, Number.MIN_VALUE); |
26 | | - } else { |
27 | | - this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, Number.MIN_VALUE); |
28 | | - } |
29 | | - } |
| 12 | + this.statusBarItem = window.createStatusBarItem("java.serverStatus", StatusBarAlignment.Right, Number.MIN_VALUE); |
30 | 13 | } |
31 | 14 |
|
32 | 15 | public showLightWeightStatus(): void { |
33 | | - if (supportsLanguageStatus()) { |
34 | | - ServerStatusItemFactory.showLightWeightStatus(this.languageStatusItem); |
35 | | - } else { |
36 | | - if (this.isAdvancedStatusBarItem) { |
37 | | - (this.statusBarItem as any).name = "Java Server Mode"; |
38 | | - } |
39 | | - this.statusBarItem.text = StatusIcon.lightWeight; |
40 | | - this.statusBarItem.command = StatusCommands.switchToStandardCommand; |
41 | | - this.statusBarItem.tooltip = "Java language server is running in LightWeight mode, click to switch to Standard mode"; |
42 | | - this.statusBarItem.show(); |
43 | | - } |
| 16 | + this.statusBarItem.name = "Java Server Mode"; |
| 17 | + this.statusBarItem.text = StatusIcon.lightWeight; |
| 18 | + this.statusBarItem.command = StatusCommands.switchToStandardCommand; |
| 19 | + this.statusBarItem.tooltip = "Java language server is running in LightWeight mode, click to switch to Standard mode"; |
| 20 | + this.statusBarItem.show(); |
44 | 21 | } |
45 | 22 |
|
46 | 23 | public showNotImportedStatus(): void { |
47 | | - if (supportsLanguageStatus()) { |
48 | | - ServerStatusItemFactory.showNotImportedStatus(this.languageStatusItem); |
49 | | - } else { |
50 | | - if (this.isAdvancedStatusBarItem) { |
51 | | - (this.statusBarItem as any).name = "No projects are imported"; |
52 | | - } |
53 | | - this.statusBarItem.text = StatusIcon.notImported; |
54 | | - this.statusBarItem.command = StatusCommands.startStandardServerCommand; |
55 | | - this.statusBarItem.tooltip = "No projects are imported, click to load projects"; |
56 | | - this.statusBarItem.show(); |
57 | | - } |
| 24 | + this.statusBarItem.name = "No projects are imported"; |
| 25 | + this.statusBarItem.text = StatusIcon.notImported; |
| 26 | + this.statusBarItem.command = StatusCommands.startStandardServerCommand; |
| 27 | + this.statusBarItem.tooltip = "No projects are imported, click to load projects"; |
| 28 | + this.statusBarItem.show(); |
58 | 29 | } |
59 | 30 |
|
60 | 31 | public showStandardStatus(): void { |
61 | | - if (supportsLanguageStatus()) { |
62 | | - ServerStatusItemFactory.showStandardStatus(this.languageStatusItem); |
63 | | - ServerStatusItemFactory.setBusy(this.languageStatusItem); |
64 | | - } else { |
65 | | - if (this.isAdvancedStatusBarItem) { |
66 | | - (this.statusBarItem as any).name = "Java Server Status"; |
67 | | - } |
68 | | - this.statusBarItem.text = StatusIcon.busy; |
69 | | - this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; |
70 | | - this.statusBarItem.tooltip = ""; |
71 | | - this.statusBarItem.show(); |
72 | | - } |
| 32 | + this.statusBarItem.name = "Java Server Status"; |
| 33 | + this.statusBarItem.text = StatusIcon.busy; |
| 34 | + this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; |
| 35 | + this.statusBarItem.tooltip = ""; |
| 36 | + this.statusBarItem.show(); |
73 | 37 | } |
74 | 38 |
|
75 | 39 | public setBusy(): void { |
76 | | - if (supportsLanguageStatus()) { |
77 | | - ServerStatusItemFactory.setBusy(this.languageStatusItem); |
78 | | - } else { |
79 | | - this.statusBarItem.text = StatusIcon.busy; |
80 | | - } |
| 40 | + this.statusBarItem.text = StatusIcon.busy; |
81 | 41 | } |
82 | 42 |
|
83 | 43 | public setError(): void { |
84 | | - if (supportsLanguageStatus()) { |
85 | | - ServerStatusItemFactory.setError(this.languageStatusItem); |
86 | | - } else { |
87 | | - this.statusBarItem.text = StatusIcon.error; |
88 | | - this.statusBarItem.command = Commands.OPEN_LOGS; |
89 | | - } |
| 44 | + this.statusBarItem.text = StatusIcon.error; |
| 45 | + this.statusBarItem.command = Commands.OPEN_LOGS; |
90 | 46 | } |
91 | 47 |
|
92 | 48 | public setWarning(): void { |
93 | | - if (supportsLanguageStatus()) { |
94 | | - ServerStatusItemFactory.setWarning(this.languageStatusItem); |
95 | | - } else { |
96 | | - this.statusBarItem.text = StatusIcon.warning; |
97 | | - this.statusBarItem.command = "workbench.panel.markers.view.focus"; |
98 | | - this.statusBarItem.tooltip = "Errors occurred in project configurations, click to show the PROBLEMS panel"; |
99 | | - } |
| 49 | + this.statusBarItem.text = StatusIcon.warning; |
| 50 | + this.statusBarItem.command = "workbench.panel.markers.view.focus"; |
| 51 | + this.statusBarItem.tooltip = "Errors occurred in project configurations, click to show the PROBLEMS panel"; |
100 | 52 | } |
101 | 53 |
|
102 | 54 | public setReady(): void { |
103 | | - if (supportsLanguageStatus()) { |
104 | | - ServerStatusItemFactory.setReady(this.languageStatusItem); |
105 | | - } else { |
106 | | - this.statusBarItem.text = StatusIcon.ready; |
107 | | - this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; |
108 | | - this.statusBarItem.tooltip = "ServiceReady"; |
109 | | - } |
| 55 | + this.statusBarItem.text = StatusIcon.ready; |
| 56 | + this.statusBarItem.command = Commands.SHOW_SERVER_TASK_STATUS; |
| 57 | + this.statusBarItem.tooltip = "ServiceReady"; |
110 | 58 | } |
111 | 59 |
|
112 | 60 | public updateTooltip(tooltip: string): void { |
113 | | - if (!supportsLanguageStatus()) { |
114 | | - this.statusBarItem.tooltip = tooltip; |
115 | | - } |
| 61 | + this.statusBarItem.tooltip = tooltip; |
116 | 62 | } |
117 | 63 |
|
118 | 64 | public dispose(): void { |
119 | 65 | this.statusBarItem?.dispose(); |
120 | | - this.languageStatusItem?.dispose(); |
121 | 66 | } |
122 | 67 | } |
123 | 68 |
|
|
0 commit comments