<commit_before><%
	org.devocative.devolcano.vo.ClassVO cls = targetClass
	org.devocative.devolcano.ImportHelper imp = importHelper
	org.devocative.devolcano.ContextVO context = context

	org.devocative.devolcano.GenTargetVO fvo = context.getGenTarget(cls, "FVO")
	org.devocative.devolcano.GenTargetVO iservice = context.getGenTarget(cls, "ServiceI")
	org.devocative.devolcano.GenTargetVO service = context.getGenTarget(cls, "ServiceM")
	org.devocative.devolcano.GenTargetVO formJ = context.getGenTarget(cls, "FormJ")

	List commonFields = ["creationDate", "creatorUser", "modificationDate", "modifierUser", "version"]

	imp.add(cls)
	imp.add(fvo)
	imp.add(iservice)
	if (formJ != null) {
		imp.add(formJ)
	}

	imp.add(javax.inject.Inject)
	imp.add(List)
	imp.add(Collections)

	imp.add(org.devocative.demeter.web.DPage)
	imp.add(org.devocative.demeter.web.component.DAjaxButton)

	imp.add(org.devocative.wickomp.grid.IGridDataSource)
	imp.add(org.devocative.wickomp.grid.WDataGrid)
	imp.add(org.devocative.wickomp.html.WFloatTable)
	imp.add(org.devocative.wickomp.grid.column.OColumnList)
	imp.add(org.devocative.wickomp.grid.column.OPropertyColumn)
	imp.add(org.devocative.wickomp.grid.OGrid)
	imp.add(org.devocative.wickomp.WModel)
	imp.add(org.devocative.wickomp.opt.OSize)
	imp.add(org.devocative.wickomp.grid.WSortField)

	imp.add(org.apache.wicket.markup.html.form.Form)
	imp.add(org.apache.wicket.model.CompoundPropertyModel)
	imp.add(org.apache.wicket.model.ResourceModel)
	imp.add(org.apache.wicket.ajax.AjaxRequestTarget)
	imp.add(org.apache.wicket.model.IModel)
	imp.add(org.apache.wicket.model.Model)
%>
package ${targetVO.pkg};

@IMPORT@

public class ${targetVO.name} extends DPage implements IGridDataSource<${cls.simpleName}> {
	private static final long serialVersionUID = ${targetVO.fqn.hashCode()}L;

	@Inject
	private ${iservice.name} ${service.name.toUncapital()};

	private ${fvo.name} filter;
	private boolean formVisible = true;
	private String[] invisibleFormItems;

	private WDataGrid<${cls.simpleName}> grid;
	private String[] removeColumns;

	private Boolean gridFit;
	private boolean gridEnabled = false;
	private OSize gridHeight = OSize.fixed(500);
	private OSize gridWidth = OSize.percent(100);

	// ------------------------------

	// Panel Call - New Filter
	public ${targetVO.name}(String id) {
		this(id, Collections.<String>emptyList(), new ${fvo.name}());
	}

	// Panel Call - Open Filter
	public ${targetVO.name}(String id, ${fvo.name} filter) {
		this(id, Collections.<String>emptyList(), filter);
	}

	// REST Call - New Filter
	public ${targetVO.name}(String id, List<String> params) {
		this(id, params, new ${fvo.name}());
	}

	// Main Constructor
	private ${targetVO.name}(String id, List<String> params, ${fvo.name} filter) {
		super(id, params);

		this.filter = filter;
	}

	// ------------------------------

	@Override
	protected void onInitialize() {
		super.onInitialize();
<% 	if(params["ajaxEditColumn"] && formJ != null) { %>
		final ${imp.add(org.devocative.wickomp.html.window.WModalWindow)} window = new WModalWindow("window");
		window.getOptions().setHeight(OSize.percent(80)).setWidth(OSize.percent(80));
		add(window);

		add(new ${imp.add(org.devocative.wickomp.html.WAjaxLink)}("add", ${imp.add(params["iconClass"])}.ADD) {
			private static final long serialVersionUID = ${(targetVO.fqn + ".WAjaxLink").hashCode()}L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				window.setContent(new ${formJ.name}(window.getContentId()));
				window.show(target);
			}
		});
<% } %>
		WFloatTable floatTable = new WFloatTable("floatTable");
		floatTable.setEqualWidth(true);
<%
	cls.allFieldsMap.each { String name, org.devocative.devolcano.vo.FieldVO field ->
		if (field.ok && field.hasFVO) {
			String component

			if (field.isOf(Number)) {
				component = """${imp.add(org.devocative.wickomp.form.range.WNumberRangeInput)}("${name}", ${imp.add(field.type)}.class)"""
			} else if (field.isOf(Date)) {
				component = """${imp.add(org.devocative.wickomp.form.range.WDateRangeInput)}("${name}")\n\t\t\t.setTimePartVisible(${field.info.hasTimePart})"""
			} else if (field.isOf(Boolean)) {
				component = """${imp.add(org.devocative.wickomp.form.WBooleanInput)}("${name}")"""
			} else if (field.embedded) {
				component = """${imp.add(org.devocative.wickomp.form.WSelectionInput)}("${name}", ${imp.add(field.mainType)}.list(), true)"""
			} else if (field.association) {
				if (field.listType == "simple") {
					component = """${imp.add(org.devocative.wickomp.form.WSelectionInput)}("${name}", ${service.name.toUncapital()}.get${name.toCapital()}List(), true)"""
				} else {
					throw new RuntimeException("'search' is not implemented: field = ${name}")
				}
			} else {
				component = """${imp.add(org.devocative.wickomp.form.WTextInput)}("${name}")""";
			}

			out << """\t\tfloatTable.add(new ${component}\n\t\t\t.setLabel(new ResourceModel("${commonFields.contains(name) ? "entity" : cls.simpleName}.${name}")));\n"""
		}
	}
%>
		Form<${fvo.name}> form = new Form<>("form", new CompoundPropertyModel<>(filter));
		form.add(floatTable);
		form.add(new DAjaxButton("search", new ResourceModel("label.search"), ${imp.add(params["iconClass"])}.SEARCH) {
			private static final long serialVersionUID = ${(targetVO.fqn + ".DAjaxButton").hashCode()}L;

			@Override
			protected void onSubmit(AjaxRequestTarget target) {
				grid.setEnabled(true);
				grid.loadData(target);
			}
		});
		add(form);

		OColumnList<${cls.simpleName}> columnList = new OColumnList<>();
<%
	cls.allFieldsMap.each { String name, org.devocative.devolcano.vo.FieldVO field ->
		if (field.ok && field.hasList) {
			String cellFormatter = ""

			if (field.isOf(Date)) {
				cellFormatter = "\n\t\t\t"

				if (field.info.hasTimePart) {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ODateFormatter)}.getDateTimeByUserPreference())"
				} else {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ODateFormatter)}.getDateByUserPreference())"
				}

				cellFormatter += """\n\t\t\t.setStyle("direction:ltr")""";
			} else if (field.isOf(Boolean)) {
				cellFormatter = "\n\t\t\t"
				cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.OBooleanFormatter)}.bool())"
			} else if (field.isOf(Number)) {
				cellFormatter = "\n\t\t\t"
				if (field.real) {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ONumberFormatter)}.real())"
				} else {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ONumberFormatter)}.integer())"
				}
				cellFormatter += """\n\t\t\t.setStyle("direction:ltr")""";
			}

			out << """\t\tcolumnList.add(new OPropertyColumn<${cls.simpleName}>(new ResourceModel("${commonFields.contains(name) ? "entity" : cls.simpleName}.${name}"), "${name}")${cellFormatter});\n"""
		}
	}

	if(formJ != null) {
		if(params["ajaxEditColumn"]) {
%>
		columnList.add(new ${imp.add(org.devocative.wickomp.grid.column.link.OAjaxLinkColumn)}<${cls.simpleName}>(new Model<String>(), ${imp.add(params["iconClass"])}.EDIT) {
			private static final long serialVersionUID = ${(targetVO.fqn + ".OAjaxLinkColumn").hashCode()}L;

			@Override
			public void onClick(AjaxRequestTarget target, IModel<${cls.simpleName}> rowData) {
				window.setContent(new ${formJ.name}(window.getContentId(), rowData.getObject()));
				window.show(target);
			}
		}.setField("EDIT"));
<%
		} else {
%>
		columnList.add(new ${imp.add(org.devocative.demeter.web.component.grid.ORESTLinkColumn)}<${cls.simpleName}>(new Model<String>(), ${formJ.name}.class, "${cls.idField.name}", ${imp.add(params["iconClass"])}.EDIT));
<%
		}
	}
%>
		OGrid<${cls.simpleName}> oGrid = new OGrid<>();
		oGrid
			.setColumns(columnList)
			.setMultiSort(false)<commit_msg>supporting ERowMod & OEditAjaxColumn<commit_after><%
	org.devocative.devolcano.vo.ClassVO cls = targetClass
	org.devocative.devolcano.ImportHelper imp = importHelper
	org.devocative.devolcano.ContextVO context = context

	org.devocative.devolcano.GenTargetVO fvo = context.getGenTarget(cls, "FVO")
	org.devocative.devolcano.GenTargetVO iservice = context.getGenTarget(cls, "ServiceI")
	org.devocative.devolcano.GenTargetVO service = context.getGenTarget(cls, "ServiceM")
	org.devocative.devolcano.GenTargetVO formJ = context.getGenTarget(cls, "FormJ")

	List commonFields = ["rowMod", "creationDate", "creatorUser", "modificationDate", "modifierUser", "version"]

	imp.add(cls)
	imp.add(fvo)
	imp.add(iservice)
	if (formJ != null) {
		imp.add(formJ)
	}

	imp.add(javax.inject.Inject)
	imp.add(List)
	imp.add(Collections)

	imp.add(org.devocative.demeter.web.DPage)
	imp.add(org.devocative.demeter.web.component.DAjaxButton)

	imp.add(org.devocative.wickomp.grid.IGridDataSource)
	imp.add(org.devocative.wickomp.grid.WDataGrid)
	imp.add(org.devocative.wickomp.html.WFloatTable)
	imp.add(org.devocative.wickomp.grid.column.OColumnList)
	imp.add(org.devocative.wickomp.grid.column.OPropertyColumn)
	imp.add(org.devocative.wickomp.grid.OGrid)
	imp.add(org.devocative.wickomp.WModel)
	imp.add(org.devocative.wickomp.opt.OSize)
	imp.add(org.devocative.wickomp.grid.WSortField)

	imp.add(org.apache.wicket.markup.html.form.Form)
	imp.add(org.apache.wicket.model.CompoundPropertyModel)
	imp.add(org.apache.wicket.model.ResourceModel)
	imp.add(org.apache.wicket.ajax.AjaxRequestTarget)
	imp.add(org.apache.wicket.model.IModel)
	imp.add(org.apache.wicket.model.Model)
%>
package ${targetVO.pkg};

@IMPORT@

public class ${targetVO.name} extends DPage implements IGridDataSource<${cls.simpleName}> {
	private static final long serialVersionUID = ${targetVO.fqn.hashCode()}L;

	@Inject
	private ${iservice.name} ${service.name.toUncapital()};

	private ${fvo.name} filter;
	private boolean formVisible = true;
	private String[] invisibleFormItems;

	private WDataGrid<${cls.simpleName}> grid;
	private String[] removeColumns;

	private Boolean gridFit;
	private boolean gridEnabled = false;
	private OSize gridHeight = OSize.fixed(500);
	private OSize gridWidth = OSize.percent(100);

	// ------------------------------

	// Panel Call - New Filter
	public ${targetVO.name}(String id) {
		this(id, Collections.<String>emptyList(), new ${fvo.name}());
	}

	// Panel Call - Open Filter
	public ${targetVO.name}(String id, ${fvo.name} filter) {
		this(id, Collections.<String>emptyList(), filter);
	}

	// REST Call - New Filter
	public ${targetVO.name}(String id, List<String> params) {
		this(id, params, new ${fvo.name}());
	}

	// Main Constructor
	private ${targetVO.name}(String id, List<String> params, ${fvo.name} filter) {
		super(id, params);

		this.filter = filter;
	}

	// ------------------------------

	@Override
	protected void onInitialize() {
		super.onInitialize();
<% 	if(params["ajaxEditColumn"] && formJ != null) { %>
		final ${imp.add(org.devocative.wickomp.html.window.WModalWindow)} window = new WModalWindow("window");
		add(window);

		add(new ${imp.add(org.devocative.wickomp.html.WAjaxLink)}("add", ${imp.add(params["iconClass"])}.ADD) {
			private static final long serialVersionUID = ${(targetVO.fqn + ".WAjaxLink").hashCode()}L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				window.setContent(new ${formJ.name}(window.getContentId()));
				window.show(target);
			}
		});
<% } %>
		WFloatTable floatTable = new WFloatTable("floatTable");
		floatTable.setEqualWidth(true);
<%
	cls.allFieldsMap.each { String name, org.devocative.devolcano.vo.FieldVO field ->
		if (field.ok && field.hasFVO) {
			String component

			if (field.isOf(Number)) {
				component = """${imp.add(org.devocative.wickomp.form.range.WNumberRangeInput)}("${name}", ${imp.add(field.type)}.class)"""
			} else if (field.isOf(Date)) {
				component = """${imp.add(org.devocative.wickomp.form.range.WDateRangeInput)}("${name}")\n\t\t\t.setTimePartVisible(${field.info.hasTimePart})"""
			} else if (field.isOf(Boolean)) {
				component = """${imp.add(org.devocative.wickomp.form.WBooleanInput)}("${name}")"""
			} else if (field.embedded) {
				component = """${imp.add(org.devocative.wickomp.form.WSelectionInput)}("${name}", ${imp.add(field.mainType)}.list(), true)"""
			} else if (field.association) {
				if (field.listType == "simple") {
					component = """${imp.add(org.devocative.wickomp.form.WSelectionInput)}("${name}", ${service.name.toUncapital()}.get${name.toCapital()}List(), true)"""
				} else {
					throw new RuntimeException("'search' is not implemented: field = ${name}")
				}
			} else {
				component = """${imp.add(org.devocative.wickomp.form.WTextInput)}("${name}")""";
			}

			String visibility = ""
			if(field.isOf(org.devocative.demeter.entity.ERowMod)) {
				visibility = "\n\t\t\t.setVisible(getCurrentUser().isRoot())"
			}

			out << """\t\tfloatTable.add(new ${component}\n\t\t\t.setLabel(new ResourceModel("${commonFields.contains(name) ? "entity" : cls.simpleName}.${name}"))${visibility});\n"""
		}
	}
%>
		Form<${fvo.name}> form = new Form<>("form", new CompoundPropertyModel<>(filter));
		form.add(floatTable);
		form.add(new DAjaxButton("search", new ResourceModel("label.search"), ${imp.add(params["iconClass"])}.SEARCH) {
			private static final long serialVersionUID = ${(targetVO.fqn + ".DAjaxButton").hashCode()}L;

			@Override
			protected void onSubmit(AjaxRequestTarget target) {
				grid.setEnabled(true);
				grid.loadData(target);
			}
		});
		add(form);

		OColumnList<${cls.simpleName}> columnList = new OColumnList<>();
<%
	cls.allFieldsMap.each { String name, org.devocative.devolcano.vo.FieldVO field ->
		if (field.ok && field.hasList) {
			String cellFormatter = ""

			if (field.isOf(Date)) {
				cellFormatter = "\n\t\t\t"

				if (field.info.hasTimePart) {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ODateFormatter)}.getDateTimeByUserPreference())"
				} else {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ODateFormatter)}.getDateByUserPreference())"
				}

				cellFormatter += """\n\t\t\t.setStyle("direction:ltr")""";
			} else if (field.isOf(Boolean)) {
				cellFormatter = "\n\t\t\t"
				cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.OBooleanFormatter)}.bool())"
			} else if (field.isOf(Number)) {
				cellFormatter = "\n\t\t\t"
				if (field.real) {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ONumberFormatter)}.real())"
				} else {
					cellFormatter += ".setFormatter(${imp.add(org.devocative.wickomp.formatter.ONumberFormatter)}.integer())"
				}
				cellFormatter += """\n\t\t\t.setStyle("direction:ltr")""";
			}

			if(field.isOf(org.devocative.demeter.entity.ERowMod)) {
				out << "\t\tif(getCurrentUser().isRoot()) {\n\t"
			}
			out << """\t\tcolumnList.add(new OPropertyColumn<${cls.simpleName}>(new ResourceModel("${commonFields.contains(name) ? "entity" : cls.simpleName}.${name}"), "${name}")${cellFormatter});\n"""
			if(field.isOf(org.devocative.demeter.entity.ERowMod)) {
				out << "\t\t}\n"
			}
		}
	}

	if(formJ != null) {
		if(params["ajaxEditColumn"]) {
%>
		columnList.add(new ${imp.add(org.devocative.demeter.web.component.grid.OEditAjaxColumn)}<${cls.simpleName}>() {
			private static final long serialVersionUID = ${(targetVO.fqn + ".OEditAjaxColumn").hashCode()}L;

			@Override
			public void onClick(AjaxRequestTarget target, IModel<${cls.simpleName}> rowData) {
				window.setContent(new ${formJ.name}(window.getContentId(), rowData.getObject()));
				window.show(target);
			}
		});
<%
		} else {
%>
		columnList.add(new ${imp.add(org.devocative.demeter.web.component.grid.ORESTLinkColumn)}<${cls.simpleName}>(new Model<String>(), ${formJ.name}.class, "${cls.idField.name}", ${imp.add(params["iconClass"])}.EDIT));
<%
		}
	}
%>
		OGrid<${cls.simpleName}> oGrid = new OGrid<>();
		oGrid
			.setColumns(columnList)
			.setMultiSort(false)
{'fraction_non_alphanumeric': 0.1897255542297306, 'fraction_numerical': 0.0010048357721534886, 'mean_word_length': 4.638810198300283, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1067967', 'n_tokens_mistral': 6103, 'n_tokens_neox': 5599, 'n_words': 770}