BuildPanelForForm() public method

Constructs a panel for editing the data of a single instance of a BusinessObject, using the control layout as specified in a UIForm object.
public BuildPanelForForm ( IUIForm uiForm ) : IPanelInfo
uiForm IUIForm The UIForm object that indicates which controls /// to create and how the controls are laid out
return IPanelInfo
        public void TestChangeControlValues_DoesNotChangeBusinessObjectValues()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();
            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);

            Habanero.Faces.Base.PanelBuilder factory = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);
            panelInfo.BusinessObject = myBO;
            //---------------Execute Test ----------------------
            ChangeValuesInControls(panelInfo);
            //---------------Test Result -----------------------

            Assert.AreEqual(START_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(START_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));

        }
        public void TestChangeControlValues_DoesNotChangeBusinessObjectValues()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);

            Habanero.Faces.Base.PanelBuilder factory = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject = myBO;
            //---------------Execute Test ----------------------
            ChangeValuesInControls(panelInfo);
            //---------------Test Result -----------------------

            Assert.AreEqual(START_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(START_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));
        }
        public void Test_BuildPanelForForm_formNull()
        {
            //---------------Set up test pack-------------------
            PanelBuilder panelBuilder = new PanelBuilder(this.GetControlFactory());

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                panelBuilder.BuildPanelForForm(null);
                Assert.Fail("expected ArgumentNullException");
            }
                //---------------Test Result -----------------------
            catch (ArgumentNullException ex)
            {
                StringAssert.Contains("Value cannot be null", ex.Message);
                StringAssert.Contains("uiForm", ex.ParamName);
            }
        }
        /// <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());
        }
        /// <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());
        }
 internal static IPanelInfo CreatePanelInfo
     (IControlFactory controlFactory, IClassDef classDef, string uiDefName, IBOEditorControl iboEditorControl)
 {
     IUIForm uiForm = GetUiForm(classDef, uiDefName);
     PanelBuilder panelBuilder = new PanelBuilder(controlFactory);
     IPanelInfo panelInfo = panelBuilder.BuildPanelForForm(uiForm);
     BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(iboEditorControl);
     layoutManager.AddControl(panelInfo.Panel, BorderLayoutManager.Position.Centre);
     return panelInfo;
 }