Beispiel #1
0
        private void MapFlidsInDumperAsNeeded(string fxtPath)
        {
            XmlDocument document = new XmlDocument();

            document.Load(fxtPath);
            XmlNode xnDoc      = document.SelectSingleNode(".//FxtDocumentDescription");
            string  sDataLabel = XmlUtils.GetAttributeValue(xnDoc, "dataLabel");

            // A more robust check for the type of fxt output and the clerk would be nice...
            if (sDataLabel.ToLowerInvariant() == "wordforms")
            {
                RecordClerk clerk = RecordClerk.FindClerk(m_mediator, "concordanceWords");
                if (clerk != null)
                {
                    int hvoWFI = m_cache.GetObjProperty(m_cache.LangProject.Hvo, (int)SIL.FieldWorks.FDO.LangProj.LangProject.LangProjectTags.kflidWordformInventory);
                    int cwfi   = m_cache.GetVectorSize(hvoWFI, (int)WordformInventory.WordformInventoryTags.kflidWordforms);
                    int cwfi2  = m_cache.GetVectorSize(clerk.OwningObject.Hvo, clerk.OwningFlid);
                    if (cwfi != cwfi2)
                    {
                        m_dumper.MapFlids((int)WordformInventory.WordformInventoryTags.kflidWordforms, clerk.OwningFlid);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Set up the submenu items for 'Create' and 'Insert' menus.
        /// </summary>
        protected void SetupContextMenu(Slice slice, SliceTreeNode sliceTreeNode)
        {
            // Get rid of old sub-menu items.
            m_mnuCreate.MenuItems.Clear();

            m_helper             = new ContextMenuHelper(sliceTreeNode);
            m_rgcpiCreateOptions = slice.Object.PropsAndClassesOwnedBy;
            // Fill in info about which object will be the new owner.
            for (int index = m_rgcpiCreateOptions.Count; --index >= 0;)
            {
                ClassAndPropInfo cpi = m_rgcpiCreateOptions[index];
                cpi.hvoOwner = slice.Object.Hvo;
            }
            // Drop atomic property options if not empty
            for (int index = m_rgcpiCreateOptions.Count; --index >= 0;)
            {
                ClassAndPropInfo cpi = (ClassAndPropInfo)m_rgcpiCreateOptions[index];
                if (cpi.fieldType == (int)FieldType.kcptOwningAtom)
                {
                    FDO.FdoCache cache = slice.ContainingDataTree.Cache;
                    if (cache.GetObjProperty(cpi.hvoOwner, (int)(cpi.flid)) != 0)
                    {
                        m_rgcpiCreateOptions.RemoveAt(index);
                    }
                }
            }
            int iBefore = m_rgcpiCreateOptions.Count;

            GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, true);
            bool fSeq = m_rgcpiCreateOptions.Count > iBefore &&
                        m_rgcpiCreateOptions[iBefore].fieldType == (int)FieldType.kcptOwningSequence;
            int iAfter = m_rgcpiCreateOptions.Count;

            if (fSeq)
            {
                // In a sequence we make another set of options to insert after the current item.
                GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, false);
            }
            for (int index = 0; index < m_rgcpiCreateOptions.Count; index++)
            {
                ClassAndPropInfo cpi    = (ClassAndPropInfo)m_rgcpiCreateOptions[index];
                String           format = DetailControlsStrings.ksNewItem;
                if (index >= iAfter)
                {
                    format = DetailControlsStrings.ksNewItemAfter;                     // can't happen if not sequence
                }
                else if (index >= iBefore)
                {
                    if (fSeq)
                    {
                        format = DetailControlsStrings.ksNewItemBefore;
                    }
                    else                     // sibling collection
                    {
                        format = DetailControlsStrings.ksNewItemWithin;
                    }
                }
                m_mnuCreate.MenuItems.Add(new MenuItem(
                                              String.Format(format, new object[] { cpi.signatureClassName, cpi.fieldName }),
                                              new EventHandler(this.HandleCreateMenuItem)));
            }
            m_mnuCreate.Enabled = m_mnuCreate.MenuItems.Count > 0;
            m_helper.SetupDeleteMenu(m_mnuDelete);
        }