LayoutRegion region = getRegion(panel);
BorderLayoutData data = (BorderLayoutData) getLayoutData(panel);
remove(panel);
CollapsePanel cp = (CollapsePanel) panel.getData("collapse");
if (cp == null) {
cp = createCollapsePanel(panel, data, region);
BorderLayoutData collapseData = new BorderLayoutData();
collapseData.setSize(data.isCollapseHidden() ? 0 : 24);
Margins m = data.getMargins();
if (m == null) {
m = new Margins();
data.setMargins(m);
}
collapseData.setMargins(new Margins(m.getTop(), m.getRight(), m.getBottom(), m.getLeft()));
if (data.isCollapseHidden()) {
cp.collapseHidden();
collapseData.setSize(0);
switch (region) {
case WEST:
collapseData.getMargins().setLeft(0);
break;
case EAST:
collapseData.getMargins().setRight(0);
break;
case NORTH:
collapseData.getMargins().setTop(0);
break;
case SOUTH:
collapseData.getMargins().setBottom(0);
break;
case CENTER:
// do nothing
}
}
cp.setLayoutData(collapseData);
cp.setData("panel", panel);
panel.setData("collapse", cp);
}
cp.clearSizeCache();
setCollapsed(panel, true);
switch (region) {
case WEST: