Move some code from the LegacyInitializer to the IJ1Helper

The current strategy for the legacy mode is to let fiji.Main create
a LegacyEnvironment that patches an encapsulated ImageJ 1.x-only
ClassLoader which in turn creates a PluginClassLoader in which the
LegacyInitializer is called to spin up the ImageJ2 context.

In that setting, it does not matter whether the IJ1Helper (initialized
by the DefaultLegacyService) or whether the LegacyInitializer calls the
code to initialize context class loader, icon and application title.

However, our plan is to let the DefaultLegacyService spin up ImageJ
1.x; In that scenario, the LegacyInitializer is no longer called,
but the IJ1Helper is.

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

Move some code from the LegacyInitializer to the IJ1Helper
Update license in a copy-edited file header

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Be extra careful to avoid eternally bouncing status messages

Without this patch, a status message originating from modern mode
would bounce back and forth merrily, hogging the CPU rather nicely.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Avoid depending on EssentialLegacyHooks

The DefaultLegacyHooks need to be loaded in order to execute
DefaultLegacyService's initialize() method, but that is exactly where we
want to call the ij1-patcher that wants to patch the
EssentialLegacyHooks.

So far, that was not a problem because we always had a different class
loader to patch, but we are about to switch to a startup process where
we force ImageJ 1.x to use the same class loader for its plugins as for
its core classes. That means we have to be careful *not* to use the
EssentialLegacyHooks class prematurely.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix license header

This file was copied from scripting-java, which has a *slightly*
different license header (although the same type of license: BSD-2).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a method to IJ1Helper to evaluate macros

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Do not require the UI service to initialize the legacy service

Catch 22...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a TestDrive for the editor in legacy mode

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a legacy default importer for the script editor

This plugin is responsible for listing the ImageJ 1.x and TrakEM2
classes (insofar available) in support of the auto-import feature of
the script editor.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add an almost JSR-223-compliant script engine for ImageJ 1.x macros

This is a crucial building block to allow Fiji to switch over to ImageJ2's
script editor: Fiji *needs* to support ImageJ 1.x macros in the script
editor, otherwise users will actually say something.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make sure that the DefaultLegacyService has a slightly higher priority

We need to make certain that the LegacyUI is initialized only when the
legacy service is available already. That means that we have to make
certain that the DefaultUIService has a lower priority than the legacy
service. Or vice versa.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Bump the parent version preemptively

This is needed for the upcoming changes in support for the script editor
as well as for ImageJ2 starting up with the legacy UI as default UI.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Avoid auto-importing non-public classes

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
No need to auto-import java.lang.*

The script languages auto-import those already themselves.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge 'ij1-macro-engine' into HEAD
Add script editor templates from Fiji's Script Editor

With ImageJ2's script editor, every component can ship their own
templates simply by bundling things in the /script-editor/ directory
of the .jar file. To provide everything needed for Fiji to switch
to the new script editor, imagej-legacy needs to take custody of the
templates for use with the legacy ImageJ 1.x classes.

This commit brings a verbatim copy of the templates from Fiji's
Script Editor. In the next commits, we will work on them more.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge 'ij1-auto-imports' into HEAD
This is the big switch to the new startup procedure

The intent of this switch is to make Fiji start up ImageJ2 in the future
instead of starting ImageJ 1.x and then letting the LegacyInitializer
spin up a corresponding ImageJ2 context.

This implies that we will have to reuse the same class loader for
ImageJ2, ImageJ 1.x and ImageJ 1.x' plugins. As a consequence, we will
have to discontinue support for Help>Refresh Menus, but given that
there are now much better ways to develop plugins in Integrated
Development Environments (such as Eclipse, Netbeans, etc), that is
not too big of a concession.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Exclude the script templates from getting license headers

The script templates are intended to be as accessible as possible. As
a consequence, they are *not* to have a license header.

For the record: the templates as of Fiji's script editor were always
intended to be freely usable. In other words, they were licensed
implicitly under the CC Zero license. For details about that license,
see http://creativecommons.org/publicdomain/zero/1.0/.

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