private bool FollowActiveLink() { try { if (m_lnkActive.TargetGuid != Guid.Empty) { // allow tools to skip loading a record if we're planning to jump to one. // interested tools will need to reset this "JumpToRecord" property after handling OnJumpToRecord. m_mediator.PropertyTable.SetProperty("SuspendLoadingRecordUntilOnJumpToRecord", m_lnkActive.ToolName + "," + m_lnkActive.TargetGuid.ToString(), PropertyTable.SettingsGroup.LocalSettings); } m_mediator.SendMessage("SetToolFromName", m_lnkActive.ToolName); // Note: It can be Guid.Empty in cases where it was never set, // or more likely, when the HVO was set to -1. if (m_lnkActive.TargetGuid != Guid.Empty) { FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); // Allow this to happen after the processing of the tool change above by using the Broadcast // method on the mediator, the SendMessage would process it before the above msg and it would // use the wrong RecordList. (LT-3260) m_mediator.BroadcastMessageUntilHandled("JumpToRecord", cache.GetIdFromGuid(m_lnkActive.TargetGuid)); } foreach (Property property in m_lnkActive.PropertyTableEntries) { m_mediator.PropertyTable.SetProperty(property.name, property.value); //TODO: I can't think at the moment of what to do about setting //the persistence or ownership of the property...at the moment the only values we're putting //in there are strings or bools } m_mediator.BroadcastMessageUntilHandled("LinkFollowed", m_lnkActive); } catch (Exception err) { string s; if (err.InnerException != null && err.InnerException.Message != null && err.InnerException.Message.Length > 0) { s = String.Format(xWorksStrings.UnableToFollowLink0, err.InnerException.Message); } else { s = xWorksStrings.UnableToFollowLink; } MessageBox.Show(s, xWorksStrings.FailedJump, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return(false); } return(true); //we handled this. }
private void m_btnTryIt_Click(object sender, System.EventArgs e) { // get a connection, if one does not exist if (Connection == null) { m_mediator.BroadcastMessageUntilHandled("ReInitParser", null); // Now we need to wait for the message to be handled. // We'll know it's done when there's a connection m_connectionTimer.Start(); m_fJustMadeConnectionToParser = true; return; } TryTheWord(); }
/// <summary> /// Implement the "Promote" command. /// </summary> public bool OnPromoteSubitemInVector(object argument) { CheckDisposed(); if (this.Object == null) { return(false); } IRnGenericRec rec = this.Object as IRnGenericRec; if (rec == null) { return(false); // shouldn't get here } IRnGenericRec recOwner = rec.Owner as IRnGenericRec; if (recOwner == null) { return(false); // shouldn't get here } // Grab the mediator now for later use, because this slice may get disposed before we // use it. Mediator mediator = m_mediator; UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(Resources.DetailControlsStrings.ksUndoPromote, Resources.DetailControlsStrings.ksRedoPromote, Cache.ActionHandlerAccessor, () => { if (recOwner.Owner is IRnGenericRec) { (recOwner.Owner as IRnGenericRec).SubRecordsOS.Insert(recOwner.OwnOrd + 1, rec); } else if (recOwner.Owner is IRnResearchNbk) { (recOwner.Owner as IRnResearchNbk).RecordsOC.Add(rec); } else { throw new Exception("RnGenericRec object not owned by either RnResearchNbk or RnGenericRec??"); } }); if (recOwner.Owner is IRnResearchNbk) { // If possible, jump to the newly promoted record. mediator.BroadcastMessageUntilHandled("JumpToRecord", rec.Hvo); } return(true); }
/// <summary> /// Handles the xCore message to go to a reversal entry. /// </summary> /// <param name="argument">The xCore Command object.</param> /// <returns>true</returns> public bool OnGotoReversalEntry(object argument) { CheckDisposed(); using (var dlg = new ReversalEntryGoDlg()) { dlg.ReversalIndex = Entry.ReversalIndex; var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); dlg.SetDlgInfo(cache, null, m_mediator); // , false if (dlg.ShowDialog() == DialogResult.OK) { // Can't Go to a subentry, so we have to go to its main entry. var selEntry = (IReversalIndexEntry)dlg.SelectedObject; m_mediator.BroadcastMessageUntilHandled("JumpToRecord", selEntry.MainEntry.Hvo); } } return(true); }
private bool FollowActiveLink() { try { //Debug.Assert(!(m_lnkActive is FwAppArgs), "Beware: This will not handle link requests for other databases/applications." + // " To handle other databases or applications, pass the FwAppArgs to the IFieldWorksManager.HandleLinkRequest method."); if (m_lnkActive.ToolName == "default") { // Need some smarts here. The link creator was not sure what tool to use. // The object may also be a child we don't know how to jump to directly. var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); ICmObject target; if (!cache.ServiceLocator.ObjectRepository.TryGetObject(m_lnkActive.TargetGuid, out target)) { return(false); // or message? } var realTarget = GetObjectToShowInTool(target); string realTool; var majorObject = realTarget.Owner ?? realTarget; var app = FwUtils.ksFlexAbbrev; switch (majorObject.ClassID) { case ReversalIndexTags.kClassId: realTool = "reversalToolEditComplete"; break; case TextTags.kClassId: realTool = "interlinearEdit"; break; case LexEntryTags.kClassId: realTool = "lexiconEdit"; break; case ScriptureTags.kClassId: return(false); // Todo: don't know how to handle this yet. //app = FwUtils.ksTeAbbrev; //realTool = "reversalToolEditComplete"; //break; case CmPossibilityListTags.kClassId: // The area listener knows about the possible list tools. // Unfortunately AreaListener is in an assembly we can't reference. // But there may be custom ones, so just listing them all here does not seem to be an option, // and anyway it would be hard to maintain. // Thus we've created this method (on AreaListener) which we call awkwardly throught the mediator. var parameters = new object[2]; parameters[0] = majorObject; m_mediator.SendMessage("GetToolForList", parameters); realTool = (string)parameters[1]; break; case RnResearchNbkTags.kClassId: realTool = "notebookEdit"; break; case DsConstChartTags.kClassId: realTarget = ((IDsConstChart)majorObject).BasedOnRA; realTool = "interlinearEdit"; // Enhance JohnT: do something to make it switch to Discourse tab break; case LexDbTags.kClassId: // other things owned by this?? default: return(false); // can't jump to it...should we put up a message? } m_lnkActive = new FwLinkArgs(realTool, realTarget.Guid); // Todo JohnT: need to do something special here if we c } // It's important to do this AFTER we set the real tool name if it is "default". Otherwise, the code that // handles the jump never realizes we have reached the desired tool (as indicated by the value of // SuspendLoadingRecordUntilOnJumpToRecord) and we stop recording context history and various similar problems. if (m_lnkActive.TargetGuid != Guid.Empty) { // allow tools to skip loading a record if we're planning to jump to one. // interested tools will need to reset this "JumpToRecord" property after handling OnJumpToRecord. m_mediator.PropertyTable.SetProperty("SuspendLoadingRecordUntilOnJumpToRecord", m_lnkActive.ToolName + "," + m_lnkActive.TargetGuid.ToString(), PropertyTable.SettingsGroup.LocalSettings); m_mediator.PropertyTable.SetPropertyPersistence("SuspendLoadingRecordUntilOnJumpToRecord", false); } m_mediator.SendMessage("SetToolFromName", m_lnkActive.ToolName); // Note: It can be Guid.Empty in cases where it was never set, // or more likely, when the HVO was set to -1. if (m_lnkActive.TargetGuid != Guid.Empty) { FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); ICmObject obj = cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(m_lnkActive.TargetGuid); if (obj is IReversalIndexEntry && m_lnkActive.ToolName == "reversalToolEditComplete") { // For the reversal index tool, just getting the tool right isn't enough. We // also need to be showing the proper index. (See FWR-1105.) string sGuid = (string)m_mediator.PropertyTable.GetValue("ReversalIndexGuid"); if (!sGuid.Equals(obj.Owner.Guid.ToString())) { m_mediator.PropertyTable.SetProperty("ReversalIndexGuid", obj.Owner.Guid.ToString()); } } // Allow this to happen after the processing of the tool change above by using the Broadcast // method on the mediator, the SendMessage would process it before the above msg and it would // use the wrong RecordList. (LT-3260) m_mediator.BroadcastMessageUntilHandled("JumpToRecord", obj.Hvo); } foreach (Property property in m_lnkActive.PropertyTableEntries) { m_mediator.PropertyTable.SetProperty(property.name, property.value); //TODO: I can't think at the moment of what to do about setting //the persistence or ownership of the property...at the moment the only values we're putting //in there are strings or bools } m_mediator.BroadcastMessageUntilHandled("LinkFollowed", m_lnkActive); } catch (Exception err) { string s; if (err.InnerException != null && !string.IsNullOrEmpty(err.InnerException.Message)) { s = String.Format(xWorksStrings.UnableToFollowLink0, err.InnerException.Message); } else { s = xWorksStrings.UnableToFollowLink; } MessageBox.Show(s, xWorksStrings.FailedJump, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return(false); } return(true); //we handled this. }