......@@ -8,7 +8,8 @@ import org.eclipse.xtext.ui.wizard.template.FileTemplate
import org.eclipse.xtext.ui.wizard.template.IFileGenerator
import org.eclipse.xtext.ui.wizard.template.IFileTemplateProvider
import org.etsi.mts.tdl.openapi2tdl.next.ConverterNext
import com.google.inject.Inject
import org.eclipse.core.runtime.preferences.InstanceScope
import org.eclipse.ui.preferences.ScopedPreferenceStore
/**
* Create a list with all file templates to be shown in the template new file wizard.
......@@ -16,20 +17,14 @@ import com.google.inject.Inject
* Each template is able to generate one or more files.
*/
class TDLtxFileTemplateProvider implements IFileTemplateProvider {
@Inject
TDLtxFile txFile
@Inject
TDLtxFileExtras txFileExtra
override getFileTemplates() {
// #[new TDLtxFile, new TDLtxFileExtras]
#[txFile, txFileExtra]
#[new TDLtxFile, new TDLtxFileFromOpenAPI]
}
}
@FileTemplate(label="TDLtx", icon="file_template.png", description="Create a new package for TDLtx.")
final class TDLtxFile {
//TODO: make it more sensible
val packageName = combo("Package Name:", #["Example", "Sample", "Tutorial", "Pack"], "The name of the package")
//TODO: reuse?
......@@ -42,28 +37,39 @@ final class TDLtxFile {
}
''')
// generator.generate('''«folder»/«packageName».tdltx''', TemplateContent.Example)
}
}
//TODO: this seems to be inactive...
@FileTemplate(label="TDLtx extra", icon="file_template.png", description="Create a new package for TDLtx with extras.")
final class TDLtxFileExtras {
// val packageName = combo("Package Name:", #["Example", "Sample", "Tutorial", "Pack"], "The name of the package")
val testFile = "/Users/philip-iii/Dev/git/etsi-labs/eg-203647-restful-api-guide/OpenAPI/ExampleAPI.yaml"
val dataDefinitionsPath = text("Data DefinitionsPath:", testFile, "The data definitions path to import from")
//TODO: reuse?
@FileTemplate(label="Data definitions import from OpenAPI", icon="file_template.png", description="Create a new package for TDLtx from OpenAPI data definitions.")
final class TDLtxFileFromOpenAPI {
//TODO: more modern way?
val s = new ScopedPreferenceStore(new InstanceScope(), "org.etsi.mts.tdl.tx.ui.template.data.openapi")
val lastUsed = "LAST_USED"
//TODO: file prompt?
val dataDefinitionsPath = text("Data Definitions Path:", s.getString(lastUsed), "The data definitions path to import from")
val sourceMapping = text("Source mapping tag:", "SOURCE_MAPPING", "The source mapping tag to be used for the data mappings")
val targetMapping = text("Target mapping tag:", "TARGET_MAPPING", "The target mapping tag to be used for the data mappings")
var validated = false
override protected updateVariables() {
validated = true
s.setValue(lastUsed, dataDefinitionsPath.value)
s.save()
super.updateVariables()
}
override generateFiles(IFileGenerator generator) {
// generator.generate('''«folder»/«name».tdltx''', '''
// /*
// * This is an example model
// */
// Package «name» {
//
// }
// ''')
// generator.generate('''«folder»/«packageName».tdltx''', TemplateContent.Example)
//TODO: this gets loaded twice? already when the template is selected? and the file is not opened automatically
ConverterNext.process(dataDefinitionsPath.value, "/Users/philip-iii/Dev/workspaces/runtime/2021-06-M3-clean/"+folder+"/"+name+".tdltx")
//NOTE: this is triggered on every key stroke.. -> lock until second screen
if (validated) {
generator.generate('''«folder»/«name».tdltx''',
ConverterNext.processToString(dataDefinitionsPath.value,
folder+"/"+name+".tdltx",
sourceMapping.value,
targetMapping.value
))
}
}
}
......@@ -2,7 +2,9 @@ TDLtxProject_Label=TDLtx
TDLtxProject_Description=<p><b>TDLtx</b></p> <p>This is a parameterized project for TDLtx. You can set a parameter to modify the content in the generated file and a parameter to set the path the file is created in.</p><p><img href="project_template.png"/></p>
TDLtxFile_Label=TDLtx
TDLtxFile_Description=Create a new package for TDLtx.
TDLtxFileExtras_Label=TDLtx extra
TDLtxFileExtras_Description=Create a new package for TDLtx with extras.
TDLtxFileExtras_Label=Data definitions import from OpenAPI
TDLtxFileExtras_Description=Create a new package for TDLtx from OpenAPI data definitions.
TDLtxProjectWithOpenAPI_Label=TDLtx with OpenAPI
TDLtxProjectWithOpenAPI_Description=<p><b>TDLtx with OpenAPI</b></p> <p>This is a parameterized project for TDLtx with the option to import data definitions from OpenAPI. You can set a parameter to modify the content in the generated file and a parameter to set the path the file is created in.</p><p><img href="project_template.png"/></p>
TDLtxFileFromOpenAPI_Label=Data definitions import from OpenAPI
TDLtxFileFromOpenAPI_Description=Create a new package for TDLtx from OpenAPI data definitions.
......@@ -45,11 +45,11 @@ Component ${componentType} {
Expected behaviour
ensure that {
when {
tester::interface sends "hello" to sut::interface
${source:CrossReference('Message.sourceGate')} sends "ey" to sut::interface
tester::interface sends "hello" {string} to sut::interface
${source:CrossReference('Message.sourceGate')} sends "hey" {string} to sut::interface
}
then {
tester::interface receives "hello back" from sut::interface
tester::interface receives "hello back" {string} from sut::interface
}
}
}
......
......@@ -3,9 +3,14 @@
*/
package org.etsi.mts.tdl;
import org.eclipse.xtext.conversion.IValueConverterService;
/**
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
public class TDLtxRuntimeModule extends AbstractTDLtxRuntimeModule {
@Override
public Class<? extends IValueConverterService> bindIValueConverterService() {
return EString2XtextConverter.class;
}
}
......@@ -63,7 +63,7 @@ public class TDLtxValidator extends AbstractTDLtxValidator {
//TODO: goes a bit in circles
//TODO: extract into an activator or something? also as command
//TODO: works in principle, occasionally causes hangs and strange errors though...
System.out.println("init EVL validator");
System.out.println("Init EVL validator..");
// Assuming you have generated the metamodel code
EPackage ePackage = tdlPackage.eINSTANCE;
......@@ -88,19 +88,20 @@ public class TDLtxValidator extends AbstractTDLtxValidator {
newValidator.getDelegates().add(existingValidator);
newValidator.getDelegates().add(evlValidator);
EValidator.Registry.INSTANCE.put(ePackage, newValidator);
}
}
initialised = true;
}
@Check
public void checkConfigurationsStartWithCapital(TestConfiguration c) {
if (!Character.isUpperCase(c.getName().charAt(0))) {
warning("Name should start with a capital",
tdlPackage.Literals.ELEMENT__NAME,
INVALID_NAME);
}
}
// @Check
// public void checkConfigurationsStartWithCapital(TestConfiguration c) {
// if (!Character.isUpperCase(c.getName().charAt(0))) {
// warning("Name should start with a capital",
// tdlPackage.Literals.ELEMENT__NAME,
// INVALID_NAME);
// }
//}
}