Try to dispose IJ1 more nicely

Niko Ehrenfeuchter reported a bug that this developer cannot reproduce
but suspects to have something to do with a mutual block between
the event dispatch thread and the thread trying to dispose of ImageJ
1.x's windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
SwitchToModernMode: propagate class loader to EDT

We need the EDT to use the plugin class loader, because the ImageJ2 UI
launches commands from the EDT by using the SJC ThreadService, which
creates a new thread, propagating the EDT thread's context class loader.
LegacyInjector: set class loader on new context

When we create the IJ2 context, we want to propagate the context class
loader from the calling thread. This will help IJ2 use IJ1's plugin
class loader while it is booting up. This is important because upon
completion of the SciJava context services being loaded, a
ServicesLoadedEvent is fired using EventService#publishLater which calls
ThreadService#run which creates a new thread in the thread pool (since
it was the first time run has been called). And it is paramount that
each and every thread of the ThreadService's thread pool gets its
context class loader set to the IJ1 plugin class loader, or else any
code later executed via ThreadService#run may not have access to all the
classes loaded via that class loader. In particular, commands executed
through the IJ2 UI such as "System Information" may not have access to
all classes and resources made available via the plugin class loader.
Merge pull request #20 from imagej/modern-mode

Fix Fiji's modern mode

After Help>Switch to Modern Mode the class loader was not set properly.
As a consequence, plugins were discovered correctly only they were
contained in .jar files that just so happened to be in the class path of
fiji-compat.

Fix this by explicitly setting Thread's context class loader to the
correct class loader when

  1. creating the Context.
  2. running the Switch to Modern Mode plugin on the EDT.

We need to do both because the ThreadService reuses threads and they can
be created from either call path.
Bump to pom-scijava 1.136

Signed-off-by: Jenkins <jenkins@dev.loci.wisc.edu>
Whoops, Contextuals now need to implement context()

Thanks, Jakome Jenkins!

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge branch 'unblock-edt-on-quit'

This avoids blocking the Event Dispatch Thread on exit when the legacy
service wants to release images.

Apparently noticed by many, but only reported by Niko Ehrenfeuchter.

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