I had another one of those "how does this work?" moments with MindManager the other day. A colleague was using MindManager to document a software installation process, mapping binary image locations in the target file system with the install steps that placed the image there. When I innocently asked "Did you use the File Explorer Smart Map Part to get the file list?" I got one of those "Huh?" looks.
You know, the "Huh?" look. The one where you ask someone a seemingly simple question and they look at you like there's a funnel growing out of your forehead, or you're speaking in tongues, or professing a desire to maintain legacy code or something.
Turns out my colleague had never used the File Explorer map part that ships with MindManger Pro. If you open a Map Document, then open the Map Parts task pane, you can select the "File Explorer" category folder to reveal three Map Parts: "All Files and Folders", "All Files" and "All Folders". Drag one of these onto a Map, and place it beneath a Topic that has a HyperLink pointing at a file system folder, and the File Explorer Map Part grabs a snapshot of the folder contents and formats it into Map SubTopics. Which beats the heck out of switching between Windows Explorer and MindManger, copying and pasting file and folder names. Or at least my co-worker thought so, since that's what he'd been doing for 50 files or so.
The MindManager Pro help explains all this better than I did. See the "Using Smart Map Parts" page in the help for details.
But the next day I received an e-mail that ran like this:
Hey Beavis:
How come that All Files and Folders map part you showed me only goes two folders deeper than the starting folder?"
It was my turn to say "Huh?" Sure enough, if you point the HyperLink of a Topic at "FolderX" and add the "All Files and Folders" Map Part to that Topic, you get the files in FolderX, and the child folders in FolderX, and the children (both files and folders) of those child folders, and that's it. But we needed at least three levels below the starting folder. I had assumed the File Explorer map parts would just recurse to the end of the file/folder tree, but that isn't the case.
Well, Smart Map Parts (SMPs) are a nifty part of the MindManager Platform. Briefly, they let you put script behind a Topic and run that script to obtain Topic content. So there had to be some script code around somewhere that ran when the File Explorer Map Part was inserted, and some more script that ran when that Map Part was refreshed. Some digging around in the Registry (thanks be for the Edit->Find command in Regedit.exe) produced a key with a ScriptPath value like this:
HKEY_LOCAL_MACHINE\SOFTWARE\Mindjet\MindManager\6\AddIns\Mindjet.Mm5GenericSmartMapPart.AddIn.2\SMPs\Mindjet.FileExplorer.Smp.1
Turns out that in the English version of a MindManager Pro 6 installation, there's a folder called
<ProgramFiles>\Mindjet\MindManager 6\Generic Smart Map Part\File Explorer\ENU\scripts
(where <ProgramFiles> is usually "C:\Program Files") and in that folder is a MMBasic script called Refresh.mmbas. This is the code that animates the File Explorer Smart Map Part. Seems likely that other languages are in a similiar folder, replacing "ENU" with a language-dependent identifier. Buried in the Refresh.mmbas code is a snippet like so:
Set attr = folderTopic.Attributes("http://schemas.mindjet.com/MindManager/GSMP/2003")
t = attr.GetAttributeValue("Type")
If t = "Files" Then
showFiles = True
maxDepth = 1
ElseIf t = "Folders" Then
showFolders = True
maxDepth = 2
ElseIf t = "FilesAndFolders" Then
showFiles = True
showFolders = True
maxDepth = 2
End If
' Everything is OK, ready to go
Call recurMap(folderTopic, mapPath, 0) ' map files and folders
folderTopic.SetLevelOfDetail(1)
Hmmm.... Looks like this is where we decide what sort of update we're going to do, and set some control variables to achieve that result. Look around some more, and it turns out showFolders, showFiles and maxDepth are all global variables, used in a subroutine called recurMap to control the scan of files and folders starting at a folder provided by the user in the HyperLink carried in the parent Topic.
Usually, I break out in hives when I see "magic numbers" in code, that is, numerics used in the manner of "1" and "2" in the snippet above. In this case, I wimped out and just mailed the code snippet and its location to my co-worker with a "don't set maxDepth too big (like 10 or something) because the map will take a year to refresh" caveat. But I also made a copy of the Refresh.mmbas file and added code to use constants like these:
Const MAX_FILE_DEPTH = 1
Const MAX_FOLDER_DEPTH = 6
Const MAX_FILEFOLDER_DEPTH = 3
Which is how I learned about the long file/folder scan time. But this got me to thinking. Shouldn't the user be able to select this level (and possibly the default) for individual File Explorer Smart Map Parts? And shouldn't there be a way to put an SMP command on the Topic context menu to solicit the user for this settting? The DevZone content talks about a "Generic SMP" framework that hosts user SMP scripts, and mentions pre-defined context menu items for use by such a map part, and the MMBasic language help has a Dialog keyword. Seems like it should be possible to combine these to get a "how many levels deep" value from the user.
I'm hoping someone has already done something like this. And I'm hoping that someone will post a modified FileExplorer SMP on the Downloads/Map Parts page. I may feel guilty (or bored, or inspired, or something just plain bloody-minded) at some future date and cobble up a modified File Explorer that lets the user set the folder depth of the Topic content created by an instance of this Smart Map Part, but then again it might take me until the second Reno presidency to get around to it.