Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="dataAccess">The ISilDataAccess to start the undo task on</param>
        /// <param name="rootSite">The view (can be <c>null</c>)</param>
        /// <param name="stUndo">Undo label</param>
        /// <param name="stRedo">Redo label</param>
        /// <param name="fCommit"><c>true</c> to call commit (and thus end all outstanding
        /// transactions). If an <see cref="UndoTaskHelper"/> object is created as part of an
        /// inner task, you probably want to set this to <c>false</c>. Default is <c>true</c>.
        /// </param>
        /// ------------------------------------------------------------------------------------
        private void Init(ISilDataAccess dataAccess, IVwRootSite rootSite, string stUndo,
                          string stRedo, bool fCommit)
        {
            Debug.Assert(dataAccess != null);
            m_vwRootSite = rootSite;
            m_fCommit    = fCommit;

            m_dataAccess = dataAccess;
            if (ActionHandlerAccessor != null)
            {
                m_nDepth = ActionHandlerAccessor.CurrentDepth;
                m_dataAccess.BeginUndoTask(stUndo, stRedo);
            }

            // Record an action that will handle replacing the selection on undo.
            SetupUndoSelection(true);
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bstrUndo"></param>
 /// <param name="bstrRedo"></param>
 public void BeginUndoTask(string bstrUndo, string bstrRedo)
 {
     m_sda.BeginUndoTask(bstrUndo, bstrRedo);
 }
Exemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialization
		/// </summary>
		/// <param name="dataAccess">The ISilDataAccess to start the undo task on</param>
		/// <param name="rootSite">The view (can be <c>null</c>)</param>
		/// <param name="stUndo">Undo label</param>
		/// <param name="stRedo">Redo label</param>
		/// <param name="fCommit"><c>true</c> to call commit (and thus end all outstanding
		/// transactions). If an <see cref="UndoTaskHelper"/> object is created as part of an
		/// inner task, you probably want to set this to <c>false</c>. Default is <c>true</c>.
		/// </param>
		/// ------------------------------------------------------------------------------------
		private void Init(ISilDataAccess dataAccess, IVwRootSite rootSite, string stUndo,
			string stRedo, bool fCommit)
		{
			Debug.Assert(dataAccess != null);
			m_vwRootSite = rootSite;
			m_fCommit = fCommit;

			m_dataAccess = dataAccess;
			if (ActionHandlerAccessor != null)
			{
				m_nDepth = ActionHandlerAccessor.CurrentDepth;
				m_dataAccess.BeginUndoTask(stUndo, stRedo);
			}

			// Record an action that will handle replacing the selection on undo.
			SetupUndoSelection(true);
		}
Exemplo n.º 4
0
 /// <summary>
 /// Start a UOW, since the base class will want one.
 /// </summary>
 public override void TestTearDown()
 {
     // Start a UOW, since the base class will try and end it.
     m_sda.BeginUndoTask("Undo something", "Redo something");
     base.TestTearDown();
 }
Exemplo n.º 5
0
            int MakeRealObject(ITsString tssTyped)
            {
                // Figure whether owning atomic or owning collection or owning sequence. Throw if none.
                IFwMetaDataCache mdc   = m_fdoCache.MetaDataCacheAccessor;
                FieldType        iType = m_fdoCache.GetFieldType(m_flidEmptyProp);

                iType &= FieldType.kcptVirtualMask;
                ISilDataAccess sdaReal = m_fdoCache.MainCacheAccessor;
                // Make a new object of the specified class in the specified property.
                int ord = 0;

                switch (iType)
                {
                default:
                    throw new Exception("ghost string property must be owning object property");

                case FieldType.kcptOwningAtom:
                    ord = -2;
                    break;

                case FieldType.kcptOwningCollection:
                    ord = -1;
                    break;

                case FieldType.kcptOwningSequence:
                    // ord = 0 set above (inserting the first and only object at position 0).
                    break;
                }
                string sClassRaw = mdc.GetClassName((uint)m_clidDst);
                string sClass    = m_mediator.StringTbl.GetString(sClassRaw, "ClassNames");
                string sUndo     = String.Format(DetailControlsStrings.ksUndoCreate0, sClass);
                string sRedo     = String.Format(DetailControlsStrings.ksRedoCreate0, sClass);

                sdaReal.BeginUndoTask(sUndo, sRedo);
                int hvoNewObj = sdaReal.MakeNewObject((int)m_clidDst, m_hvoObj, m_flidEmptyProp, ord);
                // Set its property m_flidStringProp to tssTyped. If it is multilingual, choose based on ghostWs.
                FieldType iTypeString = m_fdoCache.GetFieldType(m_flidStringProp);

                iTypeString &= FieldType.kcptVirtualMask;
                switch (iTypeString)
                {
                default:
                    throw new Exception("ghost property must store strings!");

                case FieldType.kcptMultiString:
                case FieldType.kcptMultiBigString:
                case FieldType.kcptMultiUnicode:
                case FieldType.kcptMultiBigUnicode:
                    sdaReal.SetMultiStringAlt(hvoNewObj, m_flidStringProp, m_wsToCreate, tssTyped);
                    break;

                case FieldType.kcptString:
                case FieldType.kcptBigString:
                    sdaReal.SetString(hvoNewObj, m_flidStringProp, tssTyped);
                    break;
                }

                string ghostInitMethod = XmlUtils.GetOptionalAttributeValue(m_nodeObjProp, "ghostInitMethod");

                if (ghostInitMethod != null)
                {
                    ICmObject obj     = CmObject.CreateFromDBObject(m_fdoCache, hvoNewObj);
                    Type      objType = obj.GetType();
                    System.Reflection.MethodInfo mi = objType.GetMethod(ghostInitMethod);
                    mi.Invoke(obj, null);
                }
                // Issue PropChanged for the addition of the new object. (could destroy this).
                sdaReal.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvoObj, m_flidEmptyProp, 0, 1, 0);
                sdaReal.EndUndoTask();
                return(hvoNewObj);
            }