/// <summary>
    /// Fill attribute types list.
    /// </summary>
    /// <param name="selectedType">Type that will be selected after loading the list.</param>
    private void LoadAndSelectAttributeType(string selectedType = FieldDataType.Text)
    {
        var objectType = DataClassInfo.OBJECT_TYPE;

        // Get object type based on class name
        var dci = DataClassInfoProvider.GetDataClassInfo(ClassName);

        if (dci != null)
        {
            objectType = dci.TypeInfo.ObjectType;
        }

        var types = DataTypeManager.GetFieldTypes(objectType).ToHashSetCollection();

        // Remove file type for these objects
        switch (Mode)
        {
        case FieldEditorModeEnum.ClassFormDefinition:
        case FieldEditorModeEnum.AlternativeClassFormDefinition:
            if (!IsDocumentType)
            {
                types.Remove(FieldDataType.File);
            }
            break;

        case FieldEditorModeEnum.WebPartProperties:
        case FieldEditorModeEnum.CustomTable:
        case FieldEditorModeEnum.SystemTable:
        case FieldEditorModeEnum.FormControls:
        case FieldEditorModeEnum.ProcessActions:
        case FieldEditorModeEnum.Widget:
        case FieldEditorModeEnum.AlternativeCustomTable:
        case FieldEditorModeEnum.AlternativeSystemTable:
        case FieldEditorModeEnum.InheritedFormControl:
        case FieldEditorModeEnum.EmailWidget:
            types.Remove(FieldDataType.File);
            break;
        }

        // Ensure selected type
        types.Add(selectedType);

        drpAttributeType.DataSource = types
                                      .Select(type => new ListItem(ResHelper.GetString($"TemplateDesigner.FieldTypes.{type}"), type))
                                      .OrderBy(x => x.Text);

        drpAttributeType.DataBind();

        if (drpAttributeType.Items.Count > 0)
        {
            drpAttributeType.SelectedValue = selectedType;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Fill attribute types list.
    /// </summary>
    /// <param name="selectedType">Type that will be selected after loading the list.</param>
    private void LoadAndSelectAttributeType(string selectedType = FieldDataType.Text)
    {
        var objectType = DataClassInfo.OBJECT_TYPE;

        // Get object type based on class name
        var dci = DataClassInfoProvider.GetDataClassInfo(ClassName);

        if (dci != null)
        {
            objectType = dci.TypeInfo.ObjectType;
        }

        var types = DataTypeManager.GetFieldTypes(objectType).ToHashSet();

        // Remove file type for these objects
        switch (Mode)
        {
        case FieldEditorModeEnum.WebPartProperties:
        case FieldEditorModeEnum.CustomTable:
        case FieldEditorModeEnum.SystemTable:
        case FieldEditorModeEnum.FormControls:
        case FieldEditorModeEnum.ProcessActions:
        case FieldEditorModeEnum.Widget:
        case FieldEditorModeEnum.AlternativeCustomTable:
        case FieldEditorModeEnum.AlternativeSystemTable:
        case FieldEditorModeEnum.InheritedFormControl:
            types.Remove(FieldDataType.File);
            break;
        }

        // Ensure selected type
        types.Add(selectedType);

        drpAttributeType.DataSource = ControlsHelper.GetDropDownListSource(types, "TemplateDesigner.FieldTypes");
        drpAttributeType.DataBind();

        if (drpAttributeType.Items.Count > 0)
        {
            drpAttributeType.SelectedValue = selectedType;
        }
    }