Browse Source

Inherit conditions into child codons (lexically within the same .addin file).

This ensures that, if a parent menu item is disabled, its child menu items cannot be executed using a shortcut. (at least for children defined within the same .addin file)
pull/21/head
Daniel Grunwald 15 years ago
parent
commit
632c44e10e
  1. 21
      src/Main/Core/Project/Src/AddInTree/AddIn/ExtensionPath.cs

21
src/Main/Core/Project/Src/AddInTree/AddIn/ExtensionPath.cs

@ -58,6 +58,11 @@ namespace ICSharpCode.Core @@ -58,6 +58,11 @@ namespace ICSharpCode.Core
public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement)
{
Stack<ICondition> conditionStack = new Stack<ICondition>();
extensionPath.DoSetUp(reader, endElement, conditionStack);
}
void DoSetUp(XmlReader reader, string endElement, Stack<ICondition> conditionStack)
{
List<Codon> innerCodons = new List<Codon>();
while (reader.Read()) {
switch (reader.NodeType) {
@ -66,7 +71,7 @@ namespace ICSharpCode.Core @@ -66,7 +71,7 @@ namespace ICSharpCode.Core
conditionStack.Pop();
} else if (reader.LocalName == endElement) {
if (innerCodons.Count > 0)
extensionPath.codons.Add(innerCodons);
this.codons.Add(innerCodons);
return;
}
break;
@ -77,24 +82,18 @@ namespace ICSharpCode.Core @@ -77,24 +82,18 @@ namespace ICSharpCode.Core
} else if (elementName == "ComplexCondition") {
conditionStack.Push(Condition.ReadComplexCondition(reader));
} else {
Codon newCodon = new Codon(extensionPath.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
innerCodons.Add(newCodon);
if (!reader.IsEmptyElement) {
ExtensionPath subPath = extensionPath.AddIn.GetExtensionPath(extensionPath.Name + "/" + newCodon.Id);
//foreach (ICondition condition in extensionPath.conditionStack) {
// subPath.conditionStack.Push(condition);
//}
SetUp(subPath, reader, elementName);
//foreach (ICondition condition in extensionPath.conditionStack) {
// subPath.conditionStack.Pop();
//}
ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
subPath.DoSetUp(reader, elementName, conditionStack);
}
}
break;
}
}
if (innerCodons.Count > 0)
extensionPath.codons.Add(innerCodons);
this.codons.Add(innerCodons);
}
}
}

Loading…
Cancel
Save