Login  Register

Re: Notification of File Save

Posted by Wayne Rasband-2 on Jan 06, 2021; 3:52pm
URL: http://imagej.273.s1.nabble.com/Notification-of-File-Save-tp5024300p5024335.html

> On Jan 6, 2021, at 3:18 AM, Michael Ellis <[hidden email]> wrote:
>
> Dear Wayne,
>
> The AutoClose feature is not a show stopper for me that can easily be worked around.
>
> The FileSave functionality is necessary for my application and without that support
> I can only ship my PlugIns with my own modified version of Image which I am loath to do
> as I want to make at least some of my plugins free to use for the community. (I do believe
> in putting something back)
>
> Can I put to you the idea of supporting the FileSaved functionality in a Java 1.6
> compliant way as follows:

I think we should wait for Fiji to be fixed so that it works with ij.jar files built for Java 8. You can monitor and/or contribute to this fix on the Image.sc Forum at

https://forum.image.sc/t/fiji-fails-to-launch-after-upgrade-to-imagej-daily-build/47125/6

and on GitHub at

https://github.com/imagej/ij1-patcher/issues/50

-wayne


>
> === Added ij.ImageListenerAux.java ===
>
> package ij;
>
> /**
> * An extension of the {@code ImageListener} Interface that provides
> * notification when and ImagePlus is saved.
> *
> * Note this interface is deprecated and will be removed as soon as ImageJ is
> * using Java 8 whereupon {@code imageSaved()} will be added as a default method
> * to the original {@code ImageListener}
> *
> * @deprecated
> */
> public interface ImageListenerAux extends ImageListener {
>
>    public void imageSaved(ImagePlus imp);
>
> }
>
> === Modified ImagePlus.java ===
>
> protected void notifyListeners(final int id) {
>    final ImagePlus imp = this;
> EventQueue.invokeLater(new Runnable() {
> public void run() {
> for (int i=0; i<listeners.size(); i++) {
> ImageListener listener = (ImageListener)listeners.elementAt(i);
> switch (id) {
> case OPENED:
> listener.imageOpened(imp);
> break;
> case CLOSED:
> listener.imageClosed(imp);
> break;
> case UPDATED:
> listener.imageUpdated(imp);
> break;
> case SAVED:
>                                                       if (imp instanceof ImageListenerAux){
>                                                   (ImageListenerAux)listener).imageSaved(imp);
>                                                       }
>       break;
> }
> }
> }
> });
> }
>
>
> Users needing the FileSaved functionality can just implement the newer ImageListenerAux interface.
>
> Also, when ImageJ finally settled on Jave 8 I'd suggest that all the method interface to ImageListener are defaulted so plugIn developers need
> only implement the ones they are interested in.
>
> With best regards -- Michael Ellis
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html