Let LineOutputStream#println(String) throw an IOException

This is really needed for errors in the backend.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add an icon for a script

As before, the icon is taked from the Silk icons:

	http://www.famfamfam.com/lab/icons/silk/

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add the annotation for discovering script languages

These will be discovered by the upcoming script service. Script
languages which are not added via Java 1.6' scripting framework need to
implement this interface so that ImageJ2 discovers them.

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

The purpose of this class is -- similar to the legacy plugin finder -- to
look through ImageJ.app/plugins/ and find all the scripts. Those scripts
will be added to the Plugins menu (or submenu, corresponding to the
subdirectory where the scripts were found). All the hard work is handed
off to the ScriptPlugin class.

Like in Fiji, the directory ImageJ.app/plugins/Scripts/ is special in that
the scripts will be pulled up into the top-level menu structure, e.g.
ImageJ.app/plugins/Scripts/File/Fetch.js will be available as File>Fetch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Initial version of the ScriptService

This service's purpose is to discover script language implementations and
provide some convenience functions to work with them.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptService: add canHandleFile(file) method

It is often useful to be able to test whether a given file could be
executed without executing it just yet.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptFinder: use ScriptService's canHandleFile() method

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Really look only in the plugins/ directory for scripts

As in Fiji, we only want to handle scripts that are in the plugins/
directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptFinder: log how many scripts were found

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In scripts' menu items, replace underscores and extensions

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptService: add eval(name, reader)

Not always do we want to run scripts which are stored in files;
allowing to execute scripts from InputStreams adds the option to run
scripts from Strings via a StringReader.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fixup! ScriptService: add eval(name, reader)
ScriptService: discover and add javax.scripting engines

In the future, we will add more interfaces for the Script interpreters
which the javax.scripting engines do not support, such as letting us
redirect input/output, support single-stepping and breakpoints and
importing classes/packages by default. But these are just capabilities we
will add using duck-typing, and the javax.scripting engines simply will
not support those capabilities.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptPlugin: catch all Throwables, not just ScriptException

There is no default display for exceptions, so let's make extra sure that
the user is notified of problems.

While at it, show only the target exception for ScriptExceptions.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ScriptPlugin: avoid using the deprecated Log class

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add abstract base classes for ScriptEngine and ScriptEngineFactory

We will need only a fraction of the functionality offered by Java's
Scripting support.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
AbstractScriptEngine: implement engine scope bindings

This will be needed to support proper file attributions for stack traces,
as well as making the current ImageJ context available as a local
variable.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
AbstractEngine: factor out the minimal bindings, add script context

We need the script context, unfortunately, in order to redirect readers
and writers.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
AbstractScriptEngineFactory: make the class name the default language name

... and also the default engine name.

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