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 populateParentNode(ComplementaryTherapyTreatmentShortVo voComTherapyTreatShort) { GenForm.gridTherapyRow parRow = form.gridTherapy().getRows().newRow(); parRow.setColComplementary(voComTherapyTreatShort.getAuthoringDateTime().toString()+ " - " + voComTherapyTreatShort.getAuthoringCP().toString()); parRow.setValue(voComTherapyTreatShort); if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull() && voComTherapyTreatShort.getClinicalContact().getID_ClinicalContact().equals (form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact())) { form.gridTherapy().setValue(voComTherapyTreatShort); expandParentNode(parRow); } }
private void expandParentNode(gridTherapyRow selectedRow) { if (selectedRow.getValue() instanceof ComplementaryTherapyTreatmentShortVo == false ) return; form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ComplementaryTherapyTreatmentShortVo) selectedRow.getValue())); if (form.getLocalContext().getSelectedParentInstance() == null ) return; ComplementaryTherapyTreatmentVo voParentInstance = form.getLocalContext().getSelectedParentInstance(); if(voParentInstance.getClinicalContact().getID_ClinicalContact().equals (form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact())) { // If this is the Golden Node then we'll colour it golden (ok then beige). form.getLocalContext().setGoldenInstanceFound(new Boolean(true)); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); selectedRow.setBackColor(Color.Beige); } if (voParentInstance.getComplementaryTherapy() != null) { selectedRow.setValue(voParentInstance); selectedRow.setExpanded(true); populateChildNodes(selectedRow, voParentInstance.getComplementaryTherapy()); } populateParentInstanceControls(voParentInstance); }
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 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 boolean newParentNode(ComplementaryTherapyTreatmentVo voNewParent) { if (voNewParent == null) return true; ComplementaryTherapyTreatmentShortVo voParentShort = new ComplementaryTherapyTreatmentShortVo(); voParentShort.setAuthoringCP(form.ctnTherapy().lyrTherapy().tabHeader().qmbAuthoringCP().getValue()); voParentShort.setAuthoringDateTime(form.ctnTherapy().lyrTherapy().tabHeader().dtimAuthoringDateTime().getValue()); voParentShort.setClinicalContact(voNewParent.getClinicalContact()); String[] errors = voParentShort.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } GenForm.gridTherapyRow parentRow = form.gridTherapy().getRows().newRow(); parentRow.setColComplementary(voParentShort.getAuthoringDateTime().toString()+ " - " + voParentShort.getAuthoringCP().toString()); parentRow.setValue(voParentShort); parentRow.setBackColor(Color.Beige); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); parentRow.setExpanded(true); form.gridTherapy().setValue(voParentShort); return true; }
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); } } }
private ComplementaryTherapyTreatmentVo getParentFromDomain(ComplementaryTherapyTreatmentShortVo voComplementaryTherapyTreatShort) { return domain.getComplementaryTherapy(voComplementaryTherapyTreatShort); }
private void updateContextMenusState() { if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull()) { if(form.getLocalContext().getGoldenInstanceSelected().booleanValue()) { // 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.gridTherapy().getValue() instanceof ComplementaryTherapyTreatmentShortVo) form.getContextMenus().getGenericGridUpdateItem().setVisible(false); else if (form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) form.getContextMenus().getGenericGridUpdateItem().setText("Edit Complementary Detail"); // If the golden node is selected we can now only add child nodes so set the menu text accordingly. form.getContextMenus().getGenericGridAddItem().setText("Add Complementary Detail"); // Only show the update menu if the user has selected an item to update. form.getContextMenus().getGenericGridUpdateItem().setVisible((form.getMode().equals(FormMode.VIEW)&& form.gridTherapy().getSelectedRowIndex()>=0 && form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo) || (form.getMode().equals(FormMode.EDIT) && form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo && ((ComplementaryTherapyDetailsVo)form.gridTherapy().getValue()).getID_ComplementaryTherapyDetails() == null)); } else { // If the golden instance has been found but NOT selected hide the context menu's if (form.getLocalContext().getGoldenInstanceFound().booleanValue() == true) { form.getContextMenus().hideAllGenericGridMenuItems(); return; } else { form.getContextMenus().getGenericGridAddItem().setText("New Complementary Therapy"); form.getContextMenus().getGenericGridUpdateItem().setVisible(false); } } form.getContextMenus().getGenericGridAddItem().setVisible(form.getMode().equals(FormMode.VIEW)); form.getContextMenus().getGenericGridRemoveItem().setVisible(form.getMode().equals(FormMode.EDIT) && form.gridTherapy().getValue() instanceof ComplementaryTherapyDetailsVo && ((ComplementaryTherapyDetailsVo)form.gridTherapy().getValue()).getID_ComplementaryTherapyDetails() == null); } else { form.getContextMenus().hideAllGenericGridMenuItems(); } }