use of net.jangaroo.exml.parser.ExmlToModelParser in project jangaroo-tools by CoreMedia.
the class ExmlToMxml method exmlToMxml.
private File exmlToMxml(ExmlSourceFile exmlSourceFile) throws IOException, SAXException {
ExmlModel exmlModel = new ExmlToModelParser(configClassRegistry).parse(exmlSourceFile.getSourceFile());
File sourceFile = exmlSourceFile.getSourceFile();
File outputFile = CompilerUtils.fileFromQName(exmlSourceFile.getTargetClassName(), configClassRegistry.getConfig().getSourcePath().get(0), ".mxml");
FileUtils.forceMkdir(outputFile.getParentFile());
PrintStream writer = new PrintStream(new FileOutputStream(outputFile), true, net.jangaroo.exml.api.Exmlc.OUTPUT_CHARSET);
ExmlToConfigClassParser.parseFileWithHandler(sourceFile, new ExmlToMxmlHandler(exmlSourceFile, exmlModel, writer));
return outputFile;
}
use of net.jangaroo.exml.parser.ExmlToModelParser in project jangaroo-tools by CoreMedia.
the class ExmlComponentClassGeneratorTest method testGenerateClassWithLowerCaseFileName.
@Test
public void testGenerateClassWithLowerCaseFileName() throws Exception {
setUp("exmlparser.config");
File sourceFile = getFile("/exmlparser/testLowerCase.exml");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(sourceFile);
Assert.assertEquals("TestLowerCase", model.getClassName());
Assert.assertEquals("testLowerCase", model.getConfigClass().getName());
Assert.assertEquals("exmlparser", model.getPackageName());
}
use of net.jangaroo.exml.parser.ExmlToModelParser in project jangaroo-tools by CoreMedia.
the class ExmlComponentClassGeneratorTest method testGenerateClass.
@Test
public void testGenerateClass() throws Exception {
setUp("exmlparser.config");
String expected = FileUtils.readFileToString(new File(getClass().getResource("/expected/AllElements.as").toURI()));
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/AllElements.exml"));
StringWriter output = new StringWriter();
new ExmlComponentClassGenerator(getExmlc().getConfig()).generateClass(model, output);
Assert.assertEquals(expected, output.toString());
}
use of net.jangaroo.exml.parser.ExmlToModelParser in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testParseArrayAttribute.
@Test
public void testParseArrayAttribute() throws Exception {
setUp("exmlparser.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestArrayAttribute.exml"));
Assert.assertEquals("ext.Panel", model.getSuperClassName());
JsonObject expectedJsonObject = new JsonObject("items", JsonObject.code("config.myItems"), "tools", new JsonArray("tools"));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
use of net.jangaroo.exml.parser.ExmlToModelParser in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testConfigDefaultValues.
@Test
public void testConfigDefaultValues() throws Exception {
setUp("testNamespace.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/testPackage/TestComponentWithCfgDefaults.exml"));
List<ConfigAttribute> cfgs = model.getConfigClass().getDirectCfgs();
Assert.assertEquals(9, cfgs.size());
JsonObject expectedJsonObject = new JsonObject("propertyWithLiteralDefault", "foobar", "propertyWithExpressionDefault", JsonObject.code("'foo' + 'bar'"), "propertyWithDefaultElement", new JsonObject("xtype", "button", "text", "click me!"), "propertyWithDefaultElementUsingConfig", new JsonObject("xtype", "button", "text", JsonObject.code("config.title + '!'")), "arrayPropertyWithDefaultElement", new JsonArray(new JsonObject("xtype", "button", "text", "button1"), new JsonObject("xtype", "button", "text", "button2")), "propertyWithInterfaceAndDefault", JsonObject.code(" new TestImpl() "), "propertyFromOtherPackage", JsonObject.code(" new SomeOtherClass('lala') "));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getCfgDefaults().toString(2));
}
Aggregations