@@ -6,9 +6,12 @@ import * as fse from 'fs-extra';
66import * as os from 'os' ;
77import * as path from 'path' ;
88import * as semver from 'semver' ;
9- import { CodeActionContext , commands , CompletionItem , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , Location , MarkdownString , QuickPickItemKind , Range , RelativePattern , SnippetString , SnippetTextEdit , TextDocument , TextEditorRevealType , UIKind , Uri , version , ViewColumn , window , workspace , WorkspaceConfiguration , WorkspaceEdit } from 'vscode' ;
9+ import { CodeActionContext , commands , CompletionItem , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions ,
10+ IndentAction , InputBoxOptions , languages , Location , MarkdownString , QuickPickItemKind , Range , RelativePattern ,
11+ SnippetString , SnippetTextEdit , TextDocument , TextEditorRevealType , UIKind , Uri , version , ViewColumn ,
12+ WebviewView , WebviewViewResolveContext , window , workspace , WorkspaceConfiguration , WorkspaceEdit } from 'vscode' ;
1013import { CancellationToken , CodeActionParams , CodeActionRequest , CodeActionResolveRequest , Command , CompletionRequest , DidChangeConfigurationNotification , ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn } from 'vscode-languageclient' ;
11- import { LanguageClient } from 'vscode-languageclient/node' ;
14+ import { Executable , LanguageClient } from 'vscode-languageclient/node' ;
1215import { apiManager } from './apiManager' ;
1316import { ClientErrorHandler } from './clientErrorHandler' ;
1417import { Commands , CommandTitle } from './commands' ;
@@ -39,6 +42,8 @@ import { BuildFileSelector, PICKED_BUILD_FILES, cleanupWorkspaceState } from './
3942import { pasteFile } from './pasteAction' ;
4043import { ServerStatusKind } from './serverStatus' ;
4144import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry/lib/node' ;
45+ import { Deferred } from './promiseUtil' ;
46+ import { getWebviewContent } from './dashboard/dashboard' ;
4247
4348const syntaxClient : SyntaxLanguageClient = new SyntaxLanguageClient ( ) ;
4449const standardClient : StandardLanguageClient = new StandardLanguageClient ( ) ;
@@ -47,6 +52,17 @@ const extensionName = 'Language Support for Java';
4752let storagePath : string ;
4853let clientLogFile : string ;
4954
55+ const excutable = new Deferred < Executable > ( ) ;
56+
57+ export async function getExecutable ( ) : Promise < Executable > {
58+ return excutable . promise ;
59+ }
60+
61+ const javaConfigDeferred = new Deferred < any > ( ) ;
62+ export async function getComputedJavaConfig ( ) : Promise < any > {
63+ return javaConfigDeferred . promise ;
64+ }
65+
5066/**
5167 * Shows a message about the server crashing due to an out of memory issue
5268 */
@@ -113,6 +129,21 @@ export function fixJdtLinksInDocumentation(oldDocumentation: MarkdownString): Ma
113129}
114130
115131export async function activate ( context : ExtensionContext ) : Promise < ExtensionAPI > {
132+ console . log ( 'registering webview provider' ) ;
133+ context . subscriptions . push ( window . registerWebviewViewProvider ( 'vscode-java-dashboard' , {
134+ resolveWebviewView : async function ( webviewView : WebviewView , webviewContext : WebviewViewResolveContext , token : CancellationToken ) : Promise < void > {
135+
136+ webviewView . webview . options = {
137+ enableScripts : true ,
138+ enableCommandUris : true ,
139+ localResourceRoots : [ context . extensionUri ]
140+ } ;
141+
142+ webviewView . webview . html = await getWebviewContent ( webviewView . webview , context . extensionUri ) ;
143+ }
144+ } ) ) ;
145+ console . log ( 'registered webview provider' ) ;
146+
116147 await loadSupportedJreNames ( context ) ;
117148 context . subscriptions . push ( commands . registerCommand ( Commands . FILESEXPLORER_ONPASTE , async ( ) => {
118149 const originalClipboard = await env . clipboard . readText ( ) ;
@@ -196,6 +227,9 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
196227 let requireStandardServer = ( serverMode !== ServerMode . lightWeight ) && ( ! isDebugModeByClientPort || ! ! process . env [ 'JDTLS_CLIENT_PORT' ] ) ;
197228 let initFailureReported : boolean = false ;
198229
230+ const javaConfig = await getJavaConfig ( requirements . java_home ) ;
231+ javaConfigDeferred . resolve ( javaConfig ) ;
232+
199233 // Options to control the language client
200234 const clientOptions : LanguageClientOptions = {
201235 // Register the server for java
@@ -210,7 +244,7 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
210244 initializationOptions : {
211245 bundles : collectJavaExtensions ( extensions . all ) ,
212246 workspaceFolders : workspace . workspaceFolders ? workspace . workspaceFolders . map ( f => f . uri . toString ( ) ) : null ,
213- settings : { java : await getJavaConfig ( requirements . java_home ) } ,
247+ settings : { java : javaConfig } ,
214248 extendedClientCapabilities : {
215249 classFileContentsSupport : true ,
216250 overrideMethodsPromptSupport : true ,
@@ -394,6 +428,7 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
394428 // no need to pass `resolve` into any code past this point,
395429 // since `resolve` is a no-op from now on
396430 const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , context , true ) ;
431+ excutable . resolve ( serverOptions ) ;
397432 if ( requireSyntaxServer ) {
398433 if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
399434 syntaxClient . initialize ( requirements , clientOptions ) ;
0 commit comments