private void populateChildCollectionFromGrid(RehabilitationVo voRehab) { if (form.grdActivity().getValue() == null) return; if (voRehab.getRehabActivity() == null) voRehab.setRehabActivity(new RehabilitationActivityVoCollection()); GenForm.grdActivityRow parentRow = form.grdActivity().getValue() instanceof RehabilitationShortVo ? form.grdActivity().getSelectedRow() : form.grdActivity().getSelectedRow().getParentRow(); if (parentRow.getRows().size() > 0 ) voRehab.getRehabActivity().clear(); for (int i=0; i < parentRow.getRows().size(); i++) { voRehab.getRehabActivity().add((RehabilitationActivityVo) parentRow.getRows().get(i).getValue()); } }
private void newChildInstance() { clearChildInstanceControls(); form.getLocalContext().setSelectedChildInstance(null); loadEquipment(); loadAdaptation(); loadTechnique(); if (form.grdActivity().getValue() instanceof RehabilitationShortVo) form.grdActivity().setValue(form.grdActivity().getSelectedRow().getValue()); else if (form.grdActivity().getValue() instanceof RehabilitationActivityVo) form.grdActivity().setValue(form.grdActivity().getSelectedRow().getParentRow().getValue()); }
private boolean newParentNode(RehabilitationVo voNewParent) { if (voNewParent == null) return true; RehabilitationShortVo voParentShort = new RehabilitationShortVo(); voParentShort.setAuthoringCP(form.ctnDetail().qmbAuthoringCP().getValue()); voParentShort.setAuthoringDateTime(form.ctnDetail().dtimAuthoring().getValue()); voParentShort.setClinicalContact(voNewParent.getClinicalContact()); String[] errors = voParentShort.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } GenForm.grdActivityRow parentRow = form.grdActivity().getRows().newRow(); StringBuffer text = new StringBuffer(); if(voParentShort.getAuthoringDateTime()!=null){ text.append(voParentShort.getAuthoringDateTime().toString()); text.append(" "); } if(voParentShort.getAuthoringCP()!=null) text.append(voParentShort.getAuthoringCP().toString()); parentRow.setColDateTime(text.toString()); parentRow.setValue(voParentShort); parentRow.setBackColor(Color.Beige); form.getLocalContext().setGoldenInstanceSelected(new Boolean(true)); parentRow.setExpanded(true); form.grdActivity().setValue(voParentShort); return true; }
private void populateParentNode(RehabilitationShortVo voRehabParent) { GenForm.grdActivityRow parRow = form.grdActivity().getRows().newRow(); parRow.setColDateTime(voRehabParent.getAuthoringDateTime().toString()); //parRow.setTooltip(voRehabParent.getCareContext().toString()); parRow.setValue(voRehabParent); form.grdActivity().setValue(voRehabParent); expandParentNode(parRow); }
/** * @calls the Domain Get for the selected node.. * */ private void expandParentNode(GenForm.grdActivityRow selectedRow) { if (selectedRow.getValue() instanceof RehabilitationShortVo == false ) return; form.getLocalContext().setSelectedParentInstance(getParentFromDomain((RehabilitationShortVo) selectedRow.getValue())); form.getLocalContext().setParentInstance(form.getLocalContext().getSelectedParentInstance()); //wdev-13599 if (form.getLocalContext().getSelectedParentInstance() == null ) return; RehabilitationVo voParentInstance = form.getLocalContext().getSelectedParentInstance(); if(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull() && (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.getRehabActivityIsNotNull()) { selectedRow.setExpanded(true); populateChildNodes(selectedRow, voParentInstance.getRehabActivity()); } populateParentInstanceControls(voParentInstance); }
private RehabilitationVo getParentFromDomain(RehabilitationShortVo voRehabShort) { if(engine.isRIEMode()) //wdev-13599 return domain.getRehabById(voRehabShort); else return domain.getRehabVo(voRehabShort.getClinicalContact()); }
private void updateInstance() { form.getLocalContext().setUpdatingParent(new Boolean(form.grdActivity().getValue() instanceof RehabilitationShortVo || form.grdActivity().getValue() instanceof RehabilitationVo)); form.setMode(FormMode.EDIT); if (form.grdActivity().getValue() instanceof RehabilitationActivityVo) { RehabilitationActivityVo voCachedChild = (RehabilitationActivityVo) form.grdActivity().getValue(); if (voCachedChild.getID_RehabilitationActivity() == null) { populateChildInstanceControlsForUpdate(voCachedChild); } } }
private void removeChild() { RehabilitationShortVo voParent = (RehabilitationShortVo) form.grdActivity().getSelectedRow().getParentRow().getValue(); form.grdActivity().removeSelectedRow(); form.grdActivity().setValue(voParent); updateContextMenusState(); }
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.grdActivity().getValue() == null || ((form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getGoldenInstanceSelected().equals(Boolean.FALSE)))) { form.ctnDetail().dtimAuthoring().setValue(null); form.ctnDetail().qmbAuthoringCP().setValue(null); form.ctnDetail().qmbAuthoringCP().clear(); newParentInstance(); } if (form.grdActivity().getValue() instanceof RehabilitationShortVo) { //new instance for golden parent node meaning add a new child newChildInstance(); } else if (form.grdActivity().getValue() instanceof RehabilitationActivityVo) { // New instance has been invoked with a child node selected. newChildInstance(); } form.setMode(FormMode.EDIT); }
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.grdActivity().getValue() instanceof RehabilitationShortVo) form.getContextMenus().getGenericGridUpdateItem().setVisible(false); else if (form.grdActivity().getValue() instanceof RehabilitationActivityVo) form.getContextMenus().getGenericGridUpdateItem().setText("Edit Rehab Activity"); // If the golden node is selected we can now only add child nodes so set the menu text accordingly. form.getContextMenus().getGenericGridAddItem().setText("Add Rehab Activity"); // Only show the update menu if the user has selected an item to update. form.getContextMenus().getGenericGridUpdateItem().setVisible((form.getMode().equals(FormMode.VIEW)&& form.grdActivity().getSelectedRowIndex()>=0) && form.grdActivity().getValue() instanceof RehabilitationActivityVo || (form.getMode().equals(FormMode.EDIT) && form.grdActivity().getValue() instanceof RehabilitationActivityVo && ((RehabilitationActivityVo)form.grdActivity().getValue()).getID_RehabilitationActivity() == 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 Rehabilitation"); form.getContextMenus().getGenericGridUpdateItem().setVisible(false); } } form.getContextMenus().getGenericGridAddItem().setVisible(form.getMode().equals(FormMode.VIEW)); form.getContextMenus().getGenericGridRemoveItem().setVisible(form.getMode().equals(FormMode.EDIT) && form.grdActivity().getValue() instanceof RehabilitationActivityVo && ((RehabilitationActivityVo)form.grdActivity().getValue()).getID_RehabilitationActivity() == null); } else { form.getContextMenus().hideAllGenericGridMenuItems(); } }
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.grdActivity().getValue() instanceof RehabilitationShortVo) { form.getLocalContext().setSelectedParentInstance(getParentFromDomain((RehabilitationShortVo) form.grdActivity().getValue())); form.getLocalContext().setParentInstance(form.getLocalContext().getSelectedParentInstance()); //wdev-13599 populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); //add activities if not added already populateChildNodes(form.grdActivity().getSelectedRow(),form.getLocalContext().getSelectedParentInstance().getRehabActivity()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if(form.grdActivity().getValue() instanceof RehabilitationActivityVo) { //wdev-13599 form.getLocalContext().setParentInstance(null); //---------- form.getLocalContext().setSelectedChildInstance((RehabilitationActivityVo) form.grdActivity().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(); if (form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull()) { form.btnNew().setVisible(false); form.btnUpdate().setVisible(false); } }