automatic resize of the tab panel based on contents - gwt

Hello I have implemented something like
private VerticalPanel resultPanel;
private TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
ResizeLayoutPanel resizePanel = new ResizeLayoutPanel();
myMethod(){
resizePanel.setWidth("100%");
resizePanel.setHeight("415px");
resizePanel.setWidget(tabPanel);
resultPanel = new VerticalPanel();
resultPanel.setWidth("100%");
resultPanel.add(resizePanel);
tabPanel.add(myVerticalPanel, tabHeader);
}
so the myVerticalPanel is the actual contents which is little large in height. As resizePanel height is set to 415px so rest of the contents are hidden.
I am looking for two things to achieve:
1. If there is a larger screen available then increase the tabPanel area to show more contents automatically
2. If screen is small then a scroll to appear to see rest of the contents
Please advise

You can try to replace the TabLayoutPanel with a HeaderPanel:
A panel that includes a header (top), footer (bottom), and content
(middle) area. The header and footer areas resize naturally. The
content area is allocated all of the remaining space between the
header and footer area.
Alternatively you can override the onResize() method your ResizeLayoutPanel calculate the height of your embedded content and set the appropriate height.
If you want scrolling functionality you have to embed your VerticalPanel in a ScrollPanel or use CSS to set the oferflow property.

Related

ScrolledComposite showing two scrollbars each for vertical & horizontal scroll

My current application is a RCP application using eclipse framework. There is a view whose composite is given to a Scrolled Composite and then all the relevant composites are made with the ScrolledComposite as the parent.
protected void createContent(Composite parent)
{
ScrolledComposite form = new ScrolledForm(parent,SWT.H_SCROLL|SWT.V_SCROLL);
GridLayout layout = new GridLayout(1, false);
form.getBody().setLayout(layout);
......................
.........................
}
The issue is that at times there are two vertical and two horizontal scrollbars visible. One is of the main view and the second is for the ScrolledComposite.
I have implemented a ResizeListener that will change the MinSize of the SCrolledLayout dynamically.
Rectangle rect = form.getClientArea();
form.setMinSize(SWT.DEFAULT,SWT.DEFAULT);
However Still at times there are two Scrollbars visible but they are of no use and they look annoying. So Since the scrollbars are of no use I am disabling them in the ResizeListener itself.
Rectangle rect = form.getClientArea();
form.getHorizontalBar().setVisible(false);
form.getVerticalBar().setVisible(false);
form.setMinSize(SWT.DEFAULT,SWT.DEFAULT);
Is there a better way to do this or am I goofing up somewhere.

How to Change the cursor in JavaFX Accordion title bar

I'm using custom cursors and it need to be differ in some components in my screen.
When I set the cursor for Accordion, it doesn't effects title headers but effects the body of each TitledPanes. I even tried to set the cursor for each TitledPane but it doesn't effect the title header. I'm using following way to change the cursor.
ImageCursor cursor_title = new ImageCursor(cursorImg_title,cursorImg_title.getWidth() / 2,cursorImg_title.getHeight() / 2);
accordionBody.setCursor(cursor_title);
Is there a way to change the cursor in title bar of a JavaFX Accordian?
More....
I have changed the padding of title bars using css as follows. Hope it doesn't have any relation to the problem.
.titled-pane > .title {
-fx-padding: 30;
}
A TitledPane is divided into two parts :
Title
Content
When you are setting the Cursor on the Accordion, it delegates it to the content of each TitledPane, but leaves the Title. This is by design.
To force your application to change the cursor on the title as well, we need to set it on each of these nodes. We can fetch all the nodes by using the lookupAll() on the accordion and passing the styleclass they use i.e. .title. Make sure you use this after the scene graph is visible.
accordion.lookupAll(".title").forEach(node -> node.setCursor(Cursor.CLOSED_HAND));
You can use your custom cursor in place of CLOSED_HAND.

How to create the Horizontal ScrollBar at the bottom of DataGrid as in GWT CellSampler example?

I like DataGrid since it has fixed header so wen user scrolldown they are still be able to see the column header.
However, if there are too many columns then the DataGrid will manage to fit all columns within the Fixed Width of the widget that contain it.
For example, if a 30 column DataGrid was put inside a center (with 100px) of a DockLayoutPanel then all 30 columns will be divided evenly within 100px, which is make it unreadable cos the with of each column is too small.
So, I would love to use DataGrid but the DataGrid should have a Horizontal ScrollBar at the bottom so if there are many column then the user can just scroll horizontally to the right to see the data.
If we do correctly, then it should be like the GWT CellSampler example http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCellSampler
Clearly, the CellSampler used DataGid, but I didn't see any Horizontal ScrollBar code in there.
So how to make DataGrid to display as in the CellSampler example?
You should set the minimum width for your DataGrid:
myDataGrid.setMinimumTableWidth(600, Unit.PX);
I have done following for My Table Datagrid.
FlowPanel tablePanel = new FlowPanel();
tablePanel.add( table );
tablePanel.getElement().setAttribute( "style",
"overflow-x: auto;width: " + ( Window.getClientWidth() - 37 ) + "px;clear: both" );
add( tablePanel );

Display SimplePager Pagination menu both at the top and bottom of the data

I have some data that I'm displaying in a CellTable which is inside a SimplePager. The pagination navigation options are shown in the bottom, I was wondering if it would be possible to show these on the top as well as the bottom of the data.
I want to do this because depending on the browser size, the user may not be able to see the controls.
I want the navigation controls to show both before and after the table data.
Yes, just add two pagers:
final AbstractPager pager = new SimplePager();
pager.setDisplay(cellTable);
contentPanel.add(pager);
contentPanel.add(cellTable);
final AbstractPager pager2 = new SimplePager();
pager2.setDisplay(cellTable);
contentPanel.add(pager2);
The pager shows on top if you add pager before adding celltable in layout.
CellTable table=new CellTable();
VerticalPanel containerPanel = new VerticalPanel();
SimplePager pager1 = new SimplePager(TextLocation.CENTER);
containerPanel.add(pager);
containerPanel.add(table);
SimplePager pager2 = new SimplePager(TextLocation.CENTER)
containerPanel.add(pager2)
Thus, you have to create two pager and add celltable in between of those.

fill entire area of tabhost tab with listview programmatically

Is it possible to directly fill a tabhost tab with a listview directly, or should the listview be placed on a panel first. Also, how/what sytax do I use to get the content on the tab to be 100%x and 100%y programmatically?
So in other words - a Tab with a listview on it, but the listview takes up 100%x of the tab, and all of the open space for y (except for the tabs)
Currently each tab is an empty layout file. I want to place content on the layout strictly programmatically if possible.
The above code will add a ListView to a TabHost, the ListView will fill the tab:
Dim tb As TabHost
tb.Initialize("")
Dim lv As ListView
lv.Initialize("")
For i = 0 To 10
lv.AddSingleLine("Item #" & i)
Next
tb.AddTab2("Tab1", lv)
activity.AddView(tb, 0, 0, 300dip, 300dip)