Beispiel #1
0
 /// <summary>
 ///   get the last control that had the focus in the current mgdata
 /// </summary>
 /// <returns> reference to the last focused control</returns>
 internal static MgControl getLastFocusedControl()
 {
     return((MgControl)_lastFocusedControls.getCtrl(MGDataCollection.Instance.currMgdID));
 }
Beispiel #2
0
        /// <summary>
        ///   update the display
        /// </summary>
        public void updateDisplay(String displayValue, bool isNull, bool calledFromEditSet)
        {
            MgControlBase ctrl;
            MgControlBase ctrlValue     = null;
            String        defaultValue  = "" + GuiConstants.DEFAULT_VALUE_INT;
            String        savedValue    = null;
            String        savePrevValue = null;

            bool savedIsNull    = false;
            bool savePrevIsNull = false;

            if (_controls != null)
            {
                MgControlBase firstControlValue   = null;
                bool          foundControlValue   = false;
                MgControlBase savedControlToFocus = ControlToFocus;
                for (int i = 0;
                     i < _controls.getSize();
                     i++)
                {
                    ctrl = _controls.getCtrl(i);
                    if (calledFromEditSet)
                    {
                        savedValue    = ctrl.Value;
                        savePrevValue = ctrl.getPrevValueInArray(ctrl.getDisplayLine(true));

                        savedIsNull    = ctrl.IsNull;
                        savePrevIsNull = ctrl.getPrevIsNullsInArray();
                    }
                    if (!ctrl.getForm().inRefreshDisplay())
                    {
                        ctrl.resetPrevVal(); // force update of the display
                        ctrl.SetAndRefreshDisplayValue(displayValue, isNull, false);

                        // Even if the control that contains the correct value is found we don't break the loop because:
                        // (1) we need to refresh all the controls
                        // (2) the last control that was focus with the correct value is the one that should be checked
                        if (!ctrl.isRadio())
                        {
                            if (ctrlValue == null ||
                                ctrl.Value != null && !ctrl.Value.Equals(defaultValue) &&
                                (ctrl == savedControlToFocus))
                            {
                                ctrlValue = ctrl;
                            }
                        }
                        else
                        {
                            //Fixed bug#:780359, for radio control select the correct control
                            //if not found any ctrlvalue(the control that was in focuse)
                            //select the first control with the correct value if not exist select the first control.

                            //a. save the first control (with or without the correct value)
                            if (firstControlValue == null)
                            {
                                firstControlValue = ctrl;
                            }
                            if (ctrl.Value != null && !ctrl.Value.Equals(defaultValue))
                            {
                                //b. save the first control with the correct value
                                if (!foundControlValue)
                                {
                                    firstControlValue = ctrl;
                                    foundControlValue = true;
                                }
                                //c.save the control that belong to the focus control
                                if (ctrl == savedControlToFocus)
                                {
                                    ctrlValue = ctrl;
                                }
                                else if (ctrlValue == null)
                                {
                                    ctrlValue = firstControlValue;
                                }
                            }
                        }
                    }

                    if (calledFromEditSet)
                    {
                        ctrl.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull);
                    }
                }

                // if there was a control that had the correct value and this field is linked to more than one
                // control then it means that the control that contained the correct value might have been reset by
                // one of its siblings so there is a need to refresh its value again.
                if (ctrlValue != null)
                {
                    if (calledFromEditSet)
                    {
                        savedValue    = ctrlValue.Value;
                        savePrevValue = ctrlValue.getPrevValueInArray(ctrlValue.getDisplayLine(true));

                        savedIsNull    = ctrlValue.IsNull;
                        savePrevIsNull = ctrlValue.getPrevIsNullsInArray();
                    }

                    //save the control that belong to the value on the field.

                    ControlToFocus = ctrlValue;
                    if (_controls.getSize() > 1)
                    {
                        ctrlValue.resetPrevVal(); // force update of the display
                        ctrlValue.SetAndRefreshDisplayValue(displayValue, isNull, false);
                    }

                    if (calledFromEditSet)
                    {
                        ctrlValue.setValueForEditSet(savedValue, savePrevValue, savedIsNull, savePrevIsNull);
                        ctrlValue.getForm().getTask().setLastParkedCtrl(ctrlValue);
                        Manager.SetFocus(ctrlValue, -1);
                    }

                    //Fixed bug#:465616, when the control is the current focus control then refresh his focus control
                    if (ctrlValue.isRadio() && ctrlValue == ctrlValue.getForm().getTask().getLastParkedCtrl())
                    {
                        Manager.SetFocus(ctrlValue, -1);
                    }
                }
            }
        }