Skip to content

Commit

Permalink
Launch Wizard - Allow copying of configs
Browse files Browse the repository at this point in the history
Closes apache#670
  • Loading branch information
shanedell committed Nov 29, 2023
1 parent f2d880a commit fb05a79
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 49 deletions.
213 changes: 177 additions & 36 deletions src/launchWizard/launchWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,88 @@ function getConfigIndex() {
if (configSelectedValue === 'New Config') {
document.getElementById('nameLabel').style =
'margin-top: 10px; visibility: visible;'
document.getElementById('copyLaunchConfigButton').style =
'visibility: hidden;'
} else {
document.getElementById('nameLabel').style = 'visibility: hidden;'
document.getElementById('copyLaunchConfigButton').style =
'visibility: visible;'
}

return configSelectedValue === 'New Config'
? -1
: configSelectionBox.selectedIndex
}

function getConfigValues() {
var configSelectionBox = document.getElementById('configSelected')
var configSelectedValue =
configSelectionBox.options[configSelectionBox.selectedIndex].value
const name =
configSelectedValue === 'New Config'
? document.getElementById('name').value
: configSelectedValue
const data = document.getElementById('data').value
const debugServer = parseInt(document.getElementById('debugServer').value)
const infosetFormat = document.getElementById('infosetFormat').value
const infosetOutputFilePath = document.getElementById(
'infosetOutputFilePath'
).value
const infosetOutputType = document.getElementById('infosetOutputType').value
const tdmlAction = document.getElementById('tdmlAction').value
const tdmlName = document.getElementById('tdmlName').value
const tdmlDescription = document.getElementById('tdmlDescription').value
const tdmlPath = document.getElementById('tdmlPath').value
const openHexView = document.getElementById('openHexView').checked
const openInfosetDiffView = document.getElementById(
'openInfosetDiffView'
).checked
const openInfosetView = document.getElementById('openInfosetView').checked
const program = document.getElementById('program').value
const stopOnEntry = document.getElementById('stopOnEntry').checked
const trace = document.getElementById('trace').checked
const useExistingServer = document.getElementById('useExistingServer').checked
const dataEditorPort = parseInt(
document.getElementById('dataEditorPort').value
)
const dataEditorLogFile = document.getElementById('dataEditorLogFile').value
const dataEditorLogLevel = document.getElementById('dataEditorLogLevel').value
const dfdlDebuggerLogFile = document.getElementById(
'dfdlDebuggerLogFile'
).value
const dfdlDebuggerLogLevel = document.getElementById(
'dfdlDebuggerLogLevel'
).value

const daffodilDebugClasspath = getDaffodilDebugClasspathString()

return [
name,
data,
debugServer,
infosetFormat,
infosetOutputFilePath,
infosetOutputType,
tdmlAction,
tdmlName,
tdmlDescription,
tdmlPath,
openHexView,
openInfosetDiffView,
openInfosetView,
program,
stopOnEntry,
trace,
useExistingServer,
dataEditorPort,
dataEditorLogFile,
dataEditorLogLevel,
dfdlDebuggerLogFile,
dfdlDebuggerLogLevel,
daffodilDebugClasspath,
]
}

// Function get daffodil debug classpath string
function getDaffodilDebugClasspathString() {
let childNodes = document.getElementById(
Expand Down Expand Up @@ -188,43 +261,32 @@ function save() {
configSelectionBox.options[configSelectionBox.selectedIndex].value
var updateOrCreate =
configSelectedValue === 'New Config' ? 'create' : 'update'
const name =
configSelectedValue === 'New Config'
? document.getElementById('name').value
: configSelectedValue
const data = document.getElementById('data').value
const debugServer = parseInt(document.getElementById('debugServer').value)
const infosetFormat = document.getElementById('infosetFormat').value
const infosetOutputFilePath = document.getElementById(
'infosetOutputFilePath'
).value
const infosetOutputType = document.getElementById('infosetOutputType').value
const tdmlAction = document.getElementById('tdmlAction').value
const tdmlName = document.getElementById('tdmlName').value
const tdmlDescription = document.getElementById('tdmlDescription').value
const tdmlPath = document.getElementById('tdmlPath').value
const openHexView = document.getElementById('openHexView').checked
const openInfosetDiffView = document.getElementById(
'openInfosetDiffView'
).checked
const openInfosetView = document.getElementById('openInfosetView').checked
const program = document.getElementById('program').value
const stopOnEntry = document.getElementById('stopOnEntry').checked
const trace = document.getElementById('trace').checked
const useExistingServer = document.getElementById('useExistingServer').checked
const dataEditorPort = parseInt(
document.getElementById('dataEditorPort').value
)
const dataEditorLogFile = document.getElementById('dataEditorLogFile').value
const dataEditorLogLevel = document.getElementById('dataEditorLogLevel').value
const dfdlDebuggerLogFile = document.getElementById(
'dfdlDebuggerLogFile'
).value
const dfdlDebuggerLogLevel = document.getElementById(
'dfdlDebuggerLogLevel'
).value

const daffodilDebugClasspath = getDaffodilDebugClasspathString()
const [
name,
data,
debugServer,
infosetFormat,
infosetOutputFilePath,
infosetOutputType,
tdmlAction,
tdmlName,
tdmlDescription,
tdmlPath,
openHexView,
openInfosetDiffView,
openInfosetView,
program,
stopOnEntry,
trace,
useExistingServer,
dataEditorPort,
dataEditorLogFile,
dataEditorLogLevel,
dfdlDebuggerLogFile,
dfdlDebuggerLogLevel,
daffodilDebugClasspath,
] = getConfigValues()

var obj = {
version: '0.2.0',
Expand Down Expand Up @@ -278,6 +340,85 @@ function save() {
})
}

// Function to copy selected config
function copyConfig() {
const [
name,
data,
debugServer,
infosetFormat,
infosetOutputFilePath,
infosetOutputType,
tdmlAction,
tdmlName,
tdmlDescription,
tdmlPath,
openHexView,
openInfosetDiffView,
openInfosetView,
program,
stopOnEntry,
trace,
useExistingServer,
dataEditorPort,
dataEditorLogFile,
dataEditorLogLevel,
dfdlDebuggerLogFile,
dfdlDebuggerLogLevel,
daffodilDebugClasspath,
] = getConfigValues()

var obj = {
version: '0.2.0',
configurations: [
{
request: 'launch',
type: 'dfdl',
name: `${name}`,
program: program,
data: data,
debugServer: debugServer,
infosetFormat: infosetFormat,
infosetOutput: {
type: infosetOutputType,
path: infosetOutputFilePath,
},
tdmlConfig: {
action: tdmlAction,
name: tdmlName,
description: tdmlDescription,
path: tdmlPath,
},
trace: trace,
stopOnEntry: stopOnEntry,
useExistingServer: useExistingServer,
openHexView: openHexView,
openInfosetView: openInfosetView,
openInfosetDiffView: openInfosetDiffView,
daffodilDebugClasspath: daffodilDebugClasspath,
dataEditor: {
port: dataEditorPort,
logging: {
file: dataEditorLogFile,
level: dataEditorLogLevel,
},
},
dfdlDebugger: {
logging: {
file: dfdlDebuggerLogFile,
level: dfdlDebuggerLogLevel,
},
},
},
],
}

vscode.postMessage({
command: 'copyConfig',
data: JSON.stringify(obj, null, 4),
})
}

// Function to update config values in the webview
async function updateConfigValues(config) {
document.getElementById('name').value = config.name
Expand Down
Loading

0 comments on commit fb05a79

Please sign in to comment.