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(panelData.isCollapseMini());
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;
case WEST:
case CENTER:
// do nothing
}
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;
bar.setCollapsible(data.isCollapseMini());
if (data.isCollapseMini()) {
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;
case CENTER:
// do nothing
}
bar.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
if (c instanceof Collapsible) {
((Collapsible) 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;
}