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.grdHierarchy().getValue() == null || ((form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getGoldenInstanceSelected().equals(Boolean.FALSE)))) { newParentInstance(); } // New instance has been invoked with a child node selected. if (form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo) { newChildInstance(); } form.setMode(FormMode.EDIT); }
/** * 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 newChildNode(ElectrotherapyUltrasoundTreatmentVo voEUltrasoundTreatment) { if (form.getLocalContext().getSelectedChildInstance() != null) return false; if (voEUltrasoundTreatment.countFieldsWithValue() > 1) { String strErrors[] = voEUltrasoundTreatment.validate(validateUIRules()); if(strErrors != null && strErrors.length > 0) { engine.showErrors(strErrors); return true; } promoteChild(voEUltrasoundTreatment); clearChildInstanceControls(); } return false; }
private void setUpdatedChild() { // Straight child update - Select the currently being updated child as the one so show - post save if (form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo) { form.getLocalContext().setUpdatedChild((ElectrotherapyUltrasoundTreatmentVo) form.grdHierarchy().getValue()); } else { // Find the most recently added child if (form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)) { form.getLocalContext().getSelectedParentInstance().getUltrasoundTreatments().sort(); form.getLocalContext().setUpdatedChild( form.getLocalContext().getSelectedParentInstance().getUltrasoundTreatments().get( form.getLocalContext().getSelectedParentInstance().getUltrasoundTreatments().size() - 1)); } } }
private void populateChildNode(GenForm.grdHierarchyRow childRow, ElectrotherapyUltrasoundTreatmentVo voUltraTreat) { if (voUltraTreat == null) return; childRow.setValue(voUltraTreat); if(voUltraTreat.getTarget() != null) childRow.setColTarget(voUltraTreat.getTarget().toString()); if(voUltraTreat.getAreaTreated() != null) childRow.setColAreaTreated(voUltraTreat.getAreaTreated().toString()); if(voUltraTreat.getMuscleAspect() != null) childRow.setColMuscleAspect(voUltraTreat.getMuscleAspect().toString()); if(voUltraTreat.getLaterality() != null) childRow.setColLaterality(voUltraTreat.getLaterality().toString()); childRow.setValue(voUltraTreat); //if not saved then set the colour if(voUltraTreat.getID_ElectrotherapyUltrasoundTreatment() == null) childRow.setTextColor(Color.Red); }
private void populateChildInstanceControls(ElectrotherapyUltrasoundTreatmentVo voUltraTreat) { if (voUltraTreat == null ) return; form.ctnUltra().lyrUltra().tabDetails().cmbTarget().setValue(voUltraTreat.getTarget()); if(voUltraTreat.getAreaTreated() != null) form.ctnUltra().lyrUltra().tabDetails().cmbAreaTreated().newRow(voUltraTreat.getAreaTreated(), voUltraTreat.getAreaTreated().toString()); form.ctnUltra().lyrUltra().tabDetails().cmbAreaTreated().setValue(voUltraTreat.getAreaTreated()); form.ctnUltra().lyrUltra().tabDetails().cmbMuscle().setValue(voUltraTreat.getMuscleAspect()); form.ctnUltra().lyrUltra().tabDetails().cmbLaterality().setValue(voUltraTreat.getLaterality()); form.ctnUltra().lyrUltra().tabDetails().txtComment().setValue(voUltraTreat.getComment()); form.ctnUltra().lyrUltra().tabDetails().cmbWave().setValue(voUltraTreat.getWave()); form.ctnUltra().lyrUltra().tabDetails().cmbPulse().setValue(voUltraTreat.getPulse()); form.ctnUltra().lyrUltra().tabDetails().cmbFreq().setValue(voUltraTreat.getFrequency()); form.ctnUltra().lyrUltra().tabDetails().cmbIntensity().setValue(voUltraTreat.getIntensity()); form.ctnUltra().lyrUltra().tabDetails().intDuration().setValue(voUltraTreat.getDuration()); TreatmentEquipmentConfigVo voTreatmentEquipment = voUltraTreat.getMachineUsed(); form.ctnUltra().lyrUltra().tabDetails().cmbMachine().setValue(voTreatmentEquipment); form.ctnUltra().lyrUltra().tabDetails().txtModel().setValue(voTreatmentEquipment != null ? voTreatmentEquipment.getModel() : null); form.ctnUltra().lyrUltra().tabDetails().txtSerial().setValue(voTreatmentEquipment != null ? voTreatmentEquipment.getSerialNumber(): null); }
private void populateChildCollectionFromGrid(ElectrotherapyUltrasoundVo voElectrotherapyUltrasound) { if (form.grdHierarchy().getValue() == null) return; if (voElectrotherapyUltrasound.getUltrasoundTreatments() == null) voElectrotherapyUltrasound.setUltrasoundTreatments(new ElectrotherapyUltrasoundTreatmentVoCollection()); GenForm.grdHierarchyRow parentRow = form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundShortVo ? form.grdHierarchy().getSelectedRow() : form.grdHierarchy().getSelectedRow().getParentRow(); if (parentRow.getRows().size() > 0 ) voElectrotherapyUltrasound.getUltrasoundTreatments().clear(); for (int i=0; i < parentRow.getRows().size(); i++) { voElectrotherapyUltrasound.getUltrasoundTreatments().add((ElectrotherapyUltrasoundTreatmentVo) parentRow.getRows().get(i).getValue()); } }
private void showHeaderOrDetailsTab() { if (form.getMode().equals(FormMode.VIEW)) { // In view mode just show the selected node if (form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundShortVo) form.ctnUltra().lyrUltra().showtabHeader(); else if (form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo) form.ctnUltra().lyrUltra().showtabDetails(); else form.ctnUltra().lyrUltra().showtabEmpty(); } else { if (form.getLocalContext().getUpdatingParent().equals(Boolean.TRUE)) form.ctnUltra().lyrUltra().showtabHeader(); else form.ctnUltra().lyrUltra().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.ctnUltra().lyrUltra().tabDetails().setHeaderVisible(form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo); } else { // In edit mode, make the details tab visible if a hierarchy item has been selected and we're not // editing a parent. form.ctnUltra().lyrUltra().tabDetails().setHeaderVisible(form.getLocalContext().getSelectedParentInstanceIsNotNull() && form.getLocalContext().getUpdatingParent().equals(Boolean.FALSE)); setAddApplyCaption(); } enableDetailsButtons(); }
private void updateInstance() { form.getLocalContext().setUpdatingParent(Boolean.valueOf(form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundShortVo)); if (form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo) { ElectrotherapyUltrasoundTreatmentVo voCachedChild = (ElectrotherapyUltrasoundTreatmentVo) form.grdHierarchy().getValue(); if ( voCachedChild.getID_ElectrotherapyUltrasoundTreatment() == 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.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundShortVo) { form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ElectrotherapyUltrasoundShortVo) form.grdHierarchy().getValue())); populateParentInstanceControls(form.getLocalContext().getSelectedParentInstance()); form.getLocalContext().setSelectedChildInstance(null); clearChildInstanceControls(); } else if(form.grdHierarchy().getValue() instanceof ElectrotherapyUltrasoundTreatmentVo) { // form.getLocalContext().setSelectedParentInstance(getParentFromDomain((ElectrotherapyUltrasoundShortVo) form.grdHierarchy().getSelectedRow().getParentRow().getValue())); form.getLocalContext().setSelectedChildInstance((ElectrotherapyUltrasoundTreatmentVo) form.grdHierarchy().getValue()); populateChildInstanceControls(form.getLocalContext().getSelectedChildInstance()); } form.getLocalContext().setGoldenInstanceSelected(form.getGlobalContext().Core.getCurrentClinicalContactIsNotNull() ? Boolean.valueOf(form.getLocalContext().getSelectedParentInstance().getClinicalContact().getID_ClinicalContact().equals(form.getGlobalContext().Core.getCurrentClinicalContact().getID_ClinicalContact())) : Boolean.FALSE); updateControlsState(); }