Castro
11 Aug 2009, 5:50 AM
Hello..
I have a problem when closing a TabItem. I close a TabItem but I have a confirmation message. when I click on the yes, closes the TabItem ,when I click no, the TabItem keeps active.
Source code I'm using:
TabPanel tab = new TabPanel();
TabItem item = new TabItem("Tab Test");
item.setLayout(new FitLayout());
item.setClosable(true);
tab.add(item);
item.addListener(Events.BeforeClose, new Listener<TabPanelEvent>() {
public void handleEvent(TabPanelEvent be) {
be.setCancelled(true);
buttonBar.add(new Button("Yes/No/Cancel", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
MessageBox box = new MessageBox();
box.setButtons(MessageBox.YESNOCANCEL);
box.setIcon(MessageBox.QUESTION);
box.setTitle("Close Tab");
box.setMessage("Close Tab?");
box.getButtonById(Dialog.YES).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
be.setCancelled(false);
}
});
box.show();
}
}));
However with this approach the TabItem doesn't close.
If anybody have a solution, please help me...
I have a problem when closing a TabItem. I close a TabItem but I have a confirmation message. when I click on the yes, closes the TabItem ,when I click no, the TabItem keeps active.
Source code I'm using:
TabPanel tab = new TabPanel();
TabItem item = new TabItem("Tab Test");
item.setLayout(new FitLayout());
item.setClosable(true);
tab.add(item);
item.addListener(Events.BeforeClose, new Listener<TabPanelEvent>() {
public void handleEvent(TabPanelEvent be) {
be.setCancelled(true);
buttonBar.add(new Button("Yes/No/Cancel", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
MessageBox box = new MessageBox();
box.setButtons(MessageBox.YESNOCANCEL);
box.setIcon(MessageBox.QUESTION);
box.setTitle("Close Tab");
box.setMessage("Close Tab?");
box.getButtonById(Dialog.YES).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
be.setCancelled(false);
}
});
box.show();
}
}));
However with this approach the TabItem doesn't close.
If anybody have a solution, please help me...