Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to importer to import XRP project #723

Merged
merged 1 commit into from
Nov 18, 2024
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
7 changes: 7 additions & 0 deletions vscode-wpilib/resources/webviews/gradle2020import.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ <h1>Welcome to WPILib 2020-2024 Project Importer</h1>
Check this if the project being imported is a romi project. This is not autodetected, and must be selected manually.
</div>
<br/>
<div id="xrpdiv">
<b>Import XRP Project</b>
<input id="xrpCB" type="checkbox" />
<br/>
Check this if the project being imported is an XRP project. This is not autodetected, and must be selected manually.
</div>
<br/>
<button id="importProject">Import Project</button>

</body>
Expand Down
4 changes: 2 additions & 2 deletions vscode-wpilib/src/webviews/gradle2020import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ export class Gradle2020Import extends WebViewBase {

let success = false;
if (cpp) {
const gradlePath = path.join(gradleBasePath, data.romi ? 'cppromi' : 'cpp');
const gradlePath = path.join(gradleBasePath, data.romi ? 'cppromi' : data.xrp ? 'cppxrp': 'cpp');
success = await generateCopyCpp(path.join(resourceRoot, 'cpp'), path.join(oldProjectPath, 'src'), undefined, gradlePath, toFolder,
true, []);
} else {
const gradlePath = path.join(gradleBasePath, data.romi ? 'javaromi' : 'java');
const gradlePath = path.join(gradleBasePath, data.romi ? 'javaromi' : data.xrp ? 'javaxrp' : 'java');
success = await generateCopyJava(path.join(resourceRoot, 'java'), path.join(oldProjectPath, 'src'), undefined, gradlePath, toFolder,
javaRobotPackage, '', true, []);
}
Expand Down
8 changes: 6 additions & 2 deletions vscode-wpilib/src/webviews/pages/gradle2020importpage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { IGradle2020IPCReceive, IGradle2020IPCSend } from './gradle2020importpagetypes';
import { validateProject, validateTeamNumber, validateProjectFolder } from './sharedpages';
import { validateProject, validateTeamNumber, validateProjectFolder, validateXrpRomi } from './sharedpages';

interface IVsCodeApi {
postMessage(message: IGradle2020IPCReceive): void;
Expand All @@ -25,7 +25,8 @@ function importProjectButtonClick() {
const isValidTeam = validateTeamNumber();
const isValidProject = validateProject();
const isValidFolder = validateProjectFolder();
if (!isValidTeam || !isValidProject || !isValidFolder) {
const isXrpRomiValid = validateXrpRomi();
if (!isValidTeam || !isValidProject || !isValidFolder || !isXrpRomiValid) {
return;
}

Expand All @@ -34,6 +35,7 @@ function importProjectButtonClick() {
data: {
desktop: (document.getElementById('desktopCB') as HTMLInputElement).checked,
romi: (document.getElementById('romiCB') as HTMLInputElement).checked,
xrp: (document.getElementById('xrpCB') as HTMLInputElement).checked,
fromProps: (document.getElementById('gradle2020Input') as HTMLInputElement).value,
newFolder: (document.getElementById('newFolderCB') as HTMLInputElement).checked,
projectName: (document.getElementById('projectName') as HTMLInputElement).value,
Expand Down Expand Up @@ -78,6 +80,8 @@ window.addEventListener('load', (_: Event) => {
document.getElementById('teamNumber')!.oninput = validateTeamNumber;
document.getElementById('importProject')!.onclick = importProjectButtonClick;
document.getElementById('projectFolder')!.oninput = validateProjectFolder;
document.getElementById('romiCB')!.onchange = validateXrpRomi;
document.getElementById('xrpCB')!.onchange = validateXrpRomi;

vscode.postMessage({ type: 'loaded' });
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export interface IGradle2020IPCData {
desktop: boolean;
romi: boolean;
xrp: boolean;
fromProps: string;
toFolder: string;
projectName: string;
Expand Down
19 changes: 19 additions & 0 deletions vscode-wpilib/src/webviews/pages/sharedpages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ export function validateProjectFolder(): boolean {
}
}

export function validateXrpRomi(): boolean {
const romiCB = document.getElementById('romiCB') as HTMLInputElement;
const romiCBValue = romiCB.checked;
const xrpCB = document.getElementById('xrpCB') as HTMLInputElement;
const xrpCBValue = xrpCB.checked;

const romiDiv = document.getElementById('romidiv') as HTMLDivElement;
const xrpDiv = document.getElementById('xrpdiv') as HTMLDivElement;
if (romiCBValue === true && xrpCBValue === true) {
romiDiv.classList.add('error');
xrpDiv.classList.add('error');
return false;
} else {
romiDiv.classList.remove('error');
xrpDiv.classList.remove('error');
return true;
}
}

export function validateTeamNumber(): boolean {
const elem = document.getElementById('teamNumber') as HTMLInputElement;
const s = elem.value;
Expand Down