コード例 #1
0
            public void SetupDeleteMenu(MenuItem mnuDelete)
            {
                mnuDelete.MenuItems.Clear();
                int   hvoDeleteOwner;
                int   flidDelete;
                int   ihvoDelete = -1;               // default for atomic
                Slice slice      = m_sliceTreeNode.Slice;

                bool isAtomic = slice.GetAtomicContext(out hvoDeleteOwner, out flidDelete);

                if (isAtomic ||
                    slice.GetSeqContext(out hvoDeleteOwner, out flidDelete, out ihvoDelete))
                {
                    if (ihvoDelete >= 0)
                    {
                        m_hvoDeleteTarget = m_cache.DomainDataByFlid.get_VecItem(hvoDeleteOwner, flidDelete, ihvoDelete);
                    }
                    else
                    {
                        m_hvoDeleteTarget = m_cache.DomainDataByFlid.get_ObjectProp(hvoDeleteOwner, flidDelete);
                    }
                    int      clsid           = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(m_hvoDeleteTarget).ClassID;
                    string   targetClassName = m_cache.DomainDataByFlid.MetaDataCache.GetClassName(clsid);
                    string   attrName        = m_mdc.GetFieldName((int)flidDelete);
                    MenuItem item            = new MenuItem(String.Format(DetailControlsStrings.ksItemFrom,
                                                                          new object[] { targetClassName, attrName }),
                                                            new EventHandler(this.HandleDeleteMenuItem));

                    item.Enabled = OkToDelete(hvoDeleteOwner, flidDelete, isAtomic);
                    mnuDelete.MenuItems.Add(item);
                }
                mnuDelete.Enabled = mnuDelete.MenuItems.Count > 0;
            }
コード例 #2
0
        /// <summary>
        /// Generate the nodes that the constructor arguments indicate.
        /// </summary>
        /// <returns></returns>
        public virtual XmlNode[] Generate()
        {
            List <int> ids    = FieldIds;
            var        result = new XmlNode[ids.Count];

            for (int iresult = 0; iresult < result.Length; iresult++)
            {
                XmlNode output = m_source.Clone();
                result[iresult] = output;
                int    fieldId   = ids[iresult];
                string labelName = m_mdc.GetFieldLabel(fieldId);
                string fieldName = m_mdc.GetFieldName(fieldId);
                string className = m_mdc.GetOwnClsName(fieldId);
                if (string.IsNullOrEmpty(labelName))
                {
                    labelName = fieldName;
                }
                // generate parts for any given custom layout
                GeneratePartsFromLayouts(m_rootClassId, fieldName, fieldId, ref output);
                ReplaceParamsInAttributes(output, labelName, fieldName, fieldId, className);
                // LT-6956 : custom fields have the additional attribute "originalLabel", so add it here.
                XmlUtils.AppendAttribute(output, "originalLabel", labelName);
            }
            return(result);
        }
コード例 #3
0
        private string GetFancyFieldName(int flid, IFwMetaDataCache mdc)
        {
            string f = mdc.GetFieldName(flid);
            string c = mdc.GetOwnClsName(flid);

            return(c + '_' + f);
        }
コード例 #4
0
ファイル: PartGenerator.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// This is the definition of what it means for a field to pass all current restrictions.
        /// </summary>
        /// <param name="flid"></param>
        /// <returns></returns>
        bool Accept(uint flid)
        {
            switch (m_restrictions)
            {
            case "none":
                return(true);

            case "customOnly":
                // Currently the decisive way to tell, from the mdc, is whether the field name
                // starts with 'custom'. There is an explicit column in the database for this,
                // but it isn't yet loaded into the MDC and made accessible through its interface.
                string fieldName = m_mdc.GetFieldName(flid);
                return(fieldName.StartsWith("custom"));
            }
            return(true);
        }
コード例 #5
0
            public void SetupDeleteMenu(MenuItem mnuDelete)
            {
                mnuDelete.MenuItems.Clear();
                int   hvoDeleteOwner;
                int   flidDelete;
                int   ihvoDelete = -1;               // default for atomic
                Slice slice      = m_sliceTreeNode.Slice;

                bool isAtomic = slice.GetAtomicContext(out hvoDeleteOwner, out flidDelete);

                if (isAtomic ||
                    slice.GetSeqContext(out hvoDeleteOwner, out flidDelete, out ihvoDelete))
                {
                    if (ihvoDelete >= 0)
                    {
                        m_hvoDeleteTarget = m_cache.GetVectorItem(hvoDeleteOwner, flidDelete, ihvoDelete);
                    }
                    else
                    {
                        m_hvoDeleteTarget = m_cache.GetObjProperty(hvoDeleteOwner, flidDelete);
                    }
                    int      clsid           = m_cache.GetClassOfObject(m_hvoDeleteTarget);
                    string   targetClassName = m_cache.GetClassName((uint)clsid);
                    string   attrName        = m_mdc.GetFieldName((uint)flidDelete);
                    MenuItem item            = new MenuItem(String.Format(DetailControlsStrings.ksItemFrom,
                                                                          new object[] { targetClassName, attrName }),
                                                            new EventHandler(this.HandleDeleteMenuItem));

                    item.Enabled = OkToDelete(hvoDeleteOwner, flidDelete, isAtomic);
                    mnuDelete.MenuItems.Add(item);
                }
                mnuDelete.Enabled = mnuDelete.MenuItems.Count > 0;
            }
コード例 #6
0
        bool m_fGotFocus = false;         // True if we have focus.

        public TypeAheadSupportVc(int tag, LcmCache cache)
        {
            m_tag = tag;
            IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache;

            m_clid      = mdc.GetOwnClsId(m_tag);
            m_className = mdc.GetClassName(m_clid);
            m_fieldName = mdc.GetFieldName(m_tag);
            m_type      = (CellarPropertyType)(mdc.GetFieldType(m_tag) & (int)CellarPropertyTypeFilter.VirtualMask);
            m_sda       = cache.DomainDataByFlid;
            Cache       = cache;
        }
コード例 #7
0
ファイル: XmlViewsUtils.cs プロジェクト: bbriggs/FieldWorks
		/// <summary>
		/// looks up plural form alternative first for given flid, secondly for its destination class.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="tbl"></param>
		/// <param name="owningFlid"></param>
		/// <param name="titleStr">*{dstClass}* if couldn't find result.</param>
		/// <returns>true if we found an alternate form. false if titleStr is null or in *{key}* format.</returns>
		public static bool TryFindPluralFormFromFlid(IFwMetaDataCache mdc, StringTable tbl, int owningFlid, out string titleStr)
		{
			// first see if we can find an expanded name for the name of a flid.
			string flidName = mdc.GetFieldName(owningFlid);
			if (!String.IsNullOrEmpty(flidName))
			{
				if (TryFindString(tbl, "AlternativeTitles", flidName, out titleStr))
					return true;
			}
			// secondly, see if we can find the plural form for the destination class.
			int dstClass = mdc.GetDstClsId(owningFlid);
			return TryFindPluralFormFromClassId(mdc, tbl, dstClass, out titleStr);
		}
コード例 #8
0
        bool m_fGotFocus = false;         // True if we have focus.

        public TypeAheadSupportVc(int tag, FdoCache cache)
        {
            m_tag = tag;
            IFwMetaDataCache mdc = cache.MetaDataCacheAccessor;

            m_clid      = mdc.GetOwnClsId((uint)m_tag);
            m_className = mdc.GetClassName(m_clid);
            m_fieldName = mdc.GetFieldName((uint)m_tag);
            m_type      = mdc.GetFieldType((uint)m_tag);
            m_type      = m_type & 0x1f;        // strip off virtual bit.
            m_sda       = cache.MainCacheAccessor;
            m_cache     = cache;
            CreateVirtualProperties();
        }
コード例 #9
0
		private string GetFancyFieldName(int flid, IFwMetaDataCache mdc)
		{
			string f = mdc.GetFieldName(flid);
			string c = mdc.GetOwnClsName(flid);
			return c + '_' + f;
		}
コード例 #10
0
ファイル: FwModelBrowser.cs プロジェクト: sillsdev/WorldPad
        private void m_tvClasses_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            m_lvfields.Items.Clear();
            uint clid            = (uint)m_tvClasses.SelectedNode.Tag;
            int  countFoundFlids = m_mdc.GetFields(clid, true, (int)CellarModuleDefns.kgrfcptAll,
                                                   0, null);
            int allFlidCount = countFoundFlids;

            uint[] uIds;
            using (ArrayPtr flids = MarshalEx.ArrayToNative(allFlidCount, typeof(uint)))
            {
                countFoundFlids = m_mdc.GetFields(clid, true, (int)CellarModuleDefns.kgrfcptAll,
                                                  allFlidCount, flids);
                uIds = (uint[])MarshalEx.NativeToArray(flids, allFlidCount, typeof(uint));
            }
            m_lvfields.SuspendLayout();
            List <ListViewItem> list = new List <ListViewItem>();

            for (int i = uIds.Length - 1; i >= 0; --i)
            {
                uint flid = uIds[i];
                if (flid == 0)
                {
                    continue;                     // Keep looking for suitable flids lower in the array.
                }
                string       className = m_mdc.GetOwnClsName(flid);
                ListViewItem lvi       = new ListViewItem(className);           //m_lvfields.Items.Add(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";
                uint   dstClid;
                switch (flidType)
                {
                // Basic data types.
                case (int)CellarModuleDefns.kcptBoolean:
                    type      = "Basic";
                    signature = "Boolean";
                    break;

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

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

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

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

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

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

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

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

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

                case (int)CellarModuleDefns.kcptBigString:
                    type      = "Basic";
                    signature = "String (big)";
                    break;

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

                case (int)CellarModuleDefns.kcptMultiBigString:
                    type      = "Basic";
                    signature = "MultiString (big)";
                    break;

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

                case (int)CellarModuleDefns.kcptBigUnicode:
                    type      = "Basic";
                    signature = "Unicode (big)";
                    break;

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

                case (int)CellarModuleDefns.kcptMultiBigUnicode:
                    type      = "Basic";
                    signature = "MultiUnicode (big)";
                    break;

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

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

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

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

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

                case (int)CellarModuleDefns.kcptReferenceSequence:
                    type      = "RS";
                    dstClid   = m_mdc.GetDstClsId(flid);
                    signature = m_mdc.GetClassName(dstClid);
                    break;
                }
                // Type
                lvi.SubItems.Add(type);
                // Signature
                lvi.SubItems.Add(signature);
            }
            m_lvfields.Items.AddRange(list.ToArray());
            m_lvfields.ResumeLayout(true);
        }
コード例 #11
0
ファイル: XDumper.cs プロジェクト: sillsdev/WorldPad
		private string ViewNameForFlid(int flid, IFwMetaDataCache mdc)
		{
			string sField = mdc.GetFieldName((uint)flid);
			string sClass = mdc.GetOwnClsName((uint)flid);
			return sClass + "_" + sField;
		}