Remove unused import

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make really, really sure that ImageJ 1.x is initialized before use

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Accomodate legacy command-line needs in the IJ1Helper

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Handle legacy command-line arguments

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Handle -batch as last argument

When -batch is passed as last command-line argument, the *complete*
process is supposed to be in batch mode.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Work around already-initialized instance in batch mode

When ImageJ is called via the command-line

	ImageJ -eval ... -batch

*without* the --headless option, the LegacyUI already constructed
an ImageJ 1.x frame. As a consequence, all output will go to
a text window despite the user having asked for batch execution.

We work around that by tearing down the instance when encountering
the -batch argument.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use the context class loader for the legacy environment

We cannot be sure that the class loader to be used is the exact class
loader that loaded imagej-legacy. A child of that class loader might be
desired, e.g. to add paths for additional ImageJ 1.x plugins.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Some defensive programming

The commandsTable *should* be initialized. But it might not be...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Let the ij1Helper dispose of the LegacyUI

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Show the full version even in the LegacyUI

This allows us to show the ImageJ2 version along with the legacy version.

As a consequence, we have to access the static version directly in the
IJ1Helper to avoid an infinite recursion between IJ.getVersion() and
legacyService.getLegacyVersion().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Force the initial LegacyUI status bar to show the correct version

The "correct version" being, of course, the full ImageJ2 version
including the legacy version.

This is not possible otherwise because the legacy hooks can only
be replaced with a DefaultLegacyHooks instance once ImageJ 1.x is
fully initialized, which is unfortunately *after* ImageJ 1.x
wants to report its version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge branch 'legacy-cmdline-options'

This topic branch adds back support for ImageJ 1.x command line
options such as '-eval ...' and '-batch ...'. The primary purpose
of doing this is to allow Fiji to switch from its own Main class
to using straight net.imagej.Main.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge 'legacy-version' into HEAD
Bump to next development cycle

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use the context class loader in more places

We should be consistent: either we restrict the class loader to the one
that loaded imagej-legacy, or we use the current thread's context class
loader, not both.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Remove completed fixme

This was done in the last imagej-legacy release.
LegacyUI: don't display on separate thread

This was based off the AbstractUserInterface's show() implementation, to
show a display off-thread. However, this causes problems in the legacy
layer where we depend on side-effects, such as registering an ImagePlus
in response to display creation.
DefaultLegacyOpener: factor out OpenFile

Instead of always using the OpenFile command, we will use a focused
GetPath command only if given a null path. Then we will use the
IOService directly.

This prevents unwanted dialogs to pop up, for example, if no format is
found.
DefaultLegacyOpener: cache services

Ideally we would just use context injection here. However, the
instantiation in DefaultLegacyHooks is too early for context injection
to work right now.

So let's at least cache these services between open runs.