Exemplo n.º 1
0
 private static void AddNullControlsForEmptyField(IPanelInfo panelInfo)
 {
     for (int i = 0; i < CONTROLS_PER_COLUMN; i++)
     {
         panelInfo.LayoutManager.AddControl(null);
     }
 }
        ///<summary>
        /// The Constructor for the <see cref="BOEditorControlWin"/> which passes in the
        /// <paramref name="classDef"/> for the <see cref="IBusinessObject"/> and the <paramref name="uiDefName"/> that 
        ///  is used to defined the User Interface for the <see cref="IBusinessObject"/>      
        ///</summary>
        ///<param name="controlFactory">The control factory which is used to create the Controls on this form.</param>
        ///<param name="classDef">The <see cref="IClassDef"/> for the  <see cref="IBusinessObject"/> that will be edited by this control</param>
        ///<param name="uiDefName">The user interface defined in the <see cref="IClassDef"/> that will be used to Build this control</param>
        public BOEditorControlWin(IControlFactory controlFactory, IClassDef classDef, string uiDefName)
        {
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            if (classDef == null) throw new ArgumentNullException("classDef");
            if (uiDefName == null) throw new ArgumentNullException("uiDefName");

            _panelInfo = BOEditorControlUtils.CreatePanelInfo(controlFactory, classDef, uiDefName, this);
            SetEnableState();
        }
Exemplo n.º 3
0
        private static void AssertErrorProviderHasErrors(IBusinessObjectPanel controlWin, string propertyName)
        {
            IPanelInfo panelInfo = controlWin.PanelInfo;

            PanelInfo.FieldInfo fieldInfo = panelInfo.FieldInfos[propertyName];
            string error = fieldInfo.ControlMapper.ErrorProvider.GetError(fieldInfo.InputControl);

            Assert.IsFalse(string.IsNullOrEmpty(error), "string '" + error + "' should not be null");
        }
Exemplo n.º 4
0
        private static void AssertErrorProvidersHaveBeenCleared(IBusinessObjectPanel controlWin)
        {
            IPanelInfo panelInfo = controlWin.PanelInfo;

            foreach (PanelInfo.FieldInfo fieldInfo in panelInfo.FieldInfos)
            {
                Assert.AreEqual("", fieldInfo.ControlMapper.GetErrorMessage(), "Errors should be cleared");
            }
        }
Exemplo n.º 5
0
        private IControlHabanero CreateAndAddGroupBox(IPanelInfo panelInfo, UIFormField formField)
        {
            IControlHabanero labelControl = ControlFactory.CreateGroupBox(formField.GetLabel());

            labelControl.Width = 0; // don't affect the label column's fixed width
            labelControl.Name  = formField.PropertyName;
            SetToolTip(formField, labelControl);
            panelInfo.LayoutManager.AddControl(labelControl, formField.RowSpan, 2);
            return(labelControl);
        }
        ///<summary>
        /// Constructor for <see cref="BusinessObjectPanelVWG{T}"/>
        ///</summary>
        ///<param name="controlFactory"></param>
        ///<param name="uiDefName"></param>
        public BusinessObjectPanelVWG(IControlFactory controlFactory, string uiDefName)
        {
            PanelBuilder panelBuilder = new PanelBuilder(controlFactory);

            _panelInfo = panelBuilder.BuildPanelForForm(ClassDef.Get <T>().UIDefCol[uiDefName].UIForm);
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(_panelInfo.Panel, BorderLayoutManager.Position.Centre);
            this.Size        = _panelInfo.Panel.Size;
            this.MinimumSize = _panelInfo.Panel.Size;
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates one panel for each UI Form definition of a business object
        /// </summary>
        /// <returns>Returns the list of panel info objects created</returns>
        /// TODO: improve tab order (ie make all tabs use one sequence rather than each starting a new sequence)
        public List <IPanelInfo> CreateOnePanelPerUIFormTab(IUIForm uiForm)
        {
            List <IPanelInfo> panelInfoList = new List <IPanelInfo>();

            foreach (UIFormTab formTab in uiForm)
            {
                IPanelInfo onePanelInfo = BuildPanelForTab(formTab);

                panelInfoList.Add(onePanelInfo);
            }
            return(panelInfoList);
        }
Exemplo n.º 9
0
        private ILabel CreateAndAddLabel(IPanelInfo panelInfo, UIFormField formField)
        {
//            IClassDef classDef = panelInfo.UIForm.UIDef.ClassDef;
            ILabel labelControl = ControlFactory.CreateLabel(formField.GetLabel(), formField.IsCompulsory);

            labelControl.Name    = _controlNamingStrategy.GetLabelControlName(formField);
            labelControl.Enabled = formField.Editable;
            SetToolTip(formField, labelControl);
            var containerControl = panelInfo.Panel;

            EnsureControlNameUnique(labelControl, containerControl);
            panelInfo.LayoutManager.AddControl(labelControl, formField.RowSpan, 1);
            return(labelControl);
        }
Exemplo n.º 10
0
        public void Test_UIFormTab()
        {
            //--------------- Set up test pack ------------------
            IClassDef    classDef     = Sample.CreateClassDefWithTwoPropsOneInteger();
            PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab)classDef.UIDefCol["default"].UIForm[0]);

            //--------------- Test Result -----------------------
            Assert.IsNotNull(panelInfo.UIFormTab);
            Assert.AreEqual(panelInfo.UIFormTab.Name, panelInfo.PanelTabText);
        }
Exemplo n.º 11
0
        private void AddFieldsToLayoutManager(UIFormTab formTab, IPanelInfo panelInfo)
        {
            int numberOfColumns = formTab.Count;

            int[] currentFieldPositionInColumns = new int[numberOfColumns];
            int[] rowSpanTrackerForColumn       = new int[numberOfColumns];
            int   maxRowsInColumns = formTab.GetMaxRowsInColumns();

            int[] columnSpanTrackerForRow = new int[maxRowsInColumns];
            for (int currentRowNo = 0; currentRowNo < maxRowsInColumns; currentRowNo++)
            {
                for (int currentColumnNo = 0; currentColumnNo < numberOfColumns; currentColumnNo++)
                {
                    IUIFormColumn currentFormColumn = formTab[currentColumnNo];

                    if (--rowSpanTrackerForColumn[currentColumnNo] > 0)
                    {
                        continue;
                    }
                    // keep skipping this grid position until a previous row span in this column has been decremented
                    if (--columnSpanTrackerForRow[currentRowNo] > 0)
                    {
                        continue;
                    }
                    // keep skipping this grid position until a previous column span in this row has been decremented

                    int currentFieldNoInColumn = currentFieldPositionInColumns[currentColumnNo];
                    int totalFieldsInColumn    = currentFormColumn.Count;
                    if (currentFieldNoInColumn < totalFieldsInColumn) // there exists a field in this row in this column
                    {
                        UIFormField formField = (UIFormField)currentFormColumn[currentFieldNoInColumn];
                        rowSpanTrackerForColumn[currentColumnNo] = formField.RowSpan;
                        for (int i = currentRowNo; i < currentRowNo + formField.RowSpan; i++)
                        {
                            // update colspan of all rows that this field spans into.
                            columnSpanTrackerForRow[i] = formField.ColSpan;
                        }

                        PanelInfo.FieldInfo fieldInfo = AddControlsForField(formField, panelInfo);
                        fieldInfo.InputControl.TabIndex = currentColumnNo * maxRowsInColumns + currentRowNo;
                    }
                    else
                    {
                        AddNullControlsForEmptyField(panelInfo);
                    }
                    currentFieldPositionInColumns[currentColumnNo]++;
                }
            }
        }
Exemplo n.º 12
0
        private IControlMapper CreateAndAddInputControl(IPanelInfo panelInfo, UIFormField formField)
        {
            IControlMapper   controlMapper;
            IControlHabanero inputControl = ConfigureInputControl(formField, out controlMapper);

            int numberOfGridColumnsToSpan = 1 + (CONTROLS_PER_COLUMN * (formField.ColSpan - 1));

            GridLayoutManager.ControlInfo inputControlInfo = new GridLayoutManager.ControlInfo
                                                                 (inputControl, numberOfGridColumnsToSpan, formField.RowSpan);

            inputControl.Name = _controlNamingStrategy.GetInputControlName(formField);
            EnsureControlNameUnique(inputControl, panelInfo.Panel);
            panelInfo.LayoutManager.AddControl(inputControlInfo);
            return(controlMapper);
        }
Exemplo n.º 13
0
        public void TestControlsVisible()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef     = Sample.CreateClassDefWithTwoPropsOneInteger();
            PanelBuilder panelBuilder = new PanelBuilder(GetControlFactory());
            IPanelInfo   panelInfo    = panelBuilder.BuildPanelForTab((UIFormTab)classDef.UIDefCol["default"].UIForm[0]);

            panelInfo.BusinessObject = new Sample();
            //---------------Assert Precondition----------------
            Assert.IsTrue(panelInfo.FieldInfos[0].InputControl.Visible);
            Assert.IsTrue(panelInfo.FieldInfos[1].InputControl.Visible);
            //---------------Execute Test ----------------------
            panelInfo.ControlsVisible = false;
            //---------------Test Result -----------------------
            Assert.IsFalse(panelInfo.FieldInfos[0].InputControl.Visible);
            Assert.IsFalse(panelInfo.FieldInfos[1].InputControl.Visible);
        }
Exemplo n.º 14
0
        public void TestEnableControls()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            MyBO         myBO      = new MyBO();
            PanelBuilder factory   = new PanelBuilder(GetControlFactory());
            IPanelInfo   panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject  = myBO;
            panelInfo.ControlsEnabled = false;

            //---------------Execute Test ----------------------
            panelInfo.ControlsEnabled = true;
            //---------------Test Result -----------------------
            Assert.IsTrue(panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Enabled);
            Assert.IsTrue(panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Enabled);
            //---------------Tear Down -------------------------
        }
Exemplo n.º 15
0
        ///<summary>
        /// The Constructor for the <see cref="BOEditorControlVWG"/> which passes in the
        /// <paramref name="classDef"/> for the <see cref="IBusinessObject"/> and the <paramref name="uiDefName"/> that
        ///  is used to defined the User Interface for the <see cref="IBusinessObject"/>
        ///</summary>
        ///<param name="controlFactory">The control factory which is used to create the Controls on this form.</param>
        ///<param name="classDef">The <see cref="IClassDef"/> for the  <see cref="IBusinessObject"/> that will be edited by this control</param>
        ///<param name="uiDefName">The user interface defined in the <see cref="IClassDef"/> that will be used to Build this control</param>
        public BOEditorControlVWG(IControlFactory controlFactory, IClassDef classDef, string uiDefName)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            if (classDef == null)
            {
                throw new ArgumentNullException("classDef");
            }
            if (uiDefName == null)
            {
                throw new ArgumentNullException("uiDefName");
            }

            _panelInfo = BOEditorControlUtils.CreatePanelInfo(controlFactory, classDef, uiDefName, this);
            SetEnableState();
        }
        private void CreateBOPanel(IControlFactory controlFactory, string uiDefName)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            if (string.IsNullOrEmpty(uiDefName))
            {
                throw new ArgumentNullException("uiDefName");
            }
            PanelBuilder panelBuilder = new PanelBuilder(controlFactory);

            _panelInfo = panelBuilder.BuildPanelForForm(ClassDef.Get <T>().UIDefCol[uiDefName].UIForm);
            BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this);

            layoutManager.AddControl(_panelInfo.Panel, BorderLayoutManager.Position.Centre);
            this.Size        = _panelInfo.Panel.Size;
            this.MinimumSize = _panelInfo.Panel.Size;
        }
Exemplo n.º 17
0
        public void TestPanelSetup()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);
            PanelBuilder factory = new PanelBuilder(GetControlFactory());

            //---------------Execute Test ----------------------
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject = myBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(START_VALUE_1, panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Text);
            Assert.AreEqual(START_VALUE_2, panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Text);
        }
Exemplo n.º 18
0
        public void Test_Constructor_WhenUIDefIsInherited_ShouldUseInheritedUIDef()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef       = Entity.LoadDefaultClassDef();
            IClassDef subClassDef    = LegalEntity.LoadClassDef_WithSingleTableInheritance();
            IClassDef subSubClassDef = Vehicle.LoadClassDef_WithClassTableInheritance();
            UIForm    uiForm         = new UIForm(new UIFormTab(new UIFormColumn(new UIFormField("My Form Field", "EntityType"))));
            string    uiDefName      = "EntityUiDef";

            classDef.UIDefCol.Add(new UIDef(uiDefName, uiForm, null));
            IBusinessObject businessObject = subSubClassDef.CreateNewBusinessObject();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)businessObject, uiDefName);
            //---------------Test Result -----------------------
            IPanelInfo panelInfo = defaultBOEditorForm.PanelInfo;

            Assert.IsNotNull(panelInfo);
            Assert.AreSame(uiForm, panelInfo.UIForm);
        }
        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));
        }
Exemplo n.º 20
0
        public void Test_UpdateErrorProviderError_WhenBOValid_ShouldClearErrorMessage()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
            ContactPersonTestBO person       = ContactPersonTestBO.CreateUnsavedContactPerson("", "");
            PanelBuilder        panelBuilder = new PanelBuilder(GetControlFactory());
            IPanelInfo          panelInfo    = panelBuilder.BuildPanelForTab((UIFormTab)person.ClassDef.UIDefCol["default"].UIForm[0]);

            panelInfo.BusinessObject = person;
            IControlMapper SurnameControlMapper = panelInfo.FieldInfos["Surname"].ControlMapper;

            panelInfo.UpdateErrorProvidersErrorMessages();
            //---------------Assert Precondition----------------
            Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
            //---------------Execute Test ----------------------
            person.Surname = "SomeValue";
            panelInfo.UpdateErrorProvidersErrorMessages();
            //---------------Test Result -----------------------
            Assert.AreEqual("", SurnameControlMapper.GetErrorMessage());
        }
Exemplo n.º 21
0
        public void TestClearErrorProviders()
        {
            //---------------Set up test pack-------------------
            IClassDef    classDef       = Sample.CreateClassDefWithTwoPropsOneCompulsory();
            PanelBuilder panelBuilder   = new PanelBuilder(GetControlFactory());
            IPanelInfo   panelInfo      = panelBuilder.BuildPanelForTab((UIFormTab)classDef.UIDefCol["default"].UIForm[0]);
            Sample       businessObject = new Sample();

            panelInfo.BusinessObject = businessObject;

            //businessObject.SetPropertyValue("SampleText2", "sdlkfj");
            PanelInfo.FieldInfo fieldInfo = panelInfo.FieldInfos["SampleText2"];
            panelInfo.ApplyChangesToBusinessObject();
            IErrorProvider errorProvider = fieldInfo.ControlMapper.ErrorProvider;

            //---------------Assert Precondition----------------
            Assert.IsTrue(errorProvider.GetError(fieldInfo.InputControl).Length > 0);
            //---------------Execute Test ----------------------
            panelInfo.ClearErrorProviders();
            //---------------Test Result -----------------------
            Assert.IsFalse(errorProvider.GetError(fieldInfo.InputControl).Length > 0);
        }
Exemplo n.º 22
0
        private PanelInfo.FieldInfo AddControlsForField(UIFormField formField, IPanelInfo panelInfo)
        {
            IControlHabanero labelControl;
            IControlMapper   controlMapper;

            if (formField.Layout == LayoutStyle.Label)
            {
                labelControl  = CreateAndAddLabel(panelInfo, formField);
                controlMapper = CreateAndAddInputControl(panelInfo, formField);
            }
            else
            {
                labelControl  = CreateAndAddGroupBox(panelInfo, formField);
                controlMapper = CreateAndAddInputControlToContainerControl(formField, labelControl);
            }

            CreateAndAddErrorProviderPanel(panelInfo, formField);

            PanelInfo.FieldInfo fieldInfo = new PanelInfo.FieldInfo(formField.PropertyName, labelControl, controlMapper);
            panelInfo.FieldInfos.Add(fieldInfo);
            return(fieldInfo);
        }
Exemplo n.º 23
0
        public void Test_UpdateErrorProviderError_WhenBOInvalid_ShouldSetErrorMessage()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
            ContactPersonTestBO person = ContactPersonTestBO.CreateUnsavedContactPerson("", "");

            Habanero.Faces.Base.PanelBuilder panelBuilder = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = panelBuilder.BuildPanelForTab((UIFormTab)person.ClassDef.UIDefCol["default"].UIForm[0]);

            person.Surname           = TestUtil.GetRandomString();
            panelInfo.BusinessObject = person;
            IControlMapper SurnameControlMapper = panelInfo.FieldInfos["Surname"].ControlMapper;

            person.Surname = "";
            //---------------Assert Precondition----------------
            Assert.IsFalse(person.Status.IsValid());
            Assert.AreEqual("", SurnameControlMapper.GetErrorMessage());
            //---------------Execute Test ----------------------
            panelInfo.UpdateErrorProvidersErrorMessages();
            //---------------Test Result -----------------------
            Assert.AreNotEqual("", SurnameControlMapper.GetErrorMessage());
        }
Exemplo n.º 24
0
        private static void SetupInputControlColumnWidth(IPanelInfo panelInfo, IUIFormTab formTab)
        {
            GridLayoutManager layoutManager = panelInfo.LayoutManager;
            int formColCount = 0;

            foreach (UIFormColumn formColumn in formTab)
            {
                if (formColumn.Width < 0)
                {
                    continue;
                }
                int gridCol                  = formColCount * CONTROLS_PER_COLUMN;
                int labelColumnWidth         = layoutManager.GetFixedColumnWidth(gridCol + LABEL_CONTROL_COLUMN_NO);
                int errorProviderColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + ERROR_PROVIDER_COLUMN_NO);
                int totalGap                 = (CONTROLS_PER_COLUMN - 1) * layoutManager.HorizontalGapSize;
                if (formTab.Count == 1)
                {
                    totalGap += 2 * layoutManager.BorderSize; // add extra border for single column
                }
                else if (formColCount == formTab.Count - 1)
                {
                    totalGap += layoutManager.BorderSize + layoutManager.HorizontalGapSize; // last column in multi-column
                }
                else if (formColCount > 0 && formTab.Count > 0)
                {
                    totalGap += layoutManager.HorizontalGapSize; //2 More gaps for internal column in multi-column
                }
                else if (formColCount == 0 && formTab.Count > 0)
                {
                    totalGap += layoutManager.BorderSize;
                }

                layoutManager.FixColumn
                    (gridCol + INPUT_CONTROL_COLUMN_NO,
                    formColumn.Width - labelColumnWidth - errorProviderColumnWidth - totalGap);
                formColCount++;
            }
        }
Exemplo n.º 25
0
        public void TestApplyChangesToBusinessObject()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

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

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

            panelInfo.BusinessObject = myBO;
            ChangeValuesInControls(panelInfo);

            //---------------Execute Test ----------------------

            panelInfo.ApplyChangesToBusinessObject();
            //---------------Test Result -----------------------

            Assert.AreEqual(CHANGED_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(CHANGED_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));
        }
Exemplo n.º 26
0
        private IControlMapper CreateAndAddInputControl(IPanelInfo panelInfo, UIFormField formField)
        {
            IControlMapper controlMapper;
            IControlHabanero inputControl = ConfigureInputControl(formField, out controlMapper);

            int numberOfGridColumnsToSpan = 1 + (CONTROLS_PER_COLUMN * (formField.ColSpan - 1));
            GridLayoutManager.ControlInfo inputControlInfo = new GridLayoutManager.ControlInfo
                (inputControl, numberOfGridColumnsToSpan, formField.RowSpan);

            inputControl.Name = _controlNamingStrategy.GetInputControlName(formField);
            EnsureControlNameUnique(inputControl, panelInfo.Panel);
            panelInfo.LayoutManager.AddControl(inputControlInfo);
            return controlMapper;
        }
Exemplo n.º 27
0
 private void CreateAndAddErrorProviderPanel(IPanelInfo panelInfo, UIFormField formField)
 {
     IPanel panel = ControlFactory.CreatePanel();
     panelInfo.LayoutManager.AddControl(panel, formField.RowSpan, 1);
 }
Exemplo n.º 28
0
 private static void AddNullControlsForEmptyField(IPanelInfo panelInfo)
 {
     for (int i = 0; i < CONTROLS_PER_COLUMN; i++)
         panelInfo.LayoutManager.AddControl(null);
 }
Exemplo n.º 29
0
 private IControlHabanero CreateAndAddGroupBox(IPanelInfo panelInfo, UIFormField formField)
 {
     IControlHabanero labelControl = ControlFactory.CreateGroupBox(formField.GetLabel());
     labelControl.Width = 0; // don't affect the label column's fixed width
     labelControl.Name = formField.PropertyName;
     SetToolTip(formField, labelControl);
     panelInfo.LayoutManager.AddControl(labelControl, formField.RowSpan, 2);
     return labelControl;
 }
Exemplo n.º 30
0
        private PanelInfo.FieldInfo AddControlsForField(UIFormField formField, IPanelInfo panelInfo)
        {
            IControlHabanero labelControl;
            IControlMapper controlMapper;
            if (formField.Layout == LayoutStyle.Label)
            {
                labelControl = CreateAndAddLabel(panelInfo, formField);
                controlMapper = CreateAndAddInputControl(panelInfo, formField);
            }
            else
            {
                labelControl = CreateAndAddGroupBox(panelInfo, formField);
                controlMapper = CreateAndAddInputControlToContainerControl(formField, labelControl);
            }

            CreateAndAddErrorProviderPanel(panelInfo, formField);

            PanelInfo.FieldInfo fieldInfo = new PanelInfo.FieldInfo(formField.PropertyName, labelControl, controlMapper);
            panelInfo.FieldInfos.Add(fieldInfo);
            return fieldInfo;
        }
Exemplo n.º 31
0
        private void AddFieldsToLayoutManager(UIFormTab formTab, IPanelInfo panelInfo)
        {
            int numberOfColumns = formTab.Count;
            int[] currentFieldPositionInColumns = new int[numberOfColumns];
            int[] rowSpanTrackerForColumn = new int[numberOfColumns];
            int maxRowsInColumns = formTab.GetMaxRowsInColumns();
            int[] columnSpanTrackerForRow = new int[maxRowsInColumns];
            for (int currentRowNo = 0; currentRowNo < maxRowsInColumns; currentRowNo++)
            {
                for (int currentColumnNo = 0; currentColumnNo < numberOfColumns; currentColumnNo++)
                {
                    IUIFormColumn currentFormColumn = formTab[currentColumnNo];

                    if (--rowSpanTrackerForColumn[currentColumnNo] > 0) continue;
                    // keep skipping this grid position until a previous row span in this column has been decremented 
                    if (--columnSpanTrackerForRow[currentRowNo] > 0) continue;
                    // keep skipping this grid position until a previous column span in this row has been decremented

                    int currentFieldNoInColumn = currentFieldPositionInColumns[currentColumnNo];
                    int totalFieldsInColumn = currentFormColumn.Count;
                    if (currentFieldNoInColumn < totalFieldsInColumn) // there exists a field in this row in this column
                    {
                        UIFormField formField = (UIFormField) currentFormColumn[currentFieldNoInColumn];
                        rowSpanTrackerForColumn[currentColumnNo] = formField.RowSpan;
                        for (int i = currentRowNo; i < currentRowNo + formField.RowSpan; i++)
                            // update colspan of all rows that this field spans into.
                            columnSpanTrackerForRow[i] = formField.ColSpan;

                        PanelInfo.FieldInfo fieldInfo = AddControlsForField(formField, panelInfo);
                        fieldInfo.InputControl.TabIndex = currentColumnNo*maxRowsInColumns + currentRowNo;
                    }
                    else
                    {
                        AddNullControlsForEmptyField(panelInfo);
                    }
                    currentFieldPositionInColumns[currentColumnNo]++;
                }
            }
        }
Exemplo n.º 32
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="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());
        }
Exemplo n.º 34
0
 protected static void ChangeValuesInControls(IPanelInfo panelInfo)
 {
     panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Text = CHANGED_VALUE_1;
     panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Text = CHANGED_VALUE_2;
 }
Exemplo n.º 35
0
        private ILabel CreateAndAddLabel(IPanelInfo panelInfo, UIFormField formField)
        {
//            IClassDef classDef = panelInfo.UIForm.UIDef.ClassDef;
            ILabel labelControl = ControlFactory.CreateLabel(formField.GetLabel(), formField.IsCompulsory);
            labelControl.Name = _controlNamingStrategy.GetLabelControlName(formField);
            labelControl.Enabled = formField.Editable;
            SetToolTip(formField, labelControl);
            var containerControl = panelInfo.Panel;
            EnsureControlNameUnique(labelControl, containerControl);
            panelInfo.LayoutManager.AddControl(labelControl, formField.RowSpan, 1);
            return labelControl;
        }
Exemplo n.º 36
0
        private static void SetupInputControlColumnWidth(IPanelInfo panelInfo, IUIFormTab formTab)
        {
            GridLayoutManager layoutManager = panelInfo.LayoutManager;
            int formColCount = 0;
            foreach (UIFormColumn formColumn in formTab)
            {
                if (formColumn.Width < 0) continue;
                int gridCol = formColCount * CONTROLS_PER_COLUMN;
                int labelColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + LABEL_CONTROL_COLUMN_NO);
                int errorProviderColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + ERROR_PROVIDER_COLUMN_NO);
                int totalGap = (CONTROLS_PER_COLUMN - 1) * layoutManager.HorizontalGapSize;
                if (formTab.Count == 1)
                    totalGap += 2 * layoutManager.BorderSize; // add extra border for single column
                else if (formColCount == formTab.Count - 1)
                    totalGap += layoutManager.BorderSize + layoutManager.HorizontalGapSize; // last column in multi-column
                else if (formColCount > 0 && formTab.Count > 0)
                    totalGap += layoutManager.HorizontalGapSize; //2 More gaps for internal column in multi-column
                else if (formColCount == 0 && formTab.Count > 0) totalGap += layoutManager.BorderSize;

                layoutManager.FixColumn
                    (gridCol + INPUT_CONTROL_COLUMN_NO,
                     formColumn.Width - labelColumnWidth - errorProviderColumnWidth - totalGap);
                formColCount++;
            }
        }
        /// <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="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());
        }
Exemplo n.º 39
0
        private void CreateAndAddErrorProviderPanel(IPanelInfo panelInfo, UIFormField formField)
        {
            IPanel panel = ControlFactory.CreatePanel();

            panelInfo.LayoutManager.AddControl(panel, formField.RowSpan, 1);
        }