How-To - Customization - Detect which tab on the attribute editor from which a custom IMMTreeTool was executed

Version 2


    Tree tools are customizations that display in the right-click context menu in the ArcFM Attribute Editor. Additional information on developing custom tree tools can be found here in our resource center.


    Sometimes you may have a tree tool that runs across multiple tabs in the attribute editor, but you need slightly different behavior depending on the tab. For example, you may want to do something different depending on whether the tool is run from the Design tab instead of the Selection tab.



    There isn't a direct way to see what called the tool. However, there is an easy way to determine the tab by looking upwards through the current list item's parent until you arrive at the top level parent. Then you can check that top level's ItemType property.


    Here is a sample function that obtains the top level parent from the ID8ListItem that is given by the Execute method of IMMTreeTool:


    public ID8ListItem GetTopParent(ID8ListItem item){
        if (item.ContainedBy == null) return item;
        ID8ListItem curParent = item.ContainedBy as ID8ListItem;
        while (curParent.ContainedBy != null)
            curParent = curParent.ContainedBy as ID8ListItem;
        return curParent;


    And then, to use this:


    public void Execute(ID8EnumListItem pEnumItems, int lItemCount) { 
        ID8ListItem item = pEnumItems.Next(); 
        ID8ListItem topParent = GetTopParent(item); 
        if (topParent.ItemType == mmd8ItemType.mmd8FeSelTopLevel) 
        //do something specific to the selection tab