Источник:
http://www.axaptapedia.com/TreeNodeTraverser
==============
Summary: New page: Sometimes you need to get at objects within the AOT and identify what these are. One such case struck me where a CSV of Main Menu items had been manually typed. The idea was a review of th...
Sometimes you need to get at objects within the AOT and identify what these are. One such case struck me where a CSV of Main Menu items had been manually typed. The idea was a review of the Main Menu and items Help Text, which sometimes can be overlooked with integration and lead to amongst other things, lack of status bar text.
This AOT Job should be run in a test or development environment and modified to suit your needs. It demonstrates the use of TreeNodeTraverser, which is similar yet different to TreeNodeIterator. The primary difference is that when Traversing, you need not worry about how many levels deep you may be in. It allows you to loop through each item and conduct fairly elaborate inspection of each items Property.
X++:
static void Menu_Structure_Helptext(Args _args)
{
#AOT
#Properties
Boolean writeFile;
Boolean infoDebug;
CommaIo outFile;
str errMsg;
str myClss;
str myProp;
str myNode;
str myText;
str myLabel;
TreeNode treeItem;
TreeNode treeMenu;
TreeNode treeMenuNode;
TreeNodeTraverser mainMenuTraverser;
;
infoDebug = true; // ***OPTION*** View InfoLog Output (true / false)
writeFile = false; // ***OPTION*** Export results to CSV file (true / false)
errMsg = ""; //"--- NOT DEFINED ---";
myNode = "Administration";
outFile = new AsciiIo("C:\\MENUITEMS."+myNode+".CSV","W");
outFile.outFieldDelimiter("\r\n");
outFile.outRecordDelimiter("\r");
treeMenu = TreeNode::findNode(#MenusPath + "\\" + myNode);
mainMenuTraverser = new TreeNodeTraverser(treeMenu);
while (mainMenuTraverser.next())
{
treeMenuNode = mainMenuTraverser.currentNode();
if (hasProperty(treeMenuNode.AOTgetProperties(), #PropertyLabel)==true)
{
myLabel = findProperty(treeMenuNode.AOTgetProperties(), #PropertyHelpText);
if(myLabel != "")
{
myText = SysLabel::labelId2String(myLabel);
if(infoDebug) {
info(strfmt("%1 %2", treeMenuNode.treeNodeName(), " "+myText));
}
if(writeFile) {
outFile.write(treeMenuNode.treeNodeName() + " , " + strReplace(myText,",",""));
}
}
else
{
myText = errMsg;
if(infoDebug) {
info(strfmt("%1 %2", treeMenuNode.treeNodeName(), " "+myText));
}
if(writeFile) {
outFile.write(treeMenuNode.treeNodeName() + " , " + strReplace(myText,",",""));
}
}
}
else if(hasProperty(treeMenuNode.AOTgetProperties(), #PropertyShortCut)==true)
{
if(hasProperty(treeMenuNode.AOTgetProperties(), #PropertyMenuItemType))
{
myLabel = findProperty(treeMenuNode.AOTgetProperties(), #PropertyMenuItemType);
myProp = findProperty(treeMenuNode.AOTgetProperties(), #PropertyMenuItemName);
if(myLabel == "Display") {
treeItem = TreeNode::findNode(#MenuItemsPath +"\\Display\\" + myProp);
myClss = findProperty(treeItem.AOTgetProperties(), #PropertyHelpText);
if(myClss != "") {
mytext = SysLabel::labelId2String(myClss);
}
else {
myText = errMsg;
}
}
else if(myLabel == "Action") {
treeItem = TreeNode::findNode(#MenuItemsPath +"\\Action\\" + myProp);
myClss = findProperty(treeItem.AOTgetProperties(), #PropertyHelpText);
if(myClss != "") {
mytext = SysLabel::labelId2String(myClss);
}
else {
myText = errMsg;
}
}
else if(myLabel == "Output") {
treeItem = TreeNode::findNode(#MenuItemsPath +"\\Output\\" + myProp);
myClss = findProperty(treeItem.AOTgetProperties(), #PropertyHelpText);
if(myClss != "") {
mytext = SysLabel::labelId2String(myClss);
}
else {
myText = errMsg;
}
}
}
if(infoDebug) {
info(strfmt("%1 %2", treeMenuNode.treeNodeName(), " "+myText));
}
if(writeFile) {
outFile.write(treeMenuNode.treeNodeName() + " , " + strReplace(myText,",",""));
}
}
else {
myText = errMsg;
if(infoDebug) {
info(strfmt("%1 %2", treeMenuNode.treeNodeName(), " "+myText));
}
if(writeFile) {
outFile.write(treeMenuNode.treeNodeName() + " , " + strReplace(myText,",",""));
}
}
}
}
Источник:
http://www.axaptapedia.com/TreeNodeTraverser