SplitPanel auto height after setting content

Hi !

I work on a modal window and I try to make a splitpanel height auto-resizeable regarding its content, that changes “on the fly”.

The modal window is containing a TabSheet, with many tabs. On other tabs I am able to adjust the height regarding each tab content, using an undefined height. But this doesn’t work with the tab containing the splitPanel.

This is the modal window constructor :


public ModalWindow() {
        setWidth(500, UNITS_PIXELS);
	VerticalLayout layout = (VerticalLayout) getContent();
	layout.setWidth(100, UNITS_PERCENTAGE);

	contentTab = new TabSheet();
	contentTab.setSizeFull();
        layout.addComponent(contentTab);
	layout.setExpandRatio(contentTab, 1.0f);

	close = new Button("Close",
				new Button.ClickListener() {
					@Override
					public void buttonClick(ClickEvent event) {
						getParent().removeWindow(ModalWindow.this);
					}
				});
	layout.addComponent(close);
	layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
   [...]

}

This is the Tab which causes issues (extends VerticalLayout) :


public SplitPanelTab() {
		setWidth(100, UNITS_PERCENTAGE);
		setSpacing(true);
		setMargin(true);

		basePanel = new HorizontalSplitPanel();
                // tried this because constructor set size to 100%
		basePanel.setHeight(-1, UNITS_PIXELS);
                //
		basePanel.setSplitPosition(25);

                //this generates a tree which is displayed left on the panel
		tree = generateTree();

		basePanel.addComponent(tree);

		addComponent(basePanel);
		setExpandRatio(basePanel, 1.0f);

The idea of the SplitPanel is to select one item in the tree on the left side, and display a form on the right. What I want is the panel to resize its height regarding the content displayed on the right. This is what I call after selecting a tree node :


if (basePanel.getSecondComponent() != null) {
	basePanel.removeComponent(basePanel.getSecondComponent());
}
XForm myForm= new XForm();
basePanel.addComponent(resourceMetadataForm);

Is there any hope to do that ? I am not so familiar with Vaadin layouts but maybe I took a wrong path here ?

thanks.

I found a start of answer
here

I tried to fix the panel height with the form height but this does not work.

Hi,

As Jouni said in the last post of the discussion you linked: SplitPanel doesn’t currently support undefined sizes. If you need to be able to reposition the splitter you must define a height. One workaround that would mean that you cannot reposition the splitter would be to use a HorizontalLayout instead. If you like you can add the splitter image between the two sides of the view e.g. by using a Label with XHTML content.

HTH,
/Jonatan

Thanks Jonatan. Indeed my panel didn’t need to be resizeable so I used a HorizontalLayout to display my form next to the tree.