private void populateChildNode(gridTherapyRow childRow, ComplementaryTherapyDetailsVo voComplementaryTherapyDetail) { if (voComplementaryTherapyDetail == null) return; if(voComplementaryTherapyDetail.getComplementaryTherapy() != null) childRow.setColComplementary(voComplementaryTherapyDetail.getComplementaryTherapy().toString()); if(voComplementaryTherapyDetail.getContraIndicationsChecked() != null) childRow.setColContraChecked(voComplementaryTherapyDetail.getContraIndicationsChecked().booleanValue()); if(voComplementaryTherapyDetail.getTreatment() != null) childRow.setColTreatment(voComplementaryTherapyDetail.getTreatment()); childRow.setValue(voComplementaryTherapyDetail); //if not saved then set the colour if(voComplementaryTherapyDetail.getID_ComplementaryTherapyDetails() == null) childRow.setTextColor(Color.Red); }
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.ctnTherapy().lyrTherapy().tabDetails().setHeaderVisible(form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo); } else { // In edit mode, make the details tab visible if a hierarchy item has been selected and we're not // editing a parent. form.ctnTherapy().lyrTherapy().tabDetails().setHeaderVisible(form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)); setAddApplyCaption(); } enableDetailsButtons(); }
private void newChildNode(ComplementaryTherapyDetailsVo voComplementaryTherapyDetail) { if (form.getLocalContext().getSelectedChildInstance() != null) return; if (voComplementaryTherapyDetail.countFieldsWithValue() > 1) { String strErrors[] = voComplementaryTherapyDetail.validate(); if(strErrors != null && strErrors.length > 0) { engine.showErrors(strErrors); return; } promoteChild(voComplementaryTherapyDetail); clearChildInstanceControls(); } }
private void newInstance() { //New instance has been invoked for a parent instance with no current selection made OR // with a parent that is not the Golden node.. if (form.gridTherapy().getValue() == null || ((form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getGoldenInstanceSelected().equals(Boolean.FALSE)))) { newParentInstance(); } // New instance has been invoked with a child node selected. if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) { newChildInstance(); } form.setMode(FormMode.EDIT); }
private void setUpdatedChild() { //Straight child update - Select the currently being updated child as the one so show - post save if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) { form.getLocalContext().setUpdatedChild((ComplementaryTherapyDetailsVo) form.gridTherapy().getValue()); } else { // Find the most recently added child if (form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)) { form.getLocalContext().getSelectedParentInstance().getComplementaryTherapy().sort(); form.getLocalContext().setUpdatedChild( form.getLocalContext().getSelectedParentInstance().getComplementaryTherapy().get( form.getLocalContext().getSelectedParentInstance().getComplementaryTherapy().size() - 1)); } } }
private void populateChildCollectionFromGrid(ComplementaryTherapyTreatmentVo voComplementaryTherapy) { if (form.gridTherapy().getValue() == null) return; if (voComplementaryTherapy.getComplementaryTherapy() == null) voComplementaryTherapy.setComplementaryTherapy(new ComplementaryTherapyDetailsVoCollection()); GenForm.gridTherapyRow parentRow = form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo || form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo ? form.gridTherapy().getSelectedRow() : form.gridTherapy().getSelectedRow().getParentRow(); if (parentRow.getRows().size() > 0 ) voComplementaryTherapy.getComplementaryTherapy().clear(); for (int i=0; i < parentRow.getRows().size(); i++) { voComplementaryTherapy.getComplementaryTherapy().add((ComplementaryTherapyDetailsVo) parentRow.getRows().get(i).getValue()); } }
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; } if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo) { populateParentInstanceControls((ComplementaryTherapyTreatmentVo) form.gridTherapy().getValue()); } else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo) { form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ComplementaryTherapyTreatmentShortVo) form.gridTherapy().getValue())); populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); populateChildNodes(form.gridTherapy().getSelectedRow(),form.getLocalContext().getSelectedParentInstance().getComplementaryTherapy()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) { GenForm.gridTherapyRow parentRow = form.gridTherapy().getSelectedRow().getParentRow(); populateParentInstanceControls((ComplementaryTherapyTreatmentVo) parentRow.getValue()); form.getLocalContext().setSelectedParentInstance((ComplementaryTherapyTreatmentVo) parentRow.getValue()); form.getLocalContext().setSelectedChildInstance((ComplementaryTherapyDetailsVo) form.gridTherapy().getValue()); populateChildInstanceControls(form.getLocalContext().getSelectedChildInstance()); } if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull()) form.getLocalContext().setGoldenInstanceSelected(new Boolean(form.getLocalContext().getSelectedParentInstance().getClinicalContact().getID_ClinicalContact().equals(form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact()))); updateControlsState(); }
private void populateChildInstanceControls(ComplementaryTherapyDetailsVo voComDetail) { if (voComDetail == null ) return; form.ctnTherapy().lyrTherapy().tabDetails().cmbComplementary().setValue(voComDetail.getComplementaryTherapy()); form.ctnTherapy().lyrTherapy().tabDetails().chkContra().setValue(voComDetail.getContraIndicationsChecked().booleanValue()); form.ctnTherapy().lyrTherapy().tabDetails().txtTreatment().setValue(voComDetail.getTreatment()); form.getLocalContext().setSelectedChildInstance(voComDetail); }
private void showHeaderOrDetailsTab() { if (form.getMode().equals(FormMode.VIEW)) { // In view mode just show the selected node if (form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo) form.ctnTherapy().lyrTherapy().showtabHeader(); else if(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentVo) form.ctnTherapy().lyrTherapy().showtabHeader(); else if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) form.ctnTherapy().lyrTherapy().showtabDetails(); enableParentControls(false); } else { if (form.getLocalContext().getUpdatingParent().equals(Boolean.TRUE)) form.ctnTherapy().lyrTherapy().showtabHeader(); else form.ctnTherapy().lyrTherapy().showtabDetails(); if (form.getLocalContext().getSelectedParentInstanceIsNotNull() && (form.getLocalContext().getSelectedParentInstance().getID_ComplementaryTherapyTreatmentIsNotNull())) enableParentControls(false); //on update else enableParentControls(true); //new record } }
private void setAddApplyCaption() { form.ctnTherapy().lyrTherapy().tabDetails().btnOk().setText("Add"); if (form.getLocalContext().getSelectedChildInstance() == null && (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo)) form.ctnTherapy().lyrTherapy().tabDetails().btnOk().setText("Apply"); }
private void promoteChild(ComplementaryTherapyDetailsVo voComplementaryTherapyDetail) { if (voComplementaryTherapyDetail == null) return; GenForm.gridTherapyRow childRow = null; form.gridTherapy().setValue(form.getLocalContext().getSelectedParentInstance());//maybe need new localcontext if(form.gridTherapy().getValue() != null) { if(form.gridTherapy().getSelectedRow().getValue() instanceof ComplementaryTherapyDetailsVo) childRow = form.gridTherapy().getSelectedRow().getParentRow().getRows().newRow(); else childRow = form.gridTherapy().getSelectedRow().getRows().newRow(); } populateChildNode(childRow, voComplementaryTherapyDetail); }
private void populateChildInstanceData(ComplementaryTherapyDetailsVo voComplementaryTherapyDetail) { voComplementaryTherapyDetail.setComplementaryTherapy(form.ctnTherapy().lyrTherapy().tabDetails().cmbComplementary().getValue()); voComplementaryTherapyDetail.setTreatment(form.ctnTherapy().lyrTherapy().tabDetails().txtTreatment().getValue()); voComplementaryTherapyDetail.setContraIndicationsChecked(new Boolean(form.ctnTherapy().lyrTherapy().tabDetails().chkContra().getValue())); }
private void updateInstance() { form.getLocalContext().setUpdatingParent(new Boolean(form.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo)); form.setMode(FormMode.EDIT); if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) { ComplementaryTherapyDetailsVo voCachedChild = (ComplementaryTherapyDetailsVo) form.gridTherapy().getValue(); if ( voCachedChild.getID_ComplementaryTherapyDetails() == null) { populateChildInstanceControls(voCachedChild); } } }