/* File generated with the 'Toolset Creator' macro
 * 
 * Filename:  'Plugins.txt'
 * Created:    2008.09.21 12:24:15
 * 
 * Edit the two lines below '// Settings:' to change which files
 * should be listed (e.g. you can exclude .jar files implementing
 * multiple commands via a plugins.config file)
 * 
 * For '.ijm' and '.js' files use key modifiers while selecting an
 * item from the list: 'shift': opens the macro file;
 *                     'alt':   installs the macro;
 */

// Settings:
var AllowedFileExtensions= newArray('class','txt','ijm','jar','js');
var IgnoreFilenamesContaining= newArray('$','//','//','//');


// Macros:
 macro 'Unused Tool -' {}

       var aList= getPluginList('3D');
       var aCmds= newMenu('3D Menu Tool',aList);
 macro '3D Menu Tool - C037T1d133T9d13DC555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var bList= getPluginList('Analyze');
       var bCmds= newMenu('Analyze Menu Tool',bList);
 macro 'Analyze Menu Tool - C037T1d13AT9d13 C555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var cList= getPluginList('Examples');
       var cCmds= newMenu('Examples Menu Tool',cList);
 macro 'Examples Menu Tool - C037T1d13ET9d13 C555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var dList= getPluginList('Filters');
       var dCmds= newMenu('Filters Menu Tool',dList);
 macro 'Filters Menu Tool - C037T1d13FT9d13 C555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var eList= getPluginList('Macros');
       var eCmds= newMenu('Macros Menu Tool',eList);
 macro 'Macros Menu Tool - C037T1d13MT9d13 C555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var fList= getPluginList('Scripts');
       var fCmds= newMenu('Scripts Menu Tool',fList);
 macro 'Scripts Menu Tool - C037T1d13JT9d13SC555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }

       var gList= getPluginList('Tools');
       var gCmds= newMenu('Tools Menu Tool',gList);
 macro 'Tools Menu Tool - C037T1d13TT9d13 C555' {
       cmd = getArgument();
       if (cmd!='-') run(cmd);
 }


// Functions:
function getPluginList(subfolder) {
       dir=  getDirectory('plugins')+subfolder+File.separator;
       list= newArray(''+subfolder+' not found','in the plugins directory...');
   if (!File.exists(dir)) return list;
       rawlist= getFileList(dir);
       count=   0;
   for (i=0; i< rawlist.length; i++) {
       isMacro= (getVersion>='1.41n') && (endsWith(rawlist[i],'.ijm')||endsWith(rawlist[i],'.js'));
     if (indexOf(rawlist[i], '_')==-1&&!isMacro) rawlist[i]='-';
   for (h=0; h<IgnoreFilenamesContaining.length; h++)
     if (indexOf(rawlist[i], IgnoreFilenamesContaining[h])!=-1) rawlist[i]='-';
       rawlist[i]=replace(rawlist[i],'_',' ');
   for (j=0; j<AllowedFileExtensions.length; j++)
     if (endsWith(rawlist[i],AllowedFileExtensions[j]))count++;
    }
     if(count==0) list=newArray('No executable found','on '+''+subfolder);
     else
       list=  newArray(count);
       index= 0;
   for (i=0; i< rawlist.length; i++) {
   for (h=0; h< AllowedFileExtensions.length; h++) {
       cmdlength=lengthOf(rawlist[i])-lengthOf(AllowedFileExtensions[h])-1;
     if (endsWith(rawlist[i], AllowedFileExtensions[h]))
       list[index++] = substring(rawlist[i], 0, cmdlength);
       }
    }
   return list;
}
