Держите самый красивый вариант :-) Года два назад нарисовал бессонной ночью.
X++:
//Open the selected element in a new AOT window
#AOT
void addIns_OpenNewWindowSelected(Editor e)
{
TreeNode sourceCodeNode = TreeNode::findNode(e.path());
TreeNode newWindowNode;
TreeNodePath treeNodePath;
xRefTmpReferences refTable;
int startLine = e.selectionStartLine();
int startCol = e.selectionStartCol();
int endCol = e.selectionEndCol();
str selectedText;
;
if (sourceCodeNode && e.selectionStartLine() == e.selectionEndLine() && startCol != endCol)
{
infolog.updatexRefSet(sourceCodeNode, true);
sourceCodeNode.AOTmakeXref(1);
refTable = xRefCreate::makeTmp(infolog.lastxRef());
infolog.updatexRefSet(sourceCodeNode, false);
select firstonly refTable
where refTable.line == startLine
&& refTable.Column == startCol;
if (refTable)
{
treeNodePath = refTable.Path();
if (treeNodePath)
{
newWindowNode = TreeNode::findNode(treeNodePath);
if (newWindowNode)
{
newWindowNode.AOTnewWindow();
if (!newWindowNode.AOTchildNodeCount()) //Workaround for the AX4 "open new window" bug. Remove for AX3/2009
{
infolog.getUserSetup().setUserSetup(xUserInfo::find());
}
}
}
}
else
{
e.firstSelectedLine();
selectedText = strLRTrim(subStr(e.getLine(), e.selectionStartCol(), endCol-startCol));
if (selectedText)
{
newWindowNode = TreeNode::findNode(#MacrosPath + #AOTDelimiter + selectedText);
if (newWindowNode)
{
newWindowNode.AOTedit();
}
}
}
}
}