The other day, a co-worker sent me a mail 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?"
The story behind this mail is recounted in a previous post in this blog. The story behind why this coworker calls me "Beavis" is one I can't recall at the moment, if I ever knew.
In the "The File Explorer Map Part - How Deep is Deep?" blog post, I made a general (and somewhat lame) request for a modified File Explorer Map Part that would allow the user to set the recursion depth, and hence the depth of the file/folder topic sub-tree rooted in the map part.
Well, like a scab or blister or some other blemish, I couldn't leave the problem alone.
In my installation of MindManager Pro 6 (6.2.399, service pack 2) the macro script that animates the File Explorer Map Part variants is located at <ProgramFiles>\Mindjet\MindManager 6\Generic Smart Map Part\File Explorer\ENU\scripts\Refresh.mmbas
where <ProgramFiles> is the usual "C:\Program Files" folder. The File Explorer map parts are actually variations on one Generic Smart Map Part (GSMP) implementation.
By way of background, the Generic Smart Map Part is a MindManager add-in that will use the Windows Registry and MindManager Map Part information to locate macro scripts, making calls into those scripts at specific points in the lifecycle of a Map Part instance. Each set of scripts is associated with a specific Map Part.
The lifecycle points involving GSMP macro scripts are fairly straightforward. One point is the first insertion of the map part, another is upon refresh of the map part, and still another is associated with Topic context menu commands associated with instances of the map part in the map document. By default, the File Explorer Map Part adds a "Convert to Regular" context menu command that turns the map part and its children into normal Map document Topics.
It turns out that the MindManager macro language can support user dialogs with a basic set of dialog controls: static text, checkboxes, edit boxes, drop-down lists, combo boxes,and the like. There's even a handy User Dialog editor in the macro development editor under the Edit->User Dialog menu command. The macro language help topics "Begin Dialog Definition" and "DialogFunc Prototype" provide some bare bones information on using this MindManager macro language feature.
I was mildly disappointed after reading the distribution copy of Refresh.mmbas animating the File Explorer map part. The Description.mmbas script used a localizable string from the Language.mmbas module, but a number of English Language string constants still appeared in Refresh.mmbas. In addition, the recursion depth of the folders was controlled by literal constants. Further, there are several unmet error cases (try a hyperlink pointing at www.mindjet.com, for example) and some tortured logic trying to decide if the hyperlink held by the parent topic of the File Explorer map part is referencing a file, a folder or something else.
I reined in my editorial shrew and resisted the impulse to completely rewrite Refresh.mmbas. Rather, I modified it in the following ways:
- added a custom attribute to carry folder depth
- added a Topic map part context menu item to get folder depth from user (set every time the refresh routine runs)
- set the Description and Convert to Regular Topic map part context menu items to reference the right scripts
- added a MsgBox call in the QuitOnException exit point
- added "No Hyperlink" and "Hyperlink does not point into file system" tests and error messages
- used the language.mmbas module to carry all the constants used in error messages, user prompts and topic attribute identification
- added logic and error messages to detect some missing or invalid parent Topic Hyperlink cases
All this involved writing a new script called FolderDepth.mmbas to carry the user dialog to set the folder depth. This script includes a test to validate the user-supplied folder depth against maximum and minimum values. Since there is apparently no convenient way to force the user entry to consist of digits only, this test has to accommodate arbitrary non-numeric characters.
So now I can set a folder depth to control the recursion that builds the child topics beneath a File Explorer Map part. If you want this code, see the Modified File Explorer Map Part download, and follow the installation directions. However, use it at your own risk. I'd like to hear your reactions, good or bad, but I can't promise to fix every possible problem. See the readme.txt file in the download for a description of installation, use and returning to the original File Explorer Map Part functionality.