Exemplo n.º 1
0
 public void TestFieldDefaultLabel()
 {
     UIFormField uiFormField = new UIFormField(null, "TestProperty", typeof(TextBox), null, null, true, null, null, LayoutStyle.Label);
     Assert.AreEqual("Test Property:", uiFormField.GetLabel());
     uiFormField = new UIFormField(null, "TestProperty", typeof(CheckBox), null, null, true, null, null, LayoutStyle.Label);
     Assert.AreEqual("Test Property?", uiFormField.GetLabel());
 }
Exemplo n.º 2
0
 public void TestFieldDefaultLabelFromClassDef()
 {
     ClassDef classDef = CreateTestClassDef("");
     UIFormField uiFormField = new UIFormField(null, "TestProperty", typeof(TextBox), null, null, true, null, null, LayoutStyle.Label);
     Assert.AreEqual("Tested Property:", uiFormField.GetLabel(classDef));
     uiFormField = new UIFormField(null, "TestProperty", typeof(CheckBox), null, null, true, null, null, LayoutStyle.Label);
     Assert.AreEqual("Tested Property?", uiFormField.GetLabel(classDef));
 }
Exemplo n.º 3
0
        ///<summary>
        ///Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        ///</summary>
        ///
        ///<returns>
        ///true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        ///</returns>
        ///
        ///<param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>. </param><filterpriority>2</filterpriority>
        public override bool Equals(object obj)
        {
            UIFormField otherFormField = obj as UIFormField;

            if ((object)otherFormField == null)
            {
                return(false);
            }
            return(otherFormField.PropertyName == this.PropertyName &&
                   otherFormField.ControlTypeName == this.ControlTypeName &&
                   otherFormField.Label == this.Label);
        }
Exemplo n.º 4
0
        public void TestCopyTo()
        {
            UIFormField field1 = CreateUIFormField();
            UIFormField field2 = CreateUIFormField();
            UIFormColumn uiFormColumn = new UIFormColumn();
            uiFormColumn.Add(field1);
            uiFormColumn.Add(field2);

            UIFormField[] target = new UIFormField[2];
            uiFormColumn.CopyTo(target, 0);
            Assert.AreEqual(field1, target[0]);
            Assert.AreEqual(field2, target[1]);
        }
Exemplo n.º 5
0
 public void Test_Construct_WithUIFormColumns()
 {
     //---------------Set up test pack-------------------
     UIFormField uiFormField1 = new UIFormField("label1", "prop1");
     UIFormField uiFormField2 = new UIFormField("label2", "prop2");
     UIFormField uiFormField3 = new UIFormField("label3", "prop3");
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     UIFormColumn uiFormColumn = new UIFormColumn(uiFormField1, uiFormField2, uiFormField3);
     //---------------Test Result -----------------------
     Assert.AreEqual(3, uiFormColumn.Count);
     Assert.AreSame(uiFormField1, uiFormColumn[0]);
     Assert.AreSame(uiFormField2, uiFormColumn[1]);
     Assert.AreSame(uiFormField3, uiFormColumn[2]);
 }
Exemplo n.º 6
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.º 7
0
 private void CreateAndAddErrorProviderPanel(IPanelInfo panelInfo, UIFormField formField)
 {
     IPanel panel = ControlFactory.CreatePanel();
     panelInfo.LayoutManager.AddControl(panel, formField.RowSpan, 1);
 }
Exemplo n.º 8
0
 private IControlMapper CreateAndAddInputControlToContainerControl
     (UIFormField formField, IControlHabanero containerControl)
 {
     IControlMapper controlMapper;
     IControlHabanero inputControl = ConfigureInputControl(formField, out controlMapper);
     inputControl.Dock = DockStyle.Fill;
     inputControl.Name = _controlNamingStrategy.GetInputControlName(formField);
     EnsureControlNameUnique(inputControl, containerControl);
     containerControl.Controls.Add(inputControl);
     return controlMapper;
 }
Exemplo n.º 9
0
        private static void SetInputControlNumLines(UIFormField formField, IControlHabanero inputControl)
        {
            if (!(inputControl is ITextBox)) return;
            if (formField.RowSpan <= 1) return;

            ITextBox textBox = ((ITextBox) inputControl);
            textBox.Multiline = true;
            textBox.AcceptsReturn = true;
            textBox.ScrollBars = ScrollBars.Vertical;
        }
Exemplo n.º 10
0
        public void TestHasParameterValue_True()
        {
            //---------------Set up test pack-------------------
            Hashtable parameters = new Hashtable();
            const string parameterName = "bob";
            parameters.Add(parameterName, "I can like to have a value");
            UIFormField uiFormField1 = new UIFormField("L", "L", "", "", "", "", true, null, "", parameters, LayoutStyle.Label);
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool hasParameterValue = uiFormField1.HasParameterValue(parameterName);
            //---------------Test Result -----------------------
            Assert.IsTrue(hasParameterValue);

        }
Exemplo n.º 11
0
 private static void AddMultiLineTextbox(UIFormField formField, IControlHabanero inputControl)
 {
     if (formField.RowSpan <= 1) return;
     if (inputControl is ITextBox) ((ITextBox) inputControl).Multiline = true;
 }
Exemplo n.º 12
0
 private static void AddComboBoxItems(UIFormField formField, IControlHabanero inputControl)
 {
     if (String.IsNullOrEmpty(formField.Options)) return;
     if (inputControl is IComboBox && formField.MapperTypeName.ToLower() == "listcomboboxmapper")
     {
         string[] items = formField.Options.Split('|');
         IComboBox comboBox = ((IComboBox) inputControl);
         comboBox.Items.Add(""); // This creates the blank item for the ComboBox 
         foreach (string item in items)
         {
             comboBox.Items.Add(item);
         }
     }
 }
Exemplo n.º 13
0
 public void Test_NotEquals_LabelDiff()
 {
     UIFormField uiFormField1 = new UIFormField("L", "L", "", "", "", "", true, null, "", new Hashtable(), LayoutStyle.Label);
     UIFormField uiFormField2 = new UIFormField("G", "L", "", "", "", "", true, null, "", new Hashtable(), LayoutStyle.Label);
     Assert.IsFalse(uiFormField1.Equals(uiFormField2));
     Assert.IsFalse(uiFormField1 == uiFormField2);
     //Assert.AreNotEqual(uiFormField1, uiFormField2);
 }
Exemplo n.º 14
0
 public void Test_showAsCompulsory_WhenUseCompTrue_ShouldBeTrue()
 {
     //---------------Set up test pack-------------------
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     UIFormField uiFormField = new UIFormField("L", "L", "", "", "", "", true, true
             , "", null, LayoutStyle.Label);
     //---------------Test Result -----------------------
     var showAsCompulsory = uiFormField.ShowAsCompulsory;
     Assert.IsNotNull(showAsCompulsory);
     Assert.IsTrue((bool)showAsCompulsory);
 }
Exemplo n.º 15
0
        public void TestAlignment_NotSet()
        {
            //---------------Set up test pack-------------------
            UIFormField uiFormField = new UIFormField("L", "L", "", "", "", "", true, null, "", new Hashtable(), LayoutStyle.Label);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string alignment = uiFormField.Alignment;
            //---------------Test Result -----------------------
            Assert.IsNull(alignment);

        }
Exemplo n.º 16
0
        public void TestAlignment_Set()
        {
            //---------------Set up test pack-------------------
            Hashtable parameters = new Hashtable {{"alignment", "right"}};
            UIFormField uiFormField = new UIFormField("L", "L", "", "", "", "", true, null, "", parameters, LayoutStyle.Label);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string alignment = uiFormField.Alignment;
            //---------------Test Result -----------------------
            Assert.AreEqual("right", alignment);
        }
Exemplo n.º 17
0
 public void TestNumLines_Set_RowSpan_Set()
 {
     //---------------Set up test pack-------------------
     Hashtable parameters = new Hashtable {{"numLines", 3}, {"rowSpan", 2}};
     UIFormField uiFormField = new UIFormField("L", "L", "", "", "", "", true, null, "", parameters, LayoutStyle.Label);
     //---------------Assert PreConditions---------------            
     //---------------Execute Test ----------------------
     int rowSpan = uiFormField.RowSpan;
     //---------------Test Result -----------------------
     Assert.AreEqual(2, rowSpan);
 }
Exemplo n.º 18
0
        public void TestColSpan_Set()
        {
            //---------------Set up test pack-------------------
            Hashtable parameters = new Hashtable {{"colSpan", 3}};
            UIFormField uiFormField1 = new UIFormField("L", "L", "", "", "", "", true, null, "", parameters, LayoutStyle.Label);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            int colSpan = uiFormField1.ColSpan;
            //---------------Test Result -----------------------
            Assert.AreEqual(3, colSpan);
        }
Exemplo n.º 19
0
        public void TestColSpan_NotSet()
        {
            //---------------Set up test pack-------------------
            UIFormField uiFormField1 = new UIFormField("L", "L", "", "", "", "", true, null, "", new Hashtable(), LayoutStyle.Label);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            int colSpan = uiFormField1.ColSpan;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, colSpan);

        }
Exemplo n.º 20
0
        internal IControlHabanero ConfigureInputControl(UIFormField formField, out IControlMapper controlMapper)
        {
            IControlHabanero inputControl = ControlFactory.CreateControl
                (formField.ControlTypeName, formField.ControlAssemblyName);
            controlMapper = ControlMapper.Create
                (formField.MapperTypeName, formField.MapperAssembly, inputControl, formField.PropertyName,
                 !formField.Editable, ControlFactory);
            controlMapper.ClassDef = GetClassDef(formField);
            SetInputControlAlignment(formField, inputControl);
            SetInputControlNumLines(formField, inputControl);
            
            controlMapper.SetPropertyAttributes(formField.Parameters);

            AddDecimalPlacesToNumericUpDown(formField, inputControl);

            AddComboBoxItems(formField, inputControl);

            AddEmailFunctionalityToTextBox(formField, inputControl);

            AddMultiLineTextbox(formField, inputControl);

            if (formField.KeepValuePrivate)
            {
                ITextBox tBox = inputControl as ITextBox;
                if(tBox != null)
                {
                    tBox.PasswordChar = '*';
                }
            }

            SetToolTip(formField, inputControl);
            return inputControl;
        }
Exemplo n.º 21
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.º 22
0
 private static IClassDef GetClassDef(UIFormField formField)
 {
     return formField.ClassDef;
 }
Exemplo n.º 23
0
        public void TestFieldDefaultLabelFromRelatedClassDef()
        {
            ClassDef.ClassDefs.Clear();
            ClassDef classDef = CreateTestClassDef("");
            ClassDef classDef2 = CreateTestClassDef("2");
            ClassDef.ClassDefs.Add(classDef2);
            RelKeyDef relKeyDef = new RelKeyDef();
            RelPropDef relPropDef = new RelPropDef(classDef.PropDefcol["TestProperty"], "TestProperty2");
            relKeyDef.Add(relPropDef);
            SingleRelationshipDef def = new SingleRelationshipDef("TestRel", classDef2.AssemblyName, classDef2.ClassName, relKeyDef, false, DeleteParentAction.Prevent);
            classDef.RelationshipDefCol.Add(def);

            UIFormField uiFormField = new UIFormField(null, "TestRel.TestProperty2", typeof(TextBox), null, null, true, null, null, LayoutStyle.Label);
            Assert.AreEqual("Tested Property2:", uiFormField.GetLabel(classDef));
        }
Exemplo n.º 24
0
 private static void AddDecimalPlacesToNumericUpDown(UIFormField formField, IControlHabanero inputControl)
 {
     if (String.IsNullOrEmpty(formField.DecimalPlaces)) return;
     if (inputControl is INumericUpDown && !String.IsNullOrEmpty(formField.MapperTypeName) 
         && formField.MapperTypeName.ToLower() == "numericupdowncurrencymapper")
     {
         int decimalPlaces = Convert.ToInt32(formField.DecimalPlaces);
         if (decimalPlaces >= 0)
         {
             ((INumericUpDown) inputControl).DecimalPlaces = decimalPlaces;
         }
     }
 }
Exemplo n.º 25
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.º 26
0
 private static void AddEmailFunctionalityToTextBox(UIFormField formField, IControlHabanero inputControl)
 {
     if (String.IsNullOrEmpty(formField.IsEmail)) return;
     if (inputControl is ITextBox && Convert.ToBoolean(formField.IsEmail))
     {
         ITextBox textBox = (ITextBox) inputControl;
         textBox.DoubleClick += EmailTextBoxDoubleClickedHandler;
     }
 }
Exemplo n.º 27
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.º 28
0
        private static void SetInputControlAlignment(UIFormField formField, IControlHabanero inputControl)
        {
            // Some controls have TextAlign and others don't. This code uses reflection to apply it if appropriate.
            // This did not work because the propertyInfo.SetValue method was not calling the TestBoxVWG TextAlign Set property method.
            // PropertyInfo propertyInfo = inputControl.GetType().GetProperty("TextAlign");
            //if (propertyInfo != null &&
            //    propertyInfo.PropertyType.Name == "HorizontalAlignment") //caters for the possibility of a custom control that implements textalign but doesn't have HorizontalAlignment as its type
            //{

            //    propertyInfo.SetValue(inputControl, GetAlignmentValue(formField.Alignment), new object[0]);
            //}
            if (String.IsNullOrEmpty(formField.Alignment)) return;

            if (inputControl is ITextBox)
            {
                ((ITextBox) inputControl).TextAlign = GetAlignmentValue(formField.Alignment);
            }
            if (inputControl is INumericUpDown)
            {
                ((INumericUpDown) inputControl).TextAlign = GetAlignmentValue(formField.Alignment);
            }
        }
Exemplo n.º 29
0
        public void TestHasParameterValue_False()
        {
            //---------------Set up test pack-------------------
            UIFormField uiFormField1 = new UIFormField("L", "L", "", "", "", "", true, null, "", new Hashtable(), LayoutStyle.Label);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool hasParameterValue = uiFormField1.HasParameterValue(TestUtil.GetRandomString());
            //---------------Test Result -----------------------
            Assert.IsFalse(hasParameterValue);

        }       
Exemplo n.º 30
0
 private void SetToolTip(UIFormField formField, IControlHabanero control)
 {
     string toolTipText = formField.GetToolTipText();
     IToolTip toolTip = ControlFactory.CreateToolTip();
     if (!String.IsNullOrEmpty(toolTipText))
     {
         toolTip.SetToolTip(control, toolTipText);
     }
 }
Exemplo n.º 31
0
        private static UIForm GetUiForm()
        {
            UIFormField field1 = new UIFormField("label1", "prop1", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormField field2 = new UIFormField("label2", "prop2", "control", null, null, null, true, null, null, null, LayoutStyle.Label);
            UIFormColumn uiFormColumn = new UIFormColumn();
            uiFormColumn.Add(field1);
            uiFormColumn.Add(field2);

            UIFormTab uiFormTab = new UIFormTab("Tab1");
            uiFormTab.Add(uiFormColumn);

            UIForm uiForm = new UIForm();
            uiForm.Add(uiFormTab);
            uiForm.Title = "ddd";
            uiForm.Height = 1;
            uiForm.Width = 3;
            return uiForm;
        }