public Runnable onApply( LocationModeEvent event ){
if( event.isDone() )
return null;
Location location = event.getLocation();
Dockable dockable = event.getDockable();
DockableProperty property = location == null ? null : location.getLocation();
if( event.getMode().getUniqueIdentifier().equals( normalModeIdentifier() )){
// try to set the mode prematurely
if( property != null ){
if( property.getSuccessor() == null ){
CLocationMode last = manager.getCurrentMode( dockable );
CLocationMode secondLast = manager.getPreviousMode( dockable );
if( last != null && secondLast != null ){
if( normalModeIdentifier().equals( secondLast.getUniqueIdentifier() ) &&
MaximizedMode.IDENTIFIER.equals( last.getUniqueIdentifier() )){
MaximizedModeArea area = maximizedMode.get( location.getRoot() );
if( area == this ){
area.setMaximized( dockable, false, null, event.getAffected() );
event.done(true);
return null;
}
}
}
}
}
}
// if the element is about to become a child of this station, ensure
// this station does not show a maximized element
if( location != null && getMaximized() != null ){
Map<ExtendedMode, DockStation> roots = manager.getRepresentations( location.getRoot() );
for( DockStation station : roots.values() ){
if( DockUtilities.isAncestor( getStation(), station )){
maximizedMode.unmaximize( this, event.getAffected() );
break;
}