Пример #1
0
 /// <summary>
 /// Selects an option, removing it from the AllOptions and adding
 /// it to the SelectedOptions
 /// </summary>
 public void Select(T item)
 {
     if (_allOptions.Contains(item) && !_selectedOptions.Contains(item))
     {
         if (_selectedOptions is IBusinessObjectCollection)
         {
             IBusinessObjectCollection col = (IBusinessObjectCollection)_selectedOptions;
             col.Add((IBusinessObject)item);
         }
         else
         {
             _selectedOptions.Add(item);
         }
         FireSelected(item);
     }
 }
Пример #2
0
        private static IBusinessObjectCollection AddRelatedObjects <T>(TestBO testBO,
                                                                       string relationshipName, int numberOfBos, bool isNew)
            where T : TestBO, new()
        {
            IBusinessObjectCollection children = testBO.Relationships.GetRelatedCollection(relationshipName);

            for (int count = 1; count <= numberOfBos; count++)
            {
                T testBO2 = new T();
                testBO2.SetStatus(BOStatus.Statuses.isNew, isNew);
                testBO2.MyBoID       = "2." + TestUtil.GetRandomString();
                testBO2.MyParentBoID = testBO.MyParentBoID;
                children.Add(testBO2);
            }
            return(children);
        }
Пример #3
0
        public virtual void Test_ResetBOCol_DeregistersForBOChangedEvents()
        {
            //---------------Set up test pack-------------------
            IBOColSelectorControl     colSelector = CreateSelector();
            IBusinessObject           bo;
            IBusinessObjectCollection collection = GetCollectionWithTowBOs(out bo);

            colSelector.BusinessObjectCollection = collection;
            colSelector.BusinessObjectCollection = GetCollectionWithNoItems();
            //---------------Assert Precondition----------------
            Assert.AreEqual(ActualNumberOfRows(0), colSelector.NoOfItems, "The blank item and one other");
            //---------------Execute Test ----------------------
            collection.Add(CreateNewBO());
            //---------------Test Result -----------------------
            Assert.AreEqual(ActualNumberOfRows(0), colSelector.NoOfItems, "The blank item and one other");
        }
Пример #4
0
        ///<summary>
        /// Find all objects of type boType that match the criteria.
        ///</summary>
        ///<param name="boType"></param>
        ///<param name="criteria"></param>
        ///<returns></returns>
        public virtual IBusinessObjectCollection FindAll(Type boType, Criteria criteria)
        {
            IBusinessObjectCollection col = CreateGenericCollection(boType);

            foreach (IBusinessObject bo in AllObjects.Values)
            {
                if (!boType.IsInstanceOfType(bo))
                {
                    continue;
                }
                if (criteria == null || criteria.IsMatch(bo))
                {
                    col.Add(bo);
                }
            }
            col.SelectQuery.Criteria = criteria;
            return(col);
        }
Пример #5
0
 private void Buttons_AddClicked(object sender, EventArgs e)
 {
     try
     {
         if (Grid.BusinessObjectCollection == null)
         {
             throw new GridDeveloperException("You cannot call add since the grid has not been set up");
         }
         if (BusinessObjectCreator == null)
         {
             throw new GridDeveloperException(
                       "You cannot call add as there is no business object creator set up for the grid");
         }
         _grid.SelectedBusinessObject = null;
         var newBo = BusinessObjectCreator.CreateBusinessObject();
         if (BusinessObjectEditor != null && newBo != null)
         {
             //This cannot be generalised for Win an Web due to the fact that you cannot
             // have a true Modal dialogue in VWG see VWG website for more details.
             BusinessObjectEditor.EditObject(newBo, UiDefName, delegate(IBusinessObject bo, bool cancelled)
             {
                 IBusinessObjectCollection collection = this.Grid.BusinessObjectCollection;
                 if (cancelled)
                 {
                     collection.Remove(bo);
                 }
                 else
                 {
                     if (!collection.Contains(bo))
                     {
                         collection.Add(bo);
                     }
                     _grid.RefreshBusinessObjectRow(bo);
                     _grid.Update();
                     Grid.SelectedBusinessObject = bo;
                 }
             });
         }
     }
     catch (Exception ex)
     {
         GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error trying to add an item");
     }
 }
Пример #6
0
        public virtual void Test_AddBOToCol_UpdatesItems()
        {
            //---------------Set up test pack-------------------
            IBOColSelectorControl     colSelector = CreateSelector();
            IBusinessObject           bo;
            IBusinessObjectCollection collection = GetCollectionWithOneBO(out bo);

            colSelector.BusinessObjectCollection = collection;
            //---------------Assert Precondition----------------
            Assert.AreSame(collection, colSelector.BusinessObjectCollection);
            Assert.AreEqual(ActualNumberOfRows(collection.Count), colSelector.NoOfItems, "The blank item and one other");
            //---------------Execute Test ----------------------
            IBusinessObject newBO = CreateNewBO();

            collection.Add(newBO);
            //---------------Test Result -----------------------
            Assert.AreEqual(ActualNumberOfRows(2), colSelector.NoOfItems, "The blank item and one other");
            Assert.AreSame(bo, colSelector.GetBusinessObjectAtRow(ActualIndex(0)));
            Assert.AreSame(newBO, colSelector.GetBusinessObjectAtRow(ActualIndex(1)));
        }
 private void Buttons_AddClicked(object sender, EventArgs e)
 {
     try
     {
         if (Grid.BusinessObjectCollection == null)
         {
             throw new GridDeveloperException("You cannot call add since the grid has not been set up");
         }
         if (BusinessObjectCreator == null)
         {
             throw new GridDeveloperException(
                       "You cannot call add as there is no business object creator set up for the grid");
         }
         IBusinessObject newBo = BusinessObjectCreator.CreateBusinessObject();
         if (BusinessObjectEditor != null && newBo != null)
         {
             BusinessObjectEditor.EditObject(newBo, UiDefName,
                                             delegate(IBusinessObject bo, bool cancelled)
             {
                 IBusinessObjectCollection collection = this.Grid.BusinessObjectCollection;
                 if (cancelled)
                 {
                     collection.Remove(bo);
                 }
                 else
                 {
                     if (!collection.Contains(bo))
                     {
                         collection.Add(bo);
                     }
                     Grid.SelectedBusinessObject = bo;
                 }
             });
         }
     }
     catch (Exception ex)
     {
         GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error trying to add an item");
     }
 }
        public void Test_AddItemToCollection_ShouldAddItemToComboBox()
        {
            //---------------Set up test pack-------------------
            var                       cmbox    = GetControlFactory().CreateComboBox();
            const string              propName = "SampleLookup2ID";
            CollectionComboBoxMapper  mapper   = CreateCollectionComboBoxMapper(cmbox, propName);
            Car                       car1;
            Car                       car2;
            IBusinessObjectCollection collection =
                mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
            Sample sample = new Sample {
                SampleLookupID = car1.CarID
            };

            mapper.BusinessObject = sample;
            //---------------Assert Preconditions---------------
            Assert.AreEqual(3, cmbox.Items.Count);
            //---------------Execute Test ----------------------
            collection.Add(new Car());
            //---------------Test Result -----------------------
            Assert.AreEqual(4, cmbox.Items.Count);
        }
Пример #9
0
        ///<summary>
        /// Find all objects of type boType that match the criteria.
        ///</summary>
        /// <param name="classDef"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public virtual IBusinessObjectCollection FindAll(IClassDef classDef, Criteria criteria)
        {
            Type boType = classDef.ClassType;
            IBusinessObjectCollection col = CreateGenericCollection(boType);

            col.ClassDef = classDef;
            foreach (IBusinessObject bo in GetAllObjectsSnapshot()) //AllObjects.Values.ToArray())
            {
                if (bo.ClassDef != classDef && !boType.IsInstanceOfType(bo))
                {
                    continue;
                }
                if (classDef.TypeParameter != bo.ClassDef.TypeParameter)
                {
                    continue;
                }
                if (criteria == null || criteria.IsMatch(bo))
                {
                    col.Add(bo);
                }
            }
            col.SelectQuery.Criteria = criteria;
            return(col);
        }