Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/controllers/projectController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export class ProjectController {
if (!javaVersion) {
return;
}
const workspaceFolder = Utility.getDefaultWorkspaceFolder();
const location: Uri[] = await window.showOpenDialog({
defaultUri: workspace.rootPath ? Uri.file(workspace.rootPath) : undefined,
defaultUri: workspaceFolder && workspaceFolder.uri,
canSelectFiles: false,
canSelectFolders: true,
openLabel: "Select the location",
Expand Down
17 changes: 16 additions & 1 deletion src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as child_process from "child_process";
import * as findJavaHome from "find-java-home";
import * as fse from "fs-extra";
import * as path from "path";
import { Uri, workspace } from "vscode";
import { Uri, window, workspace, WorkspaceFolder } from "vscode";
import * as xml2js from "xml2js";

export class Utility {
Expand Down Expand Up @@ -72,6 +72,21 @@ export class Utility {
});
}

public static getDefaultWorkspaceFolder(): WorkspaceFolder | undefined {
const workspaceFolders: WorkspaceFolder[] | undefined = workspace.workspaceFolders;
if (workspaceFolders === undefined) {
return undefined;
}
if (workspaceFolders.length === 1) {
return workspaceFolders[0];
}
if (window.activeTextEditor) {
const activeWorkspaceFolder: WorkspaceFolder | undefined = workspace.getWorkspaceFolder(window.activeTextEditor.document.uri);
return activeWorkspaceFolder;
}
return undefined;
}

private static openJDKDownload(reject, cause) {
let jdkUrl = "http://developers.redhat.com/products/openjdk/overview/?from=vscode";
if (process.platform === "darwin") {
Expand Down