private void expandParentNode(grdThermalRow selectedRow) { if (selectedRow.getValue() instanceof ThermalShortVo == false ) return; form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ThermalShortVo)selectedRow.getValue())); if (form.getLocalContext().getSelectedParentInstance() == null ) return; ThermalVo 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.getThermalActivity() != null) { selectedRow.setValue(voParentInstance); selectedRow.setExpanded(true); populateChildNodes(selectedRow, voParentInstance.getThermalActivity()); } populateParentInstanceControls(voParentInstance); }
private void populateChildCollectionFromGrid(ThermalVo voThermal) { if (form.grdThermal().getValue() == null) return; if (voThermal.getThermalActivity() == null) voThermal.setThermalActivity(new ThermalActivityVoCollection()); GenForm.grdThermalRow parentRow = form.grdThermal().getValue() instanceof ThermalShortVo || form.grdThermal().getValue() instanceof ThermalVo ? form.grdThermal().getSelectedRow() : form.grdThermal().getSelectedRow().getParentRow(); if (parentRow.getRows().size() > 0 ) voThermal.getThermalActivity().clear(); for (int i=0; i < parentRow.getRows().size(); i++) { voThermal.getThermalActivity().add((ThermalActivityVo) 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.grdThermal().getValue() instanceof ThermalVo) { populateParentInstanceControls((ThermalVo) form.grdThermal().getValue()); } if(form.grdThermal().getValue() instanceof ThermalShortVo) { form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ThermalShortVo) form.grdThermal().getValue())); populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); populateChildNodes(form.grdThermal().getSelectedRow(),form.getLocalContext().getSelectedParentInstance().getThermalActivity()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if(form.grdThermal().getValue() instanceof ThermalActivityVo) { GenForm.grdThermalRow parentRow = form.grdThermal().getSelectedRow().getParentRow(); populateParentInstanceControls((ThermalVo) parentRow.getValue()); form.getLocalContext().setSelectedParentInstance((ThermalVo) parentRow.getValue()); form.getLocalContext().setSelectedChildInstance((ThermalActivityVo) form.grdThermal().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.grdThermal().getValue() instanceof ThermalShortVo) form.ctnTherapy().lyrThermal().showtabHeader(); else if(form.grdThermal().getValue() instanceof ThermalVo) form.ctnTherapy().lyrThermal().showtabHeader(); else if (form.grdThermal().getValue() instanceof ThermalActivityVo) form.ctnTherapy().lyrThermal().showtabDetails(); //enableParentControls(false); } else { if (form.getLocalContext().getUpdatingParent().equals(Boolean.TRUE)) form.ctnTherapy().lyrThermal().showtabHeader(); else form.ctnTherapy().lyrThermal().showtabDetails(); if (form.getLocalContext().getSelectedParentInstanceIsNotNull() && (form.getLocalContext().getSelectedParentInstance().getID_ThermalIsNotNull())) enableParentControls(false); //on update else enableParentControls(true); //new record } }
private void populateParentNode(ThermalShortVo voThermalShort) { GenForm.grdThermalRow parRow = form.grdThermal().getRows().newRow(); parRow.setcolThermalTypeParent(voThermalShort.getAuthoringDateTime().toString()+ " - " + voThermalShort.getAuthoringCP().toString()); parRow.setValue(voThermalShort); if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull() && voThermalShort.getClinicalContact().getID_ClinicalContact().equals (form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact())) { form.grdThermal().setValue(voThermalShort); expandParentNode(parRow); } }
private boolean newParentNode(ThermalVo voNewParent) { if (voNewParent == null) return true; ThermalShortVo voParentShort = new ThermalShortVo(); voParentShort.setAuthoringCP(form.ctnTherapy().lyrThermal().tabHeader().qmbAuthoringCP().getValue()); voParentShort.setAuthoringDateTime(form.ctnTherapy().lyrThermal().tabHeader().dtimAuthoring().getValue()); voParentShort.setClinicalContact(voNewParent.getClinicalContact()); String[] errors = voParentShort.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } GenForm.grdThermalRow parentRow = form.grdThermal().getRows().newRow(); parentRow.setcolThermalTypeParent(voParentShort.getAuthoringDateTime().toString()+ " - " + voParentShort.getAuthoringCP().toString()); parentRow.setValue(voParentShort); parentRow.setBackColor(Color.Beige); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); parentRow.setExpanded(true); form.grdThermal().setValue(voParentShort); return true; }
private void updateInstance() { form.getLocalContext().setUpdatingParent(new Boolean(form.grdThermal().getValue() instanceof ThermalShortVo)); form.setMode(FormMode.EDIT); if (form.grdThermal().getValue() instanceof ThermalActivityVo) { ThermalActivityVo voCachedChild = (ThermalActivityVo) form.grdThermal().getValue(); if ( voCachedChild.getID_ThermalActivity() == null) { populateChildInstanceControls(voCachedChild); } } }
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.grdThermal().getValue() instanceof ThermalShortVo) form.getContextMenus().getGenericGridUpdateItem().setVisible(false); else if (form.grdThermal().getValue() instanceof ThermalActivityVo) form.getContextMenus().getGenericGridUpdateItem().setText("Edit Thermal 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 Thermal 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.grdThermal().getSelectedRowIndex()>=0 && form.grdThermal().getValue() instanceof ThermalActivityVo) || (form.getMode().equals(FormMode.EDIT) && form.grdThermal().getValue() instanceof ThermalActivityVo && ((ThermalActivityVo)form.grdThermal().getValue()).getID_ThermalActivity() == 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 Thermal 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.grdThermal().getValue() instanceof ThermalActivityVo && ((ThermalActivityVo)form.grdThermal().getValue()).getID_ThermalActivity() == null); } else { form.getContextMenus().hideAllGenericGridMenuItems(); } }
private ThermalVo getParentFromDomain(ThermalShortVo voThermalShort) { //return domain.getThermalDetailsByClinicalContact(voThermalShort.getClinicalContact()); return domain.getThermal(voThermalShort);// WDEV-13649 }