Browse files

Improve restoration of minimized panels

  • Loading branch information...
1 parent a8bdbfb commit faf9405a795051391bcac654f661eaee73320019 @manstis manstis committed Nov 9, 2012
View
60 ...re-workbench/src/main/java/org/uberfire/client/workbench/widgets/panels/PanelManager.java
@@ -329,27 +329,71 @@ private void onRestorePlaceEvent( @Observes RestorePlaceEvent event ) {
partToRestore.setMinimized( false );
- //TODO {manstis} Position needs to be looked up from model - will need "outer" panel feature :(
- if ( mapPanelDefinitionToPresenter.containsKey( panelToRestore ) ) {
- addWorkbenchPanel( root,
- panelToRestore,
- Position.SELF );
- } else {
- addWorkbenchPanel( root,
+ //Restore containing panel
+ if ( !mapPanelDefinitionToPresenter.containsKey( panelToRestore ) ) {
+ //TODO {manstis} Position needs to be looked up from model - will need "outer" panel feature :(
+ PanelDefinition targetPanel = findTargetPanel( panelToRestore,
+ root );
+ if ( targetPanel == null ) {
+ targetPanel = root;
+ }
+ addWorkbenchPanel( targetPanel,
panelToRestore,
panelToRestore.getPosition() );
}
+ //Restore part
final IsWidget widget = mapPartDefinitionToPresenter.get( partToRestore ).getPartView();
final IsWidget titleWidget = mapPartDefinitionToPresenter.get( partToRestore ).getTitleWidget();
-
addWorkbenchPart( partToRestore.getPlace(),
partToRestore,
panelToRestore,
titleWidget,
widget );
}
+ private PanelDefinition findTargetPanel( final PanelDefinition panelToFind,
+ final PanelDefinition panelToSearch ) {
+ final PanelDefinition northChild = panelToSearch.getChild( Position.NORTH );
+ final PanelDefinition southChild = panelToSearch.getChild( Position.SOUTH );
+ final PanelDefinition eastChild = panelToSearch.getChild( Position.EAST );
+ final PanelDefinition westChild = panelToSearch.getChild( Position.WEST );
+ PanelDefinition targetPanel = null;
+ if ( northChild != null ) {
+ if ( northChild.equals( panelToFind ) ) {
+ return panelToSearch;
+ } else {
+ targetPanel = findTargetPanel( panelToFind,
+ northChild );
+ }
+ }
+ if ( southChild != null ) {
+ if ( southChild.equals( panelToFind ) ) {
+ return panelToSearch;
+ } else {
+ targetPanel = findTargetPanel( panelToFind,
+ southChild );
+ }
+ }
+ if ( eastChild != null ) {
+ if ( eastChild.equals( panelToFind ) ) {
+ return panelToSearch;
+ } else {
+ targetPanel = findTargetPanel( panelToFind,
+ eastChild );
+ }
+ }
+ if ( westChild != null ) {
+ if ( westChild.equals( panelToFind ) ) {
+ return panelToSearch;
+ } else {
+ targetPanel = findTargetPanel( panelToFind,
+ westChild );
+ }
+ }
+ return targetPanel;
+ }
+
private PartDefinition getPartForPlace( final PlaceRequest place ) {
for ( PartDefinition part : mapPartDefinitionToPresenter.keySet() ) {
if ( part.getPlace().equals( place ) ) {

0 comments on commit faf9405

Please sign in to comment.