Login  Register

Removing NonBlockingGenericDialogs from the Window menu

Posted by dscho on Mar 03, 2014; 10:11pm
URL: http://imagej.273.s1.nabble.com/Removing-NonBlockingGenericDialogs-from-the-Window-menu-tp5006758.html

Dear Wayne,

I just noticed your fix:

https://github.com/imagej/ImageJA/commit/fb84ee03bedc20c141716acd34ee6ad8c8e32c6d#diff-f393bd19cc4b42d8d8549c384ce229e3L21

However, removing the window only when a button was clicked or a key was
pressed is very likely to miss the case where the dialog was closed
programmatically (e.g. when the dialog was only valid through the life
time of a long-running process, and closed when that process was done).

While looking at the larger context, I also could not help but notice that
the dialog is added to the Window menu long before the dialog is shown.
And indeed, it is added to the Window menu even if the dialog is not shown
at all (for which there are quite a few use cases -- I trust your
imagination to come up with even more than I could think of).

A better practice would be to implement something like this (sorry, I have
no time to test this, besides, you made clear that you like to implement
such changes yourself and ignore pull requests, therefore I will not
burden you with one):

        @Override
        public void setVisible(boolean visible) {
                if (!visible) {
                        WindowManager.removeWindow(this);
                }
                super.setVisible(visible);
                if (visible) {
                        WindowManager.addWindow(this);
                }
        }

Regards,
Johannes

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