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

Loading…
Cancel
Save