PDA

View Full Version : Resizable ContentPanel in Window not Resizable when Window isMaximed



francescoNemesi
27 Jul 2009, 8:30 AM
Hi there,

My application contains Windows in TabItems. The Window is Maximizable and can contain one or more ContentPanel(s). The ContentPanel(s) are Resizable and Draggable. If the Window is Maximized, the children ContentPanels are still Draggable, but not Resizable anymore. The code below replicates this behavior.

Any ideas how I can keep the ContentPanels resizable even when the container Window is maximized?

Thanks,
F



import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.WindowEvent;
import com.extjs.gxt.ui.client.fx.Draggable;
import com.extjs.gxt.ui.client.fx.Resizable;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.AbsoluteLayout;
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.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class TestGXT2_0 implements EntryPoint{

public void onModuleLoad() {

Viewport viewport = new Viewport();

viewport.setLayout(new BorderLayout());

ContentPanel west = new ContentPanel();
west.addText("West");

ContentPanel center = new ContentPanel();
center.setLayout(new FitLayout());
center.setHeaderVisible(false);

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
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));

TabPanel tabPanel = new TabPanel();
tabPanel.setPlain(false);

final TabItem tabItem1 = new TabItem("Tab 1");
tabItem1.setLayout(new AbsoluteLayout());
tabItem1.setMonitorWindowResize(true);
tabItem1.setScrollMode(Scroll.AUTO);


tabItem1.addListener(Events.Render, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
tabItem1.add(createWindow(tabItem1));
}
});

tabPanel.add(tabItem1);

TabItem tabItem2 = new TabItem("Tab 2");
tabItem2.addText("Tab2");
tabPanel.add(tabItem2);

center.add(tabPanel);

viewport.add(west,westData);
viewport.add(center,centerData);
RootPanel.get().add(viewport);

}

private Window createWindow(final TabItem container) {

final Window w = new Window();
w.setContainer(container.getElement());
w.setHeight(400);
w.setWidth(600);
w.setMaximizable(true);
w.setDraggable(true);
w.setHeading("Maximizable Window");

((AbsoluteLayout)container.getLayout()).setPosition(w, 20, 20);

w.addListener(Events.Render, new Listener<WindowEvent>() {
public void handleEvent(WindowEvent be) {
Draggable draggable = w.getDraggable();
draggable.setUseProxy(true);
draggable.setContainer(container);
//w.maximize();

ContentPanel cp = new ContentPanel();
cp.setHeading("Not Resizable when container Window is maximized.");
cp.setHeight(250);
cp.setWidth(250);
Resizable resizable = new Resizable(cp);
Draggable dr = new Draggable(cp);
dr.setContainer(w);
w.add(cp);

}
});

return w;
}

}