-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathConcordanceControlBase.cs
More file actions
160 lines (141 loc) · 4.42 KB
/
Copy pathConcordanceControlBase.cs
File metadata and controls
160 lines (141 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright (c) 2015-2017 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;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using SIL.FieldWorks.Common.Controls;
using SIL.FieldWorks.Common.FwUtils;
using SIL.LCModel;
using SIL.LCModel.Application;
using SIL.LCModel.DomainServices;
using SIL.FieldWorks.XWorks;
using SIL.Utils;
using XCore;
namespace SIL.FieldWorks.IText
{
public class ConcordanceControlBase : UserControl, IxCoreContentControl
{
protected Mediator m_mediator;
protected PropertyTable m_propertyTable;
protected XmlNode m_configurationParameters;
protected LcmCache m_cache;
protected OccurrencesOfSelectedUnit m_clerk;
protected IHelpTopicProvider m_helpTopicProvider;
public virtual string AccName
{
get
{
throw new NotImplementedException();
}
}
public Control PopulateCtrlTabTargetCandidateList(List<Control> targetCandidates)
{
CheckDisposed();
if (targetCandidates == null)
throw new ArgumentNullException("targetCandidates");
targetCandidates.Add(this);
return ContainsFocus ? this : null;
}
public virtual void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
{
CheckDisposed();
m_mediator = mediator;
m_propertyTable = propertyTable;
m_helpTopicProvider = m_propertyTable.GetValue<IHelpTopicProvider>("HelpTopicProvider");
m_configurationParameters = configurationParameters;
m_cache = m_propertyTable.GetValue<LcmCache>("cache");
string name = RecordClerk.GetCorrespondingPropertyName(XmlUtils.GetAttributeValue(configurationParameters, "clerk"));
m_clerk = m_propertyTable.GetValue<OccurrencesOfSelectedUnit>(name) ?? (OccurrencesOfSelectedUnit)RecordClerkFactory.CreateClerk(
m_mediator, m_propertyTable, m_configurationParameters, true, true);
m_clerk.ConcordanceControl = this;
}
public IxCoreColleague[] GetMessageTargets()
{
CheckDisposed();
return new IxCoreColleague[] { this };
}
public bool ShouldNotCall
{
get { return IsDisposed; }
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
var paneBarContainer = Parent as PaneBarContainer;
if (paneBarContainer != null)
paneBarContainer.PaneBar.Text = ITextStrings.ksSpecifyConcordanceCriteria;
}
public int Priority
{
get { return (int) ColleaguePriority.Medium; }
}
public bool PrepareToGoAway()
{
CheckDisposed();
return true;
}
public string AreaName
{
get
{
CheckDisposed();
return XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "area", "unknown");
}
}
public void CheckDisposed()
{
if (IsDisposed)
throw new ObjectDisposedException(String.Format("'{0}' in use after being disposed.", GetType().Name));
}
protected override void Dispose(bool disposing)
{
System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType() + " ******");
base.Dispose(disposing);
}
// True after the first time we do it.
internal protected bool HasLoadedMatches { get; protected set; }
// True while loading matches, to prevent recursive call.
internal protected bool IsLoadingMatches { get; protected set; }
internal protected void LoadMatches()
{
LoadMatches(true);
}
internal protected void LoadMatches(bool fLoadVirtualProperty)
{
var occurrences = SearchForMatches();
var decorator = (ConcDecorator) ((DomainDataByFlidDecoratorBase) m_clerk.VirtualListPublisher).BaseSda;
// Set this BEFORE we start loading, otherwise, calls to ReloadList triggered here just make it empty.
HasLoadedMatches = true;
IsLoadingMatches = true;
try
{
m_clerk.SetOwningObject(m_cache.LangProject, true);
decorator.SetOccurrences(m_cache.LangProject.Hvo, occurrences);
m_clerk.UpdateList(true);
}
finally
{
IsLoadingMatches = false;
}
}
protected ConcDecorator ConcDecorator
{
get { return ((ObjectListPublisher) m_clerk.VirtualListPublisher).BaseSda as ConcDecorator; }
}
protected virtual List<IParaFragment> SearchForMatches()
{
throw new NotImplementedException();
}
/// <summary>
/// If asked to Refresh, update your results list.
/// </summary>
public bool RefreshDisplay()
{
LoadMatches(true);
//I claim that all descendants which are refreshable have been refreshed -naylor
return true;
}
}
}