//@String(label="Search query",columns="25") searchString //@boolean(label="Search file contents", value="true") searchContents //@boolean(label="Ignore case", value="true") caseInsensitive /* Search_Snippets.bsh * IJ BAR: https://github.com/tferr/Scripts#scripts * * BeanShell script that instructs the built-in 'Search...' command (Plugins>Utilies>Search...) to * search inside plugins/BAR/ for clipboard contents. * * Requirements: Requires BAR_-XX.jar to be installed in the plugins folder of IJ * * NB: The 'Search' command is actually a macro[1]. This script would actually be simpler if itself * would have been written using the same ImageJ macro language. Writing it in BeanShell exemplifies * how different scripting languages can cooperate in ImageJ. * * [1] https://github.com/imagej/imagej1/blob/master/macros/Search.txt * Tiago Ferreira, 2014.10.27 */ import ij.IJ; import bar.Utils; /* Options */ String PATH = Utils.getBARDir(); // Abort if BAR directory cannot be found if (Utils.fileExists(PATH)) { // Get string from clipboard String searchString = Utils.getClipboardText(); // Concatenate all options into a single string String options = "_=["+ searchString +"] "; if (searchContents) options+= "search_contents "; if (caseInsensitive) options+= "ignore "; options += "search=Choose... choose=["+ PATH +"]"; // Pass the options string to Plugins>Utilies>Search... IJ.run("Search...", options); }