Ejemplo n.º 1
0
        /// <summary>
        /// Binds the formats.
        /// </summary>
        private void BindFormats()
        {
            FormatList.Items.Clear();

            MetaFieldType[] metaFieldTypes = MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue);
            foreach (MetaFieldType fieldType in metaFieldTypes)
            {
                if (fieldType.Attributes.ContainsKey(McDataTypeAttribute.EnumPrivate) &&
                    fieldType.Attributes[McDataTypeAttribute.EnumPrivate].ToString() != mc.Name)
                {
                    continue;
                }

                string text = CHelper.GetResFileString(fieldType.FriendlyName);

                //AK 2008-02-13
                if (MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, fieldType))
                {
                    FormatList.Items.Add(new ListItem(text, fieldType.Name));
                }
            }

            if (FieldTypeList.SelectedValue == McDataType.Enum.ToString())
            {
                FormatList.Items.Add(new ListItem(String.Format("[{0}]", GetGlobalResourceObject("GlobalMetaInfo", "NewSingleValue").ToString()), "Enum"));
                FormatList.Items.Add(new ListItem(String.Format("[{0}]", GetGlobalResourceObject("GlobalMetaInfo", "NewMultiValue").ToString()), "EnumMultiValue"));
            }

            if (FieldTypeList.SelectedValue == McDataType.Identifier.ToString() ||
                FieldTypeList.SelectedValue == McDataType.Enum.ToString() ||
                FieldTypeList.SelectedValue == McDataType.Complex.ToString() ||
                FieldTypeList.SelectedValue == McDataType.MultiReference.ToString() ||
                FormatList.Items.Count > 1)
            {
                FormatRow.Visible = true;
            }
            else
            {
                FormatRow.Visible = false;
            }

            if (FormatList.Items.Count > 0)
            {
                ShowControl();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            tblName.Text = lip.ListName;
            MetaField mf = null;

            if (ViewState["_field"] != null)
            {
                mf = lip.GetDestinationMetaField(ViewState["_field"].ToString());
            }

            if (mf != null)
            {
                NameTextBox.Text           = mf.Name;
                FriendlyNameTextBox.Text   = mf.FriendlyName;
                AllowNullsCheckBox.Checked = mf.IsNullable;
            }
            else
            {
                NameTextBox.Text           = "";
                FriendlyNameTextBox.Text   = "";
                AllowNullsCheckBox.Checked = true;
            }

            FieldTypeList.Items.Clear();
            // Building the FieldType list
            foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
            {
                if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility("List_XXX", (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                {
                    continue;
                }

                if ((mcDataType == McDataType.ReferencedField.ToString()) ||
                    (mcDataType == McDataType.Reference.ToString()) ||
                    (mcDataType == McDataType.BackReference.ToString()) ||
                    (mcDataType == McDataType.Card.ToString()) ||
                    (mcDataType == McDataType.Link.ToString()) ||
                    (mcDataType == McDataType.Complex.ToString()) ||
                    (mcDataType == McDataType.MultiReference.ToString()))
                {
                    continue;
                }
                else if (mcDataType == McDataType.Identifier.ToString())
                {
                    if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                    {
                        continue;
                    }
                }

                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
            }
            if (mf != null)
            {
                CHelper.SafeSelect(FieldTypeList, mf.GetOriginalMetaType().McDataType.ToString());
            }
            else
            {
                CHelper.SafeSelect(FieldTypeList, "String");
            }

            if (FieldTypeList.Items.Count > 0)
            {
                string typeName = String.Empty;
                if (mf != null)
                {
                    typeName = mf.TypeName;
                }
                BindFormats(typeName);
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Binds the formats.
        /// </summary>
        private void BindFormats()
        {
            FormatList.Items.Clear();

            MetaFieldType[]             metaFieldTypes = MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue);
            Dictionary <string, string> items          = new Dictionary <string, string>();

            foreach (MetaFieldType fieldType in metaFieldTypes)
            {
                if (fieldType.Attributes.ContainsKey(McDataTypeAttribute.EnumPrivate) &&
                    fieldType.Attributes[McDataTypeAttribute.EnumPrivate].ToString() != mc.Name)
                {
                    continue;
                }

                string text = CHelper.GetResFileString(fieldType.FriendlyName);

                //AK 2008-02-13 + 2009-01-28
                if (MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, fieldType) &&
                    !items.ContainsKey(fieldType.Name))
                {
                    items.Add(fieldType.Name, text);
                }
            }

            // sort by value
            List <KeyValuePair <string, string> > sortedItems = new List <KeyValuePair <string, string> >(items);

            sortedItems.Sort(
                delegate(KeyValuePair <string, string> firstPair, KeyValuePair <string, string> nextPair)
            {
                return(firstPair.Value.CompareTo(nextPair.Value));
            }
                );

            foreach (KeyValuePair <string, string> kvp in sortedItems)
            {
                FormatList.Items.Add(new ListItem(kvp.Value, kvp.Key));
            }
            //

            if (FieldTypeList.SelectedValue == McDataType.Enum.ToString())
            {
                FormatLabel.Text = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Dictionary").ToString();
                ListItem liSelected = new ListItem(String.Format("[{0}]", GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "NewSingleValue").ToString()), "Enum");
                liSelected.Selected = true;
                FormatList.Items.Add(liSelected);
                FormatList.Items.Add(new ListItem(String.Format("[{0}]", GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "NewMultiValue").ToString()), "EnumMultiValue"));
            }
            else
            {
                FormatLabel.Text = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Format").ToString();
            }

            if (FieldTypeList.SelectedValue == McDataType.Identifier.ToString() ||
                FieldTypeList.SelectedValue == McDataType.Enum.ToString() ||
                FieldTypeList.SelectedValue == McDataType.Complex.ToString() ||
                FieldTypeList.SelectedValue == McDataType.MultiReference.ToString() ||
                FormatList.Items.Count > 1)
            {
                FormatRow.Visible = true;
            }
            else
            {
                FormatRow.Visible = false;
            }

            if (!Page.IsPostBack && FieldTypeList.SelectedValue == "String")
            {
                CHelper.SafeSelect(FormatList, "Text");
            }

            if (FormatList.Items.Count > 0)
            {
                ShowControl();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            TableLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            TableLink.NavigateUrl = String.Format("{0}?class={1}", ReturnUrl, mc.Name);

            if (mf == null)
            {
                List <ListItem> listItems = new List <ListItem>();

                // Building the FieldType list
                foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
                {
                    if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                    {
                        continue;
                    }

                    if (mcDataType == McDataType.ReferencedField.ToString())
                    {
                        if (mc.GetReferences().Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.BackReference.ToString())
                    {
                        MetaField[] mfList = mc.FindReferencesWithoutBack();
                        if (mfList.Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Card.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Identifier.ToString())
                    {
                        if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Link.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Complex.ToString())
                    {
                        if (MetaDataWrapper.GetFieldFormatsByType(mcDataType).Length <= 0)
                        {
                            continue;
                        }

                        // IBN 4.7 fix: check that the list has the TitleField
                        if (ListManager.MetaClassIsList(mc))
                        {
                            if (String.IsNullOrEmpty(mc.TitleFieldName))
                            {
                                continue;
                            }
                        }
                    }
                    else if (mcDataType == McDataType.Reference.ToString())
                    {
                        if (String.IsNullOrEmpty(mc.TitleFieldName))
                        {
                            continue;
                        }
                        // IBN 4.7 fix: check that exists at least one list to which we can make a reference
                        //if (ListManager.MetaClassIsList(mc))
                        //{
                        //    bool exists = false;
                        //    foreach (MetaClass metaClass in DataContext.Current.MetaModel.MetaClasses)
                        //    {
                        //        string name = metaClass.Name;
                        //        if (!metaClass.IsBridge && !metaClass.IsCard && !String.IsNullOrEmpty(metaClass.TitleFieldName) && ListManager.MetaClassIsList(name) && name != mc.Name)
                        //        {
                        //            // Check Security
                        //            int listId = ListManager.GetListIdByClassName(name);
                        //            if (Mediachase.IBN.Business.ListInfoBus.CanRead(listId))
                        //            {
                        //                exists = true;
                        //                break;
                        //            }
                        //        }
                        //    }

                        //    if (!exists)
                        //        continue;
                        //}
                    }

                    listItems.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                    //FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                }

                listItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); });

                FieldTypeList.Items.AddRange(listItems.ToArray());

                CHelper.SafeSelect(FieldTypeList, "String");

                if (ListManager.MetaClassIsList(mc))
                {
                    ListInfo li = ListManager.GetListInfoByMetaClassName(mc.Name);
                    if (li.IsTemplate)
                    {
                        trSelector.Visible = false;
                    }
                    else
                    {
                        mfs.BindData(mc.Name);
                    }
                }
                else
                {
                    mfs.BindData(mc.Name);
                }

                if (mfs.Count == 0)
                {
                    trSelector.Visible = false;
                }

                if (FieldTypeList.Items.Count > 0)
                {
                    BindFormats();
                }
            }
            else              // Edit
            {
                NameTextBox.Text    = mf.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mf.FriendlyName;

                AllowNullsCheckBox.Checked = mf.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                McDataType mcDataType = mf.GetOriginalMetaType().McDataType;
                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType.ToString()));
                FieldTypeList.Enabled = false;

                FormatList.Items.Add(new ListItem(CHelper.GetResFileString(mf.GetOriginalMetaType().FriendlyName), mf.TypeName));
                FormatList.Enabled = false;

                if (FieldTypeList.SelectedValue != McDataType.Identifier.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.Enum.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.MultiReference.ToString() &&
                    MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue).Length <= 1)
                {
                    FormatRow.Visible = false;
                }

                trSelector.Visible = false;

                ShowControl();
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            TableLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            TableLink.NavigateUrl = String.Format("{0}?class={1}", ReturnUrl, mc.Name);

            if (mf == null)
            {
                // Building the FieldType list
                foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
                {
                    if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                    {
                        continue;
                    }

                    if (mcDataType == McDataType.ReferencedField.ToString())
                    {
                        if (mc.GetReferences().Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.BackReference.ToString())
                    {
                        MetaField[] mfList = mc.FindReferencesWithoutBack();
                        if (mfList.Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Card.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Identifier.ToString())
                    {
                        if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Link.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Complex.ToString())
                    {
                        if (MetaDataWrapper.GetFieldFormatsByType(mcDataType).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Reference.ToString())
                    {
                    }

                    FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                }

                CHelper.SafeSelect(FieldTypeList, "String");

                mfs.BindData(mc.Name);

                if (FieldTypeList.Items.Count > 0)
                {
                    BindFormats();
                }
            }
            else              // Edit
            {
                NameTextBox.Text    = mf.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mf.FriendlyName;

                AllowNullsCheckBox.Checked = mf.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                McDataType mcDataType = mf.GetOriginalMetaType().McDataType;
                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType.ToString()));
                FieldTypeList.Enabled = false;

                FormatList.Items.Add(new ListItem(CHelper.GetResFileString(mf.GetOriginalMetaType().FriendlyName), mf.TypeName));
                FormatList.Enabled = false;

                if (FieldTypeList.SelectedValue != McDataType.Identifier.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.Enum.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.MultiReference.ToString() &&
                    MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue).Length <= 1)
                {
                    FormatRow.Visible = false;
                }

                trSelector.Visible = false;

                ShowControl();
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }