int h = 0;
if (layoutData.collapse) {
if (northCollapsedImageButton == null) {
northCollapsedImageButton = new ImageButton(
Caption.IMAGES.toolCollapseDown());
northCollapsedImageButton.addStyleName("NorthCollapsedImageButton");
northCollapsedImageButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
layoutPanel.setCollapsed(northCollapsed, false);
layoutPanel.removeImpl(northCollapsedImageButton);
northCollapsedImageButton = null;
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(true);
}
northCollapsed.setVisible(true);
layoutPanel.layout();
return;
}
});
layoutPanel.addImpl(northCollapsedImageButton);
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(false);
}
northCollapsed = north;
north.setVisible(false);
}
h = WidgetHelper.getPreferredSize(northCollapsedImageButton).height;
WidgetHelper.setBounds(layoutPanel, northCollapsedImageButton, left,
top, Math.max(0, right - left), h);
} else {
if (layoutData.preferredSize == -1.0) {
h = WidgetHelper.getPreferredSize(north).height;
runTwiceFlag = true;
} else if (layoutData.preferredSize > 0.0
&& layoutData.preferredSize <= 1.0) {
h = (int) (height * layoutData.preferredSize);
} else {
h = (int) layoutData.preferredSize;
}
int _width = Math.max(0, right - left);
int _height = -1;
if (layoutData.preferredSize != -1.0) {
_height = h;
}
if (layoutData.hasDecoratorPanel()) {
final Dimension decPanelBorderSize = getDecoratorFrameSize(
layoutData.decoratorPanel, north);
_width -= decPanelBorderSize.width;
// increase 'h'
h += decPanelBorderSize.height;
}
WidgetHelper.setBounds(layoutPanel, north, left, top, _width, _height);
// split bar
if (layoutData.resizable && northSplitBar.isAttached()) {
WidgetHelper.setBounds(layoutPanel, northSplitBar, left, top + h,
Math.max(0, right - left), spacing);
}
}
top += (h + spacing);
}
if (south != null) {
final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(south);
if (layoutData.resizable && !layoutData.collapse) {
if (southSplitBar == null) {
southSplitBar = new SplitBar(layoutPanel, south, SplitBar.SOUTH);
southSplitBar.setStyleName("SouthSplitBar");
layoutPanel.addImpl(southSplitBar);
}
} else {
if (southSplitBar != null) {
layoutPanel.removeImpl(southSplitBar);
southSplitBar = null;
}
}
int h = 0;
if (layoutData.collapse) {
if (southCollapsedImageButton == null) {
southCollapsedImageButton = new ImageButton(
Caption.IMAGES.toolCollapseUp());
southCollapsedImageButton.addStyleName("SouthCollapsedImageButton");
southCollapsedImageButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
layoutPanel.setCollapsed(southCollapsed, false);
layoutPanel.removeImpl(southCollapsedImageButton);
southCollapsedImageButton = null;
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(true);
}
southCollapsed.setVisible(true);
layoutPanel.layout();
return;
}
});
layoutPanel.addImpl(southCollapsedImageButton);
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(false);
}
southCollapsed = south;
south.setVisible(false);
}
h = WidgetHelper.getPreferredSize(southCollapsedImageButton).height;
WidgetHelper.setBounds(layoutPanel, southCollapsedImageButton, left,
Math.max(0, bottom - h), Math.max(0, right - left), h);
} else {
if (layoutData.preferredSize == -1.0) {
h = WidgetHelper.getPreferredSize(south).height;
runTwiceFlag = true;
} else if (layoutData.preferredSize > 0.0
&& layoutData.preferredSize <= 1.0) {
h = (int) (height * layoutData.preferredSize);
} else {
h = (int) layoutData.preferredSize;
}
int _width = Math.max(0, right - left);
int _top = Math.max(0, bottom - h);
int _height = -1;
if (layoutData.preferredSize != -1.0) {
_height = h;
}
if (layoutData.hasDecoratorPanel()) {
final Dimension decPanelBorderSize = getDecoratorFrameSize(
layoutData.decoratorPanel, south);
_width -= decPanelBorderSize.width;
_top -= decPanelBorderSize.height;
// increase 'h'
h += decPanelBorderSize.height;
}
WidgetHelper.setBounds(layoutPanel, south, left, _top, _width,
_height);
// split bar
if (layoutData.resizable && southSplitBar.isAttached()) {
WidgetHelper.setBounds(layoutPanel, southSplitBar, left, Math.max(
0, bottom - h)
- spacing, Math.max(0, right - left), spacing);
}
}
bottom -= (h + spacing);
}
if (west != null) {
final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(west);
if (layoutData.resizable && !layoutData.collapse) {
if (westSplitBar == null) {
westSplitBar = new SplitBar(layoutPanel, west, SplitBar.WEST);
westSplitBar.setStyleName("WestSplitBar");
layoutPanel.addImpl(westSplitBar);
}
} else {
if (westSplitBar != null) {
layoutPanel.removeImpl(westSplitBar);
westSplitBar = null;
}
}
int w = 0;
if (layoutData.collapse) {
if (westCollapsedImageButton == null) {
westCollapsedImageButton = new ImageButton(
Caption.IMAGES.toolCollapseRight());
westCollapsedImageButton.addStyleName("WestCollapsedImageButton");
westCollapsedImageButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
layoutPanel.setCollapsed(westCollapsed, false);
layoutPanel.removeImpl(westCollapsedImageButton);
westCollapsedImageButton = null;
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(true);
}
westCollapsed.setVisible(true);
layoutPanel.layout();
return;
}
});
layoutPanel.addImpl(westCollapsedImageButton);
if (layoutData.hasDecoratorPanel()) {
layoutData.decoratorPanel.setVisible(false);
}
westCollapsed = west;
west.setVisible(false);
}
w = WidgetHelper.getPreferredSize(westCollapsedImageButton).width;
WidgetHelper.setBounds(layoutPanel, westCollapsedImageButton, left,
top, w, Math.max(0, bottom - top));
} else {
if (layoutData.preferredSize == -1.0) {
w = WidgetHelper.getPreferredSize(west).width;
runTwiceFlag = true;
} else if (layoutData.preferredSize > 0.0
&& layoutData.preferredSize <= 1.0) {
w = (int) (width * layoutData.preferredSize);
} else {
w = (int) layoutData.preferredSize;
}
int _width = -1;
if (layoutData.preferredSize != -1.0) {
_width = w;
}
int _height = Math.max(0, bottom - top);
if (layoutData.hasDecoratorPanel()) {
final Dimension decPanelBorderSize = getDecoratorFrameSize(
layoutData.decoratorPanel, west);
_height -= decPanelBorderSize.height;
// increase 'w'
w += decPanelBorderSize.width;
}
WidgetHelper.setBounds(layoutPanel, west, left, top, _width, _height);
// split bar
if (layoutData.resizable && westSplitBar.isAttached()) {
WidgetHelper.setBounds(layoutPanel, westSplitBar, left + w, top,
spacing, Math.max(0, bottom - top));
}
}
left += (w + spacing);
}
if (east != null) {
final BorderLayoutData layoutData = (BorderLayoutData) getLayoutData(east);
if (layoutData.resizable && !layoutData.collapse) {
if (eastSplitBar == null) {
eastSplitBar = new SplitBar(layoutPanel, east, SplitBar.EAST);
eastSplitBar.setStyleName("EastSplitBar");
layoutPanel.addImpl(eastSplitBar);
}
} else {
if (eastSplitBar != null) {
layoutPanel.removeImpl(eastSplitBar);
eastSplitBar = null;
}
}
int w = 0;
if (layoutData.collapse) {
if (eastCollapsedImageButton == null) {
eastCollapsedImageButton = new ImageButton(
Caption.IMAGES.toolCollapseLeft());
eastCollapsedImageButton.addStyleName("EastCollapsedImageButton");
eastCollapsedImageButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
layoutPanel.setCollapsed(eastCollapsed, false);