Remove unused import

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
IJ1MacroLanguage: require legacy service only lazily

This is needed because we need to be able to discover the
legacy-compatible macros at the time the legacy service is being
initialized, i.e. not yet *quite* available.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Move legacy-compatible command initialization back into service

Otherwise, the legacy-compatible commands and scripts will never be
installed unless the legacy UI is shown!

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make calls to legacy-compatible commands/scripts synchronous

There is little use in calling commands in a macro when the call returns
before the action is actually performed...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
IJ1Helper#runMacro: ensure that Macro.getOptions() works

ImageJ 1.x has this funny homebrewn way to provide thread-local
macro options (without using the ThreadLocal class at all). It
also poses a completely unnecessary restriction on the the thread
name. To support that in the broader context, we have to make
sure that the current thread name conforms to that requirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
IJ1Helpers: add delegators to get/set the macro options

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Bump to preemptively-deployed new pom-imagej

The upcoming changes require a new SciJava common version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Ensure that legacy-compatible macros find the macro options

As SciJava's script service calls scripts on different threads,
we have to make extra certain that the appropriate macro options
-- if any -- are available to the ImageJ 1.x macro engine.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a unit test for running macros with macro options

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge pull request #59 from imagej/macro-options

Fix run('Some Macro', 'macro options');

Aryeh Weiss reported that macros that are registered menu items (by putting them into Fiji.app/plugins/*_*.ijm) ignore the macro options passed via IJ.run's second parameter.

The reason is that ImageJ 1.x insists on making the macro options thread-local (which does not address the threading issues with running macros completely because there is too much global state going on in ImageJ 1.x for that, but that is beside the current issue) and SciJava's ScriptService runs scripts in a separate thread pool.

The solution is to remember the options and set them thread-locally just before running the macro from the ImageJ 1.x macro engine.

This branch also fixes a couple of other bugs identified while implementing a regression test to verify that the original issue has been solved.