コード例 #1
0
		private void SwapAllomorphWithLexeme(ILexEntry entry, IMoForm allomorph, Command cmd)
		{
			using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_dataEntryForm.Cache, cmd))
			{
				entry.AlternateFormsOS.InsertAt(entry.LexemeFormOA, allomorph.IndexInOwner);
				entry.LexemeFormOA = allomorph;
			}
		}
コード例 #2
0
		public bool OnConvertAllomorph(object cmd)
		{
			Command command = cmd as Command;
			int toClsid = (int)m_dataEntryForm.Cache.MetaDataCacheAccessor.GetClassId(command.GetParameter("toClassName"));
			ILexEntry entry = m_dataEntryForm.Root as ILexEntry;
			Slice slice = m_dataEntryForm.CurrentSlice;
			IMoForm allomorph = slice.Object as IMoForm;
			if (entry != null && allomorph != null && toClsid != 0)
			{
				if (CheckForFormDataLoss(allomorph, toClsid))
				{
					Form mainWindow = (Form)m_mediator.PropertyTable.GetValue("window");
					IMoForm newForm = null;
					using (new WaitCursor(mainWindow))
					{
						using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_dataEntryForm.Cache, cmd as Command))
						{
							newForm = CreateNewForm(toClsid);
							entry.ReplaceMoForm(allomorph, newForm);
						}
						m_dataEntryForm.RefreshList(false);
					}
					SelectNewFormSlice(newForm);
				}
			}
			return true;
		}
コード例 #3
0
ファイル: InterlinDocView.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Note: Assume we are in the OnDisplayShowLinkWords is true context.
		/// </summary>
		public bool OnJoinWords(object cmd)
		{
			// For now, suppress Undo/Redo since we're having difficulty
			// refreshing the Words record lists appropriately.
			// 1) Merge the current annotation with next twfic.
			// Since this action may irreversably overlap with current undo actions, clear the undo stack.
			//ITextStrings.ksUndoLinkWords; ITextStrings.ksRedoLinkWords;
			using (UndoRedoCommandHelper undoRedoHelper = new UndoRedoCommandHelper(Cache, cmd as Command, false, true))
			{
				// any changes in the sandbox should be ignored. we don't want to try to save it.
				using (SegmentFormsUpdateHelper sfuh = new SegmentFormsUpdateHelper(this))
				{
					sfuh.MergeAdjacentSegmentForms();
				}
			}
			return true;
		}
コード例 #4
0
ファイル: InterlinDocView.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// split the current annotation into annotations for each word in the phrase-wordform.
		/// (assume it IsPhrase)
		/// </summary>
		/// <param name="argument"></param>
		public void OnBreakPhrase(object argument)
		{
			// (LT-8069) in some odd circumstances, the break phrase icon lingers on the tool bar menu when it should
			// have disappeared. If we're in that state, just return.
			if (!ShowBreakPhraseIcon)
				return;
			// For now, suppress Undo/Redo since we're having difficulty
			// refreshing the Words record lists appropriately.
			// Since this action may irreversably overlap with current undo actions, clear the undo stack.
			// ITextStrings.ksUndoBreakPhrase; ITextStrings.ksRedoBreakPhrase;
			using (UndoRedoCommandHelper undoRedoHelper = new UndoRedoCommandHelper(Cache, argument as Command, false, true))
			{
				using (SegmentFormsUpdateHelper sfuh = new SegmentFormsUpdateHelper(this))
				{
					sfuh.BreakPhraseAnnotation();
				}
			}
			return;
		}
コード例 #5
0
ファイル: InterlinDocView.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Intercepts the 'Delete Record' command otherwise handled by the record clerk (which
		/// offers to delete the whole record). If in a free translation, delete that.
		/// </summary>
		/// <param name="commandObject"></param>
		/// <returns>true if handled</returns>
		public bool OnDeleteRecord(object commandObject)
		{
			// if we're not in document view or FocusBox is installed, return.
			if (ExistingFocusBox == null || IsFocusBoxInstalled)
				return false; // no special behavior, let clerk handle it.

			using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(Cache, commandObject as Command))
			{
				IVwSelection sel = RootBox.Selection;
				return DeleteFreeform(sel);
			}
		}
コード例 #6
0
		/// <summary>
		///
		/// </summary>
		/// <param name="argument">The xCore Command object.</param>
		/// <returns>true</returns>
		public bool OnAddApprovedAnalysis(object argument)
		{
			using (EditMorphBreaksDlg dlg = new EditMorphBreaksDlg())
			{
				IWfiWordform wf = Wordform;
				if (wf == null)
					return true;
				ITsString tssWord = Wordform.Form.BestVernacularAlternative;
				string morphs = tssWord.Text;
				FdoCache cache = Cache;
				dlg.Initialize(tssWord, morphs, cache.MainCacheAccessor.WritingSystemFactory,
					cache, m_dataEntryForm.Mediator.StringTbl, m_dataEntryForm.StyleSheet);
				Form mainWnd = m_dataEntryForm.FindForm();
				// Making the form active fixes problems like LT-2619.
				// I'm (RandyR) not sure what adverse impact might show up by doing this.
				mainWnd.Activate();
				if (dlg.ShowDialog(mainWnd) == DialogResult.OK)
				{
					morphs = dlg.GetMorphs().Trim();
					if (morphs.Length == 0)
						return true;

					string[] prefixMarkers = MoMorphType.PrefixMarkers(cache);
					string[] postfixMarkers = MoMorphType.PostfixMarkers(cache);

					List<string> allMarkers = new List<string>();
					foreach (string s in prefixMarkers)
					{
						allMarkers.Add(s);
					}

					foreach (string s in postfixMarkers)
					{
						if (!allMarkers.Contains(s))
							allMarkers.Add(s);
					}
					allMarkers.Add(" ");

					string[] breakMarkers = new string[allMarkers.Count];
					for (int i = 0; i < allMarkers.Count; ++i)
						breakMarkers[i] = allMarkers[i];

					string fullForm = SandboxBase.MorphemeBreaker.DoBasicFinding(morphs, breakMarkers, prefixMarkers, postfixMarkers);

					using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(Cache,
						argument as Command))
					{
						IWfiAnalysis newAnalysis = Wordform.AnalysesOC.Add(new WfiAnalysis());
						newAnalysis.ApprovalStatusIcon = 1; // Make it human approved.
						int vernWS = StringUtils.GetWsAtOffset(tssWord, 0);
						foreach (string morph in fullForm.Split(Unicode.SpaceChars))
						{
							if (morph != null && morph.Length != 0)
							{
								IWfiMorphBundle mb = newAnalysis.MorphBundlesOS.Append(new WfiMorphBundle());
								mb.Form.SetAlternative(morph, vernWS);
							}
						}
						int outlineFlid = BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiAnalysis", "HumanApprovedNumber");
						foreach (int haaHvo in Wordform.HumanApprovedAnalyses)
						{
							// Do PropChanged for the outline number for all of them.
							// This fixes LT-5007, as the older ones kept their old number,
							// which could have been a duplicate number.
							cache.PropChanged(
								null,
								PropChangeType.kpctNotifyAll,
								haaHvo,
								outlineFlid,
								0, 0, 0);
						}
						cache.PropChanged(
							null,
							PropChangeType.kpctNotifyAll,
							Wordform.Hvo,
							BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiWordform", "HumanApprovedAnalyses"),
							0, 1, 0);
					}
				}
			}

			return true;
		}
コード例 #7
0
ファイル: RecordClerk.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// this is triggered by any command whose message attribute is "InsertItemInVector"
		/// </summary>
		/// <param name="argument"></param>
		/// <returns>true if successful (the class is known)</returns>
		public bool OnInsertItemInVector(object argument)
		{
			CheckDisposed();

			if(!Editable)
				return false;
			// We will certainly switch records, but we're going to suppress the usual Save after we
			// switch, so the user can at least Undo one level, the actual insertion. But Undoing
			// that may not get us back to the current record, so we'd better not allow anything
			// that's already on the stack to be undone.
			// Enhance JohnT: if a dialog is brought up, the user could cancel, in which case,
			// we don't really need to throw away the Undo stack.
			SaveOnChangeRecord();

			//if there is a listener who wants to do bring up a dialog box rather than just creating a new item,
			//give them a chance.
			m_suppressSaveOnChangeRecord = true;
			try
			{
				if (m_mediator.SendMessage("DialogInsertItemInVector", argument))
					return true;
			}
			finally
			{
				m_suppressSaveOnChangeRecord = false;
			}

			Command command = (Command)argument;
			string className = "";
			try
			{
				className = XmlUtils.GetManditoryAttributeValue(command.Parameters[0], "className");
			}
			catch (ApplicationException)
			{
				throw new ConfigurationException("Could not get the necessary parameter information from this command",
					command.ConfigurationNode);
			}
			try
			{
				if (!m_list.CanInsertClass(className))
					return false;
				using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_list.Cache, argument as Command))
				{
					return InsertItemInVector(className);
				}
			}
			// This doesn't make sense, we return false if we can't add that class here, unless
			// something worse went wrong.
			//catch (InvalidEnumArgumentException)
			//{
			//    throw new ConfigurationException("The class name specified in this command cannot be added here.",
			//        command.ConfigurationNode);
			//}
			catch (ApplicationException ae)
			{
				throw new ApplicationException("Could not insert the item requested by the command " + command.ConfigurationNode, ae);
			}
		}
コード例 #8
0
ファイル: RecordClerk.cs プロジェクト: sillsdev/WorldPad
		public bool OnDeleteRecord(object commandObject)
		{
			CheckDisposed();

			// Don't handle this message if you're not the primary clerk.  This allows, for
			// example, XmlBrowseRDEView.cs to handle the message instead.

			// Note from RandyR: One of these days we should probably subclass this obejct, and perhaps the record list more.
			// The "reversalEntries" clerk wants to handle the message, even though it isn't the primary clerk.
			// The m_shouldHandleDeletion member was also added, so the "reversalEntries" clerk's primary clerk
			// would not handle the message, and delete an entire reversal index.
			if (ShouldNotHandleDeletionMessage)
				return false;

			// It may be null:
			// 1. if the objects are bing deleted using the keys,
			// 2. the last one has been deleted, and
			// 3. the user keeps pressing the del key.
			// It looks like the command is not being disabled at all or fast enough.
			if (CurrentObject == null)
				return true;

			// Don't allow an object to be deleted if it shouldn't be deleted.
			if (CurrentObject.ValidateOkToDelete() == false)
				return true;

			//when we are doing an automated test, we don't know how to click the "yes" button, so
			//look into the property table to see if there is a property controlling what we should do.
			bool doingAutomatedTest = m_mediator.PropertyTable.GetBoolProperty("DoingAutomatedTest", false);

			using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
			{
				using (CmObjectUi uiObj = CmObjectUi.MakeUi(CurrentObject))
				{
					dlg.SetDlgInfo(uiObj, Cache, m_mediator);
				}
				Form window = (Form)m_mediator.PropertyTable.GetValue("window");
				if (doingAutomatedTest ||
					DialogResult.Yes == dlg.ShowDialog(window))
				{
					window.Cursor = Cursors.WaitCursor;
					using (ProgressState state = FwXWindow.CreatePredictiveProgressState(m_mediator, "Delete record"))
					{
						state.SetMilestone(xWorksStrings.DeletingTheObject);
						state.Breath();
						// We will certainly switch records, but we're going to suppress the usual Save after we
						// switch, so the user can at least Undo one level, the actual deletion. But Undoing
						// that may not get us back to the current record, so we'd better not allow anything
						// that's already on the stack to be undone.
						SaveOnChangeRecord();
						m_suppressSaveOnChangeRecord = true;
						try
						{
							using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_list.Cache, commandObject as Command))
							{
								m_list.DeleteCurrentObject(state);
							}
							state.SetMilestone(xWorksStrings.UpdatingTheDisplay);
							state.Breath();
							BroadcastChange();
							state.Breath();
						}
						finally
						{
							m_suppressSaveOnChangeRecord = false;
						}
					}
					window.Cursor = Cursors.Default;
				}
			}
			return true; //we handled this, no need to ask anyone else.
		}
コード例 #9
0
ファイル: InterlinMaster.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Delegate this command to the idcPane. (It isn't enabled unless one exists.)
		/// </summary>
		/// <param name="argument"></param>
		public void OnAddNote(object argument)
		{
			CheckDisposed();
			using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(Cache, argument as Command))
			{
				m_idcPane.OnAddNote1(argument);
			}
		}