Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions Src/xWorks/XhtmlDocView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public bool OnJumpToRecord(object argument)
DictionaryConfigurationController.ExclusionReasonCode xrc;
// Make sure we explain to the user in case hvoTarget is not visible due to
// the current Publication layout or Configuration view.
if (!IsObjectVisible(hvoTarget, out xrc))
if (!IsObjectVisible(hvoTarget, Cache, m_propertyTable, out xrc))
{
// Tell the user why we aren't jumping to his record
GiveSimpleWarning(xrc);
Expand All @@ -189,16 +189,27 @@ public bool OnJumpToRecord(object argument)
private void GiveSimpleWarning(DictionaryConfigurationController.ExclusionReasonCode xrc)
{
// Tell the user why we aren't jumping to his record
var msg = xWorksStrings.ksSelectedEntryNotInDict;
string caption;
string reason;
string shlpTopic;
string msg = GetExclusionWarning(xrc, out caption, out shlpTopic);
// TODO-Linux: Help is not implemented on Mono
MessageBox.Show(FindForm(), msg, caption, MessageBoxButtons.OK,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, 0,
m_propertyTable.GetValue<IHelpTopicProvider>("HelpTopicProvider").HelpFile,
HelpNavigator.Topic, shlpTopic);
}

internal static string GetExclusionWarning(DictionaryConfigurationController.ExclusionReasonCode xrc, out string caption, out string shlpTopic)
{
// Tell the user why we aren't jumping to his record
var msg = xWorksStrings.ksSelectedEntryNotInDict;
string reason;
switch (xrc)
{
case DictionaryConfigurationController.ExclusionReasonCode.NotInPublication:
caption = xWorksStrings.ksEntryNotPublished;
reason = xWorksStrings.ksEntryNotPublishedReason;
shlpTopic = "User_Interface/Menus/Edit/Find_a_lexical_entry.htm"; //khtpEntryNotPublished
shlpTopic = "User_Interface/Menus/Edit/Find_a_lexical_entry.htm"; //khtpEntryNotPublished
break;
case DictionaryConfigurationController.ExclusionReasonCode.ExcludedHeadword:
caption = xWorksStrings.ksMainNotShown;
Expand All @@ -213,18 +224,13 @@ private void GiveSimpleWarning(DictionaryConfigurationController.ExclusionReason
default:
throw new ArgumentException("Unknown ExclusionReasonCode");
}
msg = String.Format(msg, reason);
// TODO-Linux: Help is not implemented on Mono
MessageBox.Show(FindForm(), msg, caption, MessageBoxButtons.OK,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, 0,
m_propertyTable.GetValue<IHelpTopicProvider>("HelpTopicProvider").HelpFile,
HelpNavigator.Topic, shlpTopic);
return String.Format(msg, reason);
}

private bool IsObjectVisible(int hvoTarget, out DictionaryConfigurationController.ExclusionReasonCode xrc)
internal static bool IsObjectVisible(int hvoTarget, LcmCache cache, PropertyTable propertyTable, out DictionaryConfigurationController.ExclusionReasonCode xrc)
{
xrc = DictionaryConfigurationController.ExclusionReasonCode.NotExcluded;
var objRepo = Cache.ServiceLocator.GetInstance<ICmObjectRepository>();
var objRepo = cache.ServiceLocator.GetInstance<ICmObjectRepository>();
Debug.Assert(objRepo.IsValidObjectId(hvoTarget), "Invalid hvoTarget!");
if (!objRepo.IsValidObjectId(hvoTarget))
throw new ArgumentException("Unknown object.");
Expand All @@ -235,8 +241,8 @@ private bool IsObjectVisible(int hvoTarget, out DictionaryConfigurationControlle

// Now we have our LexEntry
// First deal with whether the active Publication excludes it.
var m_currentPublication = m_propertyTable.GetValue<string>("SelectedPublication", null);
var publications = Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS.Select(p => p).Where(p => p.NameHierarchyString == m_currentPublication.ToString()).FirstOrDefault();
var m_currentPublication = propertyTable.GetValue<string>("SelectedPublication", null);
var publications = cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS.Select(p => p).Where(p => p.NameHierarchyString == m_currentPublication.ToString()).FirstOrDefault();
//if the publications is null in case of Dictionary view selected as $$All Entries$$.
if (publications != null && publications.NameHierarchyString != xWorksStrings.AllEntriesPublication)
{
Expand All @@ -255,7 +261,8 @@ private bool IsObjectVisible(int hvoTarget, out DictionaryConfigurationControlle
}
// Third deal with whether the entry shouldn't be shown as a minor entry.
// commented out until conditions are clarified (LT-11447)
var configuration = new DictionaryConfigurationModel(GetCurrentConfiguration(false), Cache);
string configurationName = DictionaryConfigurationListener.GetCurrentConfiguration(propertyTable, false);
var configuration = new DictionaryConfigurationModel(configurationName, cache);
if (entry.EntryRefsOS.Count > 0 && !entry.PublishAsMinorEntry && configuration.IsRootBased)
{
xrc = DictionaryConfigurationController.ExclusionReasonCode.ExcludedMinorEntry;
Expand Down
19 changes: 14 additions & 5 deletions Src/xWorks/XhtmlRecordDocView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using Gecko;
using SIL.FieldWorks.Common.FwUtils;
using SIL.LCModel;
using SIL.LCModel.Core.KernelInterfaces;
using XCore;
using SIL.Utils;
using SIL.Windows.Forms.HtmlBrowser;
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using XCore;
using static SIL.FieldWorks.XWorks.DictionaryConfigurationController;

namespace SIL.FieldWorks.XWorks
{
Expand Down Expand Up @@ -116,6 +117,14 @@ protected override void ShowRecord()
xWorksStrings.ksNoConfiguration);
return;
}
if (!XhtmlDocView.IsObjectVisible(cmo.Hvo, Cache, m_propertyTable, out ExclusionReasonCode xrc))
{
string caption;
string helpTopic;
string warning = XhtmlDocView.GetExclusionWarning(xrc, out caption, out helpTopic);
m_mainView.DocumentText = String.Format("<html><body><p>{0}</p></body></html>", warning);
return;
}
var configuration = new DictionaryConfigurationModel(configurationFile, Cache);
var xhtmlPath = LcmXhtmlGenerator.SavePreviewHtmlWithStyles(new [] { cmo.Hvo }, Clerk, null, configuration, m_propertyTable);
m_mainView.Url = new Uri(xhtmlPath);
Expand Down
2 changes: 1 addition & 1 deletion Src/xWorks/xWorksStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ Are you sure you want to delete this list?</value>
<comment>Used in Dictionary view warning dialogs.</comment>
</data>
<data name="ksSelectedEntryNotInDict" xml:space="preserve">
<value>The entry you have selected is not shown in Dictionary view, {0}.</value>
<value>The entry you have selected is not shown, {0}.</value>
<comment>Parameter is the Lexeme Form of the entry.</comment>
</data>
<data name="ksParagraphStyle" xml:space="preserve">
Expand Down
Loading