Fix the issue when Window menu items are not removed upon closing images

The problem is actually that ImageJ 1.x gets confused when adding new items, putting them into the wrong spot (when plugins were installed into the `Window` menu). As a consequence wrong menu items are removed when closing images.

In addition to the fix, the changes also include a new API to allow for conditional patching, contingent on ImageJ 1.x version ranges. The reason for this change is that this developer anticipates ImageJ 1.x to be changed in a way that breaks `ij1-patcher`. When that happens, we can make use of the new API to unbreak it quickly.

This pull request addresses and supersedes https://github.com/imagej/imagej-legacy/issues/68.