Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #606 menu to add more nodes of same type
- Loading branch information
Showing
7 changed files
with
156 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,122 @@ | ||
using Cinteros.Xrm.XmlEditorUtils; | ||
using System.Collections.Generic; | ||
using System.Windows.Forms; | ||
|
||
namespace Cinteros.Xrm.FetchXmlBuilder.AppCode | ||
{ | ||
public class FetchNodeCapabilities : TreeNodeCapabilities | ||
public class FetchNodeCapabilities | ||
{ | ||
public FetchNodeCapabilities(TreeNode node) | ||
: base(node) | ||
public string Name; | ||
public bool Multiple = true; | ||
public bool Delete = true; | ||
public bool Attributes = false; | ||
public bool Comment = true; | ||
public bool Uncomment = false; | ||
public List<FetchNodeCapabilities> ChildTypes; | ||
|
||
public FetchNodeCapabilities(string name, bool addchildren) : this(name) | ||
{ | ||
if (addchildren) | ||
{ | ||
AddChildren(); | ||
} | ||
} | ||
|
||
private FetchNodeCapabilities(string name) | ||
{ | ||
Name = name; | ||
switch (Name) | ||
{ | ||
case "fetch": | ||
Multiple = false; | ||
Delete = false; | ||
Comment = false; | ||
ChildTypes.Add(new ChildNodeCapabilities("entity", false)); | ||
ChildTypes.Add(new ChildNodeCapabilities("-", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
break; | ||
case "entity": | ||
Multiple = false; | ||
Attributes = true; | ||
break; | ||
case "link-entity": | ||
Delete = true; | ||
Attributes = true; | ||
ChildTypes.Add(new ChildNodeCapabilities("-", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("all-attributes", false)); | ||
ChildTypes.Add(new ChildNodeCapabilities("attribute", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("filter", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("order", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("link-entity", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("-", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
break; | ||
case "all-attributes": | ||
Multiple = false; | ||
break; | ||
case "attribute": | ||
case "order": | ||
Delete = true; | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
case "filter": | ||
case "condition": | ||
case "value": | ||
break; | ||
case "#comment": | ||
Comment = false; | ||
Uncomment = true; | ||
break; | ||
} | ||
} | ||
|
||
private void AddChildren() | ||
{ | ||
ChildTypes = new List<FetchNodeCapabilities>(); | ||
switch (Name) | ||
{ | ||
case "fetch": | ||
ChildTypes.Add(new FetchNodeCapabilities("entity")); | ||
ChildTypes.Add(new FetchNodeCapabilities("-")); | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "entity": | ||
case "link-entity": | ||
ChildTypes.Add(new FetchNodeCapabilities("-")); | ||
ChildTypes.Add(new FetchNodeCapabilities("all-attributes")); | ||
ChildTypes.Add(new FetchNodeCapabilities("attribute")); | ||
ChildTypes.Add(new FetchNodeCapabilities("filter")); | ||
ChildTypes.Add(new FetchNodeCapabilities("order")); | ||
ChildTypes.Add(new FetchNodeCapabilities("link-entity")); | ||
ChildTypes.Add(new FetchNodeCapabilities("-")); | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "all-attributes": | ||
case "attribute": | ||
case "order": | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "filter": | ||
Delete = true; | ||
ChildTypes.Add(new ChildNodeCapabilities("condition", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("filter", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("-", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
ChildTypes.Add(new FetchNodeCapabilities("condition")); | ||
ChildTypes.Add(new FetchNodeCapabilities("filter")); | ||
ChildTypes.Add(new FetchNodeCapabilities("-")); | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "condition": | ||
Delete = true; | ||
ChildTypes.Add(new ChildNodeCapabilities("value", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("-", true)); | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
ChildTypes.Add(new FetchNodeCapabilities("value")); | ||
ChildTypes.Add(new FetchNodeCapabilities("-")); | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "value": | ||
Delete = true; | ||
ChildTypes.Add(new ChildNodeCapabilities("#comment", true)); | ||
ChildTypes.Add(new FetchNodeCapabilities("#comment")); | ||
break; | ||
case "#comment": | ||
Delete = true; | ||
Comment = false; | ||
Uncomment = true; | ||
break; | ||
} | ||
} | ||
|
||
public int IndexOfChild(string name) | ||
{ | ||
var index = 0; | ||
while (index < ChildTypes.Count && ChildTypes[index].Name != name) | ||
{ | ||
index++; | ||
} | ||
if (index >= ChildTypes.Count) | ||
{ | ||
index = -1; | ||
} | ||
return index; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return Name + " (" + (ChildTypes != null ? ChildTypes.Count.ToString() : "?") + ")"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
FetchXmlBuilder/DockControls/TreeBuilderControl.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.