PDA

View Full Version : [Bug] beta4 problem with borderLayout in CardPanel



Webflash
5 Jun 2008, 4:14 AM
HostMode and WebMode Linux FireFox (I haven't IE)
Content of border layout not show only after resize window recalculate not help

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.CardPanel;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class GxtTest implements EntryPoint {

public void onModuleLoad() {
final CardPanel mainCardPanel = new CardPanel();

final Viewport viewPort = new Viewport();
final ContentPanel mainContentPanel = new ContentPanel();
mainContentPanel.setLayout(new FitLayout());

final ContentPanel borderPanel = new ContentPanel();
borderPanel.setLayout(new BorderLayout());

ContentPanel north = new ContentPanel();
ContentPanel west = new ContentPanel();
ContentPanel center = new ContentPanel();
ContentPanel east = new ContentPanel();
ContentPanel south = new ContentPanel();

BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH, 100);
northData.setSplit(true);
northData.setMargins(new Margins(5, 5, 0, 5));

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 200);
westData.setSplit(true);
westData.setCollapsible(true);
westData.setMargins(new Margins(5));

BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(5, 0, 5, 0));

BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 200);
eastData.setSplit(true);
eastData.setCollapsible(true);
eastData.setMargins(new Margins(5));

BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 100);
southData.setSplit(true);
southData.setMargins(new Margins(0, 5, 5, 5));

borderPanel.add(north, northData);
borderPanel.add(west, westData);
borderPanel.add(center, centerData);
borderPanel.add(east, eastData);
borderPanel.add(south, southData);

mainCardPanel.add(borderPanel);
mainContentPanel.add(mainCardPanel);

ToolBar toolBar = new ToolBar();
TextToolItem active = new TextToolItem("Active");
active.addSelectionListener(new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
mainCardPanel.setActiveItem(borderPanel);
borderPanel.recalculate();
mainCardPanel.recalculate();
mainContentPanel.recalculate();
viewPort.recalculate();
}
});
toolBar.add(active);
mainContentPanel.setTopComponent(toolBar);
viewPort.setLayout(new FitLayout());
viewPort.add(mainContentPanel);
RootPanel.get().add(viewPort);
}

}