NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 769 - Fiji window no longer closes child windows and it doesn't remember its position
Fiji window no longer closes child windows and it doesn't remember its position
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: Other
unspecified
PC Linux
: P5 enhancement
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2014-06-11 02:16 CDT by Ilan Tal
Modified: 2014-06-15 09:17 CDT
3 users (show)

See Also:


Attachments
add (18.29 KB, image/png)
2014-06-11 10:37 CDT, Ilan Tal

Description Ilan Tal 2014-06-11 02:16:43 CDT
The latest Fiji update will get me shot by my Pet-Ct users.
http://sourceforge.net/p/bifijiplugins/wiki/Pet-Ct%20Viewer/

I have a startup macro which opens B&C among other things. It used to be that closing the Fiji window killed all the child windows and now the poor user needs to kill all the children manually. Please fix this ASAP.

It now also fails to remember the position of the Fiji window, which was also a very nice feature. For that one they won't kill me, but they won't be happy.

Thanks,
Ilan
Comment 1 Mark Hiner 2014-06-11 08:41:25 CDT
Hi Ilan,

 Side question - is your plugin on an update site? I saw update sites referenced in your readme, but don't see your plugin on http://fiji.sc/List_of_update_sites. It would be cool if you added it!

Anyway just wanted you to know that I was able to reproduce this, partially, and am looking into it now... on my end, when your startup macro ran, the B/C window closed but the postage stamp window did not. Moot point because even with vanilla Fiji, running B/C and closing caused Fiji to remain open even with the windows closed. So something definitely isn't being disposed properly.

>It now also fails to remember the position of the Fiji window, which was also a >very nice feature

Indeed, this is a bug with our wrapping of the ImageJ 1.x UI. Also looking into that now.
Comment 2 Ilan Tal 2014-06-11 09:14:49 CDT
Hi Mark,
I decided to try and see if I can add my software. I need a Fiji Wiki account.
I assume that isn't the same as the source forge wiki account for the help.
http://sourceforge.net/p/bifijiplugins/wiki/Main_Page/

If I can post debug messages, perhaps I already have a Fiji Wiki account?
What should I fill in the text box under Add Personal Site for Fiji Wiki account?
Presumably somebody has to authorize it as well?
Likewise, I'm not sure what URL to use - source forge, but what exactly?

Thanks,
Ilan
Comment 3 Jan Eglinger 2014-06-11 09:21:32 CDT
Hi Ilan,

you should be able to create a wiki account right from the Updater. See here:
http://fiji.sc/How_to_set_up_and_populate_an_update_site

Jan
Comment 4 Ilan Tal 2014-06-11 10:37:19 CDT
Created attachment 158
add
Comment 5 Ilan Tal 2014-06-11 10:38:56 CDT
Hi Jan,
I got to the Add Personal Site and only 1 text box isn't grayed out.
I'll include a screen shot.

Thanks,
Ilan
Comment 6 Mark Hiner 2014-06-11 10:39:53 CDT
Hi Ilan,

I just wanted you to know that the first part of this bug is resolved in our source code (not uploaded to Fiji yet). You can see the fix here: https://github.com/imagej/imagej-legacy/commit/b58a519ef48fba8c489e00d322938c5b0514730b and if you would like to test the new code before it's uploaded, it can be downloaded from: http://jenkins.imagej.net/job/ImageJ-legacy/lastSuccessfulBuild/artifact/target/imagej-legacy-0.5.10-SNAPSHOT.jar

However, I wanted to point out that this does not quite fix the problem for your plugin in particular. I was looking at your Read_CD plugin, for example, that's invoked by your startup macro. It pops a java.awt.Frame, but does not register itself with the ImageJ 1.x Window framework.

If a Window is not registered with the framework we simply can't close it via ImageJ2. It's not a problem in typical ImageJ 1.x use because it calls System.exit() when shutting down.. so it doesn't matter that the windows aren't actually closed.

I would suggest updating any of your windows that display to call ij.WindowManager.addWindow on themselves. This will ensure IJ1 knows about your windows, and then they will be properly closed by ImageJ2 on shutdown.

Also, I have had some issues registering for Wiki accounts via the updater before. So if that doesn't work for you, you can also sign up on the wiki: http://fiji.sc/index.php?title=Special:UserLogin&type=signup


On to Window locations!
Comment 7 Mark Hiner 2014-06-11 10:41:04 CDT
> I got to the Add Personal Site and only 1 text box isn't grayed out.

Note the bug listed here: http://fiji.sc/How_to_set_up_and_populate_an_update_site#Specifying_an_existing_Fiji_Wiki_account
Comment 8 Ilan Tal 2014-06-11 10:45:21 CDT
Hi Mark,
Thanks for your very speedy service. Read CD is under my control so I can implement whatever is needed - as with anything else under my control. However B&C (brightness - contrast) isn't mine and I have no control over it.

Thanks for telling me what I need to do to make my own programs close. I will certainly do what needs to be done.

Ilan
Comment 9 Mark Hiner 2014-06-11 11:07:46 CDT
No worries Ilan! Brightness/Contrast is part of the core ImageJ 1.x and it is registered in the WindowManager. So I did confirm that it is closed by my fix :) 

Thanks again for pointing out these issues, as they are really both critical problems.
Comment 10 Mark Hiner 2014-06-11 12:39:52 CDT
OK, as of https://github.com/imagej/imagej-legacy/commit/8bf1b175ffaa6fd512575fed6448c249c21c3cb3 the Fiji window should now restore its location properly.

These changes were uploaded to Fiji, so both of these issues should be fixed when you update.
Comment 11 Ilan Tal 2014-06-11 12:54:42 CDT
Many thanks Mark.
To save a bit of time, do you have an example of the code I need to add to make the modules known to ImageJ?

Ilan
Comment 12 Mark Hiner 2014-06-11 13:53:05 CDT
Ilan,

So there's a Read_CD.java that is a plugin, and in its run() method it displays itself right? (sorry, I just glanced at the .class files)

In that same run method, you should just have to call:

WindowManager.addWindow(this);

and that should register your window with ImageJ 1.x.

Then repeat with your other Window-based plugins (or extend a common abstract class, etc... as desired).

See the ContrastAdjuster for a concrete example:
https://github.com/imagej/ImageJA/blob/master/src/main/java/ij/plugin/frame/ContrastAdjuster.java#L85

Let me know if any of that is unclear!
Comment 13 Ilan Tal 2014-06-12 01:34:12 CDT
Hi Mark,
I want to thank you again for all your help. I downloaded the new software and it does indeed kill B&C and remember its last postion. Very nice...
However I'm still not quite there. I didn't want to bother you with my code since I thought it was my problem to get it to work and I shouldn't be taking your time and energy.
I added the WindowsManager.addWindow but that isn't enough. I got a bit of a laugh that it isn't just my problem. I tried to add my site, which I also can't get to fly, and that too stays around once Fiji has been killed. (Maybe this should be the case, but my gut feeling is that it should go away.)

I thought the key might be IJ.register(class) but that too isn't enough. I updated source forge so at least WindowManager.addWindow is there. IJ.register isn't on source forge. I thought it might be PlugInDialog so I tried that but the Fix Imports didn't know what to do with it - and neither do I.

I use NetBeans which is very nice at doing all the dialogs. I make a tiny part for the interface and do the rest with NetBeans.

public class Read_CD implements PlugIn {

	@Override
	public void run(String arg) {
		ReadCdStudies dlg = new ReadCdStudies(null, false);
		dlg.setVisible(true);
	}
}

The main part is

public class ReadCdStudies extends javax.swing.JDialog implements MouseListener {
	static final long serialVersionUID = ChoosePetCt.serialVersionUID;
	static final int TblPatName = 0;
	static final int TblStudy = 1;
	static final int TblDate = 2;
	static final int TblSeries = 3;
	static final int TblPatID = 4;
	static final int numFails = 5;	// 3 is boarderline, try 5

	/**
	 * Creates new form ReadCdStudies
	 * @param parent
	 * @param modal
	 */
	public ReadCdStudies(java.awt.Frame parent, boolean modal) {
		super(parent, modal);
		initComponents();
		WindowManager.addWindow(parent);
		init();
	}
	
	@SuppressWarnings("unchecked")
	private void init() {
		IJ.register(Read_CD.class);
		jPrefer = Preferences.userNodeForPackage(ReadCdStudies.class);
		jPrefer = jPrefer.node("biplugins");
		jCurrCD = jPrefer.getInt("current CD", 0);
......

For the IJ.register I tried both ReadCdStudies.class as well as the parent Read_CD.class. Neither is enough to make it die.

I now have an account on Fiji called ilan but I still can't add my site as only 1 text box is active, and the password is grayed out.

Thanks again,
Ilan
Comment 14 Ilan Tal 2014-06-12 01:41:47 CDT
I see the parent is null. I've got to find an object here...
Comment 15 Ilan Tal 2014-06-12 03:28:22 CDT
Hi Mark,
This seems to be non trivial. The constructor comes from the way I used NetBeans to create a new project. The Read_CD is certainly not a frame and ReadCdStudies is a JDialog and not a JFrame.
I still can't figure a way to get anything like a frame from a dialog so that addWindow will be happy.
What was magic about the old version that it had no problems killing all the children?

Ilan
Comment 16 Ilan Tal 2014-06-12 04:21:01 CDT
Hi Mark,
I found addWindow could take a window and not just a frame. I am using a very old version of ImageJ for debugging purposes and it didn't have the addWindow(Window win), so I fixed it.
In short now it is killing my dialog and the problem is solved.

Thanks,
Ilan
Comment 17 Mark Hiner 2014-06-12 07:05:56 CDT
Hi Ilan,

 That's great that you got it working! It's good to hear everything's working as intended now.

 As for the update site, yes there is an unfortunate bug with creating wiki sites through the updater, or logging in when your update site password (different from your Wiki account password) is not initialized.

 Log in to the fiji.sc wiki and go to this page: http://fiji.sc/Special:ChangeUploadPassword and set the password for "Your personal upload site".

 After you do this, go back to Fiji and go through http://fiji.sc/How_to_set_up_and_populate_an_update_site again, using your existing Fiji wiki account to log in.

 You should be able to upload files to your update site at that point, and then to publicize it you just need to edit http://fiji.sc/List_of_update_sites and add an entry for your site (alphabetically sorted).

Let me know if you run into any problems with these steps!

- Mark
Comment 18 Ilan Tal 2014-06-12 07:46:34 CDT
Hi Mark,
Apparently I don't understand something. I see most people use various sites and my users know my source forge site. It would be most convenient to just continue with the same site.
I get the impression that I'm supposed to upload to some new place? Huh?

I made a small page on Fiji just so something would be "initialized". Now I can add "My site", but that is a dumb name and I can't figure out how to change it to Pet-Ct or Beth Israel plugins or something else.

If my stuff remains on source forge can the user somehow specify which plugins he wants to download? Up until now I have been using a PluginsUpdater which Johannes wrote for me way back when. It takes a list of plugins to update. Each user can choose what he wishes.

So I need a more intelligent name for the site and the ability to point it to source forge.

Thanks again,
Ilan
Comment 19 Jan Eglinger 2014-06-12 08:04:11 CDT
Hi Ilan,

having used update sites myself, maybe I can clarify a bit:

- an ImageJ update site contains the up-to-date files for the plugins served via the site, and a file (db.xml.gz) storing information about all files served by the site, including previous versions.

- an update site can be any folder accessible via internet, where *you* can upload files via ssh, webdav or ftp, and where *any user* can download files via http(s)

- the Fiji wiki provides a comfortable, but not the only place to store update sites, have a look at http://fiji.sc/List_of_update_sites for examples using different URLs.

- an update site has nothing to do with a wiki page, it's just for convenience that the Fiji wiki account creation can also be used to create and populate an update site on sites.imagej.net

- if you want to host the update site (i.e. the folder containing db.xml.gz and the files) on your own server, you just need to provide the updater with appropriate shh/webdav logon credentials, and it will create an update site on that server.

If you feel that the description on the Fiji wiki does not sufficiently explain this, please feel free to edit the instructions,
http://fiji.sc/How_to_set_up_and_populate_an_update_site
using your newly created Fiji wiki account :)

Hth,
Jan
Comment 20 Ilan Tal 2014-06-15 01:15:54 CDT
Hi Jan and Mark,
I may not be able to publish my site on the Fiji list. I tried to use the Add button on the Manage update sites. I could edit the fields but it didn't like my URL. Source forge is very nice for open source programs but it may or may not have db.xml.gz. In any case the PluginUpdater which Johannes wrote for me way back when does a very nice job.
I tried to make the URL point to a help page and/or to the Files page but it wasn't happy with it.
Likewise the documentation requests to keep alphabetical ordering and there was no way I could control that. My attempt was at the bottom of the list. It wasn't clear to me if I was writing to only my local machine, or to a server. In any case I deleted my attempt as a failure. For the moment I don't know how to include my plugins in the list of known sites.

Thanks,
Ilan
Comment 21 Johannes Schindelin 2014-06-15 09:17:09 CDT
> I may not be able to publish my site on the Fiji list.

Ilan, would you mind creating a new ticket for that? It makes it much, much easier on this side to keep track of open issues and to find the correct one quickly when one has news to share.

It also correctly reflects how quickly we fix bugs (which you cannot see when people start adding new problems in the comment section of an already-addressed bug).