Skip to content
Merged
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
32 changes: 28 additions & 4 deletions Src/LexText/LexTextControls/FeatureStructureTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum ImageKind
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components = null;

public bool IncludePreserveExistingValues { get; internal set; }

public FeatureStructureTreeView(System.ComponentModel.IContainer container)
{
///
Expand Down Expand Up @@ -109,6 +111,10 @@ public void Sort(TreeNodeCollection col)
(int)ImageKind.radio, (int)ImageKind.radio, 0,
FeatureTreeNodeInfo.NodeKind.Other);
InsertNode(noneOfTheAboveNode, childNode);
if (!HasChosenCheckBox(childNode))
{
HandleCheckBoxNodes(null, noneOfTheAboveNode);
}
}
}
}
Expand Down Expand Up @@ -139,10 +145,13 @@ private void AddNode(IFsFeatDefn defn, FeatureTreeNode parentNode)
{
AddNode(val, newNode);
}
FeatureTreeNode unknownNode = new FeatureTreeNode(LexTextControls.ksPreserveExistingValues,
(int)ImageKind.radio, (int)ImageKind.radio, 0, FeatureTreeNodeInfo.NodeKind.SymFeatValue);
InsertNode(unknownNode, newNode);
HandleCheckBoxNodes(null, unknownNode);
if (IncludePreserveExistingValues)
{
FeatureTreeNode unknownNode = new FeatureTreeNode(LexTextControls.ksPreserveExistingValues,
(int)ImageKind.radio, (int)ImageKind.radio, 0, FeatureTreeNodeInfo.NodeKind.SymFeatValue);
InsertNode(unknownNode, newNode);
HandleCheckBoxNodes(null, unknownNode);
}
}
}
var complex = defn as IFsComplexFeature;
Expand Down Expand Up @@ -311,6 +320,21 @@ private bool IsTerminalNode(TreeNode tn)
// }
// }
// }

private bool HasChosenCheckBox(FeatureTreeNode parent)
{
FeatureTreeNode sibling = (FeatureTreeNode)parent.FirstNode;
while (sibling != null)
{
if (sibling.Chosen)
{
return true;
}
sibling = (FeatureTreeNode)sibling.NextNode;
}
return false;
}

private void HandleCheckBoxNodes(TreeView tv, FeatureTreeNode tn)
{
//UndoLastSelectedNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs
// Whatever happens below, we don't want to actually leave the "More..." node selected!
// This is at least required if the user selects "Cancel" from the dialog below.
pt.Hide();
using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg(true))
{
HvoTreeNode parentNode = selectedNode.Parent as HvoTreeNode;
int hvoPos = parentNode.Hvo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void PopulateTreeFromFeatureSystem()

Assert.That(tv.Nodes.Count, Is.EqualTo(2), "Count of top level nodes in tree view");
TreeNodeCollection col = tv.Nodes[0].Nodes;
Assert.That(col.Count, Is.EqualTo(4), "Count of first level nodes in tree view");
Assert.That(col.Count, Is.EqualTo(3), "Count of first level nodes in tree view");
}
}

Expand Down Expand Up @@ -177,7 +177,7 @@ private void LoadFeatureValuesIntoTreeview(FeatureStructureTreeView tv, IFsFeatS
{
TreeNodeCollection col2 = node.Nodes;
if (node.Text == "gender")
Assert.That(col2.Count, Is.EqualTo(3), "Count of second level nodes in tree view");
Assert.That(col2.Count, Is.EqualTo(2), "Count of second level nodes in tree view");
if (node.Text == "person")
Assert.That(col2.Count, Is.EqualTo(1), "Count of second level nodes in tree view");
}
Expand All @@ -196,7 +196,7 @@ private FeatureStructureTreeView SetUpSampleData(out IFsFeatStruc featStruct)
foreach (TreeNode node in col)
{
TreeNodeCollection col2 = node.Nodes;
Assert.That(col2.Count, Is.EqualTo(3), "Count of second level nodes in tree view");
Assert.That(col2.Count, Is.EqualTo(2), "Count of second level nodes in tree view");
if (node.PrevNode == null)
node.Checked = true;
}
Expand Down
3 changes: 2 additions & 1 deletion Src/LexText/LexTextControls/MsaInflectionFeatureListDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public class MsaInflectionFeatureListDlg : Form
private const string m_helpTopic = "khtpChoose-lexiconEdit-InflFeats";
private HelpProvider helpProvider;

public MsaInflectionFeatureListDlg()
public MsaInflectionFeatureListDlg(bool includePreserveExistingValues = false)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
AccessibleName = GetType().Name;
pictureBox1.Image = m_imageListPictures.Images[0];
m_tvMsaFeatureList.IncludePreserveExistingValues = includePreserveExistingValues;
}

#region OnLoad
Expand Down
18 changes: 12 additions & 6 deletions Src/LexText/ParserCore/HCLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2506,16 +2506,22 @@ private FeatureStruct LoadFeatureStruct(IFsFeatStruc fs, FeatureSystem featSys)
var closedValue = value as IFsClosedValue;
if (closedValue != null)
{
var hcFeature = featSys.GetFeature<SymbolicFeature>("feat" + closedValue.FeatureRA.Hvo);
// TODO: should we display something to the user if a FS has an invalid value?
if (hcFeature.PossibleSymbols.TryGet("sym" + closedValue.ValueRA.Hvo, out var symbol))
hcFS.AddValue(hcFeature, symbol);
if (closedValue.ValueRA != null)
{
var hcFeature = featSys.GetFeature<SymbolicFeature>("feat" + closedValue.FeatureRA.Hvo);
// TODO: should we display something to the user if a FS has an invalid value?
if (hcFeature.PossibleSymbols.TryGet("sym" + closedValue.ValueRA.Hvo, out var symbol))
hcFS.AddValue(hcFeature, symbol);
}
}
else
{
var complexValue = (IFsComplexValue)value;
var hcFeature = featSys.GetFeature<ComplexFeature>("feat" + complexValue.FeatureRA.Hvo);
hcFS.AddValue(hcFeature, LoadFeatureStruct((IFsFeatStruc)complexValue.ValueOA, featSys));
if (complexValue.ValueOA != null)
{
var hcFeature = featSys.GetFeature<ComplexFeature>("feat" + complexValue.FeatureRA.Hvo);
hcFS.AddValue(hcFeature, LoadFeatureStruct((IFsFeatStruc)complexValue.ValueOA, featSys));
}
}
}
}
Expand Down
Loading