public CheckBoxWidgetFuntion(EntityTokenFactory entityTokenFactory) : base(CompositeName, typeof(bool), entityTokenFactory) { ParameterProfile pp = new ParameterProfile("ItemLabel", typeof(string), false, new ConstantValueProvider(""), StandardWidgetFunctions.TextBoxWidget, null, "Sub label", new HelpDefinition("Text to whow beside the checkbox")); base.AddParameterProfile(pp); }
public DateSelectorWidgetFunction(EntityTokenFactory entityTokenFactory) : base(CompositeName, typeof(DateTime), entityTokenFactory) { ParameterProfile pp = new ParameterProfile("ReadOnly", typeof(bool), false, new ConstantValueProvider(false), StandardWidgetFunctions.CheckBoxWidget, null, "Read only", new HelpDefinition("When selected users can not change the date.")); base.AddParameterProfile(pp); }
public TextBoxWidgetFuntion(EntityTokenFactory entityTokenFactory) : base(CompositeName, typeof(string), entityTokenFactory) { ParameterProfile spellCheckPP = new ParameterProfile(TextBoxWidgetFuntion.SpellCheckParameterName, typeof(bool), false, new ConstantValueProvider(true), StandardWidgetFunctions.GetBoolSelectorWidget("Allow spell checking", "Do not allow spell checking"), null, "Spell check", new HelpDefinition("By default text will be spell checked (when available). You should explicitly disable spell checking on fields that contain e-mails, code values etc. not suitable for spell checking. ")); base.AddParameterProfile(spellCheckPP); }
public FormMarkupWidgetFuntion(EntityTokenFactory entityTokenFactory) : base(CompositeName, typeof(string), entityTokenFactory) { var markupParameterProfile = new ParameterProfile(MarkupParameterName, typeof(string), true, new ConstantValueProvider( @"<TextBox Label=""$label"" Help=""$help"" SpellCheck=""true""> <TextBox.Text> <cms:bind source=""$binding"" /> </TextBox.Text> </TextBox>"), StandardWidgetFunctions.TextAreaWidget, null, "Markup", new HelpDefinition("Markup will be inserted into result form markup. Macroses are: '$binding', '$label' and '$help'")); base.AddParameterProfile(markupParameterProfile); }
private void SetParameterProfiles(bool require, string trueLabel, string falseLabel) { ParameterProfile trueLabelPP = new ParameterProfile(BoolSelectorWidgetFuntion.TrueLabelParameterName, typeof(string), require, new ConstantValueProvider(trueLabel), StandardWidgetFunctions.TextBoxWidget, null, "True label", new HelpDefinition("Label to show when value is true")); ParameterProfile falseLabelPP = new ParameterProfile(BoolSelectorWidgetFuntion.FalseLabelParameterName, typeof(string), require, new ConstantValueProvider(falseLabel), StandardWidgetFunctions.TextBoxWidget, null, "False label", new HelpDefinition("Label to show when value is false")); base.AddParameterProfile(trueLabelPP); base.AddParameterProfile(falseLabelPP); }
/// <exclude /> public static void SetParameterValue(XElement functionMarkup, ParameterProfile parameter, object parameterValue) { bool newValueNotEmpty = parameterValue != null && (!(parameterValue is IList) || ((IList) parameterValue).Count > 0) && !(parameter.IsRequired && parameterValue as string == string.Empty); var parameterNode = functionMarkup.Elements(ParameterNodeXName).FirstOrDefault(p => (string)p.Attribute("name") == parameter.Name); if (parameterNode != null) { parameterNode.Remove(); } if (newValueNotEmpty && parameterValue != parameter.GetDefaultValue()) { var newConstantParam = new ConstantObjectParameterRuntimeTreeNode(parameter.Name, parameterValue); functionMarkup.Add(newConstantParam.Serialize()); } }
/// <summary> /// Gets simple parameter value from it's markup. /// </summary> /// <returns></returns> public static object GetParameterValue(XElement parameterNode, ParameterProfile parameterProfile) { List<XElement> parameterElements = parameterNode.Elements(ParameterValueElementXName).ToList(); if (parameterElements.Any()) { return parameterElements.Select(element => element.Attribute("value").Value).ToList(); } var valueAttr = parameterNode.Attribute("value"); if (valueAttr != null) { try { return XmlSerializationHelper.Deserialize(valueAttr, parameterProfile.Type); } catch (Exception ex) { Log.LogError(LogTitle, ex); return parameterProfile.GetDefaultValue(); } } if (parameterNode.Elements().Any()) { Type paramType = parameterProfile.Type; if (paramType.IsSubclassOf(typeof(XContainer)) || (paramType.IsLazyGenericType() && paramType.GetGenericArguments()[0].IsSubclassOf(typeof(XContainer)))) { return ValueTypeConverter.Convert(parameterNode.Elements().First(), parameterProfile.Type); } throw new NotImplementedException("Not supported type of function parameter element node: '{0}'".FormatWith(paramType.FullName)); } return parameterProfile.GetDefaultValue(); }
private object GetDefaultValue(ParameterProfile parameterProfile) { // Initializing the binding object value = null; try { var fallbackValueProvider = parameterProfile.FallbackValueProvider; if (!(fallbackValueProvider is NoValueValueProvider)) { object defaultValue = fallbackValueProvider.GetValue(); if (defaultValue != null) { value = ValueTypeConverter.Convert(defaultValue, parameterProfile.Type); } } } catch (Exception) { } if (value == null) { if (parameterProfile.Type == typeof(bool)) { value = false; } } return value; }
private void ShowInputParameterSelector(ParameterProfile parameterProfile, XElement parameterName) { // string inputParameterName = functionNode.Elements().First().Attribute("value").Value; btnInputParameter.Attributes["isdisabled"] = "true"; btnInputParameter.Attributes["image"] = "${icon:accept}"; mlvWidget.SetActiveView(viewWidget_InputParameter); lstInputParameterName.Items.Clear(); foreach (var parameter in _state.Parameters) { if (InputParameterCanBeAssigned(parameterProfile.Type, parameter.Type)) { lstInputParameterName.Items.Add(parameter.Name); } } lstInputParameterName.SelectedValue = parameterName.Attribute("inputParameter").Value; InputParameterSelectorIsShown = true; }
public virtual void AddParameter(ParameterProfile parameterProfile) { _parameters.Add(parameterProfile); }
private void SetParameterProfiles(string classConfigurationName) { ParameterProfile classConfigNamePP = new ParameterProfile(VisualXhtmlEditorFuntion.ClassConfigurationNameParameterName, typeof(string), false, new ConstantValueProvider(classConfigurationName), StandardWidgetFunctions.TextBoxWidget, null, "Class configuration name", new HelpDefinition("The visual editor can be configured to offer the editor a special set of class names for formatting xhtml elements. The default value is '" + classConfigurationName + "'")); base.AddParameterProfile(classConfigNamePP); ParameterProfile typeNamePP = new ParameterProfile(VisualXhtmlEditorFuntion.EmbedableFieldTypeParameterName, typeof(Type), false, new ConstantValueProvider(null), StandardWidgetFunctions.DataTypeSelectorWidget, null, "Embedable fields, Data type", new HelpDefinition("If a data type is selected, fields from this type can be inserted into the xhtml.")); base.AddParameterProfile(typeNamePP); StringSelector.BuildInlineXhtmlEditorParameters().ForEach(AddParameterProfile); }
private void SetParameterProfiles() { ParameterProfile dataTypePP = new ParameterProfile("OptionsType", typeof(Type), true, new NoValueValueProvider(), StandardWidgetFunctions.DataTypeSelectorWidget, null, "Data type to select from", new HelpDefinition("The list of options the user can choose from will be selected from this type.")); base.AddParameterProfile(dataTypePP); ParameterProfile compactModePP = new ParameterProfile("CompactMode", typeof(bool), false, new ConstantValueProvider(false), StandardWidgetFunctions.GetBoolSelectorWidget("Compact", "Verbose"), null, "Compact UI", new HelpDefinition("When true, a more compact representation of long option lists is used. Default is false (verbose).")); base.AddParameterProfile(compactModePP); }
/// <exclude /> protected void AddParameterProfile(ParameterProfile pp) { ((List<ParameterProfile>)this.ParameterProfiles).Add(pp); }