diff --git a/vscode-wpilib/resources/webviews/gradle2020import.html b/vscode-wpilib/resources/webviews/gradle2020import.html
index 8cc60a02..2291509e 100644
--- a/vscode-wpilib/resources/webviews/gradle2020import.html
+++ b/vscode-wpilib/resources/webviews/gradle2020import.html
@@ -27,9 +27,9 @@
Welcome to WPILib 2020-2023 Project Importer
Select a gradle project.
- Base Folder. Select a base folder to place the new project into. The imported project must be placed into a new folder. Importing in place is not supported.
+ Base Folder:
Select a base folder to place the new project into. The imported project must be placed into a new folder. Importing in place is not supported.
-
+
Select a new project folder
diff --git a/vscode-wpilib/resources/webviews/projectcreator.html b/vscode-wpilib/resources/webviews/projectcreator.html
index 84758499..81b6d4df 100644
--- a/vscode-wpilib/resources/webviews/projectcreator.html
+++ b/vscode-wpilib/resources/webviews/projectcreator.html
@@ -25,9 +25,9 @@ Welcome to WPILib New Project Creator
Select a project base
- Base Folder. Select a base folder to place the new project into.
+ Base Folder:
Select a base folder to place the new project into.
-
+
Select a new project folder
diff --git a/vscode-wpilib/src/webviews/pages/gradle2020importpage.ts b/vscode-wpilib/src/webviews/pages/gradle2020importpage.ts
index ebacb8e4..bf850095 100644
--- a/vscode-wpilib/src/webviews/pages/gradle2020importpage.ts
+++ b/vscode-wpilib/src/webviews/pages/gradle2020importpage.ts
@@ -1,7 +1,7 @@
'use strict';
import { IGradle2020IPCReceive, IGradle2020IPCSend } from './gradle2020importpagetypes';
-import { validateProject, validateTeamNumber } from './sharedpages';
+import { validateProject, validateTeamNumber, validateProjectFolder } from './sharedpages';
interface IVsCodeApi {
postMessage(message: IGradle2020IPCReceive): void;
@@ -24,7 +24,8 @@ function projectSelectButtonClick() {
function importProjectButtonClick() {
const isValidTeam = validateTeamNumber();
const isValidProject = validateProject();
- if (!isValidTeam || !isValidProject) {
+ const isValidFolder = validateProjectFolder();
+ if (!isValidTeam || !isValidProject || !isValidFolder) {
return;
}
@@ -58,6 +59,7 @@ window.addEventListener('message', (event) => {
case 'newproject':
const elem = document.getElementById('projectFolder') as HTMLInputElement;
elem.value = data.data;
+ validateProjectFolder();
break;
case 'teamnumber':
const tn = document.getElementById('teamNumber') as HTMLInputElement;
@@ -80,6 +82,8 @@ window.addEventListener('load', (_: Event) => {
document.getElementById('teamNumber')!.oninput = validateTeamNumber;
// tslint:disable-next-line:no-non-null-assertion
document.getElementById('importProject')!.onclick = importProjectButtonClick;
+ // tslint:disable-next-line:no-non-null-assertion
+ document.getElementById('projectFolder')!.oninput = validateProjectFolder;
vscode.postMessage({ type: 'loaded' });
});
diff --git a/vscode-wpilib/src/webviews/pages/projectcreatorpage.ts b/vscode-wpilib/src/webviews/pages/projectcreatorpage.ts
index bbb36caa..b14afe97 100644
--- a/vscode-wpilib/src/webviews/pages/projectcreatorpage.ts
+++ b/vscode-wpilib/src/webviews/pages/projectcreatorpage.ts
@@ -1,7 +1,7 @@
'use strict';
import { IProjectIPCReceive, IProjectIPCSend, ProjectType } from './projectcreatorpagetypes';
-import { validateProject, validateTeamNumber } from './sharedpages';
+import { validateProject, validateTeamNumber, validateProjectFolder } from './sharedpages';
interface IVsCodeApi {
postMessage(message: IProjectIPCReceive): void;
@@ -74,7 +74,8 @@ function selectProjectFolder() {
function generateProject() {
const isValidTeam = validateTeamNumber();
const isValidProject = validateProject();
- if (!isValidTeam || !isValidProject) {
+ const isValidFolder = validateProjectFolder();
+ if (!isValidTeam || !isValidProject || !isValidFolder) {
return;
}
@@ -103,6 +104,7 @@ window.addEventListener('message', (event) => {
case 'newproject':
const elem = document.getElementById('projectFolder') as HTMLInputElement;
elem.value = data.data as string;
+ validateProjectFolder();
break;
case 'projecttype':
projectType = data.data as ProjectType;
@@ -148,4 +150,6 @@ window.addEventListener('load', (_: Event) => {
document.getElementById('teamNumber')!.oninput = validateTeamNumber;
// tslint:disable-next-line:no-non-null-assertion
document.getElementById('generateProject')!.onclick = generateProject;
+ // tslint:disable-next-line:no-non-null-assertion
+ document.getElementById('projectFolder')!.onchange = validateProjectFolder;
});
diff --git a/vscode-wpilib/src/webviews/pages/sharedpages.ts b/vscode-wpilib/src/webviews/pages/sharedpages.ts
index 7480161e..d5a66c41 100644
--- a/vscode-wpilib/src/webviews/pages/sharedpages.ts
+++ b/vscode-wpilib/src/webviews/pages/sharedpages.ts
@@ -1,5 +1,7 @@
'use strict';
+// import { logger } from '../../logger';
+
declare global {
// tslint:disable-next-line:interface-name no-any
interface Window { i18nTrans: (domain: string, message: string, ...args: any[]) => string; }
@@ -8,6 +10,7 @@ declare global {
export function validateProject(): boolean {
const elem = document.getElementById('projectName') as HTMLButtonElement;
const s = elem.value;
+ // logger.log('Project Name: ' + s);
const match = s.match(/\w[\w-]*$/gm);
const pdiv = document.getElementById('projectnamediv') as HTMLDivElement;
if (match === null || match.length === 0) {
@@ -23,6 +26,25 @@ export function validateProject(): boolean {
}
}
+export function validateProjectFolder(): boolean {
+ const elem = document.getElementById('projectFolder') as HTMLInputElement;
+ const s = elem.value;
+ // logger.log('Validate Project Folder: ' + s);
+ const oneDrive = s.includes('OneDrive');
+ const pdiv = document.getElementById('projectfolderdiv') as HTMLDivElement;
+ if (oneDrive === true || s.length === 0) {
+ pdiv.innerText = oneDrive === true ? window.i18nTrans('ui', 'Invalid Base Folder - Folder can\'t be in OneDrive') : window.i18nTrans('ui', 'Invalid Base Folder');
+ pdiv.classList.add('error');
+ elem.classList.add('error');
+ return false;
+ } else {
+ pdiv.innerText = window.i18nTrans('ui', 'Base Folder');
+ pdiv.classList.remove('error');
+ elem.classList.remove('error');
+ return true;
+ }
+}
+
export function validateTeamNumber(): boolean {
const elem = document.getElementById('teamNumber') as HTMLInputElement;
const s = elem.value;