From fa171eeb28dbdc81e755e24683bc2627f32b8f12 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 26 May 2016 12:17:36 +0000 Subject: [PATCH] Added code to calculate new height git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@128854 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../WorkspaceResourcesExplorerPanel.java | 58 ++++++++++++++----- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/explore/WorkspaceResourcesExplorerPanel.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/explore/WorkspaceResourcesExplorerPanel.java index b24fc00..62e279b 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/explore/WorkspaceResourcesExplorerPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/client/explore/WorkspaceResourcesExplorerPanel.java @@ -79,9 +79,11 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor if(height!=null && !height.isEmpty() && height.contains("px")){ String purgedHeight = height.replaceAll("px", ""); int heightToInt = Integer.parseInt(purgedHeight); - int newH = heightToInt-offsetBreadcrumb; - GWT.log("Set new height to center panel: "+newH); - wsExplorer.getPanel().setHeight(newH+"px"); + int nh = getNewHeightForContainer(heightToInt); + if(nh>0){ + GWT.log("Set new height to center panel: "+nh); + wsExplorer.getPanel().setHeight(nh+"px"); + } }else GWT.log("WorkspaceResourcesExplorerPanel read invalid height from parent!"); @@ -89,19 +91,6 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor } } - /** - * Sets the height to internal scroll. - * - * @param height the new height to internal scroll - */ - public void setHeightToInternalScroll(int height){ - if(height>0){ - int newH = height-offsetBreadcrumb; - GWT.log("Set new height to center panel: "+newH); - wsExplorer.getPanel().setHeight(newH+"px"); - } - } - /** * Instantiates a new workspace folder explorer panel. * @@ -315,6 +304,11 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor add(centerScrollable, DockPanel.CENTER); } + /** + * Gets the north panel height. + * + * @return the north panel height + */ public void getNorthPanelHeight(){ } @@ -496,4 +490,36 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor return showProperties; } + + + + /** + * Gets the new height for container. + * + * @param parentHeight the parent height + * @return the new height for container + */ + private int getNewHeightForContainer(int parentHeight){ + if(parentHeight>0){ + int bh = breadcrumbs.getHeight(); + bh = bh>offsetBreadcrumb?bh:offsetBreadcrumb; + if(parentHeight>bh) + return parentHeight-bh; + } + return -1; + } + + /** + * Sets the height to internal scroll. + * + * @param height the new height to internal scroll + */ + public void setHeightToInternalScroll(int height){ + + int nh = getNewHeightForContainer(height); + if(nh>0){ + GWT.log("Set new height to center panel: "+nh); + wsExplorer.getPanel().setHeight(nh+"px"); + } + } }