open() and close() methods for DockableWidget
Brought to you by:
peastman
Hi,
There is no centralised place for handling the useful events of:
1. closing a DockableWidget (ie, making it go away from the UI
2. reopening a DockableWidget - preferably in the same locatin that is last occupied.
In addition there is no centralised code to work out if a DockableWidget is currently contained in a DockingContainer or a DetachedDockingContainer and handle closing a DockableWidget.
I've tested a few different solutions to this, and would suggest the attached as a good solution
modified DockableWidget.java with open() and close() methods
oops - it closed as soon as I attached a file...
The open() method checks to see if a previous docking location has been stored, and reopens the widget there, otherwise it creates a DetachedDockingContainer and opens the DockableWidget in that.
Similarly, the close() method looks to see if the DockableWidget is currently in a DetachedDockingContainer, in which case it closes it if it is the last one out - otherwise it stores the details of the current DockingContainer and removes itself.
The modified code also has a suggested fix for the issue I raised separately (as a bug) in which DockableWidget.remove() does not null out the 'content' field.
Cheers!
Nik
Updated DockableWidget.java
woops again - I omitted 3 lines in the original file - corrected in the update.
Cheers!
Nik
second update to suggested change
I've uploaded a further update to my suggested change.
It turns out there is an easier way to detect if the DockableWidget is currently in use (check getParent() !+ null),
so I've removed the code which removes the DockableWidget's content on close().
Cheers!
Nik