Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 47 additions & 40 deletions src/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,11 @@ class DashboardPanel {
}));
this.setWebviewMessageListener();
this.webView.html = this.getWebviewContent();
this.disposables.push(vscode.commands.registerCommand('java.dashboard.refresh', async () => {
this.refreshLSInfo();
}));


this.disposables.push(vscode.commands.registerCommand('java.dashboard.revealFileInOS', async (arg: { path: string }) => {
await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.file(arg.path));
}));

this.disposables.push(vscode.commands.registerCommand('java.dashboard.dumpState', async () => {
const doc = await vscode.workspace.openTextDocument({
language: 'json',
content: JSON.stringify(currentState, null, 2)
});
vscode.window.showTextDocument(doc);
}));
}

private postMessage(message: UpdateMessage) {
Expand Down Expand Up @@ -134,7 +124,7 @@ class DashboardPanel {
`;
}

private async refreshLSInfo(): Promise<void> {
public async refreshLSInfo(): Promise<void> {
if (!this.webView) {
return;
}
Expand All @@ -154,32 +144,49 @@ class DashboardPanel {
}

export namespace Dashboard {
export function initialize(context: vscode.ExtensionContext): void {
console.log('registering dashboard webview provider');
let dashboardPanel: DashboardPanel;
let webviewPanel: vscode.WebviewPanel;

context.subscriptions.push(vscode.commands.registerCommand(Commands.OPEN_JAVA_DASHBOARD, async () => {
if (!dashboardPanel) {
webviewPanel = vscode.window.createWebviewPanel('java.dashboard', 'Java Dashboard', vscode.ViewColumn.Active, {
enableScripts: true,
enableCommandUris: true,
retainContextWhenHidden: true,
localResourceRoots: [context.extensionUri],
});
webviewPanel.iconPath = Uri.file(path.join(context.extensionPath, 'icons', 'icon128.png'));
dashboardPanel = new DashboardPanel(webviewPanel.webview, context);

webviewPanel.onDidDispose(() => {
dashboardPanel.dispose();
dashboardPanel = undefined;
webviewPanel = undefined;
vscode.commands.executeCommand('setContext', 'java:dashboard', false);
}, undefined, context.subscriptions);
} else {
webviewPanel.reveal();
}
}));
console.log('registered dashboard webview provider');
}
export function initialize(context: vscode.ExtensionContext): void {
console.log('registering dashboard webview provider');

let dashboardPanel: DashboardPanel | undefined = undefined;
let webviewPanel: vscode.WebviewPanel | undefined = undefined;

context.subscriptions.push(vscode.commands.registerCommand('java.dashboard.refresh', async () => {
await vscode.commands.executeCommand(Commands.OPEN_JAVA_DASHBOARD);
if (dashboardPanel) {
await dashboardPanel.refreshLSInfo();
}
}));

context.subscriptions.push(vscode.commands.registerCommand('java.dashboard.dumpState', async () => {
const doc = await vscode.workspace.openTextDocument({
language: 'json',
content: JSON.stringify(currentState, null, 2)
});
vscode.window.showTextDocument(doc);
}));

context.subscriptions.push(vscode.commands.registerCommand(Commands.OPEN_JAVA_DASHBOARD, async () => {
if (!dashboardPanel || !webviewPanel) {
webviewPanel = vscode.window.createWebviewPanel('java.dashboard', 'Java Dashboard', vscode.ViewColumn.Active, {
enableScripts: true,
enableCommandUris: true,
retainContextWhenHidden: true,
localResourceRoots: [context.extensionUri],
});

webviewPanel.iconPath = Uri.file(path.join(context.extensionPath, 'icons', 'icon128.png'));
dashboardPanel = new DashboardPanel(webviewPanel.webview, context);

webviewPanel.onDidDispose(() => {
dashboardPanel?.dispose();
dashboardPanel = undefined;
webviewPanel = undefined;
vscode.commands.executeCommand('setContext', 'java:dashboard', false);
}, undefined, context.subscriptions);
} else {
webviewPanel.reveal();
}
}));
console.log('registered dashboard webview provider');
}
}
4 changes: 3 additions & 1 deletion test/lightweight-mode-suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ suite('Java Language Extension - LightWeight', () => {

suiteSetup(async function() {
getJavaConfiguration().update('server.launchMode', 'LightWeight');
await extensions.getExtension('redhat.java').activate();
await extensions.getExtension('redhat.java')!.activate();
});

test('should register syntax-only java commands', () => {
Expand All @@ -30,6 +30,8 @@ suite('Java Language Extension - LightWeight', () => {
Commands.FILESEXPLORER_ONPASTE,
Commands.CHANGE_JAVA_SEARCH_SCOPE,
Commands.OPEN_JAVA_DASHBOARD,
'java.dashboard.dumpState',
'java.dashboard.refresh',
Commands.ADD_JAVA_RUNTIME
].sort();
const foundJavaCommands = commands.filter((value) => {
Expand Down
Loading