PDA

View Full Version : [FIXED] BorderLayoutContainer ContentPanel expand does not work if executed from code



raivis
21 Nov 2011, 1:43 AM
Hello. Just noticed, that if I set up BorderLayoutPanel and populate it with ContentPanel, then ContentPanel's collapse and expand will not work if i execute it from my own code (Toolbutton works as expected).
rev 1806



public class GxtModule implements EntryPoint {


@Override
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();


final BorderLayoutContainer blcMain = new BorderLayoutContainer();
blcMain.setBorders(true);


final ContentPanel cpCenter = new ContentPanel();
final ContentPanel cpSouth = new ContentPanel();


MarginData centerData = new MarginData();


BorderLayoutData southData = new BorderLayoutData(100);
southData.setMargins(new Margins(5));
southData.setCollapsible(true);
southData.setSplit(true);


blcMain.setCenterWidget(cpCenter, centerData);
blcMain.setSouthWidget(cpSouth, southData);


TextButton btExpander = new TextButton("Colapse/expand");
btExpander.addDomHandler(new ClickHandler() {


@Override
public void onClick(ClickEvent event) {
cpSouth.setExpanded(!cpSouth.isExpanded());
}
}, ClickEvent.getType());


cpCenter.add(btExpander);


blcMain.setWidth(500);
blcMain.setHeight(500);
rootPanel.add(blcMain);
}
}



I also noticed, that isExpanded always returns true regardless ContentPanel's state. After running this code ContentPanel is at first collapsed, but when I click the button second time I am getting exception that leads to:



...Caused by: java.lang.NullPointerException: null
at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.onCollapse(BorderLayoutContainer.java:599)
at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer$Handler.onBeforeCollapse(BorderLayoutContainer.java:228)
...


I also tried to use local boolean variable instead of isExpanded(). Exception does not get triggered but ContentPanel still remains collapsed.

Colin Alworth
30 Nov 2011, 2:42 PM
Thanks for the report, there is something wrong there, and we'll look into it.

Here is a workaround that should get you by for now:

@Override public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();


final BorderLayoutContainer blcMain = new BorderLayoutContainer();
blcMain.setBorders(true);


final ContentPanel cpCenter = new ContentPanel();
final ContentPanel cpSouth = new ContentPanel();


MarginData centerData = new MarginData();


BorderLayoutData southData = new BorderLayoutData(100);
southData.setMargins(new Margins(5));
southData.setCollapsible(true);
southData.setSplit(true);


blcMain.setCenterWidget(cpCenter, centerData);
blcMain.setSouthWidget(cpSouth, southData);


TextButton btExpander = new TextButton("Colapse/expand");
btExpander.addDomHandler(new ClickHandler() {
private boolean expanded = true;
@Override
public void onClick(ClickEvent event) {
Widget w = blcMain.getSouthWidget();
if (w instanceof CollapsePanel) {// collapsed, need to expand
expand((CollapsePanel) w);
} else {// w instanceof ContentPanel
((ContentPanel) w).collapse();
}
}
private native void expand(CollapsePanel w) /*-{
w.@com.sencha.gxt.widget.core.client.CollapsePanel::onExpandButton()();
}-*/;
}, ClickEvent.getType());


cpCenter.add(btExpander);


blcMain.setWidth(500);
blcMain.setHeight(500);
rootPanel.add(blcMain);
}

raivis
30 Nov 2011, 11:54 PM
Thanks for the workaround, it's working this way.

darrellmeyer
5 Dec 2011, 11:17 AM
This is fixed SVN (rev 1953). Change will go out in next release later this week.

darrellmeyer
12 Dec 2011, 6:57 PM
Fixed in beta 1.