private void addCategory(DynamicGridRow rowParent, ReportsCategoryListVo voCategory) { if (voCategory == null) return; DynamicGridRow categoryRow = null; if (rowParent == null) categoryRow = form.dyngrdReports().getRows().newRow(); else categoryRow = rowParent.getRows().newRow(); categoryRow.setValue(voCategory); categoryRow.setSelectable(false); categoryRow.setCollapsedImage(form.getImages().Core.ReportCategory); categoryRow.setExpandedImage(form.getImages().Core.ReportCategory); DynamicGridCell cellName = createCell(categoryRow, getColumn(COLUMN_NAME)); cellName.setValue(voCategory.getName()); if (voCategory.getSubCategoriesIsNotNull() && voCategory.getSubCategories().size() > 0) { categoryRow.setExpanded(true); addSubcategories(categoryRow, voCategory.getSubCategories()); } }
private boolean hasReports(ReportsCategoryListVo reportsCategoryListVo) { if(reportsCategoryListVo.getReportsIsNotNull() && reportsCategoryListVo.getReports().size() > 0) return true; if(reportsCategoryListVo.getSubCategories() == null || reportsCategoryListVo.getSubCategories().size() == 0) return false; int count = reportsCategoryListVo.getSubCategories().size(); for (int i = 0; i < count; i++) { if(hasReports(reportsCategoryListVo.getSubCategories().get(i)) == true) return true; } return false; }
private boolean rowExists(ReportsCategoryListVo voCategory) { if(voCategory == null || voCategory.getID_ReportsCategory() == null) return false; DynamicGridRowCollection rows = form.dyngrdReports().getRows(); for (int i = 0; i < rows.size(); i++) { DynamicGridRow dynamicGridRow = rows.get(i); Object value = dynamicGridRow.getValue(); if (value instanceof ReportsCategoryListVo) { ReportsCategoryListVo voReportsCategory = (ReportsCategoryListVo) value; if( voCategory.getID_ReportsCategory().equals(voReportsCategory.getID_ReportsCategory())) return true; } } return false; }
private DynamicGridRow getReportRow(DynamicGridRowCollection parentRows, ReportListVo voReportList) { if (parentRows == null) return null; for (int i = 0; i < parentRows.size(); i++) { DynamicGridRow dynamicGridRow = parentRows.get(i); Object value = dynamicGridRow.getValue(); if (value instanceof ReportsCategoryListVo) { ReportsCategoryListVo voReportsCategory = (ReportsCategoryListVo) value; if (voReportsCategory.getReports().indexOf(voReportList) >= 0) { return dynamicGridRow; } } if (dynamicGridRow.getRows() != null && dynamicGridRow.getRows().size() > 0) { DynamicGridRow row = getReportRow(dynamicGridRow.getRows(), voReportList); if (row != null) return row; } } return null; }
private void addParentCategories(ReportsCategoryListVoCollection voReportsCategoryColl) { for (int i = 0; i < voReportsCategoryColl.size(); i++) { if(hasReports(voReportsCategoryColl.get(i))) { // Display the parent category - (when parent = null) if (voReportsCategoryColl.get(i).getParentCategory() == null) addCategory(null, voReportsCategoryColl.get(i)); else { try { ReportsCategoryListVo rootCat = domain.getRootCategory(voReportsCategoryColl.get(i).getParentCategory()); if(hasReports(rootCat)) addCategory(null, rootCat); } catch (DomainInterfaceException e) { e.printStackTrace(); engine.showMessage("Error getting root category for '" + voReportsCategoryColl.get(i).getName() + "' !\n" + e.toString()); } } } } }
private void addCategory(DynamicGridRow rowParent, ReportsCategoryListVo voCategory) { if (voCategory == null) return; if(rowExists(voCategory)) return; DynamicGridRow categoryRow = null; if (rowParent == null) categoryRow = form.dyngrdReports().getRows().newRow(); else categoryRow = rowParent.getRows().newRow(); categoryRow.setValue(voCategory); categoryRow.setSelectable(false); categoryRow.setCollapsedImage(form.getImages().Core.ReportCategory); categoryRow.setExpandedImage(form.getImages().Core.ReportCategory); DynamicGridCell cellName = createCell(categoryRow, getColumn(COLUMN_NAME)); cellName.setValue(voCategory.getName()); if (voCategory.getSubCategoriesIsNotNull() && voCategory.getSubCategories().size() > 0) { categoryRow.setExpanded(true); addSubcategories(categoryRow, voCategory.getSubCategories()); } }