コード例 #1
0
        /// <summary>
        /// Creates an <see cref="IFilterControl"/> using the <see cref="IControlFactory"/> and creates all the filter controls
        /// defined by the <see cref="FilterDef"/> given.
        /// </summary>
        /// <param name="filterDef">The <see cref="FilterDef"/> to use in creation.</param>
        /// <returns>The created <see cref="IFilterControl"/></returns>
        public IFilterControl BuildFilterControl(FilterDef filterDef)
        {
            IFilterControl filterControl = _controlFactory.CreateFilterControl();

            BuildFilterControl(filterDef, filterControl);
            return(filterControl);
        }
コード例 #2
0
        public void TestAddDateFilterDateTimePicker_Composites()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate1           = DateTime.Now;
            DateTime             testDate2           = testDate1.AddDays(1);

            filterControl.AddDateFilterDateTimePicker("test1:", "TestColumn1", testDate1, FilterClauseOperator.OpLessThan, false);
            filterControl.AddDateFilterDateTimePicker("test2:", "TestColumn2", testDate2, FilterClauseOperator.OpLessThan, false);

            //---------------Execute Test ----------------------
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();

            //---------------Test Result -----------------------
            IFilterClause clause1 =
                filterClauseFactory.CreateDateFilterClause("TestColumn1", FilterClauseOperator.OpLessThan, new DateTime(testDate1.Year, testDate1.Month, testDate1.Day));
            IFilterClause clause2 =
                filterClauseFactory.CreateDateFilterClause("TestColumn2", FilterClauseOperator.OpLessThan, new DateTime(testDate2.Year, testDate2.Month, testDate2.Day));
            IFilterClause compClause =
                filterClauseFactory.CreateCompositeFilterClause(clause1, FilterClauseCompositeOperator.OpAnd, clause2);

            Assert.AreEqual(compClause.GetFilterClauseString(), expectedFilterClause);

            //---------------Tear Down -------------------------
        }
コード例 #3
0
        public void Test_DefaultLayoutManager()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();

            //---------------Execute Test ----------------------
            //            IControlHabanero control = factory.CreatePanel();
            IFilterControl ctl = factory.CreateFilterControl();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(FlowLayoutManager), ctl.LayoutManager);
        }
コード例 #4
0
        ///<summary>
        /// Constructs a new instance of a <see cref="ReadOnlyGridControlWin"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public ReadOnlyGridControlWin(IControlFactory controlFactory)
        {
            _controlFactory             = controlFactory;
            _grid                       = new ReadOnlyGridWin();
            FilterControl               = _controlFactory.CreateFilterControl();
            _buttons                    = _controlFactory.CreateReadOnlyGridButtonsControl();
            _readOnlyGridControlManager = new ReadOnlyGridControlManager(this, _controlFactory);
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager borderLayoutManager = new BorderLayoutManagerWin(this, _controlFactory);

            borderLayoutManager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            borderLayoutManager.AddControl(_buttons, BorderLayoutManager.Position.South);
            borderLayoutManager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            FilterMode = FilterModes.Filter;
            Grid.Name  = "GridControl";

            _doubleClickEditsBusinessObject   = false;
            DoubleClickEditsBusinessObject    = true;
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;

            this.OnAsyncOperationStarted += (sender, e) =>
            {
                lock (this)
                {
                    this._inAsyncOperation = true;
                }
                this.Enabled       = false;
                this.UseWaitCursor = true;
                var f = this.FilterControl as Control;
                if (f != null)
                {
                    f.UseWaitCursor = true;              // just to make sure
                }
                this.Cursor = Cursors.WaitCursor;
            };
            this.OnAsyncOperationComplete += (sender, e) =>
            {
                lock (this)
                {
                    this._inAsyncOperation = false;
                }
                this.Enabled       = true;
                this.UseWaitCursor = false;
                var f = this.FilterControl as Control;
                if (f != null)
                {
                    f.UseWaitCursor = false;                 // this is required to work around sometimes coming out of async but the wait cursor is left on the filter
                }
                this.Cursor = Cursors.Default;
            };
        }
コード例 #5
0
        public void Test_FilterModeHidesButtonPanel()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            //---------------Execute Test ----------------------
            IFilterControl ctl = factory.CreateFilterControl();
            //---------------Test Result -----------------------
            Button filterButton = (Button)ctl.FilterButton;

            Assert.IsFalse(filterButton.Parent.Visible);
            //Assert.IsFalse(ctl.ClearButton.Visible);
            //---------------Tear Down -------------------------
        }
コード例 #6
0
        public void Test_SetFilterModeSearchSetsText()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            //---------------Assert Preconditions --------------
            Assert.AreEqual("Filter", ctl.FilterButton.Text);
            //---------------Execute Test ----------------------
            ctl.FilterMode = FilterModes.Search;
            //---------------Test Result -----------------------
            Assert.AreEqual("Search", ctl.FilterButton.Text);
            //---------------Tear Down -------------------------
        }
コード例 #7
0
        public void TestAddDatePicker()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory       = GetControlFactory();
            DateTime        testDate      = DateTime.Now;
            IFilterControl  filterControl = factory.CreateFilterControl();

            //---------------Execute Test ----------------------
            IControlHabanero dtPicker = filterControl.AddDateFilterDateTimePicker("test:", "testcolumn", testDate, FilterClauseOperator.OpGreaterThan, true);

            //---------------Test Result -----------------------
            Assert.IsNotNull(dtPicker);
            Assert.IsTrue(dtPicker is IDateTimePicker);
        }
コード例 #8
0
        public void TestAddDatePicker_NullDefaultValue()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory       = GetControlFactory();
            DateTime        testDate      = DateTime.Now;
            IFilterControl  filterControl = factory.CreateFilterControl();

            //---------------Execute Test ----------------------
            IDateTimePicker dtPicker = filterControl.AddDateFilterDateTimePicker("test:", "testcolumn", null, FilterClauseOperator.OpGreaterThan, true);

            //---------------Test Result -----------------------
            Assert.IsNotNull(dtPicker);
            Assert.AreEqual(null, dtPicker.ValueOrNull);
        }
コード例 #9
0
        public void Test_SetFilterModeSearch_MakesButtonPanelVisible()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory       = GetControlFactory();
            IFilterControl  ctl           = factory.CreateFilterControl();
            Control         buttonControl = ((Button)ctl.FilterButton).Parent;

            //---------------Assert Preconditions --------------
            Assert.IsFalse(buttonControl.Visible);
            //---------------Execute Test ----------------------
            ctl.FilterMode = FilterModes.Search;
            //---------------Test Result -----------------------
            Assert.IsTrue(buttonControl.Visible);
            //---------------Tear Down -------------------------
        }
コード例 #10
0
        public void Test_SetFilterGroupBoxSetsText()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory            = GetControlFactory();
            IFilterControl  ctl                = factory.CreateFilterControl();
            string          groupBoxHeaderText = TestUtil.GetRandomString();

            //---------------Assert Preconditions --------------
            Assert.AreEqual("Filter the Grid", ctl.FilterGroupBox.Text);
            //---------------Execute Test ----------------------
            ctl.HeaderText = groupBoxHeaderText;
            //---------------Test Result -----------------------
            Assert.AreEqual(ctl.HeaderText, ctl.FilterGroupBox.Text);
            Assert.AreEqual(groupBoxHeaderText, ctl.FilterGroupBox.Text);
            //---------------Tear Down -------------------------
        }
コード例 #11
0
        public void TestChangeDateTimePickerAppliesFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory        = GetControlFactory();
            IFilterControl  ctl            = factory.CreateFilterControl();
            IDateTimePicker dateTimePicker = ctl.AddDateFilterDateTimePicker("test", "propname", DateTime.Now, FilterClauseOperator.OpLessThan, true);

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            dateTimePicker.Value = DateTime.Now.AddMonths(-1);
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
コード例 #12
0
        public void TestChangeCheckBoxAppliesFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory  = GetControlFactory();
            IFilterControl  ctl      = factory.CreateFilterControl();
            ICheckBox       checkBox = ctl.AddBooleanFilterCheckBox("test", "propname", false);

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            checkBox.Checked = true;
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
コード例 #13
0
 ///<summary>
 /// Constructs a new instance of a <see cref="EditableGridControlVWG"/>.
 ///</summary>
 ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
 public EditableGridControlVWG(IControlFactory controlFactory)
 {
     if (controlFactory == null) throw new HabaneroArgumentException("controlFactory", 
             "Cannot create an editable grid control if the control factory is null");
     _controlFactory = controlFactory;
     _grid = _controlFactory.CreateEditableGrid();
     _editableGridManager = new EditableGridControlManager(this, controlFactory);
     Buttons = _controlFactory.CreateEditableGridButtonsControl();
     FilterControl = _controlFactory.CreateFilterControl();
     InitialiseButtons();
     InitialiseFilterControl();
     BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(this);
     manager.AddControl(FilterControl, BorderLayoutManager.Position.North);
     manager.AddControl(_grid, BorderLayoutManager.Position.Centre);
     manager.AddControl(Buttons, BorderLayoutManager.Position.South);
     this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
     this.AllowUsersToAddBO = true;
 }
コード例 #14
0
        public void TestChangeDateRangeComboBoxAppliesFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory    factory           = GetControlFactory();
            IFilterControl     ctl               = factory.CreateFilterControl();
            IDateRangeComboBox dateRangeComboBox = ctl.AddDateRangeFilterComboBox("test", "propname", true, true);
            string             text              = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            dateRangeComboBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
コード例 #15
0
        public void Test_WithAddStringFilterTextBoxFilterClause_WhenTextBoxValueChanged_ShouldApplyFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();
            ITextBox        textBox = ctl.AddStringFilterTextBox("test", "propname", FilterClauseOperator.OpEquals);
            string          text    = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            textBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
コード例 #16
0
        public void TestAddDateFilterDateTimePicker_DefaultDateCorrect()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate            = DateTime.Today.AddDays(-2);

            //---------------Execute Test ----------------------
            filterControl.AddDateFilterDateTimePicker("test:", "TestColumn", testDate, FilterClauseOperator.OpGreaterThan, false);
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();
            //---------------Test Result -----------------------
            IFilterClause clause =
                filterClauseFactory.CreateDateFilterClause("TestColumn", FilterClauseOperator.OpGreaterThan, new DateTime(testDate.Year, testDate.Month, testDate.Day));

            Assert.AreEqual(clause.GetFilterClauseString(), expectedFilterClause);
            //---------------Tear Down -------------------------
        }
コード例 #17
0
        public void TestChangeCheckBoxDoesNotApplyFilter_InSearchMode()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            ctl.FilterMode = FilterModes.Search;
            ICheckBox checkBox = ctl.AddBooleanFilterCheckBox("test", "propname", false);

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.AreEqual(FilterModes.Search, ctl.FilterMode);
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            checkBox.Checked = true;
            //---------------Test Result -----------------------
            Assert.IsFalse(filterFired, "The filter event should not have been fired when the text was changed.");
        }
コード例 #18
0
        public void TestChangeComboBoxTextAppliesFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            string[]  optionList = { "one", "two" };
            IComboBox comboBox   = ctl.AddStringFilterComboBox("test", "propname", optionList, true);
            string    text       = optionList[optionList.Length - 1];

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            comboBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsTrue(filterFired, "The filter event should have been fired when the text was changed.");
        }
コード例 #19
0
        public void TestAddDateFilterDateTimePicker_OpLessThanOrEqualToOperator()
        {
            //---------------Set up test pack-------------------
            IControlFactory      factory             = GetControlFactory();
            IFilterClauseFactory filterClauseFactory = new DataViewFilterClauseFactory();
            IFilterControl       filterControl       = factory.CreateFilterControl();
            DateTime             testDate            = DateTime.Today.AddDays(-2);
            IDateTimePicker      dtePicker           = filterControl.AddDateFilterDateTimePicker("test:", "TestColumn", testDate, FilterClauseOperator.OpLessThanOrEqualTo, false);
            //---------------Execute Test ----------------------
            DateTime newDateTime = DateTime.Today.AddDays(+4);

            dtePicker.Value = newDateTime;
            string expectedFilterClause = filterControl.GetFilterClause().GetFilterClauseString();
            //---------------Test Result -----------------------
            IFilterClause clause =
                filterClauseFactory.CreateDateFilterClause("TestColumn", FilterClauseOperator.OpLessThanOrEqualTo, new DateTime(newDateTime.Year, newDateTime.Month, newDateTime.Day));

            Assert.AreEqual(clause.GetFilterClauseString(), expectedFilterClause);

            //---------------Tear Down -------------------------
        }
コード例 #20
0
        public void Test_WithAddStringFilterTextBox_WhenTextBoxValueChanged_AndInSearchMode_ShouldNotApplyFilter()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            ctl.FilterMode = FilterModes.Search;
            ITextBox textBox = ctl.AddStringFilterTextBox("test", "propname");
            string   text    = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.AreEqual(FilterModes.Search, ctl.FilterMode);
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            textBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsFalse(filterFired, "The filter event should not have been fired when the text was changed.");
        }
コード例 #21
0
        ///<summary>
        /// Constructs a new instance of a <see cref="EditableGridControlVWG"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public EditableGridControlVWG(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new HabaneroArgumentException("controlFactory",
                                                    "Cannot create an editable grid control if the control factory is null");
            }
            _controlFactory      = controlFactory;
            _grid                = _controlFactory.CreateEditableGrid();
            _editableGridManager = new EditableGridControlManager(this, controlFactory);
            Buttons              = _controlFactory.CreateEditableGridButtonsControl();
            FilterControl        = _controlFactory.CreateFilterControl();
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(this);

            manager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            manager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            manager.AddControl(Buttons, BorderLayoutManager.Position.South);
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
            this.AllowUsersToAddBO            = true;
        }
コード例 #22
0
        public void TestChangeComboBoxTextDoesNotApplyFilter_InSearchMode()
        {
            //---------------Set up test pack-------------------
            IControlFactory factory = GetControlFactory();
            IFilterControl  ctl     = factory.CreateFilterControl();

            ctl.FilterMode = FilterModes.Search;
            string[]  optionList = { "one", "two" };
            IComboBox comboBox   = ctl.AddStringFilterComboBox("test", "propname", optionList, true);
            string    text       = TestUtil.GetRandomString();

            bool filterFired = false;

            ctl.Filter += delegate { filterFired = true; };
            //---------------Assert Preconditions --------------
            Assert.AreEqual(FilterModes.Search, ctl.FilterMode);
            Assert.IsFalse(filterFired);
            //---------------Execute Test ----------------------
            comboBox.Text = text;
            //---------------Test Result -----------------------
            Assert.IsFalse(filterFired, "The filter event should not have been fired when the text was changed.");
        }
コード例 #23
0
        ///<summary>
        /// Constructs a new instance of a <see cref="ReadOnlyGridControlVWG"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public ReadOnlyGridControlVWG(IControlFactory controlFactory)
        {
            _controlFactory             = controlFactory;
            _grid                       = new ReadOnlyGridVWG();
            _readOnlyGridControlManager = new ReadOnlyGridControlManager(this, _controlFactory);
            FilterControl               = _controlFactory.CreateFilterControl();
            _buttons                    = _controlFactory.CreateReadOnlyGridButtonsControl();
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager borderLayoutManager = new BorderLayoutManagerVWG(this, _controlFactory);

            borderLayoutManager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            borderLayoutManager.AddControl(_buttons, BorderLayoutManager.Position.South);
            borderLayoutManager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            FilterMode = FilterModes.Filter;
            _grid.Name = "GridControl";
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
            this.Buttons["Add"].Visible       = _allowUsersToAddBo;
            this.Buttons["Edit"].Visible      = _allowUsersToEditBo;
            this.BusinessObjectSelected      += (s, e) =>
            {
                this.SetButtonStatesForSelectedObject();
            };
        }