diff --git a/Src/Common/Controls/XMLViews/XmlSeqView.cs b/Src/Common/Controls/XMLViews/XmlSeqView.cs
index 2a0d34de29..456847cec6 100644
--- a/Src/Common/Controls/XMLViews/XmlSeqView.cs
+++ b/Src/Common/Controls/XMLViews/XmlSeqView.cs
@@ -358,20 +358,6 @@ private XmlNode ItemDisplayCondition
get { return m_xnSpec.SelectSingleNode("elementDisplayCondition"); }
}
- ///
- /// Receives the broadcast message "JumpToRecord" before RecordClerk
- /// (because this is the active Control?), so we can see if we
- /// need to display a failure message.
- ///
- public bool OnJumpToRecord(object argument)
- {
- CheckDisposed();
-#pragma warning disable 618 // suppress obsolete warning
- Mediator.BroadcastMessage("CheckJump", argument);
-#pragma warning restore 618
- return false; // I don't want to be seen as handling this!
- }
-
///
/// Receives the broadcast message "PropertyChanged"
///
diff --git a/Src/xWorks/RecordClerk.cs b/Src/xWorks/RecordClerk.cs
index e3744ae20b..fcb5817fc3 100644
--- a/Src/xWorks/RecordClerk.cs
+++ b/Src/xWorks/RecordClerk.cs
@@ -112,19 +112,6 @@ public int ListItemsClass
///
private string m_relatedClerk;
- ///
- /// When m_relatedClerk is not null, and this is also not null, it controls how we find the
- /// related object which we should switch to when a view using this is activated.
- /// owned: try to find one of our own objects which is or is owned by the object selected in the
- /// related clerk (e.g., Base Records clerk should try to find an object that is or owns the record
- /// selected in the records clerk).
- /// ownee: if the other clerk's object is or owns the object already selected in this, don't change.
- /// otherwise try to select the object owned in the other clerk. (e.g., Records Clerk should not
- /// switch to a higher-level record if it is in one that corresponds to part of the selection in
- /// the base record clerk).
- ///
- private string m_relationToRelatedClerk;
-
///
/// this is an object which gives us the list of filters which we should offer to the user from the UI.
/// this does not include the filters they can get that by using the FilterBar.
@@ -344,7 +331,6 @@ public virtual void Init(Mediator mediator, PropertyTable propertyTable, XmlNode
m_list = RecordList.Create(cache, mediator, propertyTable, clerkConfiguration.SelectSingleNode("recordList"));
m_list.Clerk = this;
m_relatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relatedClerk");
- m_relationToRelatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relationToRelatedClerk");
TryRestoreSorter(clerkConfiguration, cache);
TryRestoreFilter(clerkConfiguration, cache, updateAndNotify);
@@ -1858,15 +1844,6 @@ public void UpdateStatusBarRecordNumber(String noRecordsText)
ResetStatusBarMessageForCurrentObject();
}
- ///
- /// Overridden in SubitemRecordClerk, this records the subitem.
- ///
- ///
- internal virtual void SetSubitem(ICmObject subitem)
- {
-
- }
-
internal virtual bool SetCurrentFromRelatedClerk()
{
if (!String.IsNullOrEmpty(m_relatedClerk))
@@ -1874,51 +1851,7 @@ internal virtual bool SetCurrentFromRelatedClerk()
var relatedClerk = FindClerk(m_propertyTable, m_relatedClerk);
if (relatedClerk != null && Cache.ServiceLocator.IsValidObjectId(relatedClerk.CurrentObjectHvo))
{
- var target = relatedClerk.CurrentObject;
- if (m_relationToRelatedClerk != null && m_relationToRelatedClerk.StartsWith("root:"))
- {
- // The object to look for in our list is a 'root' of the one in the other list:
- // that is, the object in the other list itself or one of its owners, the highest one in the
- // hierarchy of a specified class. For example, the other list may contain subrecords,
- // we want to select an owning top-level record.
- var className = m_relationToRelatedClerk.Substring("root:".Length).Trim();
- var mdc = Cache.MetaDataCacheAccessor;
- var classId = mdc.GetClassId(className);
- var targetObj = target;
- for(;targetObj != null; targetObj = targetObj.Owner)
- {
- if (targetObj.ClassID == classId)
- target = targetObj; // it ends up with the highest thing of that class in the owner list (possibly the original target)
- }
- if (target != relatedClerk.CurrentObject)
- SetSubitem(relatedClerk.CurrentObject);
- else
- SetSubitem(null); // same object, no need for special subitem behavior.
- }
- else if (m_relationToRelatedClerk != null && m_relationToRelatedClerk == "part")
- {
- if (relatedClerk is SubitemRecordClerk)
- {
- // It should keep track of precisely which object we want.
- var subitemClerk = relatedClerk as SubitemRecordClerk;
- if (subitemClerk.UsedToSyncRelatedClerk)
- {
- // We've synchronized this clerk from the related one ONCE. In case we initialize
- // another view from this Clerk, we don't want to do it again...for example, if we
- // switch from doc to Edit, then change records, then switch to Browse, we want
- // to stay on the same record, not switch again to the document view one.
- // Of course this would be a problem if more than one Clerk had the same
- // related clerk, but that hasn't happened yet.
- return false;
- }
- if (subitemClerk.Subitem != null)
- {
- target = subitemClerk.Subitem;
- subitemClerk.UsedToSyncRelatedClerk = true;
- }
- }
- }
- JumpToRecord(target.Hvo);
+ JumpToRecord(relatedClerk.CurrentObjectHvo);
return true;
}
}
@@ -2293,7 +2226,6 @@ public int VirtualFlid
bool m_fReloadingDueToMissingObject = false;
private void BroadcastChange(bool suppressFocusChange)
{
- ClearInvalidSubitem();
if (CurrentObjectHvo != 0 && !m_list.CurrentObjectIsValid)
{
MessageBox.Show(xWorksStrings.SelectedObjectHasBeenDeleted,
@@ -2323,13 +2255,6 @@ private void BroadcastChange(bool suppressFocusChange)
SelectedRecordChanged(suppressFocusChange);
}
- ///
- /// A hook to allow a subclass to remove an invalid subitem.
- ///
- protected virtual void ClearInvalidSubitem()
- {
- }
-
private int FindClosestValidIndex(int idx, int cobj)
{
for (int i = idx + 1; i < cobj; ++i)
diff --git a/Src/xWorks/SubitemRecordClerk.cs b/Src/xWorks/SubitemRecordClerk.cs
deleted file mode 100644
index f099ca6a0d..0000000000
--- a/Src/xWorks/SubitemRecordClerk.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2015 SIL International
-// This software is licensed under the LGPL, version 2.1 or later
-// (http://www.gnu.org/licenses/lgpl-2.1.html)
-
-using System.Xml;
-using SIL.FieldWorks.Common.ViewsInterfaces;
-using SIL.LCModel;
-using SIL.Utils;
-using XCore;
-
-namespace SIL.FieldWorks.XWorks
-{
- ///
- /// A SubItemRecordClerk has an additional notion of the current item. Within the current item of the
- /// RecordList, a smaller item may be selected. For example, the main list may be of top-level
- /// RnGenericRecords, but the SubItemRecordClerk can trak owned records.
- /// Currently, the subitem must be owned by the top-level item, and displayed in the document view
- /// using direct owning relationships. Possible subitems are configured by noting the property
- /// that can contain them (possibly recursively).
- ///
- public class SubitemRecordClerk : RecordClerk
- {
- internal int SubitemFlid { get; private set; }
- public override void Init(XCore.Mediator mediator, PropertyTable propertyTable, XmlNode viewConfiguration)
- {
- base.Init(mediator, propertyTable, viewConfiguration);
- XmlNode clerkConfiguration = ToolConfiguration.GetClerkNodeFromToolParamsNode(viewConfiguration);
- var subitemNames = XmlUtils.GetMandatoryAttributeValue(clerkConfiguration, "field").Split('.');
- SubitemFlid = Cache.MetaDataCacheAccessor.GetFieldId(subitemNames[0].Trim(), subitemNames[1].Trim(), true);
- }
-
- public ICmObject Subitem { get; set; }
- public bool UsedToSyncRelatedClerk { get; set; }
-
- internal override void SetSubitem(ICmObject subitem)
- {
- base.SetSubitem(subitem);
- Subitem = subitem;
- }
-
- internal override void ViewChangedSelectedRecord(SIL.FieldWorks.Common.FwUtils.FwObjectSelectionEventArgs e, SIL.FieldWorks.Common.ViewsInterfaces.IVwSelection sel)
- {
- base.ViewChangedSelectedRecord(e, sel);
- UsedToSyncRelatedClerk = false;
- if (sel == null)
- return;
- // See if we can make an appropriate Subitem selection.
- var clevels = sel.CLevels(false);
- if (clevels < 2)
- return; // paranoia.
- // The object we get with level = clevels - 1 is the root of the whole view, which is of no interest.
- // The one with clevels - 2 is one of the objects in the top level of the list.
- // We get that initially, along with the tag that determines whether we can drill deeper.
- // Starting with clevels - 3, if there are that many, we keep getting more levels
- // as long as there are some and the previous level had the right tag.
- int hvoObj, tag, ihvo, cpropPrevious;
- IVwPropertyStore vps;
- sel.PropInfo(false, clevels - 2, out hvoObj, out tag, out ihvo,
- out cpropPrevious, out vps);
- int hvoTarget = hvoObj;
- for (int index = clevels - 3; index >= 0 && tag == SubitemFlid; index --)
- {
- sel.PropInfo(false, index, out hvoTarget, out tag, out ihvo,
- out cpropPrevious, out vps);
- }
- if (hvoTarget != hvoObj)
- {
- // we did some useful drilling.
- Subitem = Cache.ServiceLocator.GetObject(hvoTarget);
- }
- else
- {
- Subitem = null; // no relevant subitem.
- }
- }
-
- protected override void ClearInvalidSubitem()
- {
- if (Subitem == null)
- return; // nothing to do.
- if (!Subitem.IsOwnedBy(CurrentObject))
- Subitem = null; // not valid to try to select it as part of selecting current object.
- }
- }
-}
diff --git a/Src/xWorks/XmlDocView.cs b/Src/xWorks/XmlDocView.cs
index 0c4e000b26..ab54a10d8b 100644
--- a/Src/xWorks/XmlDocView.cs
+++ b/Src/xWorks/XmlDocView.cs
@@ -6,7 +6,6 @@
using System.Diagnostics;
using System.Drawing;
using System.Linq;
-using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using SIL.LCModel.Application;
@@ -48,13 +47,6 @@ public class XmlDocView : XWorksViewBase, IFindAndReplaceContext, IPostLayoutIni
protected XmlSeqView m_mainView;
protected string m_configObjectName;
private string m_titleStr; // Helps avoid running through SetInfoBarText 4x!
- private string m_currentPublication;
- private string m_currentConfigView; // used when this is a Dictionary view to store which view is active.
-
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.Container components = null;
#region Consruction and disposal
/// -----------------------------------------------------------------------------------
@@ -73,180 +65,6 @@ public XmlDocView()
base.AccNameDefault = "XmlDocView"; // default accessibility name
}
- #region TitleBar Layout Menu
-
- ///
- /// Populate the list of layout views for the second dictionary titlebar menu.
- ///
- /// The parameter.
- /// The display.
- ///
- public bool OnDisplayLayouts(object parameter, ref UIListDisplayProperties display)
- {
- var layoutList = GatherBuiltInAndUserLayouts();
- foreach (var view in layoutList)
- {
- display.List.Add(view.Item1, view.Item2, null, null, true);
- }
- return true;
- }
-
- private IEnumerable> GatherBuiltInAndUserLayouts()
- {
- var layoutList = new List>();
- layoutList.AddRange(GetBuiltInLayouts(m_propertyTable.GetValue("currentContentControlParameters", null)));
- var builtInLayoutList = new List();
- builtInLayoutList.AddRange(from layout in layoutList select layout.Item2);
- var userLayouts = m_mainView.Vc.LayoutCache.LayoutInventory.GetLayoutTypes();
- layoutList.AddRange(GetUserDefinedDictLayouts(builtInLayoutList, userLayouts));
- return layoutList;
- }
-
- private static IEnumerable> GetBuiltInLayouts(XmlNode configNode)
- {
- var configLayouts = XmlUtils.FindNode(configNode, "configureLayouts");
- // The configureLayouts node doesn't always exist!
- if (configLayouts != null)
- {
- var layouts = configLayouts.ChildNodes;
- return ExtractLayoutsFromLayoutTypeList(layouts.Cast());
- }
- return new List>();
- }
-
- private static IEnumerable> ExtractLayoutsFromLayoutTypeList(IEnumerable layouts)
- {
- return from XmlNode layout in layouts
- select new Tuple(XmlUtils.GetAttributeValue(layout, "label"),
- XmlUtils.GetAttributeValue(layout, "layout"));
- }
-
- private static IEnumerable> GetUserDefinedDictLayouts(
- IEnumerable builtInLayouts,
- IEnumerable layouts)
- {
- var allUserLayoutTypes = ExtractLayoutsFromLayoutTypeList(layouts);
- var result = new List>();
- // This part prevents getting Reversal Index layouts or Notebook layouts in our (Dictionary) menu.
- result.AddRange(from layout in allUserLayoutTypes
- where builtInLayouts.Any(builtIn => builtIn == BaseLayoutName(layout.Item2))
- select layout);
- return result;
- }
-
- private static string BaseLayoutName(string name)
- {
- if (String.IsNullOrEmpty(name))
- return String.Empty;
- // Find out if this layout name has a hashmark (#) in it. Return the part before it.
- var parts = name.Split(Inventory.kcMarkLayoutCopy);
- var result = parts.Length > 1 ? parts[0] : name;
- return result;
- }
-
- #endregion
-
- ///
- /// Receives the broadcast message "PropertyChanged"
- ///
- public void OnPropertyChanged(string name)
- {
- switch (name)
- {
- case "SelectedPublication":
- var pubDecorator = GetPubDecorator();
- if (pubDecorator != null)
- {
- var pubName = GetSelectedPublication();
- if (xWorksStrings.AllEntriesPublication == pubName)
- { // A null publication means show everything
- pubDecorator.Publication = null;
- m_mainView.RefreshDisplay();
- }
- else
- { // look up the publication object
- var pub = (from item in Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS
- where item.Name.UserDefaultWritingSystem.Text == pubName
- select item).FirstOrDefault();
- if (pub != null && pub != pubDecorator.Publication)
- { // change the publication if it is different from the current one
- pubDecorator.Publication = pub;
- m_mainView.RefreshDisplay();
- }
- }
- }
- break;
- case "DictionaryPublicationLayout":
- var layout = GetSelectedConfigView();
- m_mainView.Vc.ResetTables(layout);
- m_mainView.RefreshDisplay();
- break;
- default:
- // Not sure what other properties might change, but I'm not doing anything.
- break;
- }
- return;
- }
-
-
- public DictionaryPublicationDecorator GetPubDecorator()
- {
- var sda = m_mainView.DataAccess;
- while (sda != null && !(sda is DictionaryPublicationDecorator) && sda is DomainDataByFlidDecoratorBase)
- sda = ((DomainDataByFlidDecoratorBase) sda).BaseSda;
- return sda as DictionaryPublicationDecorator;
- }
-
- // Return CmPossibility if any alternative matches SelectedPublication.
- // If we don't have any record of what publication is selected (typically, first-time startup),
- // pick the first one as a default.
- // If the selected one is not found (typically it is $$all_entries$$), or there are none (pathological), return null.
- ICmPossibility Publication
- {
- get
- {
- // We don't want to use GetSelectedPublication here because it supplies a default,
- // and we want to treat that case specially.
- var pubName = m_propertyTable.GetStringProperty("SelectedPublication", null);
- if (pubName == null)
- {
- if (Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS.Count > 0)
- return Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS[0];
- else
- return null;
- }
- var pub = (from item in Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS
- where IsDesiredPublication(item, pubName)
- select item).FirstOrDefault();
- return pub;
- }
- }
-
- private bool IsDesiredPublication(ICmPossibility item, string name)
- {
- foreach (var ws in item.Name.AvailableWritingSystemIds)
- {
- if (item.Name.get_String(ws).Text == name)
- return true;
- }
- return false;
- }
-
- private string GetSelectedConfigView()
- {
- string sLayoutType = m_propertyTable.GetStringProperty("DictionaryPublicationLayout", String.Empty);
- if (String.IsNullOrEmpty(sLayoutType))
- sLayoutType = "publishStem";
- return sLayoutType;
- }
-
- private string GetSelectedPublication()
- {
- // Sometimes we just want the string value which might be '$$all_entries$$'
- return m_propertyTable.GetStringProperty("SelectedPublication",
- xWorksStrings.AllEntriesPublication);
- }
-
/// -----------------------------------------------------------------------------------
///
/// Clean up any resources being used.
@@ -266,8 +84,6 @@ protected override void Dispose( bool disposing )
{
Subscriber.Unsubscribe(EventConstants.ClerkOwningObjChanged, ClerkOwningObjChanged);
DisposeTooltip();
- if(components != null)
- components.Dispose();
}
m_currentObject = null;
@@ -283,92 +99,21 @@ protected override void SetInfoBarText()
if (m_informationBar == null)
return;
- var context = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "persistContext", "");
// SetInfoBarText() was getting run about 4 times just creating one XmlDocView!
- // To prevent that, add the following guards:
- if (m_titleStr != null && NoReasonToChangeTitle(context))
+ // To prevent that, add the following guard:
+ if (m_titleStr != null)
return;
var titleStr = GetBaseTitleStringFromConfig();
- bool fBaseCalled = false;
if (titleStr == string.Empty)
{
base.SetInfoBarText();
- fBaseCalled = true;
- // titleStr = ((IPaneBar)m_informationBar).Text; // can't get to work.
- // (EricP) For some reason I can't provide an IPaneBar get-accessor to return
- // the new Text value. If it's desirable to allow TitleFormat to apply to
- // Clerk.CurrentObject, then we either have to duplicate what the
- // base.SetInfoBarText() does here, or get the string set by the base.
- // for now, let's just return.
- if (titleStr == null || titleStr == string.Empty)
- return;
- }
- if (context == "Dict")
- {
- m_currentPublication = GetSelectedPublication();
- m_currentConfigView = GetSelectedConfigView();
- titleStr = MakePublicationTitlePart(titleStr);
- SetConfigViewTitle();
- }
-
- // If we have a format attribute, format the title accordingly.
- string sFmt = XmlUtils.GetAttributeValue(m_configurationParameters,
- "TitleFormat");
- if (sFmt != null)
- {
- titleStr = String.Format(sFmt, titleStr);
- }
-
- // If we find that the title is something like ClassifiedDictionary ({SelectedPublication})
- // replace the {} with the name of the selected publication.
- // Enhance: by removing the Debug.Fail, this could be made to insert the value of any
- // property in the mediator's property table.
- var propertyFinder = new Regex(@"\{([^\}]+)\}");
- var match = propertyFinder.Match(titleStr);
- if (match.Success)
- {
- string replacement;
- if (match.Groups[1].Value == "SelectedPublication")
- {
- replacement = GetSelectedPublication();
- if (replacement == xWorksStrings.AllEntriesPublication)
- replacement = xWorksStrings.ksAllEntries;
- }
- else
- {
- Debug.Fail(@"Unexpected <> value in title string: " + match.Groups[0].Value);
- // This might be useful one day?
- replacement = m_propertyTable.GetStringProperty(match.Groups[0].Value, null);
- }
- if (replacement != null)
- titleStr = propertyFinder.Replace(titleStr, replacement);
+ return;
}
-
- // if we haven't already set the text through the base,
- // or if we had some formatting to do, then set the infoBar text.
- if (!fBaseCalled || sFmt != null)
- ((IPaneBar)m_informationBar).Text = titleStr;
+ ((IPaneBar)m_informationBar).Text = titleStr;
m_titleStr = titleStr;
}
- #region Dictionary View TitleBar stuff
-
- private const int kSpaceForMenuButton = 26;
-
- private void SetConfigViewTitle()
- {
- if (!String.IsNullOrEmpty(m_currentConfigView))
- {
- var maxLayoutViewWidth = Width/2 - kSpaceForMenuButton;
- var result = GatherBuiltInAndUserLayouts();
- var curViewName = FindViewNameInList(result);
- // Limit length of View title to remaining available width
- curViewName = TrimToMaxPixelWidth(Math.Max(2, maxLayoutViewWidth), curViewName);
- ResetSpacer(maxLayoutViewWidth, curViewName);
- }
- }
-
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
@@ -376,97 +121,6 @@ protected override void OnSizeChanged(EventArgs e)
SetInfoBarText();
}
- private string FindViewNameInList(IEnumerable> layoutList)
- {
- var result = "";
- foreach (var tuple in layoutList.Where(tuple => tuple.Item2 == m_currentConfigView))
- {
- result = tuple.Item1;
- break;
- }
- return result;
- }
-
- private string MakePublicationTitlePart(string titleStr)
- {
- // titleStr to start is localized equivalent of 'Entries'
- // Limit length of Publication title to half of available width
- var maxPublicationTitleWidth = Math.Max(2, Width/2 - kSpaceForMenuButton);
- if (String.IsNullOrEmpty(m_currentPublication) ||
- m_currentPublication == xWorksStrings.AllEntriesPublication)
- {
- m_currentPublication = xWorksStrings.AllEntriesPublication;
- titleStr = xWorksStrings.ksAllEntries;
- // Limit length of Publication title to half of available width
- titleStr = TrimToMaxPixelWidth(maxPublicationTitleWidth, titleStr);
- }
- else
- {
- titleStr = String.Format(xWorksStrings.ksPublicationEntries,
- GetPublicationName(), titleStr);
- titleStr = TrimToMaxPixelWidth(maxPublicationTitleWidth, titleStr);
- }
- return titleStr;
- }
-
- private string GetPublicationName()
- {
- if (Publication == null || Publication.Name == null || Publication.Name.BestAnalysisAlternative == null)
- return "***"; // what we show in the menu for a pub with no name in any language.
- return Publication.Name.BestAnalysisAlternative.Text;
- }
-
- private bool NoReasonToChangeTitle(string context)
- {
- switch (context)
- {
- case "Reversal":
- return !IsCurrentReversalWsChanged();
- case "Dict":
- return !IsCurrentPublicationChanged() && !IsCurrentConfigViewChanged();
- default:
- // No need to change anything; dump out!
- return true;
- }
- }
-
- private bool IsCurrentReversalWsChanged()
- {
- if (m_currentObject == null)
- return true;
- var wsName = GetSafeWsName();
- return m_currentPublication == null || m_currentPublication != wsName;
- }
-
- private string GetSafeWsName()
- {
- if (m_currentObject == null || !m_currentObject.IsValidObject)
- {
- if (m_hvoOwner < 1)
- return String.Empty;
- return WritingSystemServices.GetReversalIndexWritingSystems(
- Cache, m_hvoOwner, false)[0].LanguageName;
- }
- return WritingSystemServices.GetReversalIndexEntryWritingSystem(
- Cache,
- m_currentObject.Hvo,
- Cache.LangProject.CurrentAnalysisWritingSystems[0]).LanguageName;
- }
-
- private bool IsCurrentPublicationChanged()
- {
- var newPub = GetSelectedPublication();
- return newPub != m_currentPublication;
- }
-
- private bool IsCurrentConfigViewChanged()
- {
- var newView = GetSelectedConfigView();
- return newView != m_currentConfigView;
- }
-
- #endregion
-
///
/// Read in the parameters to determine which sequence/collection we are editing.
///
@@ -600,10 +254,7 @@ private void TryToJumpToSelection(Point where)
///
internal ICmObject SubitemClicked(Point where, int clsid)
{
- var adjuster = (m_currentConfigView != null && m_currentConfigView.StartsWith("publishRoot")) ?
- (IPreferedTargetAdjuster)new MainEntryFromSubEntryTargetAdjuster() :
- new NullTargetAdjuster();
- return SubitemClicked(where, clsid, m_mainView, Cache, Clerk.SortItemProvider, adjuster);
+ return SubitemClicked(where, clsid, m_mainView, Cache, Clerk.SortItemProvider, new NullTargetAdjuster());
}
private ToolTip m_tooltip;
@@ -804,125 +455,6 @@ protected override void ShowRecord()
base.ShowRecord();
}
- ///
- /// Used to verify current content control so that Find Lexical Entry behaves differently
- /// in Dictionary View.
- ///
- private const string ksLexDictionary = "lexiconDictionary";
-
- ///
- /// Check to see if the user needs to be alerted that JumpToRecord is not possible.
- ///
- /// the hvo of the record
- ///
- public bool OnCheckJump(object argument)
- {
- var hvoTarget = (int)argument;
- var currControl = m_propertyTable.GetStringProperty("currentContentControl", "");
- // Currently this (LT-11447) only applies to Dictionary view
- if (hvoTarget > 0 && currControl == ksLexDictionary)
- {
- 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))
- {
- // Tell the user why we aren't jumping to his record
- GiveSimpleWarning(xrc);
- }
- }
- return true;
- }
-
- 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;
- switch (xrc)
- {
- case DictionaryConfigurationController.ExclusionReasonCode.NotInPublication:
- caption = xWorksStrings.ksEntryNotPublished;
- reason = xWorksStrings.ksEntryNotPublishedReason;
- shlpTopic = "User_Interface/Menus/Edit/Find_a_lexical_entry.htm"; //khtpEntryNotPublished
- break;
- case DictionaryConfigurationController.ExclusionReasonCode.ExcludedHeadword:
- caption = xWorksStrings.ksMainNotShown;
- reason = xWorksStrings.ksMainNotShownReason;
- shlpTopic = "khtpMainEntryNotShown";
- break;
- case DictionaryConfigurationController.ExclusionReasonCode.ExcludedMinorEntry:
- caption = xWorksStrings.ksMinorNotShown;
- reason = xWorksStrings.ksMinorNotShownReason;
- shlpTopic = "khtpMinorEntryNotShown";
- break;
- 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("HelpTopicProvider").HelpFile,
- HelpNavigator.Topic, shlpTopic);
- }
-
- private bool IsObjectVisible(int hvoTarget, out DictionaryConfigurationController.ExclusionReasonCode xrc)
- {
- xrc = DictionaryConfigurationController.ExclusionReasonCode.NotExcluded;
- var objRepo = Cache.ServiceLocator.GetInstance();
- Debug.Assert(objRepo.IsValidObjectId(hvoTarget), "Invalid hvoTarget!");
- if (!objRepo.IsValidObjectId(hvoTarget))
- throw new ArgumentException("Unknown object.");
- var entry = objRepo.GetObject(hvoTarget) as ILexEntry;
- Debug.Assert(entry != null, "HvoTarget is not a LexEntry!");
- if (entry == null)
- throw new ArgumentException("Target is not a LexEntry.");
-
- // Now we have our LexEntry
- // First deal with whether the active Publication excludes it.
- if (m_currentPublication != xWorksStrings.AllEntriesPublication)
- {
- var currentPubPoss = Publication;
- if (!entry.PublishIn.Contains(currentPubPoss))
- {
- xrc = DictionaryConfigurationController.ExclusionReasonCode.NotInPublication;
- return false;
- }
- // Second deal with whether the entry shouldn't be shown as a headword
- if (!entry.ShowMainEntryIn.Contains(currentPubPoss))
- {
- xrc = DictionaryConfigurationController.ExclusionReasonCode.ExcludedHeadword;
- return false;
- }
- }
- // Third deal with whether the entry shouldn't be shown as a minor entry.
- // commented out until conditions are clarified (LT-11447)
- if (entry.EntryRefsOS.Count > 0 && !entry.PublishAsMinorEntry && IsRootBasedView)
- {
- xrc = DictionaryConfigurationController.ExclusionReasonCode.ExcludedMinorEntry;
- return false;
- }
- // If we get here, we should be able to display it.
- return true;
- }
-
- private const string ksRootBasedPrefix = "publishRoot";
-
- protected bool IsRootBasedView
- {
- get
- {
- if (String.IsNullOrEmpty(m_currentConfigView))
- return false;
-
- return m_currentConfigView.Split(
- new[] {"#"}, StringSplitOptions.None)[0] == ksRootBasedPrefix;
- }
- }
-
///
/// Ensure that we have the current record selected and visible in the window. See LT-9109.
///
@@ -955,21 +487,6 @@ private void SelectAndScrollToCurrentRecord()
RecordClerk clerk = Clerk;
int levelFlid = 0;
var indexes = new List();
- if (Clerk is SubitemRecordClerk)
- {
- var subitemClerk = Clerk as SubitemRecordClerk;
- levelFlid = subitemClerk.SubitemFlid;
- if (subitemClerk.Subitem != null)
- {
- // There's a subitem. See if we can select it.
- var item = subitemClerk.Subitem;
- while (item.OwningFlid == levelFlid)
- {
- indexes.Add(item.OwnOrd);
- item = item.Owner;
- }
- }
- }
var currentIndex = AdjustedClerkIndex();
indexes.Add(currentIndex);
// Suppose it is the fifth subrecord of the second subrecord of the ninth main record.
@@ -1083,8 +600,10 @@ protected override void SetupDataContext()
// Review JohnT: should it be m_configurationParameters or .FirstChild?
IApp app = m_propertyTable.GetValue("App");
+ // Pass null for the publication argument since it is only used when the configuration has a
+ // node; no configuration that instantiates XmlDocView has one.
m_mainView = new XmlSeqView(Cache, m_hvoOwner, m_fakeFlid, m_configurationParameters, Clerk.VirtualListPublisher, app,
- Publication);
+ null);
m_mainView.Init(m_mediator, m_propertyTable, m_configurationParameters); // Required call to xCore.Colleague.
m_mainView.Dock = DockStyle.Fill;
m_mainView.Cache = Cache;
@@ -1376,29 +895,6 @@ public interface IPreferedTargetAdjuster
ICmObject AdjustTarget(ICmObject target);
}
- ///
- /// If the initial target is a subentry replace it with the appropriate top-level entry.
- ///
- internal class MainEntryFromSubEntryTargetAdjuster : IPreferedTargetAdjuster
- {
- public ICmObject AdjustTarget(ICmObject firstMatch)
- {
- if (firstMatch is ILexEntry)
- {
- var subentry = (ILexEntry)firstMatch;
- var componentsEntryRef =
- subentry.EntryRefsOS.Where(se => se.RefType == LexEntryRefTags.krtComplexForm).FirstOrDefault();
- if (componentsEntryRef != null)
- {
- var root = componentsEntryRef.PrimaryEntryRoots.FirstOrDefault();
- if (root != null)
- return root;
- }
- }
- return firstMatch; // by default change nothing.
- }
- }
-
public class NullTargetAdjuster : IPreferedTargetAdjuster
{
public ICmObject AdjustTarget(ICmObject target)
diff --git a/Src/xWorks/xWorksTests/ItemClickedTests.cs b/Src/xWorks/xWorksTests/ItemClickedTests.cs
index f68b854067..2918e3ecfa 100644
--- a/Src/xWorks/xWorksTests/ItemClickedTests.cs
+++ b/Src/xWorks/xWorksTests/ItemClickedTests.cs
@@ -71,19 +71,6 @@ public void ItemClicked()
mockItems.Items.Remove(boot.Hvo);
result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, nullAdjuster);
Assert.That(result, Is.Null);
-
- // MainEntryFromSubEntryTargetAdjuster should convert subentry to main entry
- // Make boot a subentry of bootRoot
- var bootRoot = MakeEntry("boo", "fragment of boot");
- var ler = Cache.ServiceLocator.GetInstance().Create();
- boot.EntryRefsOS.Add(ler);
- ler.RefType = LexEntryRefTags.krtComplexForm;
- ler.PrimaryLexemesRS.Add(bootRoot);
- mockItems.Items.Add(boot.Hvo); // not rejected as item
- mockItems.Items.Add(bootRoot.Hvo); // has to be valid itself also
- var subentryAdjuster = new MainEntryFromSubEntryTargetAdjuster();
- result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, subentryAdjuster);
- Assert.That(result, Is.EqualTo(bootRoot));
}
}