PDA

View Full Version : [1.2.4] Collapsed ContentPanel in BorderLayout won't expand-Can't collapse pre render



The_Jackal
14 Apr 2009, 5:19 PM
I made a viewport with center and south panels. I set the south panel to be initially collapsed with southPanel.collapse(). The bug is that it can not be expanded.

Clicking on the expand button has no effect. Also note that the button is still in "expanded" state (image has arrows facing down).

The collapse method appears to have different behaviour if the ContentPanel is not rendered. Perhaps this causes the issue?

Environment: GWT 1.5, Hosted mode, FireFox and IE

The code to recreate:



public class ContentPanelBug implements EntryPoint
{
public void onModuleLoad()
{
ContentPanel centerPanel = new ContentPanel();
centerPanel.setHeading("Center Panel");

ContentPanel southPanel = new ContentPanel();
southPanel.setHeading("South Panel");

// This line causes the panel to be permanently collapsed - can not expand it
southPanel.collapse();

Viewport viewport = new Viewport();

final BorderLayout borderLayout = new BorderLayout();
viewport.setLayout(borderLayout);

BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(5, 0, 5, 0));

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
westData.setSplit(true);
westData.setCollapsible(true);
westData.setMargins(new Margins(5));

BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 50);
southData.setSplit(true);
southData.setCollapsible(true);
southData.setMargins(new Margins(0, 5, 5, 5));

viewport.add(centerPanel, centerData);
viewport.add(southPanel, southData);

RootPanel.get().add(viewport);
}
}
Note: if the southPanel.collapse() is moved to the last line (after the RootPanel call) then the panel is expandable but this is an inconvenient place to put it (for example if the view creation code is in another class).

gelgey
17 Jun 2009, 4:59 AM
Try calling borderLayout.collapse(LayoutRegion.SOUTH) instead of southPanel.collapse().

The_Jackal
18 Jun 2009, 9:50 PM
Thanks, but unfortunately you can only call this method after the BorderLayout has been rendered. I'd like to collapse the panel it before it's rendered - at BorderLayout creation time.

This but is still present in 1.2.4

Update: Note that I believe that the ContentPanel.collapse() method is broken when the content panel is not rendered (rendered == false). When used in a border layout the content panel is open, empty and can not be subsequently collapsed!

There is a hacky work around - set the ContentPanel's state to collapsed.

Map<String, Object> st = panel.getState();
st.put("collapsed", true);
panel.saveState();

Should this be what the collapse method does?

- Carl