private void putItemHierarchyOnGrid(PlanOfAction action, grdPlanRow row) { row.setcolPlan(action); if(action.getChildInstances().size()>0) for (int i = 0; i < action.getChildInstances().size(); i++) { putItemHierarchyOnGrid((PlanOfAction)action.getChildInstances().get(i), row.getRows().newRow()); } }
private boolean hasSelectedItem(PlanOfAction action, PlanOfAction primaryPlan, PlanOfActionCollection secondaryPlans) { form.getLocalContext().setHasSelectedItem(false); searchHierarchyForPrimary( action, primaryPlan); if(!form.getLocalContext().getHasSelectedItem()) for (int i = 0; i < secondaryPlans.size(); i++) searchHierarchyForSecondary( action, secondaryPlans.get(i)); return form.getLocalContext().getHasSelectedItem(); }
private void searchHierarchyForSecondary(PlanOfAction action, PlanOfAction secondaryPlan) { if(action.getChildInstances().size()==0) if(action.equals(secondaryPlan)) form.getLocalContext().setHasSelectedItem(true); for (int j = 0; j < action.getChildInstances().size(); j++) { searchHierarchyForSecondary( (PlanOfAction)action.getChildInstances().get(j), secondaryPlan); } }
private void searchHierarchyForPrimary(PlanOfAction action, PlanOfAction primaryPlan) { if(action.getChildInstances().size()==0) if(action.equals(primaryPlan)) form.getLocalContext().setHasSelectedItem(true); for (int j = 0; j < action.getChildInstances().size(); j++) { searchHierarchyForPrimary( (PlanOfAction)action.getChildInstances().get(j), primaryPlan); } }
private boolean searchTreeHierarchy(grdPlanRow rowParent, PlanOfAction planOfAction, boolean bPrimary) { boolean bPlanFound = false; if(rowParent.getRows().size()==0) if(rowParent.getcolPlan().equals(planOfAction)){ if(bPrimary) rowParent.setcolPrimary(true); else rowParent.setcolSecondary(true); return true; } for (int j = 0; j < rowParent.getRows().size(); j++) { grdPlanRow rowChild = rowParent.getRows().get(j); if(rowChild.getcolPlan().equals(planOfAction)){ if(bPrimary) rowChild.setcolPrimary(true); else rowChild.setcolSecondary(true); return true; } bPlanFound = searchTreeHierarchy(rowChild, planOfAction, bPrimary); } return bPlanFound; }
private void populatePrimaryPlanFromGrd(grdPlanRowCollection collRows) { if(collRows==null) collRows = form.grdPlan().getRows(); PlanOfAction primaryPlanOfAction = new PlanOfAction(); for (int i = 0; i < collRows.size(); i++) { GenForm.grdPlanRow rowParent = collRows.get(i); if(rowParent.getRows().size()==0){ if(rowParent.getcolPrimary()){ primaryPlanOfAction = rowParent.getcolPlan(); if(form.getLocalContext().getPrimaryPlanOfAction()==null) form.getLocalContext().setPrimaryPlanOfAction(primaryPlanOfAction); i = collRows.size(); } } else{ for (int j = 0; j < rowParent.getRows().size(); j++) { GenForm.grdPlanRow rowChild = rowParent.getRows().get(j); if(rowChild.getcolPrimary()){ primaryPlanOfAction = rowChild.getcolPlan(); if(form.getLocalContext().getPrimaryPlanOfAction()==null) form.getLocalContext().setPrimaryPlanOfAction(primaryPlanOfAction); j = rowParent.getRows().size(); } if(rowChild.getRows().size()>0){ populatePrimaryPlanFromGrd(rowChild.getRows()); } } } } }
private PlanOfActionCollection populateSecondaryPlansFromGrd(grdPlanRowCollection collRows, PlanOfActionCollection voPlanOfActionColl) { if(collRows==null) collRows = form.grdPlan().getRows(); for (int i = 0; i < collRows.size(); i++) { GenForm.grdPlanRow rowParent = collRows.get(i); if(rowParent.getRows().size()==0){ if(rowParent.getcolSecondary()) voPlanOfActionColl.add(rowParent.getcolPlan()); } else{ for (int j = 0; j < rowParent.getRows().size(); j++) { GenForm.grdPlanRow rowChild = rowParent.getRows().get(j); PlanOfAction voPlanOfAction = rowChild.getcolPlan(); if(rowChild.getcolSecondary()) voPlanOfActionColl.add(voPlanOfAction); if(rowChild.getRows().size()>0) populateSecondaryPlansFromGrd(rowChild.getRows(), voPlanOfActionColl); } } } return voPlanOfActionColl; }
private void populatePlanGrid(PlanOfAction primaryPlan, PlanOfActionCollection secondaryPlans) { form.grdPlan().getRows().clear(); PlanOfActionCollection collPlanOfAction = form.getLocalContext().getPlanOfActionCollection(); for (int i = 0; i < collPlanOfAction.size(); i++) { if(collPlanOfAction.get(i).getParent()==null && hasSelectedItem(collPlanOfAction.get(i), primaryPlan, secondaryPlans)) putItemHierarchyOnGrid(collPlanOfAction.get(i), form.grdPlan().getRows().newRow()); } setSelectedPlans(); form.grdPlan().expandAll(); }