private static ClassDef GetClassDef() { PropDef propDefPK = new PropDef(ENUM_PKPROP_NAME, typeof(Guid), PropReadWriteRule.WriteNew, null); PropDef propDef = new PropDef(ENUM_PROP_NAME, typeof(TestEnum), PropReadWriteRule.ReadWrite, TestEnum.Option1); PropDef propDef2 = new PropDef(ENUM_PROP_NAME_EMPTY, typeof(TestEnumEmpty), PropReadWriteRule.ReadWrite, null); PropDef propDef3 = new PropDef(ENUM_PROP_NAME_PASCAL, typeof(TestEnumPascalCase), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef { propDefPK }; PropDefCol propDefCol = new PropDefCol { propDefPK, propDef, propDef2, propDef3 }; UIFormField uiFormField = new UIFormField(TestUtil.GetRandomString(), propDef.PropertyName, typeof(IComboBox), "EnumComboBoxMapper", "Habanero.Faces.Base", true, null, null, LayoutStyle.Label); UIFormColumn uiFormColumn = new UIFormColumn { uiFormField }; UIFormTab uiFormTab = new UIFormTab { uiFormColumn }; UIForm uiForm = new UIForm { uiFormTab }; UIDef uiDef = new UIDef("default", uiForm, null); UIDefCol uiDefCol = new UIDefCol { uiDef }; ClassDef classDef = new ClassDef(typeof(EnumBO), primaryKeyDef, propDefCol, new KeyDefCol(), null, uiDefCol); return(classDef); }
public void TestFieldToolTipFromClassDef() { ClassDef classDef = CreateTestClassDef(""); UIFormField uiFormField = new UIFormField(null, "TestProperty", typeof(TextBox), null, null, true, null, null, LayoutStyle.Label); Assert.AreEqual("This is a property for testing.", uiFormField.GetToolTipText(classDef)); }
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); } }
public void Test_NotEqualsDiffFieldCount() { //---------------Set up test pack------------------- UIFormColumn uiFormColumn1 = new UIFormColumn(); UIFormField def = CreateUIFormField("bob", "bob"); uiFormColumn1.Add(def); UIFormColumn uiFormColumn2 = new UIFormColumn(); uiFormColumn2.Add(def); UIFormField def2 = CreateUIFormField("bob1", "bob1"); uiFormColumn1.Add(def); uiFormColumn1.Add(def2); uiFormColumn2.Add(def2); //--------------Assert PreConditions---------------- Assert.AreNotEqual(uiFormColumn1.Count, uiFormColumn2.Count); //---------------Execute Test ---------------------- bool operatorEquals = uiFormColumn1 == uiFormColumn2; bool equalsMethod = uiFormColumn1.Equals(uiFormColumn2); bool equalsObjectMethod = uiFormColumn1.Equals((object)uiFormColumn2); //---------------Test Result ----------------------- Assert.IsFalse(operatorEquals); Assert.IsFalse(equalsMethod); Assert.IsFalse(equalsObjectMethod); //---------------Tear Down ------------------------- }
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); }
public void GetRowSpanForColumnToTheRight_TwoColumns() { //---------------Set up test pack------------------- Hashtable parameters1 = new Hashtable(); parameters1.Add("rowSpan", 1); parameters1.Add("colSpan", 3); UIFormField field1 = CreateUIFormField("label2", "prop2", parameters1); Hashtable parameters2 = new Hashtable(); parameters2.Add("rowSpan", 2); parameters2.Add("colSpan", 2); UIFormField field2 = CreateUIFormField("label2", "prop2", parameters2); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); //---------------Execute Test ---------------------- int rowsPanForColumnToTheRight1 = uiFormColumn.GetRowSpanForColumnToTheRight(1); int rowsPanForColumnToTheRight2 = uiFormColumn.GetRowSpanForColumnToTheRight(2); //---------------Test Result ----------------------- Assert.AreEqual(3, rowsPanForColumnToTheRight1); Assert.AreEqual(1, rowsPanForColumnToTheRight2); }
private object GetValue(BaseWidget widget, UIFormField fieldValue, BaseField fieldSchema) { //if CustomValueBinder exists then call it else var value = widget.GetValue(); return(value); }
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()); }
public void TestLabelText_UsesPropertyNameWithCamelCase() { XmlUIFormFieldLoader loader = new XmlUIFormFieldLoader(new DtdLoader(), new DefClassFactory()); UIFormField uiProp = (UIFormField)loader.LoadUIProperty(@"<field property=""TestPropName"" />"); Assert.AreEqual(null, uiProp.Label); Assert.AreEqual("Test Prop Name:", uiProp.GetLabel()); }
public void Test_Layout_Default() { //---------------Execute Test ---------------------- UIFormField uiFormField1 = CreateFormField(); //---------------Test Result ----------------------- Assert.AreEqual(LayoutStyle.Label, uiFormField1.Layout); }
///// <summary> ///// A handler to deal with the case of an entered panel ///// </summary> ///// <param name="sender">The object that notified of the event</param> ///// <param name="e">Attached arguments regarding the event</param> //private void PanelEnteredHandler(object sender, EventArgs e) //{ // _firstControl.Focus(); //} ///// <summary> ///// A handler to deal with the press of an Enter key when the control ///// is an up-down object ///// </summary> ///// <param name="sender">The object that notified of the event</param> ///// <param name="e">Attached arguments regarding the event</param> //private static void UpDownEnterHandler(object sender, EventArgs e) //{ // INumericUpDown upDown = (INumericUpDown) sender; // upDown.Select(0, upDown.Text.Length); //} ///// <summary> ///// A handler to deal with the press of an Enter key when the control ///// is a date-time picker ///// </summary> ///// <param name="sender">The object that notified of the event</param> ///// <param name="e">Attached arguments regarding the event</param> //private static void DateTimePickerEnterHandler(object sender, EventArgs e) //{ //} ///// A handler to deal with a double-click on an email textbox, which ///// causes the default mail client on the user system to be opened ///// </summary> ///// <param name="sender">The object that notified of the event</param> ///// <param name="e">Attached arguments regarding the event</param> //private static void EmailTextBoxDoubleClickedHandler(object sender, EventArgs e) //{ // ITextBox tb = (ITextBox) sender; // if (tb.Text.IndexOf("@") != -1) // { // string comm = "mailto:" + tb.Text; // Process.Start(comm); // } //} /// <summary> /// Creates the appropriate control for the given field element. /// Preference is given to a specific type over the type and assembly names. /// </summary> private static IControlHabanero CreateControl(UIFormField field, IControlFactory factory) { if (field.ControlType != null) { return(factory.CreateControl(field.ControlType)); } return(factory.CreateControl(field.ControlTypeName, field.ControlAssemblyName)); }
public void TestLabelText_UsesQuestionMark_WhenCheckBoxField() { XmlUIFormFieldLoader loader = new XmlUIFormFieldLoader(new DtdLoader(), new DefClassFactory()); UIFormField uiProp = (UIFormField)loader.LoadUIProperty(@"<field property=""TestPropName"" type=""CheckBox"" />"); Assert.AreEqual(null, uiProp.Label); Assert.AreEqual("Test Prop Name?", uiProp.GetLabel()); }
public void Test_Layout() { UIFormField uiFormField1 = CreateFormField(); //---------------Execute Test ---------------------- uiFormField1.Layout = LayoutStyle.GroupBox; //---------------Test Result ----------------------- Assert.AreEqual(LayoutStyle.GroupBox, uiFormField1.Layout); }
/// <summary> /// Checks whether a given field should be editable and makes appropriate /// changes. If the property is an ObjectID and the BO /// is not new, then editing should not be done. /// </summary> /// <param name="field">The field being added</param> /// <param name="ctl">The control being prepared</param> /// <returns>Returns true if editable</returns> private bool CheckIfEditable(UIFormField field, IControlHabanero ctl) { bool editable = field.Editable; if (editable) { if (_firstControl == null) { _firstControl = ctl; } } if (editable) { object parameterValue = field.GetParameterValue("editable"); if (parameterValue != null) { editable = Convert.ToBoolean(parameterValue); } parameterValue = field.GetParameterValue("readWriteRule"); string writeRule = ""; if (parameterValue != null) { writeRule = Convert.ToString(parameterValue); } if (writeRule.Length > 0) { if (writeRule == "ReadOnly") { editable = false; } if (writeRule == "WriteNew") { if (_currentBusinessObject.Status.IsNew) { editable = true; } else { editable = false; } } if (writeRule == "WriteNotNew") { if (_currentBusinessObject.Status.IsNew) { editable = false; } else { editable = true; } } } } return(editable); }
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); }
public void ResolveFieldValue(UIFormField formField, Action <object, BaseField> onSetValue) { var fieldSchema = this._formContext.GetField(formField.WidgetId); object value; ResolveData(fieldSchema, formField, out value); onSetValue.Invoke(value, fieldSchema); }
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)); }
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); }
private void SetToolTip(UIFormField formField, IControlHabanero control) { string toolTipText = formField.GetToolTipText(); IToolTip toolTip = ControlFactory.CreateToolTip(); if (!String.IsNullOrEmpty(toolTipText)) { toolTip.SetToolTip(control, toolTipText); } }
public void Test_Not_EqualsNull() { UIFormField uiFormField1 = CreateFormField(); const UIFormField uiFormField2 = null; Assert.IsFalse(uiFormField1 == uiFormField2); Assert.IsFalse(uiFormField2 == uiFormField1); Assert.IsFalse(uiFormField1.Equals(uiFormField2)); //Assert.AreNotEqual(uiFormField2, uiFormField1); }
public void TestEquals() { UIFormField uiFormField1 = CreateFormField(); UIFormField uiFormField2 = CreateFormField(); Assert.IsTrue(uiFormField1 == uiFormField2); Assert.IsFalse(uiFormField1 != uiFormField2); Assert.IsTrue(uiFormField1.Equals(uiFormField2)); //Assert.AreEqual(uiFormField1, uiFormField2); }
public UIFormColumn CreateUIFormColumn_2Fields(string propName) { UIFormField field1 = new UIFormField("label1", propName, "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); return(uiFormColumn); }
public void TestRemove() { UIFormField field = CreateUIFormField(); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field); Assert.IsTrue(uiFormColumn.Contains(field)); uiFormColumn.Remove(field); Assert.IsFalse(uiFormColumn.Contains(field)); }
private static void AddMultiLineTextbox(UIFormField formField, IControlHabanero inputControl) { if (formField.RowSpan <= 1) { return; } if (inputControl is ITextBox) { ((ITextBox)inputControl).Multiline = true; } }
public UIFormColumn CreateUIFormColumn_2Fields(string propName) { UIFormField field1 = CreateUIFormField("label1", propName, null); UIFormField field2 = CreateUIFormField("label2", "prop2", null); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); return(uiFormColumn); }
public UIFormColumn CreateUIFormColumn_1FieldWith2RowAnd3ColSpan() { Hashtable parameters = new Hashtable(); parameters.Add("rowSpan", 2); parameters.Add("colSpan", 3); UIFormField field1 = CreateUIFormField("label1", "prop1", parameters); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); return(uiFormColumn); }
public void Test_showAsCompulsory_WhenUseCompNull_ShouldReturnNull() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- UIFormField uiFormField = new UIFormField("L", "L", "", "", "", "", true, null , "", null, LayoutStyle.Label); //---------------Test Result ----------------------- var showAsCompulsory = uiFormField.ShowAsCompulsory; Assert.IsNull(showAsCompulsory); }
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); }
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); }
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); }