I have two questions:
1. Is there any way by macro or JavaScript to determine if a given tool(set) is loaded? That is, available as icon(s) in the toolbar, but not necessarily active/selected. I want to notify the user in a macro if a missing tool needs to be loaded. 2. Is there any way by macro or JavaScript to determine if a given plugin is available? That is, available in the menus so that it can be called using run("<Plugin Name>"). I want to notify a user if a needed plugin is missing, with instructions where to get it. Yes I know that 2) would be possible by parsing the output from List.setCommands; I just wondered if there is a more direct way to do it. The toolset I want loaded for 1) has some macros installed, but they do not appear in List.setCommands. Stein -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Stein,
re 2. I use: function check4Plugins() { nmeArray = newArray( "Plugin-name#1", "Plugin-name#2" ); List.setCommands; for ( i=0; i<nmeArray.length; i++ ) { if ( List.get(nmeArray[i]) == "" ) { exit( "The ImageJ-PlugIn \"" + nmeArray[i] + "\" must be installed!" ); } } } I faintly remember that Wayne has recommended this or a similar approach. Regards Herbie :::::::::::::::::::::::::::::::::::::::::: Am 21.11.19 um 21:15 schrieb Stein Rørvik: > I have two questions: > > > 1. Is there any way by macro or JavaScript to determine if a given tool(set) is loaded? > That is, available as icon(s) in the toolbar, but not necessarily active/selected. > I want to notify the user in a macro if a missing tool needs to be loaded. > > 2. Is there any way by macro or JavaScript to determine if a given plugin is available? > That is, available in the menus so that it can be called using run("<Plugin Name>"). > I want to notify a user if a needed plugin is missing, with instructions where to get it. > > Yes I know that 2) would be possible by parsing the output from List.setCommands; > I just wondered if there is a more direct way to do it. The toolset I want loaded for 1) > has some macros installed, but they do not appear in List.setCommands. > > Stein > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Stein Rørvik
Dear Stein,
This macro lists informations about current tools: n=eval('js','IJ.getInstance().getComponents()[0].getNumTools() '); for (i=0;i<n;i++) { setTool(i); s=eval('js','IJ.getInstance().getComponents()[1].getComponents()[0].getText()'); name = IJ.getToolName() ; print (i, ";", name, ";", s); } Jerome. Le jeu. 21 nov. 2019 à 21:25, Stein Rørvik <[hidden email]> a écrit : > I have two questions: > > > 1. Is there any way by macro or JavaScript to determine if a given > tool(set) is loaded? > That is, available as icon(s) in the toolbar, but not necessarily > active/selected. > I want to notify the user in a macro if a missing tool needs to be loaded. > > 2. Is there any way by macro or JavaScript to determine if a given > plugin is available? > That is, available in the menus so that it can be called using > run("<Plugin Name>"). > I want to notify a user if a needed plugin is missing, with instructions > where to get it. > > Yes I know that 2) would be possible by parsing the output from > List.setCommands; > I just wondered if there is a more direct way to do it. The toolset I want > loaded for 1) > has some macros installed, but they do not appear in List.setCommands. > > Stein > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks,
Just what I was looking for! My toolset loads 8 tools but only 6 of them is listed in this script. But that is still good enough to identify if my toolset is loaded or not. Stein -----Original Message----- From: ImageJ Interest Group <[hidden email]> On Behalf Of Jerome Mutterer Sent: 21. november 2019 22:03 To: [hidden email] Subject: Re: How to determine availability of tools and plugins Dear Stein, This macro lists informations about current tools: n=eval('js','IJ.getInstance().getComponents()[0].getNumTools() '); for (i=0;i<n;i++) { setTool(i); s=eval('js','IJ.getInstance().getComponents()[1].getComponents()[0].getText()'); name = IJ.getToolName() ; print (i, ";", name, ";", s); } Jerome. Le jeu. 21 nov. 2019 à 21:25, Stein Rørvik <[hidden email]> a écrit : > I have two questions: > > > 1. Is there any way by macro or JavaScript to determine if a given > tool(set) is loaded? > That is, available as icon(s) in the toolbar, but not necessarily > active/selected. > I want to notify the user in a macro if a missing tool needs to be loaded. > > 2. Is there any way by macro or JavaScript to determine if a given > plugin is available? > That is, available in the menus so that it can be called using > run("<Plugin Name>"). > I want to notify a user if a needed plugin is missing, with instructions > where to get it. > > Yes I know that 2) would be possible by parsing the output from > List.setCommands; > I just wondered if there is a more direct way to do it. The toolset I want > loaded for 1) > has some macros installed, but they do not appear in List.setCommands. > > Stein > > -- > ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7C5a2bb576d82c4ef387ce08d76ec685ea%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637099671237218724&sdata=wHpDmIZoRdLyGRDwoFwt0O9ZNTA%2F9vfE%2FHF8J5%2FSq1U%3D&reserved=0 > -- ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7C5a2bb576d82c4ef387ce08d76ec685ea%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637099671237218724&sdata=wHpDmIZoRdLyGRDwoFwt0O9ZNTA%2F9vfE%2FHF8J5%2FSq1U%3D&reserved=0 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Herbie
Thanks,
this works for me. Stein -----Original Message----- From: ImageJ Interest Group <[hidden email]> On Behalf Of Herbie Sent: 21. november 2019 21:36 To: [hidden email] Subject: Re: How to determine availability of tools and plugins Dear Stein, re 2. I use: function check4Plugins() { nmeArray = newArray( "Plugin-name#1", "Plugin-name#2" ); List.setCommands; for ( i=0; i<nmeArray.length; i++ ) { if ( List.get(nmeArray[i]) == "" ) { exit( "The ImageJ-PlugIn \"" + nmeArray[i] + "\" must be installed!" ); } } } I faintly remember that Wayne has recommended this or a similar approach. Regards Herbie :::::::::::::::::::::::::::::::::::::::::: Am 21.11.19 um 21:15 schrieb Stein Rørvik: > I have two questions: > > > 1. Is there any way by macro or JavaScript to determine if a given tool(set) is loaded? > That is, available as icon(s) in the toolbar, but not necessarily active/selected. > I want to notify the user in a macro if a missing tool needs to be loaded. > > 2. Is there any way by macro or JavaScript to determine if a given plugin is available? > That is, available in the menus so that it can be called using run("<Plugin Name>"). > I want to notify a user if a needed plugin is missing, with instructions where to get it. > > Yes I know that 2) would be possible by parsing the output from > List.setCommands; I just wondered if there is a more direct way to do > it. The toolset I want loaded for 1) has some macros installed, but they do not appear in List.setCommands. > > Stein > > -- > ImageJ mailing list: > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimage > j.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no > %7C6fe015ee81684287d10c08d76ec29c76%7Ce1f00f39604145b0b309e0210d8b32af > %7C1%7C0%7C637099654438641706&sdata=Iut5KnwBzwtzGBRC0VqEjKmKRQFlwc > gjJWhUtHJWMF4%3D&reserved=0 > -- ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cstein.rorvik%40sintef.no%7C6fe015ee81684287d10c08d76ec29c76%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637099654438641706&sdata=Iut5KnwBzwtzGBRC0VqEjKmKRQFlwcgjJWhUtHJWMF4%3D&reserved=0 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |