Пример #1
0
        private void AddEditCell(IVwEnv vwenv, IVwCacheDa cda, int i)
        {
            string  sField = ksEditColumnBaseName + i;
            XmlNode node   = m_columns[i - 1] as XmlNode;

            // Make a cell and embed an editable virtual string for the column.
            vwenv.OpenTableCell(1, 1);
            // Initialize the virtual property.
            IVwVirtualHandler vh = cda.GetVirtualHandlerName(EditRowModelClass, sField);

            Debug.Assert(vh != null);
            int flid = (int)m_mdc.GetFieldId(EditRowModelClass, sField, false);
            int ws   = LangProject.GetWritingSystem(node, m_cache, null, m_cache.DefaultAnalWs);

            // Paragraph directionality must be set before the paragraph is opened.
            bool fRTL = IsWsRTL(ws);

            vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
                                  (int)FwTextPropVar.ktpvEnum, fRTL ? -1 : 0);
            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
                                  (int)FwTextPropVar.ktpvEnum,
                                  fRTL ? (int)FwTextAlign.ktalRight : (int)FwTextAlign.ktalLeft);

            vh.Load(khvoNewItem, flid, ws, cda);
            // Fill in the cell with the virtual property.
            vwenv.OpenParagraph();
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptIsEditable);
            vwenv.AddStringAltMember(flid, ws, this);
            vwenv.CloseParagraph();
            vwenv.CloseTableCell();
        }
Пример #2
0
 protected virtual void ReallyDeleteReversalIndex(IReversalIndex ri)
 {
     try
     {
         Debug.Assert(ri.Hvo == m_list.OwningObject.Hvo);
         m_list.ListModificationInProgress = true;                       // can't reload deleted list! (LT-5353)
         // Clear out any virtual data stored in the cache for this reversal index.
         IVwCacheDa        cda = m_cache.MainCacheAccessor as IVwCacheDa;
         IVwVirtualHandler vh  = cda.GetVirtualHandlerName("LexSense",
                                                           LexSenseReversalEntriesTextHandler.StandardFieldName);
         if (vh != null)
         {
             int wsDel = ri.WritingSystemRAHvo;
             IEnumerator <IReversalIndexEntry> erie = ri.EntriesOC.GetEnumerator();
             while (erie.MoveNext())
             {
                 foreach (LinkedObjectInfo loi in erie.Current.BackReferences)
                 {
                     if (loi.RelObjClass == (int)LexSense.kClassId)
                     {
                         vh.Load(loi.RelObjId, vh.Tag, wsDel, cda);
                     }
                 }
             }
         }
         m_cache.BeginUndoTask(LexEdStrings.ksUndoDelete, LexEdStrings.ksRedoDelete);
         int cobjOld = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count;
         ri.DeleteUnderlyingObject();
         int cobjNew;
         int hvoIdxNew = ReversalIndexAfterDeletion(m_cache, out cobjNew);
         m_cache.EndUndoTask();
         SetReversalIndexHvo(hvoIdxNew);
         // Without this, switching to the ReversalEntries tool can crash if it was
         // displaying data from the deleted reversal entry.
         m_cache.PropChanged(null, PropChangeType.kpctNotifyAll,
                             m_cache.LangProject.LexDbOAHvo,
                             (int)LexDb.LexDbTags.kflidReversalIndexes,
                             0, cobjNew, cobjOld);
     }
     finally
     {
         m_list.ListModificationInProgress = false;
     }
     // Can't do this until ListModificationInProgress flag is cleared because it
     // redisplays everything after reloading the list: if the list isn't actually
     // reloaded, it tries to display a deleted object -- CRASH!
     ChangeOwningObjectIfPossible();
     // Without this, stale data can still display in the BulkEditSenses tool if you
     // recreate the deleted reversal index.
     m_mediator.SendMessage("MasterRefresh", null);
 }
Пример #3
0
        protected override FdoObjectSet <ICmObject> GetObjectSet()
        {
            IVwVirtualHandler handler = (m_cache.MainCacheAccessor as IVwCacheDa).GetVirtualHandlerId(m_flid);

            Debug.Assert(handler != null);

            IReversalIndex ri = m_owningObject as IReversalIndex;

            Debug.Assert(ri != null && ri.IsValidObject(), "The owning ReversalIndex object is invalid!?");
            // Force the handler to (re)load the property.
            handler.Load(ri.Hvo, m_flid, ri.WritingSystemRAHvo, m_cache.MainCacheAccessor as IVwCacheDa);
            int[] items = m_cache.GetVectorProperty(ri.Hvo, m_flid, true);
            return(new FdoObjectSet <ICmObject>(m_cache, items, true));
        }
Пример #4
0
        /// <summary>
        /// Merge the underling objects. This method handles the transaction, then delegates
        /// the actual merge to MergeObject. If the flag is true, we merge
        /// strings and owned atomic objects; otherwise, we don't change any that aren't null
        /// to begin with.
        /// </summary>
        /// <param name="fLoseNoTextData"></param>
        protected override void ReallyMergeUnderlyingObject(int survivorHvo, bool fLoseNoTextData)
        {
            ICmObject survivor = CmObject.CreateFromDBObject(m_cache, survivorHvo);

            base.ReallyMergeUnderlyingObject(survivorHvo, fLoseNoTextData);

            // Update virtual prop on survivor, so it is displayed properly.
            // Reloading the VH and calling PropChanged fixes LT-6274.
            IVwVirtualHandler vh = BaseVirtualHandler.GetInstalledHandler(m_cache, "ReversalIndexEntry", "ReferringSenses");
            int flid             = vh.Tag;

            vh.Load(survivor.Hvo, flid, 0, m_cache.VwCacheDaAccessor);
            m_cache.MainCacheAccessor.PropChanged(
                null,
                (int)PropChangeType.kpctNotifyAll,
                survivor.Hvo,
                flid,
                0,
                0,
                0);
        }
Пример #5
0
        protected override void ReallyDeleteUnderlyingObject()
        {
            IReversalIndexEntry rei = Object as IReversalIndexEntry;
            int hvoGoner            = rei.Hvo;
            int hvoIndex            = rei.ReversalIndex.Hvo;
            IVwVirtualHandler vh    = BaseVirtualHandler.GetInstalledHandler(m_cache, "ReversalIndex", "AllEntries");
            int flid = vh.Tag;

            base.ReallyDeleteUnderlyingObject();

            // Remove goner from the cache.
            vh.Load(hvoIndex, flid, 0, m_cache.VwCacheDaAccessor);

            m_cache.MainCacheAccessor.PropChanged(
                null,
                (int)PropChangeType.kpctNotifyAll,
                hvoIndex,
                flid,
                0,
                0,
                1);
        }
Пример #6
0
 void Reload()
 {
     m_vh.Load(m_hvo, m_tag, m_ws, m_cache.VwCacheDaAccessor);
 }
Пример #7
0
		/// <summary>
		/// If object hvo has no cached value for the property flidVirtual, do nothing.
		/// Otherwise, compute a new value for the property, and issue a PropChanged. (Currently only string type supported)
		/// If it has owning properties of type clidVirtual, do the same for all their items.
		/// </summary>
		/// <param name="hvo"></param>
		/// <param name="flidVirtual"></param>
		/// <param name="mdc"></param>
		/// <param name="sda"></param>
		private void RecomputeVirtuals(int hvo, uint clidVirtual, int flidVirtual, int typeVirtual, IFwMetaDataCache mdc, ISilDataAccess sda,
			IVwVirtualHandler vh)
		{
			if (Cache.GetClassOfObject(hvo) != clidVirtual)
				return;
			// Unless it's a computeEveryTime property, we don't need to worry if it's not already cached.
			if (vh.ComputeEveryTime || sda.get_IsPropInCache(hvo, flidVirtual, typeVirtual, 0))
			{
				vh.Load(hvo, flidVirtual, 0, Cache.VwCacheDaAccessor);
				switch (typeVirtual)
				{
					case (int)CellarModuleDefns.kcptString:
						sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvo, flidVirtual, 0, 0, 0);
						break;
					default:
						Debug.WriteLine("RecomputeVirtuals: unimplemented prop type");
						break;
				}
			}
			uint[] flids = DbOps.GetFieldsInClassOfType(mdc, (int)clidVirtual, FieldType.kgrfcptOwning);
			foreach (uint flid in flids)
			{
				int type = mdc.GetFieldType(flid);
				if (type == (int)CellarModuleDefns.kfcptOwningAtom)
				{
					RecomputeVirtuals(sda.get_ObjectProp(hvo, (int)flid), clidVirtual, flidVirtual, typeVirtual, mdc, sda, vh);
				}
				else
				{
					// must be owning sequence or collection; do them all.
					int chvo = sda.get_VecSize(hvo, (int)flid);
					for (int i = 0; i < chvo; i++)
						RecomputeVirtuals(sda.get_VecItem(hvo, (int)flid, i), clidVirtual, flidVirtual, typeVirtual, mdc, sda, vh);

				}
			}
		}
Пример #8
0
		protected virtual void ForceReloadVirtualProperty(IVwVirtualHandler handler)
		{
			handler.Load(m_owningObject.Hvo, m_flid, 0, m_cache.MainCacheAccessor as IVwCacheDa);
		}