public void FillingCTTest1()
        {
            var productions  = MyLanguageGrammar.ProcessedProductions;
            var controlTable = new ControlTable();

            controlTable.FillByProcessedProductions(productions, FormalNonterminals.EXPRESSION);

            Assert.IsTrue(controlTable.ElementsCount == 24);
        }
Esempio n. 2
0
        public static FieldControl CreateDefaultFieldControl(Field field)
        {
            FieldControl control = null;

            var    choiceSetting        = field.FieldSetting as ChoiceFieldSetting;
            var    longTextSetting      = field.FieldSetting as LongTextFieldSetting;
            var    dateTimeFieldSetting = field.FieldSetting as DateTimeFieldSetting;
            string hint = field.FieldSetting.ControlHint;

            if (!string.IsNullOrEmpty(hint))
            {
                control = CreateFieldControlByHint(hint);
            }
            //choice field?
            else if (choiceSetting != null)
            {
                control = CreateDefaultChoiceControl(choiceSetting);
            }
            //longtext field?
            else if (longTextSetting != null)
            {
                control = CreateDefaultLongTextControl(longTextSetting);
            }
            //datetime field?
            else if (dateTimeFieldSetting != null)
            {
                control = CreateDefaultDateTimeControl(dateTimeFieldSetting);
            }

            //generic way, also a fallback logic if we don't have a field control by now
            if (control == null)
            {
                Type controlType = null;

                if (!ControlTable.TryGetValue(field.FieldSetting.ShortName, out controlType))
                {
                    throw new ApplicationException(String.Concat("Cannot resolve the generic field control by '", field.GetType().FullName, "'"));
                }

                control = (FieldControl)Activator.CreateInstance(controlType);
            }

            if (control == null)
            {
                throw new ApplicationException(string.Concat("Failed to instantiate a field control for field ", field.Name));
            }

            control.FieldName = field.Name;
            control.DoAutoConfigure(field.FieldSetting);

            return(control);
        }
Esempio n. 3
0
        /// <summary>
        ///   set a reference to a control attached to this field
        /// </summary>
        /// <param name = "ctrl">the control which is attached to this field</param>
        public virtual void SetControl(MgControlBase ctrl)
        {
            if (_controls == null)
            {
                _controls = new ControlTable();
            }
            if (!_controls.contains(ctrl))
            {
                _controls.addControl(ctrl);

                //save the first ctrl
                if (_controls.getSize() == 1)
                {
                    ControlToFocus = ctrl;
                }
            }
        }
Esempio n. 4
0
        public IActionResult GetRowsFiltered(string nameTable, string listFilter)
        {
            var filterList = new List <object>();

            try
            {
                List <List <object>[]> table;
                IControlRowsTable      controlTable = new ControlTable();
                if (nameTable.Equals("tableDrugs") || nameTable.Equals("exjvnlpTable"))
                {
                    table = AllTableJvnlp;
                }
                else
                {
                    table = CalcDrugs;
                }

                filterList = controlTable.FilterRows(nameTable, listFilter, table);
            }
            catch (Exception e)
            {
                return(new JsonResult(new { message = e.Message })
                {
                    StatusCode = 500
                });
            }

            var jsonFilterList = JsonConvert.SerializeObject(filterList.Take(VisibleLines));

            return(new JsonResult(new
            {
                filterRowList = jsonFilterList,
                filterListLength = filterList.Take(VisibleLines).Count() - 3,
                filterListViewLength = filterList.Count - 3
            })
            {
                StatusCode = 200
            });
        }
Esempio n. 5
0
        public IActionResult GetRowsNavigate(string nameTable, string nameButton, int idList, string listFilter)
        {
            try
            {
                List <List <object>[]> table;
                IControlRowsTable      controlTable = new ControlTable();
                if (nameTable.Equals("tableDrugs") || nameTable.Equals("exjvnlpTable"))
                {
                    table = AllTableJvnlp;
                }
                else
                {
                    table = CalcDrugs;
                }

                var filterList = controlTable.FilterRows(nameTable, listFilter, table);
                var nextCount  = idList * VisibleLines;
                switch (nameButton)
                {
                case "startlist":
                    idList    = 1;
                    nextCount = 0;
                    break;

                case "nextlist":
                    if (nextCount > filterList.Count)
                    {
                        return(new JsonResult(null));
                    }
                    idList++;
                    break;

                case "prevlist":
                    if (nextCount <= VisibleLines)
                    {
                        return(new JsonResult(null));
                    }

                    idList--;
                    nextCount = (idList - 1) * VisibleLines;
                    break;
                }

                var viewList = filterList.Skip(nextCount).Take(VisibleLines);

                var jsonFilterList = JsonConvert.SerializeObject(viewList);

                return(new JsonResult(new
                {
                    navigateRowList = jsonFilterList,
                    navigateListLength = VisibleLines * (idList - 1) + viewList.Count() - 3,
                    navigateListViewLength = filterList.Count - 3,
                    IdList = idList
                })
                {
                    StatusCode = 200
                });
            }
            catch (Exception e)
            {
                return(new JsonResult(new { message = e.Message })
                {
                    StatusCode = 500
                });
            }
        }