public void TestFilterDefWithParameters()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          paramName    = TestUtil.GetRandomString();
            string          paramValue   = TestUtil.GetRandomString();
            string          filterDefXml = string.Format(
                @"
                        <filter>
                            <filterProperty name=""prop1"" label=""label1"" />
                            <filterProperty name=""prop2"" label=""label2"" >
                                <parameter name=""{0}"" value=""{1}"" />
                            </filterProperty>
                        </filter>
	            "    , paramName, paramValue);

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.IsNotNull(filterDef);
            Assert.AreEqual(2, filterDef.FilterPropertyDefs.Count);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs[1].Parameters.Count);
            Assert.IsTrue(filterDef.FilterPropertyDefs[1].Parameters.ContainsKey(paramName));
            Assert.AreEqual(paramValue, filterDef.FilterPropertyDefs[1].Parameters[paramName]);

            //---------------Tear Down -------------------------
        }
        public void TestFilterDef()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          propName     = TestUtil.GetRandomString();
            string          label        = TestUtil.GetRandomString();
            string          filterDefXml = string.Format(
                @"
                        <filter>
                            <filterProperty name=""{0}"" label=""{1}"" />
                        </filter>
	            "    , propName, label);

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------

            Assert.IsNotNull(filterDef);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs.Count);
            Assert.AreEqual(propName, filterDef.FilterPropertyDefs[0].PropertyName);
            Assert.AreEqual(label, filterDef.FilterPropertyDefs[0].Label);
            Assert.AreEqual("StringTextBoxFilter", filterDef.FilterPropertyDefs[0].FilterType);
            Assert.AreEqual("Habanero.Faces.Base", filterDef.FilterPropertyDefs[0].FilterTypeAssembly);
            Assert.AreEqual(FilterClauseOperator.OpLike, filterDef.FilterPropertyDefs[0].FilterClauseOperator);
            Assert.AreEqual(0, filterDef.FilterPropertyDefs[0].Parameters.Count);
            Assert.AreEqual(FilterModes.Filter, filterDef.FilterMode);
            Assert.AreEqual(0, filterDef.Columns);


            //---------------Tear Down -------------------------
        }
Exemple #3
0
        /// <summary>
        /// Creates the object using the data that has been read in using
        /// LoadFromReader(). This method needs to be implemented by the
        /// sub-class.
        /// Creates the FilterDef with the propDefs, columns and filtermode.
        /// <returns></returns>
        /// </summary>
        /// <returns>Returns the object created</returns>
        protected override object Create()
        {
            IFilterDef filterDef = _defClassFactory.CreateFilterDef(_propertyDefs);

            filterDef.Columns    = _columns;
            filterDef.FilterMode = _filterMode;
            return(filterDef);
        }
 private void SetupLayoutManager(IFilterControl filterControl, IFilterDef filterDef)
 {
     if (filterDef.Columns <= 0) return;
     GridLayoutManager layoutManager = new GridLayoutManager(filterControl.FilterPanel, _controlFactory);
     int rows = filterDef.FilterPropertyDefs.Count/filterDef.Columns + 1;
     int cols = filterDef.Columns * 2;
     layoutManager.SetGridSize(rows, cols);
     filterControl.LayoutManager = layoutManager;
 }
Exemple #5
0
        private void SetupLayoutManager(IFilterControl filterControl, IFilterDef filterDef)
        {
            if (filterDef.Columns <= 0)
            {
                return;
            }
            GridLayoutManager layoutManager = new GridLayoutManager(filterControl.FilterPanel, _controlFactory);
            int rows = filterDef.FilterPropertyDefs.Count / filterDef.Columns + 1;
            int cols = filterDef.Columns * 2;

            layoutManager.SetGridSize(rows, cols);
            filterControl.LayoutManager = layoutManager;
        }
Exemple #6
0
        /// <summary>
        /// Clears and populates the given <see cref="IFilterControl"/> using the <see cref="FilterDef"/> given.
        /// </summary>
        /// <param name="filterDef">The <see cref="FilterDef"/> defining what filter fields are required</param>
        /// <param name="filterControl">The <see cref="IFilterControl"/> to place the filter controls on.</param>
        public void BuildFilterControl(IFilterDef filterDef, IFilterControl filterControl)
        {
            filterControl.FilterControls.Clear();
            filterControl.FilterMode = filterDef.FilterMode;

            SetupLayoutManager(filterControl, filterDef);

            foreach (IFilterPropertyDef filterPropertyDef in filterDef.FilterPropertyDefs)
            {
                var customFilter = BuildCustomFilter(filterPropertyDef);
                filterControl.AddCustomFilter(filterPropertyDef.Label, customFilter);
            }
        }
        /// <summary>
        /// Clears and populates the given <see cref="IFilterControl"/> using the <see cref="FilterDef"/> given.
        /// </summary>
        /// <param name="filterDef">The <see cref="FilterDef"/> defining what filter fields are required</param>
        /// <param name="filterControl">The <see cref="IFilterControl"/> to place the filter controls on.</param>
        public void BuildFilterControl(IFilterDef filterDef, IFilterControl filterControl)
        {
            filterControl.FilterControls.Clear();
            filterControl.FilterMode = filterDef.FilterMode;

            SetupLayoutManager(filterControl, filterDef);
			
            foreach (IFilterPropertyDef filterPropertyDef in filterDef.FilterPropertyDefs)
            {
            	var customFilter = BuildCustomFilter(filterPropertyDef);
            	filterControl.AddCustomFilter(filterPropertyDef.Label, customFilter);
            }

        }
        public void Test_Invalid_NoProperties()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            const string    filterDefXml = @"<filter />";

            //---------------Execute Test ----------------------
            try
            {
                IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);
                Assert.Fail("An error should have occurred because a filter requires at least on filterProperty.");

                //---------------Test Result -----------------------
            }
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("The 'filter' node does not conform", ex.Message);
            }
        }
        public void TestFilterClauseOperator()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter>
                            <filterProperty name=""prop1"" label=""label1"" operator=""OpEquals""/>
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.AreEqual(FilterClauseOperator.OpEquals, filterDef.FilterPropertyDefs[0].FilterClauseOperator);

            //---------------Tear Down -------------------------
        }
        public void TestColumns()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter columns=""3"">
                            <filterProperty name=""prop1"" label=""label1"" />
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.AreEqual(3, filterDef.Columns);

            //---------------Tear Down -------------------------
        }
        public void TestFilterMode_Search()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            string          filterDefXml =
                @"
                        <filter filterMode=""Search"">
                            <filterProperty name=""prop1"" label=""label1"" />
                        </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------

            Assert.AreEqual(FilterModes.Search, filterDef.FilterMode);
            //---------------Tear Down -------------------------
        }
        public void TestFilterDef_AlternateFormat()
        {
            //---------------Set up test pack-------------------
            XmlFilterLoader loader       = CreateXmlFilterLoader();
            const string    filterDefXml = @"
                            <filter>
			                    <filterProperty name=""name""  label=""label"" >
			                    </filterProperty>
			                </filter>
	            "    ;

            //---------------Execute Test ----------------------
            IFilterDef filterDef = loader.LoadFilterDef(filterDefXml);

            //---------------Test Result -----------------------
            Assert.IsNotNull(filterDef);
            Assert.AreEqual(1, filterDef.FilterPropertyDefs.Count);
            //---------------Tear Down -------------------------
        }
Exemple #13
0
        public void TestFilterDef()
        {
            //---------------Set up test pack-------------------
            string gridDefXml = string.Format(
                @"
					<grid>
                        <filter>
                            <filterProperty name=""{0}"" label=""{1}"" />
                        </filter>
						<column heading=""testheading1"" property=""{0}""  />
					</grid>"                    , "testpropname1", "testlabel1");

            //---------------Execute Test ----------------------
            IUIGrid    def       = loader.LoadUIGridDef(gridDefXml);
            IFilterDef filterDef = def.FilterDef;

            //---------------Test Result -----------------------

            Assert.IsNotNull(filterDef);
            Assert.AreEqual(1, def.Count);
            //---------------Tear Down -------------------------
        }
        public IFilterDef CreateUIFilter(IClassDef classDef)
        {
            if (classDef == null)
            {
                throw new ArgumentNullException("classDef");
            }
            var filterPropertyDefs = new List <IFilterPropertyDef>();

            foreach (var propDef in classDef.PropDefcol)
            {
                if (propDef.IsPartOfObjectIdentity())
                {
                    continue;
                }
                if (propDef.IsPropForeignKey())
                {
                    continue;
                }
                filterPropertyDefs.Add(CreateUIFilterProperty(propDef));
            }
            IFilterDef filterDef = _factory.CreateFilterDef(filterPropertyDefs);

            return(filterDef);
        }