final BorderLayoutData data = getLayoutData(c);
if (c instanceof CollapsePanel) {
final CollapsePanel collapse = (CollapsePanel) c;
final BorderLayoutData panelData = (BorderLayoutData) collapse.getContentPanel().getLayoutData();
SplitBar bar = collapse.getData("splitBar");
if (bar == null || bar.getTargetWidget() != c) {
bar = collapse.getSplitBar();
bar.setCollapsible(true);
c.setData("splitBar", bar);
if (panelData.isCollapseHidden()) {
collapse.collapseHidden();
}
bar.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
onExpandClick((CollapsePanel) c);
}
});
}
}
if (data.isCollapsible() && c instanceof ContentPanel && !c.isRendered()) {
final ContentPanel cp = (ContentPanel) c;
cp.setCollapsible(true);
cp.setHideCollapseTool(true);
IconConfig config = ToolButton.DOUBLELEFT;
switch (getRegion(cp)) {
case NORTH:
config = ToolButton.DOUBLEUP;
break;
case SOUTH:
config = ToolButton.DOUBLEDOWN;
break;
case EAST:
config = ToolButton.DOUBLERIGHT;
break;
}
cp.getHeader().addTool(new ToolButton(config, new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
cp.collapse();
}
}));
cp.addBeforeCollapseHandler(collapseHandler);
cp.addBeforeExpandHandler(collapseHandler);
}
if (data.isSplit()) {
SplitBar bar = c.getData("splitBar");
if (bar == null || bar.getTargetWidget() != c) {
bar = createSplitBar(c);
final SplitBar fbar = bar;
if (data.isCollapseMini()) {
bar.setCollapsible(true);
switch (getRegion(c)) {
case EAST:
bar.updateMini(Direction.RIGHT);
break;
case WEST:
bar.updateMini(Direction.LEFT);
break;
case NORTH:
bar.updateMini(Direction.UP);
break;
case SOUTH:
bar.updateMini(Direction.DOWN);
break;
}
}
if (data.isCollapseMini()) {
bar.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
((ContentPanel) c).collapse();
}
});
}
bar.addSplitBarDragHandler(new SplitBarDragHandler() {
@Override
public void onDragEvent(SplitBarDragEvent event) {
LayoutRegion region = getRegion(c);
if (event.isStart()) {
boolean side = region == LayoutRegion.WEST || region == LayoutRegion.EAST;
int size = side ? c.getOffsetWidth() : c.getOffsetHeight();
int centerSize = side ? lastCenter.getWidth() : lastCenter.getHeight();
fbar.setMinSize(data.getMinSize());
fbar.setMaxSize(Math.min(size + centerSize, data.getMaxSize()));
} else {
if (event.getSize() < 1) {
return;
}