br.com.jarch.apt.generate.ListXhtmlCodeGenerate Maven / Gradle / Ivy
package br.com.jarch.apt.generate;
import br.com.jarch.util.FileUtils;
import br.com.jarch.util.LogUtils;
import br.com.jarch.util.ProcessorUtils;
import javax.lang.model.element.Element;
import java.io.File;
import java.io.IOException;
import static br.com.jarch.util.ProcessorUtils.addCode;
public final class ListXhtmlCodeGenerate {
private Element element;
private File fileListXhtml;
private File fileListaXhtml;
private String nomeSemCaracterEspecial;
private String nomeSemCaracterEspecialMinusculo;
public 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 void create(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