I am trying to disable drag and drop of dockables into and out of the ScreenDockStation. My customer has requested that the externalize button must explicitly be pressed to move a dockable out of the main application frame, and the unexternalize button must be pressed to return the dockable to the application frame.
I was able to disable dragging out of the ScreenDockStation using the following code:
However, I have not found a way to disable drag and drop into the ScreenDockStation without disabling dockables from being accepted to that location at all via DockAcceptance. Any help would be appreciated.
DockAcceptance is probably not going to help, because a DockAcceptance is a very hard boundary. The “VetoableDockRelocatorListener” on the other hand is only called during drag and drop operations, and hence should be the right place to prevent unwanted drag and drop operations. The listener will not be triggered if the user clicks a button. The listener can suppress events from happening by calling “event.forbid”, in the example below we forbid any event that would change the “floating” state of a Dockable.
You could also use the VetoableDockRelocatorListener to find out when a drag and drop operation starts/stops, and enable/disable the DockAcceptance you already wrote. I guess the UI would look a bit better, because that would stop the framework from creating unwanted events in the first place. Calling “forbid” basically says to the framework “forget the last MouseEvent”, a DockAcceptance however says “do something else with the MouseEvent”, where “something else” could mean “select another parent for the Dockable”.