PDA

View Full Version : [FIXED] TabPanel + Drag&Drop



Canto
26 Apr 2008, 1:56 AM
When closing tab that have d&d ContentPanel this ContentPanel doesn't die and it's still visible in previous tab (or in blank space if no tab are left). Panel isn't active, you cannot drag, collapse it but you can select text.




public class Platnosci extends Container implements EntryPoint {

RootPanel rootPanel = RootPanel.get();

public void onModuleLoad() {
rootPanel.add(this);
}

public void onRender(Element parent, int pos) {
super.onRender(parent, pos);

TabPanel tabPanel = new TabPanel();
tabPanel.enableTabScroll = true;
tabPanel.setWidth(600);

for (int i = 0; i < 5; i++) {
TabItem tab = new TabItem();
Date date = new Date();
tab.setText(date.toLocaleString().replaceFirst(
"\\d\\d:\\d\\d:\\d\\d", ""));
tab.closable = true;
tab.setHeight("100%");
HorizontalPanel hp = new HorizontalPanel();
ContentPanel cp = new ContentPanel();
cp.setHeading("lorem ipsum blah balh blah");
cp.collapsed = true;
cp.collapsible = true;
cp.draggable = true;
Draggable d = new Draggable(cp);
d.container = MainPanel.tabPanel;
hp.add(cp);
tab.add(hp);
tabPanel.add(tab);
}
rootPanel.add(tabPanel);
}
}
You can ommit HorizontalPanel the effect is still the same.
Problem seems to exists only when closing active(selected) tab.

darrellmeyer
27 Apr 2008, 11:03 AM
Thanks for the code sample, it really helps. There was a bug when closing tabs which was noticable when closing the last tab. The fix is in SVN. Here is what the code looks like with the current code:

for (int i = 0; i < 2; i++) {
TabItem tab = new TabItem();
tab.setText("test");
tab.setClosable(true);
tab.setHeight("100%");
HorizontalPanel hp = new HorizontalPanel();
ContentPanel cp = new ContentPanel();
cp.setHeading("lorem ipsum blah balh blah");
cp.setCollapsible(true);
cp.collapse();

Draggable d = new Draggable(cp);
d.container = tabPanel;
hp.add(cp);
tab.add(hp);
tabPanel.add(tab);
}