コード例 #1
0
		/// <summary>
		/// This method is called when a user selects Delete Relation on a Lexical Relation slice.
		/// For: Pair relation (eg. Antonym)
		///     tree relation (parts/whole when deleting a Parts slice)
		/// </summary>
		/// <param name="hvo"></param>
		public void DeleteReference(int hvo)
		{
			CheckDisposed();
			if (hvo <= 0)
			{
				throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
			}
			else
			{
				Form mainWindow = (Form)Mediator.PropertyTable.GetValue("window");
				mainWindow.Cursor = Cursors.WaitCursor;
				using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
				{
					CmObjectUi ui = CmObjectUi.MakeUi(m_cache, hvo);
					ILexReference lr = LexReference.CreateFromDBObject(m_cache, hvo);

					//We need this to determine which kind of relation we are deleting
					LexRefType lrtOwner =
					(LexRefType)CmObject.CreateFromDBObject(m_cache, lr.OwnerHVO);

					int analWs = m_cache.DefaultAnalWs;
					int userWs = m_cache.DefaultUserWs;
					ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
					tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);

					switch ((LexRefType.MappingTypes)lrtOwner.MappingType)
					{
					case LexRefType.MappingTypes.kmtSenseTree:
					case LexRefType.MappingTypes.kmtEntryTree:
					case LexRefType.MappingTypes.kmtEntryOrSenseTree:
						tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
						tisb.Append(String.Format(LexEdStrings.ksDeleteLexTree, "\x2028"));
						dlg.SetDlgInfo(ui, m_cache, Mediator, tisb.GetString() );
						break;
					default:
						dlg.SetDlgInfo(ui, m_cache, Mediator);
						break;
					}

					if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
					{
						lr.DeleteUnderlyingObject();
						//Update the display because we have removed this slice from the Lexical entry.
						UpdateForDelete(hvo);

						mainWindow.Cursor = Cursors.Default;
					}
					else //If the user selected Cancel in the delete dialog do nothing
					{
						mainWindow.Cursor = Cursors.Default;
						return;
					}
				}

			}
		}
コード例 #2
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.
		}
コード例 #3
0
ファイル: FdoUiCore.cs プロジェクト: sillsdev/WorldPad
		public void DeleteUnderlyingObject()
		{
			CheckDisposed();

			ICmObject cmo = GetCurrentCmObject();
			if (cmo != null && m_obj != null && cmo.Hvo == m_obj.Hvo)
			{
				object command = this;
				if (m_command != null)
					command = m_command;
				m_mediator.SendMessage("DeleteRecord", command);
			}
			else
			{
				Form mainWindow = (Form)m_mediator.PropertyTable.GetValue("window");
				mainWindow.Cursor = Cursors.WaitCursor;
				try
				{
					using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
					{
						dlg.SetDlgInfo(this, m_cache, Mediator);
						if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
							ReallyDeleteUnderlyingObject();
					}
				}
				finally
				{
					mainWindow.Cursor = Cursors.Default;
				}
			}
		}
コード例 #4
0
ファイル: ReversalListener.cs プロジェクト: sillsdev/WorldPad
		public void DeleteReversalIndex(IReversalIndex ri)
		{
			CheckDisposed();

			Form mainWindow = (Form)m_mediator.PropertyTable.GetValue("window");
			mainWindow.Cursor = Cursors.WaitCursor;
			using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
			{
				SIL.FieldWorks.FdoUi.CmObjectUi ui = new SIL.FieldWorks.FdoUi.CmObjectUi(ri);
				dlg.SetDlgInfo(ui, m_cache, m_mediator);
				dlg.TopMessage = LexEdStrings.ksDeletingThisRevIndex;
				dlg.BottomQuestion = LexEdStrings.ksReallyWantToDeleteRevIndex;
				if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
					ReallyDeleteReversalIndex(ri);
			}
			mainWindow.Cursor = Cursors.Default;
		}