public bool OnMappingJumpToNaturalClass(object args)
		{
			CheckDisposed();
			int hvo = RuleFormulaControl.CurrentHvo;
			IMoModifyFromInput mapping = new MoModifyFromInput(m_cache, hvo);
			Mediator.PostMessage("FollowLink", FwLink.Create("naturalClassedit",
				m_cache.GetGuidFromId(mapping.ModificationRAHvo), m_cache.ServerName, m_cache.DatabaseName));
			return true;
		}
        public bool OnMappingJumpToNaturalClass(object args)
        {
            CheckDisposed();
            int hvo = RuleFormulaControl.CurrentHvo;
            IMoModifyFromInput mapping = new MoModifyFromInput(m_cache, hvo);

            Mediator.PostMessage("FollowLink", FwLink.Create("naturalClassedit",
                                                             m_cache.GetGuidFromId(mapping.ModificationRAHvo), m_cache.ServerName, m_cache.DatabaseName));
            return(true);
        }
Exemple #3
0
		/// <summary>
		/// This method is the one to override if you need side effects when DeleteUnderlyingObject
		/// is called. If other objects should be deleted also, do NOT delete them directly; this
		/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
		/// whole lot (including this) will be deleted in one relatively efficient operation.
		/// You should not modify objectsToDeleteAlso except to add HVOs to it.
		/// You must not use the FDO object after calling this, it has been put into the deleted state.
		/// </summary>
		/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
		/// <param name="state"></param>
		public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
		{
			switch (Owner.ClassID)
			{
				case MoAffixProcess.kclsidMoAffixProcess:
					// if this is owned by a MoAffixProcess we must remove all of the associated output mappings
					IMoAffixProcess rule = Owner as IMoAffixProcess;
					foreach (int mappingHvo in rule.OutputOS.HvoArray)
					{
						switch (m_cache.GetClassOfObject(mappingHvo))
						{
							case MoCopyFromInput.kclsidMoCopyFromInput:
								IMoCopyFromInput copy = new MoCopyFromInput(m_cache, mappingHvo);
								if (copy.ContentRAHvo == Hvo)
									objectsToDeleteAlso.Add(mappingHvo);
								break;

							case MoModifyFromInput.kclsidMoModifyFromInput:
								IMoModifyFromInput modify = new MoModifyFromInput(m_cache, mappingHvo);
								if (modify.ContentRAHvo == Hvo)
									objectsToDeleteAlso.Add(mappingHvo);
								break;
						}
					}
					break;

				case PhPhonData.kclsidPhPhonData:
					List<LinkedObjectInfo> linkedObjs = LinkedObjects;
					foreach (LinkedObjectInfo loi in linkedObjs)
					{
						if (loi.RelObjClass == PhIterationContext.kclsidPhIterationContext
							&& loi.RelObjField == (int)PhIterationContext.PhIterationContextTags.kflidMember)
						{
							IPhIterationContext ctxt = new PhIterationContext(m_cache, loi.RelObjId);
							ctxt.DeleteObjectSideEffects(objectsToDeleteAlso, state);
							objectsToDeleteAlso.Add(loi.RelObjId);
						}
						else if (loi.RelObjClass == PhSequenceContext.kclsidPhSequenceContext
							&& loi.RelObjField == (int)PhSequenceContext.PhSequenceContextTags.kflidMembers
							&& m_cache.GetVectorSize(loi.RelObjId, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) == 1)
						{
							IPhSequenceContext ctxt = new PhSequenceContext(m_cache, loi.RelObjId);
							ctxt.DeleteObjectSideEffects(objectsToDeleteAlso, state);
							objectsToDeleteAlso.Add(loi.RelObjId);
						}
					}
					break;
			}
			base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
		}
		public void SetMappingNaturalClass()
		{
			SelectionHelper sel = SelectionHelper.Create(m_view);

			Set<int> natClasses = new Set<int>();
			foreach (IPhNaturalClass nc in m_cache.LangProject.PhonologicalDataOA.NaturalClassesOS)
			{
				if (nc.ClassID == PhNCFeatures.kclsidPhNCFeatures)
					natClasses.Add(nc.Hvo);
			}
			int ncHvo = m_insertionControl.DisplayChooser(MEStrings.ksRuleNCOpt, MEStrings.ksRuleNCChooserLink,
				"naturalClassedit", "RuleNaturalClassFlatList", natClasses);
			m_view.Select();
			if (ncHvo != 0)
			{
				int index = -1;
				using (new UndoRedoTaskHelper(m_cache, MEStrings.ksAffixRuleUndoSetNC, MEStrings.ksAffixRuleRedoSetNC))
				{
					int curHvo = CurrentHvo;
					switch (m_cache.GetClassOfObject(curHvo))
					{
						case MoCopyFromInput.kclsidMoCopyFromInput:
							IMoCopyFromInput copy = new MoCopyFromInput(m_cache, curHvo);
							IMoModifyFromInput newModify = new MoModifyFromInput();
							Rule.OutputOS.InsertAt(newModify, copy.IndexInOwner);
							newModify.ModificationRAHvo = ncHvo;
							newModify.ContentRAHvo = copy.ContentRAHvo;
							index = newModify.IndexInOwner;
							newModify.NotifyNew();

							copy.DeleteUnderlyingObject();
							break;

						case MoModifyFromInput.kclsidMoModifyFromInput:
							IMoModifyFromInput modify = new MoModifyFromInput(m_cache, curHvo);
							modify.ModificationRAHvo = ncHvo;
							index = modify.IndexInOwner;
							break;
					}
				}

				ReconstructView((int)MoAffixProcess.MoAffixProcessTags.kflidOutput, index, true);
			}
		}
		public void SetMappingFeatures()
		{
			SelectionHelper sel = SelectionHelper.Create(m_view);
			bool reconstruct = false;
			int index = -1;
			using (new UndoRedoTaskHelper(m_cache, MEStrings.ksAffixRuleUndoSetMappingFeatures, MEStrings.ksAffixRuleRedoSetMappingFeatures))
			{
				using (PhonologicalFeatureChooserDlg featChooser = new PhonologicalFeatureChooserDlg())
				{
					int hvo = CurrentHvo;
					switch (m_cache.GetClassOfObject(hvo))
					{
						case MoCopyFromInput.kclsidMoCopyFromInput:
							featChooser.SetDlgInfo(m_cache, m_mediator);
							if (featChooser.ShowDialog() == DialogResult.OK)
							{
								// create a new natural class behind the scenes
								PhNCFeatures featNC = new PhNCFeatures();
								m_cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Append(featNC);
								featNC.Name.UserDefaultWritingSystem = string.Format(MEStrings.ksRuleNCFeatsName,
									Rule.Form.BestVernacularAnalysisAlternative.Text);
								featNC.FeaturesOA = new FsFeatStruc();
								featChooser.FS = featNC.FeaturesOA;
								featChooser.UpdateFeatureStructure();
								featNC.FeaturesOA.NotifyNew();
								featNC.NotifyNew();

								IMoCopyFromInput copy = new MoCopyFromInput(m_cache, hvo);
								IMoModifyFromInput newModify = new MoModifyFromInput();
								Rule.OutputOS.InsertAt(newModify, copy.IndexInOwner);
								newModify.ModificationRAHvo = featNC.Hvo;
								newModify.ContentRAHvo = copy.ContentRAHvo;
								index = newModify.IndexInOwner;
								newModify.NotifyNew();

								copy.DeleteUnderlyingObject();

								reconstruct = true;
							}
							break;

						case MoModifyFromInput.kclsidMoModifyFromInput:
							IMoModifyFromInput modify = new MoModifyFromInput(m_cache, hvo);
							featChooser.SetDlgInfo(m_cache, m_mediator, modify.ModificationRA.FeaturesOA);
							if (featChooser.ShowDialog() == DialogResult.OK)
							{
								if (modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count == 0)
								{
									IMoCopyFromInput newCopy = new MoCopyFromInput();
									Rule.OutputOS.InsertAt(newCopy, modify.IndexInOwner);
									newCopy.ContentRAHvo = modify.ContentRAHvo;
									index = newCopy.IndexInOwner;
									newCopy.NotifyNew();

									modify.DeleteUnderlyingObject();
								}
								else
								{
									index = modify.IndexInOwner;
								}
								reconstruct = true;
							}
							break;
					}
				}
			}

			m_view.Select();
			if (reconstruct)
				ReconstructView((int)MoAffixProcess.MoAffixProcessTags.kflidOutput, index, true);
		}
		/// <summary>
		/// Updates the context that the mappings point to. This is used when the context changes
		/// from a single context to a sequence context.
		/// </summary>
		/// <param name="oldHvo">The old hvo.</param>
		/// <param name="newHvo">The new hvo.</param>
		void UpdateMappings(int oldHvo, int newHvo)
		{
			foreach (int mappingHvo in Rule.OutputOS.HvoArray)
			{
				switch (m_cache.GetClassOfObject(mappingHvo))
				{
					case MoCopyFromInput.kclsidMoCopyFromInput:
						IMoCopyFromInput copy = new MoCopyFromInput(m_cache, mappingHvo);
						if (copy.ContentRAHvo == oldHvo)
							copy.ContentRAHvo = newHvo;
						break;

					case MoModifyFromInput.kclsidMoModifyFromInput:
						IMoModifyFromInput modify = new MoModifyFromInput(m_cache, mappingHvo);
						if (modify.ContentRAHvo == oldHvo)
							modify.ContentRAHvo = newHvo;
						break;
				}
			}
		}