Ejemplo n.º 1
0
 /// <summary> Gets the name of the class that contains this field. </summary>
 /// <param name='luFlid'>Field identification number. In the database, this corresponds to the "Id"
 /// column in the Field$ table. </param>
 /// <returns>Points to the output name of the class that contains the field.
 /// In the database, this is the "Name" column in the Class$ table that corresponds to the
 /// Class column in the Field$ table.</returns>
 public virtual string GetOwnClsName(int luFlid)
 {
     return(m_metaDataCache.GetOwnClsName(luFlid));
 }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Refresh the lv (list view) control based on the tv (tree view) control.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void AfterSelectMethod()
        {
            string holdType = "", holdSig = "";
            int    clid = (int)m_tvModel.SelectedNode.Tag;

            // Get flids.
            int[] uFlids             = m_mdc.GetFields(clid, true, (int)CellarPropertyTypeFilter.All);
            List <ListViewItem> list = new List <ListViewItem>();

            for (int i = uFlids.Length - 1; i >= 0; --i)
            {
                int flid = uFlids[i];
                if (flid == 0)
                {
                    continue;                     // Keep looking for suitable flids lower in the array.
                }
                else
                {
                    if (FDOBrowserForm.m_virtualFlag == false && (flid >= 20000000 && flid < 30000000))
                    {
                        continue;
                    }
                    else
                    {
                        string       className = m_mdc.GetOwnClsName(flid);
                        ListViewItem lvi       = new ListViewItem(className);
                        list.Add(lvi);
                        // flid
                        lvi.SubItems.Add(flid.ToString());
                        // field name
                        string fieldname = m_mdc.GetFieldName(flid);
                        lvi.SubItems.Add(fieldname);
                        int    flidType  = m_mdc.GetFieldType(flid);
                        string type      = "Not recognized";
                        string signature = "Not recognized";
                        int    dstClid;
                        switch (flidType)
                        {
                        // Basic data types.
                        case (int)CellarPropertyType.Boolean:
                            type      = "Basic";
                            signature = "Boolean";
                            break;

                        case (int)CellarPropertyType.Integer:
                            type      = "Basic";
                            signature = "Integer";
                            break;

                        case (int)CellarPropertyType.Numeric:
                            type      = "Basic";
                            signature = "Numeric";
                            break;

                        case (int)CellarPropertyType.Float:
                            type      = "Basic";
                            signature = "Float";
                            break;

                        case (int)CellarPropertyType.Time:
                            type      = "Basic";
                            signature = "Time";
                            break;

                        case (int)CellarPropertyType.Guid:
                            type      = "Basic";
                            signature = "Guid";
                            break;

                        case (int)CellarPropertyType.Image:
                            type      = "Basic";
                            signature = "Image";
                            break;

                        case (int)CellarPropertyType.GenDate:
                            type      = "Basic";
                            signature = "GenDate";
                            break;

                        case (int)CellarPropertyType.Binary:
                            type      = "Basic";
                            signature = "Binary";
                            break;

                        case (int)CellarPropertyType.String:
                            type      = "Basic";
                            signature = "String";
                            break;

                        case (int)CellarPropertyType.MultiString:
                            type      = "Basic";
                            signature = "MultiString";
                            break;

                        case (int)CellarPropertyType.Unicode:
                            type      = "Basic";
                            signature = "Unicode";
                            break;

                        case (int)CellarPropertyType.MultiUnicode:
                            type      = "Basic";
                            signature = "MultiUnicode";
                            break;

                        // CmObjects.
                        case (int)CellarPropertyType.OwningAtomic:
                            type      = "OA";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;

                        case (int)CellarPropertyType.ReferenceAtomic:
                            type      = "RA";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;

                        case (int)CellarPropertyType.OwningCollection:
                            type      = "OC";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;

                        case (int)CellarPropertyType.ReferenceCollection:
                            type      = "RC";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;

                        case (int)CellarPropertyType.OwningSequence:
                            type      = "OS";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;

                        case (int)CellarPropertyType.ReferenceSequence:
                            type      = "RS";
                            dstClid   = m_mdc.GetDstClsId(flid);
                            signature = m_mdc.GetClassName(dstClid);
                            break;
                        }

                        if (flid >= 20000000 && flid < 30000000)
                        {
                            type += " (Virt)";
                        }
                        else if (flid > 10000000)
                        {
                            type += " (BackRef)";
                        }

                        lvi.SubItems.Add(type);
                        lvi.SubItems.Add(signature);
                    }
                }
            }

            // Add custom fields

            if (FDOBrowserForm.CFields != null && FDOBrowserForm.CFields.Count > 0)
            {
                foreach (CustomFields cf in FDOBrowserForm.CFields)
                {
                    if (clid == cf.ClassID)
                    {
                        string       clasName = m_mdc.GetClassName(cf.ClassID);
                        ListViewItem lv       = new ListViewItem(clasName);
                        list.Add(lv);
                        // classname
                        //lv.SubItems.Add(clasName);
                        // flid
                        lv.SubItems.Add(cf.FieldID.ToString());
                        // field name
                        lv.SubItems.Add(cf.Name);
                        // Type
                        switch (cf.Type)
                        {
                        case "ICmPossibility":
                            holdType = "Custom - RA";
                            break;

                        case "FdoReferenceCollection<ICmPossibility>":
                            holdType = "Custom - RC";
                            break;

                        case "IStText":
                            holdType = "Custom - OA";
                            break;

                        default:
                            holdType = "Custom";
                            break;
                        }
                        lv.SubItems.Add(holdType);
                        // Signature
                        switch (cf.Type)
                        {
                        case "ITsString":
                            holdSig = "String";
                            break;

                        case "System.Int32":
                            holdSig = "Integer";
                            break;

                        case "SIL.FieldWorks.Common.FwUtils.GenDate":
                            holdSig = "GenDate";
                            break;

                        case "ICmPossibility":
                            holdSig = "CmPossibility";
                            break;

                        case "FdoReferenceCollection<ICmPossibility>":
                            holdSig = "CmPossibility";
                            break;

                        case "IStText":
                            holdSig = "StText";
                            break;

                        default:
                            MessageBox.Show(String.Format("Type not recognized for signature for custom model fields.  Type: {0}", cf.Type));
                            break;
                        }
                        lv.SubItems.Add(holdSig);
                    }
                }
            }
            LoadListView(list);
        }