/** * Invoked when the user clicks OK to add a new element to the child array * Basically we update the hierarchy grid with the newly added details * clearing the control to facilitate new input. We then update the local * context variable with the new child * */ private boolean newChildRow(HandlingMovementDetailVo voHandlingMovementDetail) { if (form.getLocalContext().getSelectedChildInstance() != null) return false; if (voHandlingMovementDetail.countFieldsWithValue() > 1) { String strErrors[] = voHandlingMovementDetail.validate(); if (strErrors != null && strErrors.length > 0) { engine.showErrors(strErrors); return true; } promoteChild(voHandlingMovementDetail); clearChildInstanceControls(); } return false; }
private void setUpdatedChild() { // Straight child update - Select the currently being updated child as // the one so show - post save if (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo) { form.getLocalContext().setUpdatedChild((HandlingMovementDetailVo) form.dyngrdDetails().getValue()); } else { // Find the most recently added child if (form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)) { if(form.getLocalContext().getSelectedParentInstance() != null && form.getLocalContext().getSelectedParentInstance().getDetailsIsNotNull()) { if(form.getLocalContext().getSelectedParentInstance().getDetails().size() > 0) { form.getLocalContext().getSelectedParentInstance().getDetails().sort(); form.getLocalContext().setUpdatedChild(form.getLocalContext().getSelectedParentInstance().getDetails().get(form.getLocalContext().getSelectedParentInstance().getDetails().size() - 1)); } } } } }
private void populateChildCollectionFromGrid(PatientHandlingMovementVo voPatHandMovement) { if (form.dyngrdDetails().getValue() == null) return; if (voPatHandMovement.getDetails() == null) voPatHandMovement.setDetails(new HandlingMovementDetailVoCollection()); DynamicGridRow parentRow = form.dyngrdDetails().getValue() instanceof PatientHandlingMovementVo ? form.dyngrdDetails().getSelectedRow() : form.dyngrdDetails().getSelectedRow().getParent(); if (parentRow.getRows().size() > 0) voPatHandMovement.getDetails().clear(); for (int i = 0; i < parentRow.getRows().size(); i++) { voPatHandMovement.getDetails().add((HandlingMovementDetailVo) parentRow.getRows().get(i).getValue()); } }
private void showHeaderOrDetailsTab() { if (form.getMode().equals(FormMode.VIEW)) { // In view mode just show the selected node if (form.dyngrdDetails().getValue() instanceof PatientHandlingMovementVo) form.ctnHandling().lyrDetails().showtabHeader(); else if (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo) form.ctnHandling().lyrDetails().showtabDetails(); else form.ctnHandling().lyrDetails().showtabEmpty(); } else { if (form.getLocalContext().getUpdatingParent().equals(Boolean.TRUE)) form.ctnHandling().lyrDetails().showtabHeader(); else form.ctnHandling().lyrDetails().showtabDetails(); } }
private void setDetailsTabVisibility() { if (form.getMode().equals(FormMode.VIEW)) { // In view mode, make the details tab visible if a detail instance // is selected in the hierarchy grid. form.ctnHandling().lyrDetails().tabDetails().setHeaderVisible(form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo); } else { // In edit mode, make the details tab visible if a hierarchy item // has been selected and we're not // editing a parent. form.ctnHandling().lyrDetails().tabDetails().setHeaderVisible(form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)); setAddApplyCaption(); } enableDetailsButtons(); }
private void updateInstance() { form.getLocalContext().setUpdatingParent(new Boolean(form.dyngrdDetails().getValue() instanceof PatientHandlingMovementVo)); if (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo) { HandlingMovementDetailVo voCachedChild = (HandlingMovementDetailVo) form.dyngrdDetails().getValue(); if (voCachedChild.getID_HandlingMovementDetail() == null) { populateChildInstanceControls(voCachedChild); } } form.setMode(FormMode.EDIT); }
private void getSelectedInstance() { // In update mode we can select nodes without displaying anything but // the context // menus can change based on what's selected so we need to update them if (form.getMode().equals(FormMode.EDIT)) { updateContextMenusState(); return; } // expand the selected parent if (form.dyngrdDetails().getValue() instanceof PatientHandlingMovementVo) { form.getLocalContext().setSelectedParentInstance((PatientHandlingMovementVo) form.dyngrdDetails().getValue()); populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo) { form.getLocalContext().setSelectedParentInstance((PatientHandlingMovementVo) form.dyngrdDetails().getSelectedRow().getParent().getValue()); form.getLocalContext().setSelectedChildInstance((HandlingMovementDetailVo) form.dyngrdDetails().getValue()); populateChildInstanceControls(form.getLocalContext().getSelectedChildInstance()); } updateControlsState(); }
private void populateChildInstanceControls(HandlingMovementDetailVo voHandlingMovementDetail) { if (voHandlingMovementDetail == null) return; form.ctnHandling().lyrDetails().tabDetails().cmbMovement().setValue(voHandlingMovementDetail.getMovement()); form.ctnHandling().lyrDetails().tabDetails().chklistMechEquip().setValues(voHandlingMovementDetail.getMechanicalEquipmentIsNotNull() ? voHandlingMovementDetail.getMechanicalEquipment() : null); form.ctnHandling().lyrDetails().tabDetails().txtOtherEquip().setValue(voHandlingMovementDetail.getOtherEquipment()); form.ctnHandling().lyrDetails().tabDetails().intNoStaff().setValue(voHandlingMovementDetail.getNoOfStaff()); form.ctnHandling().lyrDetails().tabDetails().txtDetails().setValue(voHandlingMovementDetail.getDetails()); }
private void populateChildInstanceData(HandlingMovementDetailVo voHandlingMovementDetail) { voHandlingMovementDetail.setMovement(form.ctnHandling().lyrDetails().tabDetails().cmbMovement().getValue()); voHandlingMovementDetail.setMechanicalEquipment(form.ctnHandling().lyrDetails().tabDetails().chklistMechEquip().getValues()); voHandlingMovementDetail.setOtherEquipment(form.ctnHandling().lyrDetails().tabDetails().txtOtherEquip().getValue()); voHandlingMovementDetail.setNoOfStaff(form.ctnHandling().lyrDetails().tabDetails().intNoStaff().getValue()); voHandlingMovementDetail.setDetails(form.ctnHandling().lyrDetails().tabDetails().txtDetails().getValue()); }
private void promoteChild(HandlingMovementDetailVo voEUltrasoundTreatment) { if (voEUltrasoundTreatment == null) return; DynamicGridRow childRow = form.dyngrdDetails().getSelectedRow().getRows().newRow(); populateChildRow(childRow, voEUltrasoundTreatment); }
private void setAddApplyCaption() { form.ctnHandling().lyrDetails().tabDetails().btnOk().setText("Add"); if (form.getLocalContext().getSelectedChildInstance() == null && (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo)) form.ctnHandling().lyrDetails().tabDetails().btnOk().setText("Apply"); }
private void updateContextMenusState() { if (form.dyngrdDetails().getSelectedRow() != null) { // If the golden instance is currently selected we change the text // of the update context menu // based on whether a parent or child node is selected in the grid. if (form.dyngrdDetails().getValue() instanceof PatientHandlingMovementVo) form.getContextMenus().getGenericGridUpdateItem().setText("Edit Patient Handling Movement"); else if (form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo) form.getContextMenus().getGenericGridUpdateItem().setText("Edit Details"); // If the golden node is selected we can now only add child nodes so // set the menu text accordingly. form.getContextMenus().getGenericGridAddItem().setText("Add Details"); // Only show the update menu if the user has selected an item to // update. form.getContextMenus().getGenericGridUpdateItem().setVisible((form.getMode().equals(FormMode.VIEW) && form.dyngrdDetails().getSelectedRow() != null) || (form.getMode().equals(FormMode.EDIT) && form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo && ((HandlingMovementDetailVo) form.dyngrdDetails().getValue()).getID_HandlingMovementDetail() == null)); } else { form.getContextMenus().getGenericGridAddItem().setText("New Patient Handling Movement"); form.getContextMenus().getGenericGridUpdateItem().setVisible(false); } form.getContextMenus().getGenericGridAddItem().setVisible(form.getGlobalContext().Core.getCurrentCareContextIsNotNull() && form.getMode().equals(FormMode.VIEW)); form.getContextMenus().getGenericGridRemoveItem().setVisible(form.getMode().equals(FormMode.EDIT) && form.dyngrdDetails().getValue() instanceof HandlingMovementDetailVo && ((HandlingMovementDetailVo) form.dyngrdDetails().getValue()).getID_HandlingMovementDetail() == null); }