Search in sources :

Example 11 with CodeGenFile

use of ilargia.entitas.codeGeneration.data.CodeGenFile in project Entitas-Java by Rubentxu.

the class CodeGeneratorApp 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<>();
            if (componentsGenerator.isSelected())
                codeGenerators.add(new EntityGenerator());
            if (componentIndicesGenerator.isSelected())
                codeGenerators.add(new ComponentIndicesGenerator());
            if (contextsGenerator.isSelected())
                codeGenerators.add(new ContextGenerator());
            codeGenerators.add(new MatcherGenerator());
            codeGenerators.add(new EntitasGenerator());
            TypeReflectionProvider provider = new TypeReflectionProvider(fieldComponentFolder.getText());
            CodeGeneratorOld generator = new CodeGeneratorOld();
            return generator.generate(provider, fieldGeneratedFolder.getText(), codeGenerators);
        }
    };
    Thread loadingThread = new Thread(loader, "generated-loader");
    loadingThread.setDaemon(true);
    loadingThread.start();
}
Also used : Task(javafx.concurrent.Task) ArrayList(java.util.ArrayList) TypeReflectionProvider(ilargia.entitas.codeGenerator.providers.TypeReflectionProvider) ICodeGenerator(ilargia.entitas.codeGeneration.interfaces.ICodeGenerator) CodeGenFile(ilargia.entitas.codeGeneration.data.CodeGenFile) FXML(javafx.fxml.FXML)

Aggregations

CodeGenFile (ilargia.entitas.codeGeneration.data.CodeGenFile)11 ICodeGenerator (ilargia.entitas.codeGeneration.interfaces.ICodeGenerator)7 JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)6 ICodeGeneratorDataProvider (ilargia.entitas.codeGeneration.interfaces.ICodeGeneratorDataProvider)3 ArrayList (java.util.ArrayList)3 Task (javafx.concurrent.Task)3 FXML (javafx.fxml.FXML)3 java.io (java.io)2 java.util (java.util)2 JavaDocSource (org.jboss.forge.roaster.model.source.JavaDocSource)2 ComponentInfo (com.ilargia.games.entitas.codeGenerator.data.ComponentInfo)1 TypeReflectionProvider (com.ilargia.games.entitas.codeGenerator.providers.TypeReflectionProvider)1 CodeGenerator (ilargia.entitas.codeGeneration.CodeGenerator)1 CodeGeneratorData (ilargia.entitas.codeGeneration.data.CodeGeneratorData)1 ICodeGenFilePostProcessor (ilargia.entitas.codeGeneration.interfaces.ICodeGenFilePostProcessor)1 ComponentInfo (ilargia.entitas.codeGenerator.data.ComponentInfo)1 TypeReflectionProvider (ilargia.entitas.codeGenerator.providers.TypeReflectionProvider)1 TaskAction (org.gradle.api.tasks.TaskAction)1