use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.
the class ComponentEntityGenerator method getCodeGenFile.
private CodeGenFile<JavaClassSource> getCodeGenFile(String contextName, ComponentData data) {
if (entities.containsKey(contextName)) {
return entities.get(contextName);
} else {
JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$sEntity extends Entity {}", contextName));
CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>(contextName + "Entity", sourceGen, data.getSubDir());
entities.put(contextName, genFile);
return genFile;
}
}
use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.
the class ComponentMatcherGenerator method getCodeGenFile.
private CodeGenFile<JavaClassSource> getCodeGenFile(String contextName, ComponentData data) {
if (contexts.containsKey(contextName)) {
return contexts.get(contextName);
} else {
JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", WordUtils.capitalize(contextName) + "Matcher"));
CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>(contextName + "Matcher", sourceGen, data.getSubDir());
contexts.put(contextName, genFile);
return genFile;
}
}
use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.
the class EntitasGenerator method generateEntitas.
private CodeGenFile<JavaClassSource> generateEntitas(Set<String> contextNames, String pkgDestiny) {
JavaClassSource sourceGen = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}");
CodeGenFile<JavaClassSource> genFile = new CodeGenFile<JavaClassSource>("Entitas", sourceGen, "");
sourceGen.setPackage(pkgDestiny);
createMethodConstructor(sourceGen, contextNames);
createContextsMethod(sourceGen, contextNames);
createMethodAllContexts(sourceGen, contextNames);
createContextFields(sourceGen, contextNames);
System.out.println(genFile.getFileContent());
return genFile;
}
use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.
the class CodeGeneratorJFX method handleGenerate.
@FXML
public void handleGenerate(ActionEvent actionEvent) throws IOException {
result.setText("");
progress.setVisible(true);
result.setText("Generating...");
if (props != null)
saveProperties();
// loads the items at another thread, asynchronously
Task loader = new Task<List<CodeGenFile>>() {
{
setOnSucceeded(workerStateEvent -> {
progress.setVisible(false);
result.setText("Success");
});
setOnFailed(workerStateEvent -> {
result.setText("Failed");
getException().printStackTrace();
});
}
@Override
protected List<CodeGenFile> call() throws Exception {
List<ICodeGenerator> codeGenerators = new ArrayList<>();
// return generator.generate(provider, fieldGeneratedFolder.getText(), codeGenerators);
return null;
}
};
Thread loadingThread = new Thread(loader, "generated-loader");
loadingThread.setDaemon(true);
loadingThread.start();
}
use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.
the class CodeGenerator method generate.
List<CodeGenFile> generate(String messagePrefix, List<ICodeGeneratorDataProvider> dataProviders, List<ICodeGenerator> codeGenerators, List<ICodeGenFilePostProcessor> postProcessors) {
_cancel = false;
List<CodeGeneratorData> data = new ArrayList<>();
int total = dataProviders.size() + codeGenerators.size() + postProcessors.size();
int progress = 0;
for (ICodeGeneratorDataProvider dataProvider : dataProviders) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Creating model", dataProvider.getName(), (float) progress / total);
}
data.addAll(dataProvider.getData());
}
List<CodeGenFile> files = new ArrayList<>();
for (ICodeGenerator generator : codeGenerators) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Creating files", generator.getName(), (float) progress / total);
}
files.addAll(generator.generate(data));
}
for (ICodeGenFilePostProcessor postProcessor : postProcessors) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Processing files", postProcessor.getName(), (float) progress / total);
}
files = postProcessor.postProcess(files);
}
return files;
}
Aggregations