br.com.jarch.apt.generate.ListXhtmlCodeGenerate Maven / Gradle / Ivy
The newest version!
package br.com.jarch.apt.generate;
import br.com.jarch.core.annotation.JArchGenerateCrud;
import br.com.jarch.util.FileUtils;
import br.com.jarch.util.LogUtils;
import br.com.jarch.apt.util.ProcessorUtils;
import javax.lang.model.element.Element;
import java.io.File;
import java.io.IOException;
import static br.com.jarch.apt.util.ProcessorUtils.addCode;
public final class ListXhtmlCodeGenerate {
private final Element element;
private final File fileListXhtml;
private final File fileListaXhtml;
private final String nomeSemCaracterEspecial;
private final String nomeSemCaracterEspecialMinusculo;
private ListXhtmlCodeGenerate(Element element, String name, String nameSubPackage) {
this.element = element;
nomeSemCaracterEspecial = ProcessorUtils.getNameWithoutCharEspecialCapitalize(name);
nomeSemCaracterEspecialMinusculo = ProcessorUtils.getNameWithoutCharEspecialStartLowerCase(name);
File folder = new File(ProcessorUtils.getPathPage(element, nameSubPackage));
if (!folder.exists()) {
folder.mkdir();
}
fileListXhtml = new File(ProcessorUtils.getPathPage(element, nameSubPackage) + nomeSemCaracterEspecialMinusculo + "List.xhtml");
fileListaXhtml = new File(ProcessorUtils.getPathPage(element, nameSubPackage) + "lista" + nomeSemCaracterEspecial + ".xhtml");
}
public static void generate(Element element, JArchGenerateCrud generateCrud) {
new ListXhtmlCodeGenerate(element, generateCrud.master().name(), generateCrud.nameSubPackage())
.generate(generateCrud.allowInsert(), generateCrud.allowClone(), generateCrud.allowChange(),
generateCrud.allowDelete());
}
private void generate(boolean allowInsert, boolean allowClone, boolean allowChange, boolean allowDelete) {
if (ProcessorUtils.isFileExistsClientOrWebOrWs(fileListXhtml) || ProcessorUtils.isFileExistsClientOrWebOrWs(fileListaXhtml)) {
return;
}
StringBuilder listXhtml = new StringBuilder();
addCode(listXhtml, "");
addCode(listXhtml, "");
addCode(listXhtml, "\t");
addCode(listXhtml, "\t\t ");
addCode(listXhtml, "\t ");
addCode(listXhtml, "");
addCode(listXhtml, "\t");
addCode(listXhtml, "\t\t");
addCode(listXhtml, "\t\t\t ");
addCode(listXhtml, "\t\t\t ");
addCode(listXhtml, "\t\t\t\tupdate=\"@(.list-datatable)\"/>");
addCode(listXhtml, "\t\t\t ");
addCode(listXhtml, "\t\t ");
addCode(listXhtml, "\t ");
addCode(listXhtml, " ");
addCode(listXhtml, "");
try {
FileUtils.save(fileListXhtml, listXhtml.toString());
ProcessorUtils.messageNote("JARCH Created ==> " + fileListXhtml.getAbsoluteFile(), element);
} catch (IOException e) {
LogUtils.generate(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy