PDA

View Full Version : TabItem.setClosable doesn't have effect post-render



maniac
30 Oct 2009, 1:33 AM
Hi,

I have some TabItems in my TabPanel I want to call setClosable for after rendering (use case is that I want the last tab of the panel to be non-closable). With TabItem's current implementation, that doesn't seem to have any effect.

My current workaround is subclassing TabItem and TabItem.HeaderItem to add or remove the x-tab-strip-closable style on calling setClosable(), like this:



private class ContentTabItem extends TabItem {
public class ContentHeaderItem extends TabItem.HeaderItem {
public void setClosable(boolean closable) {
if (rendered) {
removeStyleName("x-tab-strip-closable");
if (closable) {
addStyleName("x-tab-strip-closable");
}
}
}
}

public ContentTabItem(String label) {
header = new ContentHeaderItem();
setText(label);
}

@Override
public void setClosable(boolean closable) {
super.setClosable(closable);
((ContentHeaderItem) header).setClosable(closable);
}
}
However, I think this should be fixed at the Gxt level (directly in TabItem.HeaderItem). What do you think?

sven
30 Oct 2009, 1:35 AM
This is not a bug but a feature request. Moving this to the correct forum.