When i use this code i am almost satisfied but instead of closing the dockable, when I close the Window. I would like to reintegrate it in the Station. The same way as the “internalize action” (CTRL+N).
I tried to use .drop on the station but that way the position is not as expected.
There are two simple solutions. In both cases you will need to modify the WindowListener from the other example to get the Dockable whose dialog is closed.
1.
The nice solution, call “action” with the dockable of the dialog:
public void action( Dockable dockable ) {
while( dockable != null ){
if( dockable instanceof CommonDockable ){
action( ((CommonDockable)dockable).getDockable() );
return;
}
DockStation station = dockable.asDockStation();
if( station == null ){
return;
}
else{
dockable = station.getFrontDockable();
}
}
}
public void action( CDockable dockable ){
dockable.setExtendedMode( ExtendedMode.NORMALIZED );
}```
**2.**
Or if you like a hack more you can create the "normalize action" (ctrl+N) and trigger it from the application. Like this:
// ‘control’ is the CControl of your application.
CNormalizeAction normalize = new CNormalizeAction( control );
// The method calls ‘bind’ and ‘unbind’ are not necessary for this specific action. But in general
// you would need to bind/unbind an action before/after using it.
// normalize.intern().bind( dockable ); // not needed in this example
normalize.intern().action( dockable ); // this is like calling ctrl+N
// normalize.intern().unbind( dockable ); // not needed in this example
I already had an Idea in the direction as your first solution. But i had the problem, that i didn’t knew how to obtain the CDockable from the Dockable.