/* * ActionBar Updater-Makro, by Rainer M. Engel, 2012 * ActionBar is a plugin for ImageJ created by Jerome Mutterer * http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:action_bar:start */ ijDir = getDirectory("imagej"); // CONFIG HERE ################################################################ ActBar = ijDir+"plugins"+File.separator+"ActionBar"+File.separator+"test.txt"; // YOUR ActionBar verbose = true; // print to log dialog = false; // show dialog before updating //############################################################################# if (verbose) { print("\\Clear"); print("start updating ActionBar.."); print("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); } ActScr = File.openAsString(ActBar); //print(ActScr); SRClines= split(ActScr,"\n"); if (verbose) { print("-> found "+lengthOf(SRClines)+" lines in ActionBar-Script"); } // filter path-containing lines from script ----------------------------------- paths = newArray(); // create Array to store paths in ranks = newArray(); // create Array to store ranks in vers = newArray(); // create Array to store versions in exts = newArray(); // create Array to store extentions (format) in for (i=0; i found "+lengthOf(paths)+" linked makros inside of ActionBar-Script"); } //------------------------------------------------------------------------------ // check existence of makros --------------------------------------------------- makroC = newArray(); // create Array to count found makros for (i=0; i found "+lengthOf(makroC)+" makros at their defined paths"); } //------------------------------------------------------------------------------ // check for updated makros ---------------------------------------------------- UpdateV = 0; UpdateP = newArray(); // Updated paths to new versions UpdateC = 0; for (i=0; i found "+UpdateC+" update(s) in makros"); } //------------------------------------------------------------------------------ // dialog ---------------------------------------------------------------------- if (dialog == true && UpdateC != 0) { wfu = getBoolean("ActionBar-Updater found "+UpdateC+" Update(s).\nPerform update?"); if (wfu == 0) { exit() } } //------------------------------------------------------------------------------ // Assemble updated action-bar file (if there are updates) --------------------- if (UpdateC == 0) { if (verbose) { print("-> No need to make any updates.. stopping here!"); print("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); } } else { outLog = File.delete(ActBar); outLog = File.open(ActBar); c = 0; for (i=0; i ActionBar-file has been updated!"); print("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); } } //------------------------------------------------------------------------------ // FUNCTIONS .................................................................. function getPath(path) { // get string of path only dotIndex = lastIndexOf(path, "\")"); if (dotIndex!=-1) path = substring(path, 0, dotIndex); first = indexOf(path, "(\""); if (first!=-1) path = substring(path, first+2, lengthOf(path)); return path; } function getVerIncr(version) { // get version from path dotIndex = lastIndexOf(version, "."); if (dotIndex!=-1) version = substring(version, 0, dotIndex); first = indexOf(path, "_v"); if (first!=-1) version = substring(version, first+2, lengthOf(version)); version = IJ.pad(version, 0); return version; } function getExt(extention) { // get filetype from path dotIndex = lastIndexOf(extention, "."); if (dotIndex!=-1) extention = substring(extention, dotIndex, lengthOf(extention)); return extention; } //.............................................................................