BuildFilterControl() public method

Creates an IFilterControl using the IControlFactory and creates all the filter controls defined by the FilterDef given.
public BuildFilterControl ( Habanero.BO.ClassDefinition.FilterDef filterDef ) : IFilterControl
filterDef Habanero.BO.ClassDefinition.FilterDef The to use in creation.
return IFilterControl
Exemplo n.º 1
0
 /// <summary>
 /// Initialises the grid with a given alternate UI definition for the class
 ///  </summary>
 /// <param name="classDef">The Classdef used to initialise the grid</param>
 /// <param name="uiGridDef">The <see cref="IUIGrid"/> that specifies the grid </param>
 /// <param name="uiDefName">The name of the <see cref="IUIGrid"/></param>
 public void InitialiseGrid(IClassDef classDef, IUIGrid uiGridDef, string uiDefName)
 {
     if (classDef == null)
     {
         throw new ArgumentNullException("classDef");
     }
     if (uiDefName == null)
     {
         throw new ArgumentNullException("uiDefName");
     }
     if (uiGridDef == null)
     {
         throw new ArgumentNullException("uiGridDef");
     }
     if (uiGridDef.FilterDef != null)
     {
         FilterControlBuilder builder = new FilterControlBuilder(_controlFactory);
         builder.BuildFilterControl(uiGridDef.FilterDef, Grid.FilterControl);
         ShowFilterControl();
     }
     else if (!FilterControlSetupProgramatically())
     {
         HideFilterControl();
     }
     _gridBaseInitialiser.InitialiseGrid(classDef, uiGridDef, uiDefName);
 }
        public void Test_BuildFilterControl_Simple()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            string propName = TestUtil.GetRandomString();
            FilterDef filterDef = CreateFilterDef_1Property(propName);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);
            filterControl.Size = new Size(1000, 800);
            //---------------Test Result -----------------------
            Assert.IsNotNull(filterControl);
            Assert.AreEqual(1, filterControl.Controls.Count, "Always has GroupBox");
            Assert.AreEqual(FilterModes.Filter, filterControl.FilterMode);
            Assert.AreEqual(1, filterControl.FilterControls.Count);
            Assert.IsNotNull(filterControl.GetChildControl(propName));
            Assert.IsInstanceOf(typeof (StringTextBoxFilter), filterControl.FilterControls[0]);
            IPanel filterPanel = filterControl.FilterPanel;
            Assert.AreEqual(2, filterPanel.Controls.Count);
            IControlHabanero label = filterControl.FilterPanel.Controls[0];
            Assert.IsInstanceOf(typeof(ILabel), label);
            Assert.Greater(label.Width, 0);
            Assert.Greater(label.Height, 0);
            Assert.Greater(label.Left, 0);
            Assert.IsTrue(label.Visible);
            IControlHabanero textBox = filterControl.FilterPanel.Controls[1];
            Assert.IsInstanceOf(typeof(ITextBox), textBox);
            //Assert.AreEqual(label.Top, textBox.Top);
            //Assert.GreaterOrEqual(textBox.Left, label.Left + label.Width);
        }
        public void Test_BuildFilterControl_Simple_CheckLayout()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            string propName = TestUtil.GetRandomString();
            FilterDef filterDef = CreateFilterDef_1Property(propName);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);
            filterControl.Size = new Size(1000, 800);
            //---------------Test Result -----------------------
            IControlHabanero label = filterControl.FilterPanel.Controls[0];
            IControlHabanero textBox = filterControl.FilterPanel.Controls[1];
            Assert.AreEqual(label.Top, textBox.Top);
            Assert.GreaterOrEqual(textBox.Left, label.Left + label.Width);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initialises the grid with a given alternate UI definition for the class
 ///  </summary>
 /// <param name="classDef">The Classdef used to initialise the grid</param>
 /// <param name="uiGridDef">The <see cref="IUIGrid"/> that specifies the grid </param>
 /// <param name="uiDefName">The name of the <see cref="IUIGrid"/></param>
 public void InitialiseGrid(IClassDef classDef, IUIGrid uiGridDef, string uiDefName)
 {
     if (classDef == null) throw new ArgumentNullException("classDef");
     if (uiDefName == null) throw new ArgumentNullException("uiDefName");
     if (uiGridDef == null) throw new ArgumentNullException("uiGridDef");
     if (uiGridDef.FilterDef != null)
    {
         FilterControlBuilder builder = new FilterControlBuilder(_controlFactory);
         builder.BuildFilterControl(uiGridDef.FilterDef, Grid.FilterControl);
         ShowFilterControl();
     }
     else if (!FilterControlSetupProgramatically())
     {
         HideFilterControl();
     }
     _gridBaseInitialiser.InitialiseGrid(classDef, uiGridDef, uiDefName);
 }
        public void Test_ResizeControl_ShouldPlaceTextBoxInCorrectPosition()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            string propName = TestUtil.GetRandomString();
            FilterDef filterDef = CreateFilterDef_1Property(propName);
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);
            //---------------Assert Precondition----------------
            IPanel filterPanel = filterControl.FilterPanel;
            Assert.AreEqual(2, filterPanel.Controls.Count);
            IControlHabanero label = filterControl.FilterPanel.Controls[0];
            Assert.IsInstanceOf(typeof(ILabel), label);
            Assert.GreaterOrEqual(label.Width, 0);
            Assert.GreaterOrEqual(label.Height, 0);
            Assert.GreaterOrEqual(label.Left, 0);
            Assert.IsTrue(label.Visible);
            IControlHabanero textBox = filterControl.FilterPanel.Controls[1];
            Assert.IsInstanceOf(typeof(ITextBox), textBox);
            Assert.LessOrEqual(textBox.Left, label.Left + label.Width);

            //---------------Execute Test ----------------------
            filterControl.Size = new Size(999, 800);
            filterControl.Width = 1000;
            //---------------Test Result -----------------------

            Assert.GreaterOrEqual(textBox.Left, label.Left + label.Width);
        }
        public void Test_BuildFilterControl_Layout_1OrMoreColumns_UsesGridLayout_MoreThanOneRow()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            FilterDef filterDef = CreateFilterDef_3Properties();

            //---------------Execute Test ----------------------
            filterDef.Columns = 2;
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof (GridLayoutManager), filterControl.LayoutManager);
            GridLayoutManager layoutManager = (GridLayoutManager) filterControl.LayoutManager;
            Assert.AreEqual(4, layoutManager.Columns.Count);
            Assert.AreEqual(2, layoutManager.Rows.Count);
        }
        public void Test_BuildFilterControl_Layout_0Columns_UsesFlowLayout()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            FilterDef filterDef = CreateFilterDef_1Property();

            //---------------Execute Test ----------------------
            filterDef.Columns = 0;
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof (FlowLayoutManager), filterControl.LayoutManager);
        }
        public void Test_BuildFilterControl_FilterMode_Search()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            FilterDef filterDef = CreateFilterDef_1Property();

            //---------------Execute Test ----------------------
            filterDef.FilterMode = FilterModes.Search;
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(FilterModes.Search, filterControl.FilterMode);
        }
        public void Test_BuildFilterControl_PreviouslyBuiltFilterControl()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            FilterDef filterDef = CreateFilterDef_1Property();

            //---------------Execute Test ----------------------
            IFilterControl filterControl = GetControlFactory().CreateFilterControl();
            builder.BuildFilterControl(filterDef, filterControl);
            builder.BuildFilterControl(filterDef, filterControl);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, filterControl.FilterControls.Count);
        }
        public void Test_BuildFilterControl_AlreadyConstructedFilterControl()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            const string filterType = "Habanero.Faces.Test.Base.FilterController.SimpleFilterStub";
            const string filterTypeAssembly = "Habanero.Faces.Test.Base";
            FilterDef filterDef = CreateFilterDef_1PropertyWithTypeAndAssembly(filterType, filterTypeAssembly);

            //---------------Execute Test ----------------------
            IFilterControl filterControl = GetControlFactory().CreateFilterControl();
            builder.BuildFilterControl(filterDef, filterControl);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, filterControl.FilterControls.Count);
            Assert.IsInstanceOf(typeof (SimpleFilterStub), filterControl.FilterControls[0]);
        }
        public void Test_BuildFilterControl_TwoProperties_DifferentTypes()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            FilterDef filterDef = CreateFilterDef_2PropertiesWithType("StringTextBoxFilter", "BoolCheckBoxFilter");

            //---------------Execute Test ----------------------
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(2, filterControl.FilterControls.Count);
            Assert.IsInstanceOf(typeof (StringTextBoxFilter), filterControl.FilterControls[0]);
            Assert.IsInstanceOf(typeof (ITextBox), filterControl.FilterControls[0].Control);
            Assert.IsInstanceOf(typeof (BoolCheckBoxFilter), filterControl.FilterControls[1]);
            Assert.IsInstanceOf(typeof (ICheckBox), filterControl.FilterControls[1].Control);
        }
        public void Test_BuildFilterControl_TwoProperties_CheckPropNames()
        {
            //---------------Set up test pack-------------------
            FilterControlBuilder builder = new FilterControlBuilder(GetControlFactory());
            string testprop1 = TestUtil.GetRandomString();
            string testprop2 = TestUtil.GetRandomString();
            FilterDef filterDef = CreateFilterDef_2Properties(testprop1, testprop2);

            //---------------Execute Test ----------------------
            IFilterControl filterControl = builder.BuildFilterControl(filterDef);

            //---------------Test Result -----------------------
            Assert.AreEqual(2, filterControl.FilterControls.Count);
            Assert.AreEqual(testprop1, filterControl.FilterControls[0].PropertyName);
            Assert.AreEqual(testprop2, filterControl.FilterControls[1].PropertyName);
            Assert.AreEqual(FilterClauseOperator.OpEquals, filterControl.FilterControls[0].FilterClauseOperator);
            Assert.AreEqual(FilterClauseOperator.OpLike, filterControl.FilterControls[1].FilterClauseOperator);
        }