public static void install(String app) { ChoosePropertiesTagUtil.application = app; Table table = el("propertiesTable"); HTMLCollection<TableRow> rows = table.rows; for (int i = 1; i < rows.length; i++) { // row 0 is placeholder TableRow row = rows.$get(i); Image openClose = NextGlobalJs.next.dom.getInnerElementById(row, "openCloseBtn"); openClose.style.visibility = "hidden"; if (i + 1 < rows.length) { TableRow row2 = rows.$get(i + 1); String row1Property = row.getAttribute("data-forProperty"); String row2Property = row2.getAttribute("data-forProperty"); if (row2Property.length() > row1Property.length() + 1) { String base = row2Property.substring(0, row1Property.length() + 1); if (base.equals(row1Property + ".")) { openClose.style.visibility = ""; colapseGroup(row, rows); installOpenCloseButton(openClose, row, rows); } } } } }
private static void colapseGroup(TableRow row, HTMLCollection<TableRow> rows) { for (int i = row.rowIndex + 1; i < rows.length; i++) { TableRow row2 = rows.$get(i); String row1Property = row.getAttribute("data-forProperty"); String row2Property = row2.getAttribute("data-forProperty"); if (row2Property.length() > row1Property.length() + 1) { String base = row2Property.substring(0, row1Property.length() + 1); if (base.equals(row1Property + ".")) { row2.style.display = "none"; } else { break; } } } }
private static void openGroup(TableRow row, HTMLCollection<TableRow> rows) { String row1Property = row.getAttribute("data-forProperty"); for (int i = row.rowIndex + 1; i < rows.length; i++) { TableRow row2 = rows.$get(i); Image openClose = NextGlobalJs.next.dom.getInnerElementById(row2, "openCloseBtn"); openClose.src = application + OPEN; openClose.setAttribute("data-open", "false"); String row2Property = row2.getAttribute("data-forProperty"); if (row2Property.length() > row1Property.length() + 1) { String base = row2Property.substring(0, row1Property.length() + 1); if (base.equals(row1Property + ".")) { if (row2Property.substring(base.length()).indexOf('.') > 0) { continue; } row2.style.display = ""; } else { break; } } else { break; } } }