Example #1
0
        /// <summary>
        /// A constructor as before, but with a UIDefName specified
        /// </summary>
        public PanelFactory(BusinessObject bo, string uiDefName, IControlFactory controlFactory)
        {
            _uiDefName      = uiDefName;
            _controlFactory = controlFactory;
            BOMapper mapper = new BOMapper(bo);

            IUIDef uiDef = mapper.GetUIDef(uiDefName);

            if (uiDef == null)
            {
                string errMessage = "Cannot create a panel factory for '" + bo.ClassDef.ClassName
                                    + "' since the classdefs do not contain a uiDef '" + uiDefName + "'";
                throw new HabaneroDeveloperException
                          ("There is a serious application error please contact your system administrator"
                          + Environment.NewLine + errMessage, errMessage);
            }
            _uiForm = uiDef.GetUIFormProperties();
            if (_uiForm == null)
            {
                string errMsg = "Cannot create a panel factory for '" + bo.ClassDef.ClassName
                                + "' since the classdefs do not contain a form def for uidef '" + uiDefName + "'";
                throw new HabaneroDeveloperException
                          ("There is a serious application error please contact your system administrator"
                          + Environment.NewLine + errMsg, errMsg);
            }
            InitialiseFactory(bo);
        }
        public void TestAddRowP_RowValueDBNull_VirtualProp_NUll_ShouldNotRaiseException_FIXBUG()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            ClassDef.ClassDefs.Clear();
            IClassDef classDef = MyBO.LoadClassDefWithUIAllDataTypes();

            classDef.UIDefCol["default"].UIGrid.Add(new UIGridColumn("VirtualProp", "-TestProp-", typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable()));
            BusinessObjectCollection <MyBO> boCollection = new BusinessObjectCollection <MyBO>();

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(0, boCollection.Count);
            Assert.AreEqual(0, boCollection.PersistedBusinessObjects.Count, "Should be no created items to start");
            //            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] { DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value });
            //---------------Test Result -----------------------
            Assert.IsFalse(itsTable.Rows[0].HasErrors);
            //Behaviour has been changed to persist the business object
            Assert.AreEqual
                (1, boCollection.PersistedBusinessObjects.Count,
                "Adding a row to the table should use the collection to create the object");
            //            Assert.AreEqual
            //                (1, boCollection.CreatedBusinessObjects.Count,
            //                 "Adding a row to the table should use the collection to create the object");
            Assert.AreEqual(1, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
Example #3
0
        public override void SetValue(object component, object value)
        {
            IBusinessObject bo       = GetBusinessObject(component);
            BOMapper        boMapper = new BOMapper(bo);

            boMapper.SetDisplayPropertyValue(PropertyName, value);
        }
        public void TestAddRowP_RowValueDBNull_BOProp_DateTime_NUll_ShouldNotRaiseException_FIXBUG()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            SetupTestData();
            BusinessObjectCollection <MyBO> boCollection = new BusinessObjectCollection <MyBO>();

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);

            //--------------Assert PreConditions----------------
            Assert.AreEqual(0, boCollection.Count);
            Assert.AreEqual(0, boCollection.PersistedBusinessObjects.Count, "Should be no created items to start");
//            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] { DBNull.Value, DBNull.Value, DBNull.Value });
            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.PersistedBusinessObjects.Count,
                "Adding a row to the table should use the collection to create the object");
//            Assert.AreEqual
//                (1, boCollection.CreatedBusinessObjects.Count,
//                 "Adding a row to the table should use the collection to create the object");
            Assert.AreEqual(1, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
Example #5
0
        public override object GetValue(object component)
        {
            IBusinessObject bo       = GetBusinessObject(component);
            BOMapper        boMapper = new BOMapper(bo);

            return(boMapper.GetPropertyValueToDisplay(PropertyName));
        }
Example #6
0
        public void Test_SetDisplayPropertyValue_WithRelatedPropName_ShouldSetPropValue()
        {
            //---------------Set up test pack-------------------
            const string underlyingPropName = "MyRelatedTestProp";
            const string propName           = "MyRelationship." + underlyingPropName;

            ClassDef.ClassDefs.Clear();

            var myBOClassDef    = MyBO.LoadClassDefWithRelationship();
            var relatedClassDef = MyRelatedBo.LoadClassDef();

            MyBO        myBO        = (MyBO)myBOClassDef.CreateNewBusinessObject();
            MyRelatedBo myRelatedBo = (MyRelatedBo)relatedClassDef.CreateNewBusinessObject();

            myBO.Relationships.SetRelatedObject("MyRelationship", myRelatedBo);
            BOMapper boMapper         = new BOMapper(myBO);
            var      initialPropValue = RandomValueGen.GetRandomString();

            myRelatedBo.SetPropertyValue(underlyingPropName, initialPropValue);
            //---------------Assert Precondition----------------
            Assert.AreEqual(initialPropValue, myRelatedBo.GetPropertyValue(underlyingPropName));
            //---------------Execute Test ----------------------
            var expectedPropValue = RandomValueGen.GetRandomString();

            boMapper.SetDisplayPropertyValue(propName, expectedPropValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedPropValue, myRelatedBo.GetPropertyValue(underlyingPropName));
        }
Example #7
0
        protected virtual IClassDef GetLookupTypeClassDef(out Type classType)
        {
            BOMapper  mapper             = new BOMapper(BusinessObject);
            IClassDef lookupTypeClassDef = mapper.GetLookupListClassDef(PropertyName);

            classType = lookupTypeClassDef.ClassType;
            return(lookupTypeClassDef);
        }
Example #8
0
 /// <summary>
 /// Returns the property value of the business object being mapped
 /// </summary>
 /// <returns>Returns the property value in appropriate object form</returns>
 protected virtual object GetPropertyValue()
 {
     if (_businessObject != null)
     {
         var boMapper = new BOMapper(_businessObject);
         return(boMapper.GetPropertyValueToDisplay(PropertyName));
     }
     return(null);
 }
Example #9
0
        public void TestGetLookupListDoesntExist()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadClassDefWithNoLookup();
            MyBO     bo     = new MyBO();
            BOMapper mapper = new BOMapper(bo);

            Assert.AreEqual(0, mapper.GetLookupList("TestProp").Count);
        }
Example #10
0
        public void Test_GetPropertyValueToDisplay_WhenVirtualPropertyValue()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadDefaultClassDef();
            MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();

            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("MyNameIsMyBo", mapper.GetPropertyValueToDisplay("-MyName-"));
        }
Example #11
0
        public void Test_GetPropertyValueToDisplay_SimpleLookup()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadClassDefWithSimpleIntegerLookup();
            MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("TestProp2", "Text");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("Text", mapper.GetPropertyValueToDisplay("TestProp2"));
        }
Example #12
0
        public void Test_GetPropertyValue_WithDot()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef        = MyBO.LoadClassDefWithRelationship();
            _itsRelatedClassDef = MyRelatedBo.LoadClassDef();
            //MyBO bo1 = (MyBO)itsClassDef.CreateNewBusinessObject(connection);
            MyBO        bo1             = (MyBO)_itsClassDef.CreateNewBusinessObject();
            MyRelatedBo relatedBo       = (MyRelatedBo)_itsRelatedClassDef.CreateNewBusinessObject();
            Guid        myRelatedBoGuid = relatedBo.ID.GetAsGuid();

            bo1.SetPropertyValue("RelatedID", myRelatedBoGuid);
            relatedBo.SetPropertyValue("MyRelatedTestProp", "MyValue");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("MyValue", mapper.GetPropertyValueToDisplay("MyRelationship.MyRelatedTestProp"));
        }
        public void TestDuplicateColumnNames()
        {
            //---------------Set up test pack-------------------
            SetupTestData();
            BOMapper mapper = new BOMapper(_collection.ClassDef.CreateNewBusinessObject());

            //---------------Execute Test ----------------------
            try
            {
                itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef("duplicateColumns").UIGrid);
                Assert.Fail("Expected to throw an DuplicateNameException");
            }
            //---------------Test Result -----------------------
            catch (DuplicateNameException ex)
            {
                StringAssert.Contains("Only one column per property can be specified", ex.Message);
            }
        }
Example #14
0
        public void Test_SetPropertyDisplayValue_WithIntString_ShouldBeAbleGetString()
        {
            //---------------Set up test pack-------------------

            ClassDef.ClassDefs.Clear();
            MyBO.LoadDefaultClassDef();
            var          testBo   = new MyBO();
            var          boMapper = new BOMapper(testBo);
            const string propName = "TestProp";

            boMapper.SetDisplayPropertyValue(propName, "7");
            //---------------Assert Precondition----------------
            Assert.AreEqual("7", boMapper.GetPropertyValueToDisplay(propName).ToString());
            //---------------Execute Test ----------------------
            boMapper.SetDisplayPropertyValue(propName, "3");
            //---------------Test Result -----------------------
            Assert.AreEqual("3", boMapper.GetPropertyValueToDisplay(propName).ToString());
            Assert.AreEqual("3", testBo.TestProp);
        }
        ///// <summary>
        ///// Gets or sets whether the user is able to right-click to
        ///// add additional items to the drop-down list
        ///// </summary>
        //public override bool RightClickEnabled
        //{
        //    get { return base.RightClickEnabled && _allowRightClick; }
        //    set
        //    {
        //        _allowRightClick = value;
        //        base.RightClickEnabled = value;
        //    }
        //}

        /// <summary>
        /// Sets up the list of items to display and calls SetLookupList()
        /// to populate the ComboBox with this list
        /// </summary>
        private void SetupLookupList()
        {
            if (_businessObject == null)
            {
                Dictionary <string, string> emptyList = new Dictionary <string, string>();
                LookupList = emptyList;
                return;
            }
            BOMapper mapper = new BOMapper(_businessObject);
            Dictionary <string, string> col = mapper.GetLookupList(PropertyName);

            //if (!_isRightClickInitialised)
            //{
            //    //SetupRightClickBehaviour();
            //    if (_attributes != null && !_attributes.Contains("rightClickEnabled") &&
            //        GlobalUIRegistry.UISettings != null &&
            //        GlobalUIRegistry.UISettings.PermitComboBoxRightClick != null)
            //    {
            //        ClassDef lookupClassDef = mapper.GetLookupListClassDef(_propertyName);
            //        if (lookupClassDef != null)
            //        {
            //            Type boType = lookupClassDef.ClassType;
            //            if (GlobalUIRegistry.UISettings.PermitComboBoxRightClick(boType, this))
            //            {
            //                RightClickEnabled = _allowRightClick;
            //            }
            //        }
            //    }
            //    else
            //    {
            //        RightClickEnabled = _allowRightClick;
            //    }
            //    _isRightClickInitialised = true;
            //}
            CustomiseLookupList(col);
            LookupList = col;
            var boPropertyValue = GetPropertyValue();

            if (col.Count > 0 && boPropertyValue != null)
            {
                SetLookupListValueFromBO(boPropertyValue);
            }
        }
        public void TestAddRow_UpdatesCollection()
        {
            BusinessObjectCollection <MyBO> col = null;
            IDataSetProvider dataSetProvider    = GetDataSetProviderWithCollection(ref col);
            BOMapper         mapper             = new BOMapper(col.ClassDef.CreateNewBusinessObject());
            DataTable        table = dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);
            MyBO             boNew = new MyBO();

            boNew.SetPropertyValue("TestProp", "bo3prop1");
            boNew.SetPropertyValue("TestProp2", "s2");
            //---------------Assert Precondition----------------
            Assert.AreEqual(4, table.Rows.Count);
            Assert.AreEqual(4, col.Count);
            Assert.AreEqual(4, col.CreatedBusinessObjects.Count);
            //---------------Execute Test ----------------------
            table.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });
            //---------------Test Result -----------------------
            Assert.AreEqual(5, col.Count);
            Assert.AreEqual(5, col.CreatedBusinessObjects.Count);
            Assert.AreEqual(5, table.Rows.Count);
        }
Example #17
0
        public void Test_GetPropertyValue_WithDot_IncorrectRelationshipName()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            _itsClassDef        = MyBO.LoadClassDefWithRelationship();
            _itsRelatedClassDef = MyRelatedBo.LoadClassDef();
            MyBO     bo1    = (MyBO)_itsClassDef.CreateNewBusinessObject();
            BOMapper mapper = new BOMapper(bo1);

            //---------------Execute Test ----------------------
            try
            {
                mapper.GetPropertyValueToDisplay("MyIncorrectRelationship.MyRelatedTestProp");
                Assert.Fail("Expected to throw an RelationshipNotFoundException");
            }
            //---------------Test Result -----------------------
            catch (RelationshipNotFoundException ex)
            {
                StringAssert.Contains("The relationship 'MyIncorrectRelationship' on 'MyBO' cannot be found", ex.Message);
            }
        }
Example #18
0
        public void Test_SetDisplayPropertyValue_WhenLookupList_ShouldSetUnderlyingValue()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            const string propertyName = "TestProp2";
            const string expectedLookupDisplayValue = "s1";
            Guid         expectedLookupValue;

            StringUtilities.GuidTryParse("{E6E8DC44-59EA-4e24-8D53-4A43DC2F25E7}", out expectedLookupValue);
            _itsClassDef = MyBO.LoadClassDefWithLookup();
            MyBO     bo1      = (MyBO)_itsClassDef.CreateNewBusinessObject();
            BOMapper boMapper = new BOMapper(bo1);

            //---------------Assert Precondition----------------
            Assert.IsNullOrEmpty(bo1.TestProp2);
            //---------------Execute Test ----------------------
            boMapper.SetDisplayPropertyValue(propertyName, expectedLookupDisplayValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedLookupValue, bo1.GetPropertyValue(propertyName));
            Assert.AreEqual(expectedLookupDisplayValue, bo1.GetPropertyValueToDisplay(propertyName));
        }
        public void TestAddRowCreatesBusinessObjectThroughCollection()
        {
            SetupTestData();
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> boCollection = new BusinessObjectCollection <MyBO>();
            MyBO bo = new MyBO();

            bo.SetPropertyValue("TestProp", "bo1prop1");
            bo.SetPropertyValue("TestProp2", "s1");
            bo.Save();
            boCollection.Add(bo);

            MyBO bo2 = new MyBO();

            bo2.SetPropertyValue("TestProp", "bo2prop1");
            bo2.SetPropertyValue("TestProp2", "s2");
            bo2.Save();
            boCollection.Add(bo2);

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);


            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, boCollection.Count);
            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });

            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.CreatedBusinessObjects.Count,
                "Adding a row to the table should use the collection to create the object");
            //Assert.AreEqual(2, boCollection.Count, "Adding a row to the table should not add a bo to the main collection");
            Assert.AreEqual(3, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
        public void Test_EditDataTable_ToDBNull_EditsBo()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col = null;
            IDataSetProvider dataSetProvider    = GetDataSetProviderWithCollection(ref col);
            BOMapper         mapper             = new BOMapper(col.ClassDef.CreateNewBusinessObject());
            DataTable        table = dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);
            MyBO             bo1   = col[0];
//            const string updatedvalue = "UpdatedValue";
            const string columnName         = "TestProp";
            object       origionalPropValue = bo1.GetPropertyValue(columnName);

            //---------------Assert Precondition----------------
            Assert.IsTrue(dataSetProvider is EditableDataSetProvider);
            Assert.AreEqual(4, table.Rows.Count);
            Assert.AreEqual(bo1.ID.AsString_CurrentValue(), table.Rows[0][_dataTableIdColumnName]);
            Assert.AreEqual(origionalPropValue, table.Rows[0][columnName]);
            //---------------Execute Test ----------------------
            table.Rows[0][columnName] = DBNull.Value;
            //---------------Test Result -----------------------
            Assert.AreEqual(bo1.ID.AsString_CurrentValue(), table.Rows[0][_dataTableIdColumnName]);
            Assert.AreEqual(DBNull.Value, table.Rows[0][columnName]);
            Assert.AreEqual(null, bo1.GetPropertyValue(columnName));
        }
Example #21
0
        /// <summary>
        /// Sets the property value to that provided.  If the property value
        /// is invalid, the error provider will be given the reason why the
        /// value is invalid.
        /// </summary>
        protected virtual void SetPropertyValue(object value)
        {
            if (_businessObject == null)
            {
                return;
            }
            var boMapper = new BOMapper(_businessObject);

            try
            {
                boMapper.SetDisplayPropertyValue(PropertyName, value);
            }
            catch (InvalidPropertyValueException ex)
            {
                SetError(ex.Message);
                return;
            }
            catch (HabaneroIncorrectTypeException ex)
            {
                SetError(ex.Message);
                return;
            }
            UpdateErrorProviderErrorMessage();
        }
Example #22
0
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormWin"/> class  with
        /// the specified businessObject, uiDefName and post edit action.
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        /// <param name="creator">The Creator used to Create the Group Control.</param>
        public DefaultBOEditorFormWin(BusinessObject bo, string uiDefName, IControlFactory controlFactory, GroupControlCreator creator)
        {
            _bo                 = bo;
            _controlFactory     = controlFactory;
            GroupControlCreator = creator;
            _uiDefName          = uiDefName;

            BOMapper mapper = new BOMapper(bo);

            IUIForm def;

            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);

            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm, this.GroupControlCreator);
            _panelInfo = panelBuilder.BuildPanelForForm(def, this.GroupControlCreator);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;

            _buttons = _controlFactory.CreateButtonGroupControl();
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OkButtonHandler);

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonWin)okbutton;
            this.Load        += delegate { FocusOnFirstControl(); };
            this.FormClosing += OnFormClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }
        /// <summary>
        /// Constructs the <see cref="DefaultBOEditorFormVWG"/> class  with
        /// the specified <see cref="BusinessObject"/>, uiDefName and <see cref="IControlFactory"/>.
        /// </summary>
        /// <param name="bo">The business object to represent</param>
        /// <param name="uiDefName">The name of the ui def to use.</param>
        /// <param name="controlFactory">The <see cref="IControlFactory"/> to use for creating the Editor form controls</param>
        public DefaultBOEditorFormVWG(BusinessObject bo, string uiDefName, IControlFactory controlFactory)
        {
            _bo                 = bo;
            _controlFactory     = controlFactory;
            _uiDefName          = uiDefName;
            GroupControlCreator = _controlFactory.CreateTabControl;
            BOMapper mapper = new BOMapper(bo);

            IUIForm def;

            if (_uiDefName.Length > 0)
            {
                IUIDef uiMapper = mapper.GetUIDef(_uiDefName);
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class, under the 'ui' " +
                                                     "with the name '" + _uiDefName + "'.");
                }
                def = uiMapper.UIForm;
            }
            else
            {
                IUIDef uiMapper = mapper.GetUIDef();
                if (uiMapper == null)
                {
                    throw new NullReferenceException("An error occurred while " +
                                                     "attempting to load an object editing form.  A possible " +
                                                     "cause is that the class definitions do not have a " +
                                                     "'form' section for the class.");
                }
                def = uiMapper.UIForm;
            }
            if (def == null)
            {
                throw new NullReferenceException("An error occurred while " +
                                                 "attempting to load an object editing form.  A possible " +
                                                 "cause is that the class definitions do not have a " +
                                                 "'form' section for the class.");
            }

            PanelBuilder panelBuilder = new PanelBuilder(_controlFactory);

            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol["default"].UIForm);
            //_panelInfo = panelBuilder.BuildPanelForForm(_bo.ClassDef.UIDefCol[uiDefName].UIForm);
            _panelInfo = panelBuilder.BuildPanelForForm(def);

            _panelInfo.BusinessObject = _bo;
            _boPanel = _panelInfo.Panel;
            _buttons = _controlFactory.CreateButtonGroupControl();
            // These buttons used to be "&Cancel" and "&OK", but they are missing the "&" in win, so I took them out for VWG
            //  Soriya had originally removed them from Win in revision 2854, but I'm not sure of the reason other than
            //  externally, when fetching the button from the button control, it would be fetched using the text only.
            //  I would prefer to have the "&" in the control, but it may break existing code that uses the buttons on this form.
            //  Also, it seems that VWG does not do anything with the "&"
            _buttons.AddButton("Cancel", CancelButtonHandler);
            IButton okbutton = _buttons.AddButton("OK", OKButtonHandler);

            okbutton.TabStop = false;
            //okbutton.TabIndex = 3;
            //okbutton.TabStop = true;
            //cancelButton.TabIndex = 4;
            //cancelButton.TabStop = true;

            okbutton.NotifyDefault(true);
            this.AcceptButton = (ButtonVWG)okbutton;
            this.Load        += delegate { FocusOnFirstControl(); };
            this.Closing     += OnClosing;

            this.Text = def.Title;
            SetupFormSize(def);
            MinimizeBox = false;
            MaximizeBox = false;
            //this.ControlBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            CreateLayout();
            OnResize(new EventArgs());
        }