Sometimes one needs to investigate where some field or method is used in the AOT. There may be a long list of AOT paths in the "Used by" form, and having a project with all those application elements may be a good starting point.
Add a button to xRefReferencesUsedByTypedTree form, set its Text property to "Create project" and MultiSelect to Yes:
Override its clicked method and use the following code:
Now, if you select one or more records in the "used by" grid and press the button, a new project will be created:
Add a button to xRefReferencesUsedByTypedTree form, set its Text property to "Create project" and MultiSelect to Yes:
Override its clicked method and use the following code:
void clicked()
{
#TreeNodeSysNodeType
XrefPaths xRefPathsLocal;
Set treeNodeLocalPaths;
SetEnumerator treeNodeLocalPathEnumerator;
SysProjectFilterRunBase project;
UtilElements utilElements;
ProjectNode projectNode;
Dialog dialog;
DialogField dialogField;
super();
treeNodeLocalPaths = new Set(Types::String);
for (xRefPathsLocal = xRefPaths_ds.getFirst(true) ?
xRefPaths_ds.getFirst(true) : xRefPaths_ds.cursor();
xRefPathsLocal;
xRefPathsLocal = xRefPaths_ds.getNext())
{
treeNodeLocalPaths.add(xRefPathsLocal.Path);
}
if (treeNodeLocalPaths.elements() == 0)
{
info("There are no AOT objects to create the project from.");
return;
}
dialog = new dialog("Create project");
dialogField = dialog.addFieldValue(
extendedTypeStr(ProjectName),
'UsedByProject');
if (dialog.run())
{
projectNode = SysTreeNode::createProject(any2str(dialogField.value()));
project = new SysProjectFilterRunBase();
project.parmProjectNode(projectNode);
project.grouping(SysProjectGrouping::AOT);
treeNodeLocalPathEnumerator = treeNodeLocalPaths.getEnumerator();
while (treeNodeLocalPathEnumerator.moveNext())
{
utilElements = xUtilElements::findTreeNode(
treeNode::findNode(
SysTreeNode::applObjectPath(
treeNodeLocalPathEnumerator.current())),
false);
if (utilElements.RecId != 0)
{
project.doUtilElements(utilElements);
}
}
project.write();
}
}
Now, if you select one or more records in the "used by" grid and press the button, a new project will be created:
Just what I needed, awesome!
ReplyDelete