This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new b588312 Update the launch config wizard manipulation of Daffodil
Debugger Classpath:
b588312 is described below
commit b5883124b2435b87bca39bfc5121290c7f87fdbf
Author: Shane Dell <[email protected]>
AuthorDate: Fri Jan 6 11:29:14 2023 -0500
Update the launch config wizard manipulation of Daffodil Debugger Classpath:
- Remove replace and append check boxes.
- Replace single box that listed the classpath items with a UI list.
- Browse will work the same but when you select a folder or file it will
be added to the list.
- List items will have a minus button beside the text. Both button and
text are clickable and when clicked it will remove that specifc item from the
list.
- Save now will now write the daffodil debugger classpath to the
launch.json.
- Update UI list to autopopulate the classpath items if set in the
configuration.
Closes #268
---
src/launchWizard/launchWizard.js | 104 +++++++++++++++++++++------------------
src/launchWizard/launchWizard.ts | 73 +++++++++------------------
src/styles/styles.css | 28 +++++++++++
3 files changed, 105 insertions(+), 100 deletions(-)
diff --git a/src/launchWizard/launchWizard.js b/src/launchWizard/launchWizard.js
index 0fe98ca..c664f48 100644
--- a/src/launchWizard/launchWizard.js
+++ b/src/launchWizard/launchWizard.js
@@ -18,20 +18,6 @@
// Retrieve vscode api - Doing this multiple times causes issues with the
scripts
const vscode = acquireVsCodeApi()
-// Function to update which checkbox is checked for the classpath,
replace/action
-function daffodilDebugClassAction(action) {
- switch (action) {
- case 'replace':
- document.getElementById('daffodilDebugClasspathReplace').checked = true
- document.getElementById('daffodilDebugClasspathAppend').checked = false
- break
- case 'append':
- document.getElementById('daffodilDebugClasspathReplace').checked = false
- document.getElementById('daffodilDebugClasspathAppend').checked = true
- break
- }
-}
-
// Function to call extension to open file picker
function filePicker(id, description) {
vscode.postMessage({
@@ -41,6 +27,37 @@ function filePicker(id, description) {
})
}
+// Function to remove child node from list
+async function removeDebugClasspathItem(child) {
+ document.getElementById('daffodilDebugClasspathTable').removeChild(child)
+}
+
+// Function to update classpath list
+async function updateClasspathList(data, delimeter) {
+ let list = document.getElementById('daffodilDebugClasspathTable')
+ let itemArray = data.split(delimeter)
+
+ for (var i = 0; i < itemArray.length; i++) {
+ let item = itemArray[i]
+ let li = document.createElement('li')
+ li.id = `debug-classpath-li-${item}`
+ li.style = 'margin-left: -5px;'
+ li.innerHTML = `
+ <p id="debug-classpath-li-${itemArray[i]}" class="debug-classpath-item">
+ <button id="remove-debug-classpath-li-${itemArray[i]}"
class="minus-button" type="button">-</button>
+ ${itemArray[i]}
+ </p>`
+
+ li.onclick = () => {
+ list.removeChild(li)
+ }
+
+ if (!document.contains(li)) {
+ list.appendChild(li)
+ }
+ }
+}
+
// Function to update select infoset output type
function updateInfosetOutputType() {
var infosetSelectionBox = document.getElementById('infosetOutputType')
@@ -112,6 +129,18 @@ function save() {
const trace = document.getElementById('trace').checked
const useExistingServer =
document.getElementById('useExistingServer').checked
+ let list = document.getElementById('daffodilDebugClasspathTable')
+
+ let daffodilDebugClasspath = ''
+
+ for (var i = 0; i < list.childNodes.length; i++) {
+ let item = list.childNodes[i]
+ let classpath = item.innerHTML.split('"')[3]
+
+ daffodilDebugClasspath +=
+ i === list.childNodes.length - 1 ? classpath : classpath + ':'
+ }
+
var obj = {
version: '0.2.0',
configurations: [
@@ -133,6 +162,7 @@ function save() {
openHexView: openHexView,
openInfosetView: openInfosetView,
openInfosetDiffView: openInfosetDiffView,
+ daffodilDebugClasspath: daffodilDebugClasspath,
},
],
}
@@ -145,7 +175,7 @@ function save() {
}
// Function to update config values in the webview
-function updateConfigValues(config) {
+async function updateConfigValues(config) {
document.getElementById('name').value = config.name
document.getElementById('data').value = config.data
document.getElementById('debugServer').value = parseInt(config.debugServer)
@@ -171,52 +201,28 @@ function updateConfigValues(config) {
document.getElementById('trace').checked = config.trace
document.getElementById('useExistingServer').checked =
config.useExistingServer
- updateInfosetOutputType()
-}
-// Function for updating the classpath input box
-function updateClasspath(message) {
- let action = ''
-
- if (
- document.getElementById('daffodilDebugClasspathAppend').checked &&
- !document.getElementById('daffodilDebugClasspathReplace').checked
- ) {
- action = 'append'
- } else {
- action = 'replace'
+ if (config.daffodilDebugClasspath !== '') {
+ await updateClasspathList(config.daffodilDebugClasspath, ':')
}
- if (action === 'append') {
- let newValue = ''
- var filesToAdd = message.value.split(':')
-
- for (var i = 0; i < filesToAdd.length; i++) {
- if (
- !document
- .getElementById('daffodilDebugClasspath')
- .value.includes(filesToAdd[i])
- ) {
- newValue += filesToAdd[i] + ':'
- }
- }
+ updateInfosetOutputType()
+}
- document.getElementById('daffodilDebugClasspath').value =
- newValue + document.getElementById('daffodilDebugClasspath').value
- } else {
- document.getElementById('daffodilDebugClasspath').value = message.value
- }
+// Function for updating the classpath input box
+async function updateClasspath(message) {
+ await updateClasspathList(message.value, ',')
}
// Function that gets called by default to create and update the hex web view
;(function main() {
// Listener for getting messages/data from the extension
- window.addEventListener('message', (event) => {
+ window.addEventListener('message', async (event) => {
const message = event.data
switch (message.command) {
case 'updateConfValues':
- updateConfigValues(message.configValues)
+ await updateConfigValues(message.configValues)
break
case 'dataUpdate':
document.getElementById('data').value = message.value
@@ -225,7 +231,7 @@ function updateClasspath(message) {
document.getElementById('program').value = message.value
break
case 'daffodilDebugClasspathUpdate':
- updateClasspath(message)
+ await updateClasspath(message)
break
}
})
diff --git a/src/launchWizard/launchWizard.ts b/src/launchWizard/launchWizard.ts
index f5eee8b..77f4c6e 100644
--- a/src/launchWizard/launchWizard.ts
+++ b/src/launchWizard/launchWizard.ts
@@ -152,38 +152,7 @@ async function openFilePicker(description) {
title: description,
})
.then(async (fileUri) => {
- if (fileUri && fileUri[0]) {
- let stats = fs.statSync(fileUri[0].fsPath)
-
- if (stats.isDirectory()) {
- let basePath = fileUri[0].fsPath
- let fileString = ''
-
- fs.readdirSync(basePath).forEach((file) => {
- if (file.includes('.jar')) {
- fileString += `${basePath}/${file},`
- }
- })
-
- return fileString.substring(0, fileString.length - 1) // make sure
to remove comma at the end of the string
- }
-
- if (fileUri.length === 1) {
- return fileUri[0].fsPath
- } else {
- let files = ''
-
- fileUri.forEach((file) => {
- if (file.fsPath.includes('.jar')) {
- files += `${file.fsPath},`
- }
- })
-
- return files.substring(0, files.length - 1) // make sure to remove
comma at the end of the string
- }
- }
-
- return ''
+ return fileUri && fileUri[0] ? fileUri[0].fsPath : ''
})
if (chosenFile.includes(rootPath)) {
@@ -325,13 +294,22 @@ class LaunchWizard {
let stopOnEntry = defaultValues.stopOnEntry ? 'checked' : ''
let trace = defaultValues.trace ? 'checked' : ''
let useExistingServer = defaultValues.useExistingServer ? 'checked' : ''
- let daffodilDebugClasspathAction =
- defaultValues.daffodilDebugClasspathAction === 'append'
- ? defaultConf.daffodilDebugClasspath
- : 'replace'
- let replaceCheck =
- daffodilDebugClasspathAction !== 'append' ? 'checked' : ''
- let appendCheck = daffodilDebugClasspathAction === 'append' ? 'checked' :
''
+
+ let daffodilDebugClasspathList =
+ '<ul id="daffodilDebugClasspathTable" style="list-style: none;
padding-left: 20px;">'
+ if (defaultValues.daffodilDebugClasspath) {
+ let itemArray = defaultValues.daffodilDebugClasspath.split(':')
+ for (var i = 0; i < itemArray.length; i++) {
+ daffodilDebugClasspathList += `
+ <li style="margin-left: -5px;"
onclick="removeDebugClasspathItem(this)">
+ <p id="debug-classpath-li-${itemArray[i]}"
class="debug-classpath-item">
+ <button id="remove-debug-classpath-li-${itemArray[i]}"
class="minus-button" type="button">-</button>
+ ${itemArray[i]}
+ </p>
+ </li>`
+ }
+ }
+ daffodilDebugClasspathList += '</ul>'
let infosetFormatSelect = ''
let infosetFormatTypes = ['xml', 'json']
@@ -412,20 +390,13 @@ class LaunchWizard {
<div id="daffodilDebugClasspathDiv" class="setting-div">
<p>Daffodil Debugger Classpath:</p>
- <p class="setting-description">Additional classpaths to be added to
the debugger.</p>
+ <p class="setting-description">Additional classpaths to be added to
the debugger:</p>
- <label class="container" style="margin-top: 10px; margin-bottom:
0px;">Replace value in input box with selected files.
- <input type="checkbox" id="daffodilDebugClasspathReplace"
${replaceCheck} onclick="daffodilDebugClassAction('replace')">
- <span class="checkmark"></span>
- </label>
+ ${daffodilDebugClasspathList}
- <label class="container" style="margin-top: 10px; margin-bottom:
10px;">Append selected files to value in input box.
- <input type="checkbox" id="daffodilDebugClasspathAppend"
${appendCheck} onclick="daffodilDebugClassAction('append')">
- <span class="checkmark"></span>
- </label>
-
- <input class="file-input"
value="${defaultValues.daffodilDebugClasspath}" id="daffodilDebugClasspath"/>
- <button id="daffodilDebugClasspathBrowse" class="browse-button"
type="button" onclick="filePicker('daffodilDebugClasspath', 'Select jar
files/folder with desired jars')">Browse</button>
+ <p style="margin-left: 5px">
+ <button id="daffodilDebugClasspathBrowse" class="browse-button"
type="button" onclick="filePicker('daffodilDebugClasspath', 'Select jar
files/folder with desired jars')">Browse</button>
+ </p>
</div>
<div id="dataDiv" class="setting-div">
diff --git a/src/styles/styles.css b/src/styles/styles.css
index ae33cdf..db088de 100644
--- a/src/styles/styles.css
+++ b/src/styles/styles.css
@@ -30,6 +30,20 @@
margin-left: 10px;
}
+.debug-classpath-item {
+ color: white;
+ cursor: pointer;
+ background-color: rgb(80, 78, 78);
+ width: 375px;
+ height: 25px;
+ font-size: 12px;
+ border: none;
+ border-radius: 12px;
+ padding-left: 7px;
+ margin: 0px;
+ margin-top: 5px;
+}
+
/* Hide the browser's default checkbox */
.container input {
position: absolute;
@@ -119,6 +133,20 @@
height: 25px;
}
+.minus-button {
+ background-color: lightgray;
+ border: none;
+ border-radius: 12px;
+ color: black;
+ text-align: center;
+ text-decoration: none;
+ display: inline-block;
+ font-size: 12px;
+ cursor: pointer;
+ width: 25px;
+ margin-top: 4px;
+}
+
.setting-description {
font-size: 14px;
margin: 0px;