Axaptapedia is now maintained by AgileCadence For more information please click here.

Editor scripts OpenInAOT

From Axaptapedia
Revision as of 09:52, 1 December 2006 by 212.42.91.114 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Description

  • This is a nice script that will be very helpful to beginners for studying the Axapta objects. It will also drastically increase the development speed, because you won't have to search for objects in AOT every time.
  • It also provides the overview of System Kernel objects that are not present in the AOT.
  • System functions can also be looked up.
  • In case there are more than one object with the selected name, a listview with the possible choices is shown, where the developer can select the needed object type.
  • To lookup an object in AOT you can highlight the object name in the editor or simply put the cursor somewhere in the middle of its name.

Code

Simply create a new method in class Editor Scripts and paste the following code in it. <xpp> //<Editor_Scripts_OpenInAOT_ikash date=2006-12-01 txt='a script to open the selected object in AOT'> void addIns_OpenInAOT(Editor e) {

   #AOT
   TreeNode        treeNode;
   FreeText        selectedLine;
   str 1           curSymbol;
   int             iCurSymbol, iCopyFrom, iCopyTo;
   Set             selectedNodesSet = new Set(Types::Class);
   SetIterator     setIterator;
   Map             map;
   void            add2Set(TreeNodePath _path)
   {
       ;
       treeNode = TreeNode::findNode(_path + #AOTRootPath + selectedLine);
       if (treeNode)
           selectedNodesSet.add(treeNode);
   }
   ;

// if (e.selectionStartLine() != e.selectionEndLine()) // return;

   if (e.selectionStartCol() != e.selectionEndCol())
       selectedLine = subStr(e.currentLine(), e.selectionStartCol(), e.selectionEndCol() - e.selectionStartCol());
   else
   {
       selectedLine = e.currentLine();
       iCurSymbol = e.selectionStartCol();
       while (iCurSymbol >= 0)
       {
           curSymbol = subStr(selectedLine, iCurSymbol, 1);
           if (strAlpha(curSymbol) == )
           {
               iCopyFrom = iCurSymbol + 1;
               break;
           }
           iCurSymbol--;
       }
       iCurSymbol = e.selectionEndCol();
       while (iCurSymbol <= strLen(selectedLine))
       {
           curSymbol = subStr(selectedLine, iCurSymbol, 1);
           if (strAlpha(curSymbol) == )
           {
               iCopyTo = iCurSymbol;
               break;
           }
           iCurSymbol++;
       }
       selectedLine = subStr(selectedLine, iCopyFrom, iCopyTo - iCopyFrom);
   }
   if (selectedLine)
   {
       //The main elementTypes - can be extended
       add2Set(#ExtendedDataTypesPath);
       add2Set(#BaseEnumsPath);
       add2Set(#TablesPath);
       add2Set(#ClassesPath);
       add2Set(#FormsPath);
       add2Set(#ReportsPath);
       //if nothing was found in the AOT, we'll try searching in systemDocumentation
       if (selectedNodesSet.elements() == 0)
       {
           add2Set(#SystemFunctionsPath);
           add2Set(#SystemTablesPath);
           add2Set(#SystemTypesPath);
           add2Set(#SystemEnumsPath);
           add2Set(#SystemClassesPath);
       }
       if (selectedNodesSet.elements() > 0)
       {
           setIterator = new SetIterator(selectedNodesSet);
           setIterator.begin();
           if (selectedNodesSet.elements() == 1)
           {
               treeNode = setIterator.value();
           }
           else
           {
               map = new Map(Types::String, Types::String);
               while (setIterator.more())
               {
                   treeNode = setIterator.value();
                   map.insert(treeNode.treeNodePath(), treeNode.AOTparent().treeNodeName());
                   setIterator.next();
               }
               treeNode = TreeNode::findNode(pickList(map, "Location", "Select element type"));
           }
           if (treeNode && treeNode.treeNodePath() != TreeNode::rootNode().treeNodePath())
           {
               if (treeNode.AOTparent().AOTparent().treeNodePath() == #SystemDocPath)
               {
                   treeNode.AOTnewWindow();
                   treeNode.AOTedit();
               }
               else
               {
                   treeNode.AOTshowProperties();
                   treeNode.AOTnewWindow();
               }
           }
       }
   }

} </xpp>

Used in

Editor scripts