Skip to content

Commit

Permalink
Properly handle hyperlink to another project
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOliver28 committed Jun 27, 2024
1 parent b169d18 commit 34cde00
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Src/xWorks/LinkListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ private bool FollowActiveLink(bool suspendLoadingRecord)
{
try
{
var cache = m_propertyTable.GetValue<LcmCache>("cache");
//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 = m_propertyTable.GetValue<LcmCache>("cache");
ICmObject target;
if (!cache.ServiceLocator.ObjectRepository.TryGetObject(m_lnkActive.TargetGuid, out target))
return false; // or message?
Expand Down Expand Up @@ -500,6 +500,12 @@ private bool FollowActiveLink(bool suspendLoadingRecord)
m_lnkActive = new FwLinkArgs(realTool, realTarget.Guid);
// Todo JohnT: need to do something special here if we c
}
// Return false if the link is to a different database
var databases = m_lnkActive.PropertyTableEntries.Where(p => p.name == "database");
if (databases.Any() && databases.First().name != cache.LangProject.ShortName)
{
return false;
}
// 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.
Expand All @@ -518,10 +524,8 @@ private bool FollowActiveLink(bool suspendLoadingRecord)
// or more likely, when the HVO was set to -1.
if (m_lnkActive.TargetGuid != Guid.Empty)
{
LcmCache cache = m_propertyTable.GetValue<LcmCache>("cache");
ICmObject obj = cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(m_lnkActive.TargetGuid);
if (obj is IReversalIndexEntry && m_lnkActive.ToolName == "reversalToolEditComplete" ||
(m_lnkActive?.PropertyTableEntries.Where(p => p.name.Equals("database")).Any() ?? false))
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.)
Expand Down

0 comments on commit 34cde00

Please sign in to comment.