GWT Layout: "take up the rest of the space." - gwt

My existing layout is a stack of two divs - g:layers in a LayoutPanel. The top div should be as big as it needs to be to contain its contents. The bottom div should take up the rest of the space on the screen, without causing scrollbars to appear.
The contents of the top div can change, so the size of the top div can change.
My current solution is a callback that's triggered whenever the contents of the top div change. The containing LayoutPanel can then recalculate the size of the top div and explicitly set the top and bottom attributes of the second layer to take up the rest of the space. Is there a better way? Something like,
<g:LayoutPanel>
<g:layer top="0px" height="whatever you need, baby">
<c:SomeWidget/>
</g:layer>
<g:layer top="the bottom of the first layer" bottom="0px">
<c:Anotherwidget/>
</g:layer>
</g:LayoutPanel>

What about using DockLayoutPanel?
<g:DockLayoutPanel unit='PX'>
<north size="10" ui:field='northWidget'>
<c:SomeWidget/>
</north>
<center>
<c:Anotherwidget/>
</center>
</g:DockLayoutPanel>
Then the center will take up the rest of the space. If you want to resize the top, call
setWidgetSize(northWidget, newSize); and the center widget will be recalculated.

The answer seems to be that there is not a better way. Manual recalculation isn't so bad when you get used to it!

I think HeaderPanel is the standard Widget to do this. Maybe it was added after the question was asked. We missed it too and had our own version for a while.

Related

How to align controls vertically?

I have several elements on screen in XML file
<layout:VerticalLayout xmlns:layout="sap.ui.layout" xmlns="sap.m">
<Input />
<Button />
<!-- ... -->
</layout:VerticalLayout>
How can I add something like layout gravity or align the controls vertically? E.g. I want the elements in the center of the screen.
Since you're using the sap.m library anyway, I would recommend to use the sap.m.VBox control (or sap.m.HBox for horizontal layouts)
The VBox does exactly the same as the VerticalLayout and more (you can specify alignment, justification in a truly flexible way).
The VBox and HBox inherit from sap.m.FlexBox, see these examples on what you can do: https://sdk.openui5.org/entity/sap.m.FlexBox

DockLayoutPanel issues with text wrapping

So I am using a dock layout panel. In the north I have a title and menubar and center has a table. My problem is when the title gets long and wraps the text, it pushed the menubar down and you can no longer see it. This is because you have to set fixed sizes for all panels except center.
I thought about moving it all to center panel but the problem is that when my table gets big and a scroll bar appears I want to always see the header and menubar even when scrolling on the table. So I cant just put everything in scroll panel.
How can I create a layout that fills these requirements:
1. Always see the title and menubar
2. Scrollable table
3. When the window is resized and text from title wraps it resizes the whole thing correctly.
here is Layout right now:
<g:DockLayoutPanel >
<g:north size="80">
<g:VerticalPanel width="100%">
<g:HorizontalPanel width="100%">
<g:HTML ui:field="title" styleName="{style.title}"></g:HTML>
</g:HorizontalPanel>
<g:HorizontalPanel styleName="{style.infoBar}" width="100%">
<g:MenuBar animationEnabled="true" styleName="{res.css.menuBar}" focusOnHoverEnabled="false" ui:field="menuBar"></g:MenuBar>
</g:HorizontalPanel>
</g:VerticalPanel>
</g:north>
<g:center>
<g:ScrollPanel>
<g:SimplePanel ui:field="content" styleName="{style.content}">Table or tree goes here
</g:SimplePanel>
</g:ScrollPanel>
</g:center>
<g:south size="20">
<g:VerticalPanel styleName="{style.footerPanel}">
<g:HTML ui:field="messageBar">Fotter text here</g:HTML>
</g:VerticalPanel>
</g:south>
</g:DockLayoutPanel>
Have you tried to use two DockLayoutPanel?
The first has the title in the center area and in the south another DockLayoutPanel with the menu in the north area and the table in the center?
If title and menu may be shown underneath each other you can put title and menu in separate north-panels (that actually works).
With that you can at least ensure that the menu gets shown.

GWT:how to make tabPanel to 100% height

I am using TabPanel in my GWt application
<g:HTMLPanel>
<div class="center">
<g:TabLayoutPanel ui:field="tabPanel" barUnit="PX"
barHeight="40" width="100%;">
<g:tab>
<g:header>
DashBoard
</g:header>
</ g:TabLayoutPanel>
using this for my tabpanel height
.gwt-TabLayoutPanel {
min-height:500px;
}
its working fine , BUT i want this height to be 100%, But when I make it to 100% ,The whole TabPanel disappears ,
Any solution for that ..coz when my stuff hights increase , the lower are start cutting off ..
thanks
Put your TabLayoutPanel in a LayoutPanel or any other panel that provides size to its children. For example, if you put your panel directly into the RootLayoutPanel, it will take 100% of the screen automatically, and it will resize with the browser window.
The problem with 100% height is it will be 1px if the parent container does not have a height set.
You might find the following article intresting as a possible workarround.
http://www.tutwow.com/htmlcss/quick-tip-css-100-height/

Resizing Children in SplitLayoutPanel

I'm having an issue resizing the child widget inside a SplitLayoutPanel. I have a table in the South region of my layout. When I drag the splitter to increase the size the table doesn't resize. It stays at it's fixed height which causes white space under neath the table. When I shrink the South panel the table appears to "hide" behind the footer div image I have at the bottom of the Window. Is there a way to resize the table as the panel increases/decreases in size?
How I my South Panel is laid out. The "South" panel is real just the center panel filling out the rest of the space.
That center panel has a SimplePanel.
Attached to the SimplePanel is a LayoutPanel. I'm using that because there is a button bar above the table and SimplePanel only takes one Widget so I had to nest the widgets inside something else.
LayoutPanel's height and width are set to 100%
I'm guessing what needs to happen is the layout panel height needs to adjust. I'm not sure.
If need be I can post code. I'm also using the MVP/Activity/Places method
UPDATE
SplitLayoutPanel UI:
<g:SplitLayoutPanel>
<g:north size='250'>
. . .
</g:north size='250'>
<g:center>
<g:SimplePanel ui:field="south"/>
</g:center>
</g:SplitLayoutPanel>
Table Layout:
<g:LayoutPanel width="100%" height="100%">
<g:layer top='0px' height='125px'>
ButtonBar is here
</g:layer>
<g:layer top='30px' bottom='5px'>
<g:HorizontalPanel width="100%" height="100%">
<table:CustomTable height="500"/>
</g:HorizontalPanel>
</g:layer>
</g:LayoutPanel>
The Table Widget is placed into the center panel of the SplitLayoutPanel.

GWT questions. How to implement this kind of Tab Panel or Docklayout Panel

I have a complicated GWT question. Wish someone can give me some tips.
I want to create a panel that looks like in the following( content on the left, and some texts in the middle of the right side(tab), OR on the top of right side. (see the first picture)
Firstly, I considered the tab panel. but tap panel only has the horizontal tab on top. So this will not work unless I use third party libraries.
Then I tired the docklayoutpanel. but there is some problem as well. I put the content in mid, and put a label with some text in east. The height of the tab will be the same as the height of content. (see the 2nd picture). I dont like this. I dont want the white space shown up.
So does anyone have good idea about how to implement this kind of panel?
Thanks a lot.
Regards!
1st picture
|-------------------------|
|------- content ---------|---------|
|-------------------------|---tab---|
|-------------------------|---------|
| ------------------------|
2nd picture
|-------------------------|white space|
|------- content ---------|-----------|
|-------------------------|----tab----|
|-------------------------|-----------|
| ------------------------|white space|
Also, for the 2nd method, I tried to set the east area of docklayoutpanel to be transparent. But I did not know how to do this. and i am not sure if it will clean out the white space area.
Put the tabs in an "east" panel with height: 100%, and give it the background color you want. Put the main content in a "center" panel. Do not use "north" or "south".
If you want vertical centering for the tabs, then the easiest method is to use VerticalPanel with verticalAlignment="MIDDLE".
<ui:style>
.centerPanel { background-color: royalblue; }
.eastPanel { background-color: lightblue; width: 100%; height: 100%; }
</ui:style>
<g:DockLayoutPanel unit="EM">
<g:center>
<g:FlowPanel addStyleNames="{style.centerPanel}">
<g:Label>Content</g:Label>
</g:FlowPanel>
</g:center>
<g:east size="8">
<g:VerticalPanel addStyleNames="{style.eastPanel}"
verticalAlignment="MIDDLE">
<g:FlowPanel>
<g:Label>Tab1</g:Label>
<g:Label>Tab2</g:Label>
</g:FlowPanel>
</g:VerticalPanel>
</g:east>
</g:DockLayoutPanel>
The result looks like this: