Skip to content
Snippets Groups Projects
Commit 2b9345a9 authored by Martti Käärik's avatar Martti Käärik
Browse files

Updated OpenAPI project wizard to include more libraries and removed redundant settings.

parent 03dec706
No related branches found
No related tags found
No related merge requests found
Pipeline #9359 passed
......@@ -34,18 +34,19 @@ final class TDLtxProjectWithOpenAPI {
val lastUsed = "LAST_USED"
//TODO: file prompt?
//TODO: remove after testing
val advanced = check("Advanced:", false)
val advanced = check("Advanced:", true)
val advancedGroup = group("Properties")
// val name = combo("Package Name:", #["Example", "Sample", "Tutorial", "Pack"], "The name of the package", advancedGroup)
val name = text("Main Package Name:", "Main", "The name of the main package")
//TODO: add other options
val importStandard = check("Import TDL Library", true, "Import TDL standard library definitions.", advancedGroup)
val importHTTP = check("Import HTTP Library", false, "Import TDL HTTP library definitions.", advancedGroup)
val importHTTP = check("Import HTTP Library", true, "Import TDL HTTP library definitions.", advancedGroup)
val importJava = check("Import Java mapping libraries", false, "Import TDL Java mappings.", advancedGroup)
val extendedNature = check("Add additional natures", false, "Add Eclipse Plug-in and Java natures", advancedGroup)
val path = text("Path:", "tdl", "The package path to place the files in", advancedGroup)
val dataDefinitionsPath = text("Data DefinitionsPath:", s.getString(lastUsed), "The data definitions path to import from", advancedGroup)
val sourceMapping = text("Source mapping tag:", "SOURCE_MAPPING", "The source mapping tag to be used for the data mappings", advancedGroup)
val targetMapping = text("Target mapping tag:", "TARGET_MAPPING", "The target mapping tag to be used for the data mappings", advancedGroup)
// val dataDefinitionsPath = text("Data DefinitionsPath:", s.getString(lastUsed), "The data definitions path to import from", advancedGroup)
// val sourceMapping = text("Source mapping tag:", "SOURCE_MAPPING", "The source mapping tag to be used for the data mappings", advancedGroup)
// val targetMapping = text("Target mapping tag:", "TARGET_MAPPING", "The target mapping tag to be used for the data mappings", advancedGroup)
@Inject
PluginImageHelper pluginImageHelper
......@@ -57,20 +58,21 @@ final class TDLtxProjectWithOpenAPI {
importHTTP.enabled = advanced.value
extendedNature.enabled = advanced.value
dataDefinitionsPath.enabled = advanced.value
sourceMapping.enabled = advanced.value
targetMapping.enabled = advanced.value
// dataDefinitionsPath.enabled = advanced.value
// sourceMapping.enabled = advanced.value
// targetMapping.enabled = advanced.value
if (!advanced.value) {
name.value = "Main"
path.value = "tdl"
importStandard.value = true
importHTTP.value = false
importHTTP.value = true
importJava.value = false
extendedNature.value = false
dataDefinitionsPath.value = s.getString(lastUsed)
sourceMapping.value = "SOURCE_MAPPING"
targetMapping.value = "TARGET_MAPPING"
// dataDefinitionsPath.value = s.getString(lastUsed)
// sourceMapping.value = "SOURCE_MAPPING"
// targetMapping.value = "TARGET_MAPPING"
}
}
......@@ -88,6 +90,7 @@ final class TDLtxProjectWithOpenAPI {
projectName = projectInfo.projectName
location = projectInfo.locationPath
projectNatures += #[XtextProjectHelper.NATURE_ID]
projectNatures += #["org.etsi.mts.tdl.nature"]
builderIds += #[XtextProjectHelper.BUILDER_ID]
if (extendedNature.value) {
projectNatures += #[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"]
......@@ -107,22 +110,29 @@ final class TDLtxProjectWithOpenAPI {
imports += "Import all from HTTP\n"
imports += "Import all from HTTP.MessageBased\n"
}
if (importJava.value) {
addFile('''src/«path»/Java.tdltx''', TemplateHelper.getLibrary("Java"))
addFile('''src/«path»/TdlRuntime.tdltx''', TemplateHelper.getLibrary("TdlRuntime"))
if (importHTTP.value) {
addFile('''src/«path»/HttpJavaMappings.tdltx''', TemplateHelper.getLibrary("HttpJavaMappings"))
imports += "Import all from HttpJavaMappings\n"
}
imports += "Import all from Java\n"
}
//TODO: make target package name configurable? i.e. based on name
addFile('''src/«path»/imported.tdltx''',
ConverterNext.processToString(dataDefinitionsPath.value,
"src/"+path.value+"/Imported.tdltx",
sourceMapping.value,
targetMapping.value
))
val importsName = "generated_from_"+ConverterNext.getTargetPackageName(dataDefinitionsPath.value)
// addFile('''src/«path»/imported.tdltx''',
// ConverterNext.processToString(dataDefinitionsPath.value,
// "src/"+path.value+"/Imported.tdltx",
// sourceMapping.value,
// targetMapping.value
// ))
// val importsName = "generated_from_"+ConverterNext.getTargetPackageName(dataDefinitionsPath.value)
addFile('''src/«path»/«name».tdltx''', '''
/*
* This is an example package
*/
Package «name» {
Import all from TDL
Import all from «importsName»
Type simple
«imports»
}
''')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment