Skip to content

Commit da5ff14

Browse files
authored
New view of configure java runtime (#493)
* New view of Configure Java Runtime Signed-off-by: Yan Zhang <[email protected]> * remove large empty spaces Signed-off-by: Yan Zhang <[email protected]> * subscribe onDidClasspathUpdate to update source level on the fly Signed-off-by: Yan Zhang <[email protected]> * exclude default project when listing source level entries Signed-off-by: Yan Zhang <[email protected]> * Fix: jump to correct tab when JAVA_HOME points to a JDK < 11 Signed-off-by: Yan Zhang <[email protected]> * Fix: current JDK was not selected on Setup LS tab Signed-off-by: Yan Zhang <[email protected]> * Fix: improve UX of Project JDK configuration when no M/G projects detected Signed-off-by: Yan Zhang <[email protected]> * Fix: runtime.name must be unique to avoid unexpected behavior Signed-off-by: Yan Zhang <[email protected]> * Fix: unrecongized maven/gradle projects Signed-off-by: Yan Zhang <[email protected]> * Fix: wrong selected entry in combobox when java.home points to JDK 8 Signed-off-by: Yan Zhang <[email protected]> * show spinner while loading the jdks Signed-off-by: Yan Zhang <[email protected]> * Add workspace overview in Project JDKs tab Signed-off-by: Yan Zhang <[email protected]> * prevent losing focus after picking correct LS JDK Signed-off-by: Yan Zhang <[email protected]> * add shortcut: navigate to build scripts Signed-off-by: Yan Zhang <[email protected]> * fetch project metadata from Project Manager if possible Signed-off-by: Yan Zhang <[email protected]> * refine wording Signed-off-by: Yan Zhang <[email protected]> * address styling comments Signed-off-by: Yan Zhang <[email protected]>
1 parent b59e749 commit da5ff14

25 files changed

+1544
-475
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ out/
6262
.DS_Store
6363

6464
.vscode-test
65+
66+
*.vsix

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
6+
"version": "0.2.0",
77
"configurations": [
88
{
99
"name": "Extension",

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ webpack.config.ext.js
1313
webpack.config.js
1414
out/**/*.map
1515
out/assets/**/*.js
16+
*.vsix

package-lock.json

Lines changed: 166 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"@types/request-promise-native": "^1.0.17",
112112
"@types/semver": "^5.5.0",
113113
"@types/vscode": "1.32.0",
114+
"@types/winreg": "^1.2.30",
114115
"arch": "^2.1.2",
115116
"autoprefixer": "^8.5.1",
116117
"bootstrap": "^4.5.2",
@@ -148,7 +149,11 @@
148149
"VisualStudioExptTeam.vscodeintellicode"
149150
],
150151
"dependencies": {
152+
"@types/fs-extra": "^9.0.1",
153+
"expand-home-dir": "0.0.3",
154+
"fs-extra": "^9.0.1",
151155
"semver": "^5.7.1",
152-
"vscode-extension-telemetry-wrapper": "^0.9.0"
156+
"vscode-extension-telemetry-wrapper": "^0.9.0",
157+
"winreg-utf8": "^0.1.1"
153158
}
154159
}

src/assets/vscode.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ $card-bg: var(--vscode-sideBar-background);
3535
$card-color: var(--vscode-sideBarTitle-foreground);
3636
$card-border-color: var(--vscode-sideBar-border);
3737

38+
$input-group-addon-bg: var(--vscode-sideBar-background);
39+
$input-group-addon-color: var(--vscode-sideBarTitle-foreground);
40+
41+
$code-color: var(--vscode-textPreformat-foreground);
42+
43+
$input-color:var(--vscode-sideBarTitle-foreground);
44+
$input-bg:var(--vscode-sideBar-background);
3845
@import "~bootstrap/scss/bootstrap";
46+

src/java-runtime/assets/index.html

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,33 @@
1111
<div class="container mt-5 mb-5">
1212
<div class="row mb-3">
1313
<div class="col">
14-
<h1>Java Development Kit</h1>
14+
<h1>Configure Java Runtime</h1>
1515
</div>
1616
</div>
17-
<div class="row" id="jdkAcquisitionPanel">
17+
18+
<!-- Configure JDKs -->
19+
<div class="row mb-3">
20+
<div class="col">
21+
<div class="card">
22+
<div class="card-body" id="jdkConfigurationPanel"></div>
23+
</div>
24+
</div>
25+
</div>
26+
27+
<!-- Install A JDK -->
28+
<div class="row mb-3">
29+
<div class="col">
30+
<div class="card">
31+
<div class="card-body">
32+
<div class="row mb-3">
33+
<div class="col">
34+
<h3 class="font-weight-light">Install A JDK</h3>
35+
<div class="row" id="jdkInstallationPanel"></div>
36+
</div>
37+
</div>
38+
</div>
39+
</div>
40+
</div>
1841
</div>
1942
</div>
2043
</body>

src/java-runtime/assets/index.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import "../../assets/vscode.scss";
54
import "bootstrap/js/src/tab";
6-
import bytes = require("bytes");
7-
import * as ReactDOM from "react-dom";
8-
import { JavaRuntimeEntry, JdkData } from "../types";
9-
import { JdkAcquisitionPanel, JdkAcquisitionPanelProps } from "./jdk.acquisition";
5+
import * as $ from "jquery";
106
import * as React from "react";
7+
import * as ReactDOM from "react-dom";
8+
import "../../assets/vscode.scss";
9+
import { JavaRuntimeEntry, JdkData, ProjectRuntimeEntry } from "../types";
10+
import { JdkConfigurationPanel } from "./jdk.configure";
11+
import { JdkInstallationPanel } from "./jdk.installation";
12+
import { requestJdkInfo } from "./vscode.api";
13+
import bytes = require("bytes");
1114

1215
window.addEventListener("message", event => {
1316
if (event.data.command === "applyJdkInfo") {
1417
applyJdkInfo(event.data.jdkInfo);
1518
} else if (event.data.command === "showJavaRuntimeEntries") {
16-
showJavaRuntimeEntries(event.data.entries);
19+
showJavaRuntimeEntries(event.data.args);
1720
}
1821
});
1922

20-
let jdkEntries: JavaRuntimeEntry[];
21-
22-
function showJavaRuntimeEntries(entries: JavaRuntimeEntry[]) {
23-
jdkEntries = entries;
23+
let jdkEntries: JavaRuntimeEntry[] | undefined;
24+
let projectRuntimes: ProjectRuntimeEntry[] | undefined;
25+
let javaHomeError: any;
26+
let javaDotHome: string | undefined;
27+
function showJavaRuntimeEntries(args: {
28+
javaRuntimes?: JavaRuntimeEntry[];
29+
projectRuntimes?: ProjectRuntimeEntry[];
30+
javaHomeError?: string;
31+
javaDotHome?: string;
32+
}) {
33+
jdkEntries = args.javaRuntimes;
34+
projectRuntimes = args.projectRuntimes;
35+
javaHomeError = args.javaHomeError;
36+
javaDotHome = args.javaDotHome;
2437
render();
2538
}
2639

@@ -35,32 +48,31 @@ function applyJdkInfo(jdkInfo: any) {
3548
name: jdkInfo.release_name,
3649
os: binary.os,
3750
arch: binary.architecture,
38-
size: bytes(binary.binary_size, {unitSeparator: " "}),
51+
size: bytes(binary.binary_size, { unitSeparator: " " }),
3952
downloadLink: encodedLink
4053
};
4154

4255
render();
4356
}
4457

4558
function render() {
46-
const props: JdkAcquisitionPanelProps = {
59+
const props = {
4760
jdkEntries: jdkEntries,
61+
projectRuntimes: projectRuntimes,
4862
jdkData: jdkData,
49-
onRequestJdk: requestJdkInfo
63+
onRequestJdk: requestJdkInfo,
64+
javaHomeError,
65+
javaDotHome
5066
};
5167

52-
ReactDOM.render(React.createElement(JdkAcquisitionPanel, props), document.getElementById("jdkAcquisitionPanel"));
68+
ReactDOM.render(React.createElement(JdkConfigurationPanel, props), document.getElementById("jdkConfigurationPanel"));
69+
ReactDOM.render(React.createElement(JdkInstallationPanel, props), document.getElementById("jdkInstallationPanel"));
70+
71+
$("a.navigation").click(e => {
72+
($($(e.target).attr("href") || "") as any).tab("show");
73+
});
74+
5375
}
5476

5577
render();
5678

57-
declare function acquireVsCodeApi(): any;
58-
const vscode = acquireVsCodeApi();
59-
60-
function requestJdkInfo(jdkVersion: string, jvmImpl: string) {
61-
vscode.postMessage({
62-
command: "requestJdkInfo",
63-
jdkVersion: jdkVersion,
64-
jvmImpl: jvmImpl
65-
});
66-
}

src/java-runtime/assets/jdk.acquisition.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import * as _ from "lodash";
5+
import * as React from "react";
6+
import { JavaRuntimeEntry } from "../types";
7+
8+
export interface InstalledJDKPanelProps {
9+
jdkEntries?: JavaRuntimeEntry[];
10+
}
11+
12+
export const InstalledJDKPanel = (props: InstalledJDKPanelProps) => {
13+
return (
14+
<div className="col">
15+
<div className="row">
16+
<div className="col">
17+
<h3 className="font-weight-light">Detected JDKs</h3>
18+
<p>
19+
JDKs installed on this machine are listed below:
20+
</p>
21+
<JDKTablePanel jdkEntries={props.jdkEntries} />
22+
</div>
23+
</div>
24+
</div>
25+
);
26+
};
27+
28+
29+
const JDKTablePanel = (props: InstalledJDKPanelProps) => {
30+
const isLoading = _.isEmpty(props && props.jdkEntries);
31+
32+
if (isLoading) {
33+
return (<div className="spinner-border spinner-border-sm" role="status">
34+
<span className="sr-only">Loading...</span>
35+
</div>);
36+
}
37+
38+
const entryData = (props && props.jdkEntries) || [];
39+
const entries = entryData.map((entry, index) => {
40+
return (
41+
<tr key={index}>
42+
<th scope="row">{index + 1}</th>
43+
<td>
44+
{entry.fspath}
45+
</td>
46+
<td>
47+
{entry.majorVersion}
48+
</td>
49+
</tr>
50+
);
51+
});
52+
53+
return (
54+
<div className="table-responsive">
55+
<table className="table table-borderless table-hover table-sm mb-0">
56+
<thead>
57+
<tr>
58+
<th scope="col">#</th>
59+
<th scope="col">Path</th>
60+
<th scope="col">Version</th>
61+
</tr>
62+
</thead>
63+
<tbody>
64+
{entries}
65+
</tbody>
66+
</table>
67+
</div>
68+
);
69+
};

0 commit comments

Comments
 (0)