-
22 Jul 2009 5:05 AM #1
[FNR] [2.0] Event Close not fired when Closing TabItem
[FNR] [2.0] Event Close not fired when Closing TabItem
Hi,
I've just find an issue in the TabItem class: When closing the TabItem programmatically (using the close method), the Close Event isn't fired whereas using the closing-cross the event is well fired.
Here the snippet code (I took the AdvancePanel example, and i just add a new button, and the listener in the addTabMethod)
RegardsCode:package com.test.client; import com.extjs.gxt.ui.client.event.BaseEvent; import com.extjs.gxt.ui.client.event.ButtonEvent; import com.extjs.gxt.ui.client.event.Events; import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.widget.HorizontalPanel; import com.extjs.gxt.ui.client.widget.Info; import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.TabItem; import com.extjs.gxt.ui.client.widget.TabPanel; import com.extjs.gxt.ui.client.widget.VerticalPanel; import com.extjs.gxt.ui.client.widget.button.Button; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; /* * * Entry point classes define <code>onModuleLoad()</code>. */ public class Test implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { RootPanel.get().add(new AdvancedTabExample()); } public class AdvancedTabExample extends LayoutContainer { private int index = 0; private TabPanel advanced; public AdvancedTabExample() { VerticalPanel vp = new VerticalPanel(); vp.setSpacing(10); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(5); Button add = new Button("Add Tab"); add.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { addTab(); advanced.setSelection(advanced.getItem(index - 1)); } }); hp.add(add); Button close = new Button("Close Selected Item"); close.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { advanced.getSelectedItem().close(); } }); hp.add(close); vp.add(hp); advanced = new TabPanel(); advanced.setSize(600, 250); advanced.setMinTabWidth(115); advanced.setResizeTabs(true); advanced.setAnimScroll(true); advanced.setTabScroll(true); advanced.setCloseContextMenu(true); while (index < 7) { addTab(); } advanced.setSelection(advanced.getItem(6)); vp.add(advanced); add(vp); } private void addTab() { final TabItem item = new TabItem(); item.addListener(Events.Close, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { Info.display("Item Closed", "Item : " + item.getText() + " Closed"); }; }); item.setText("New Tab " + ++index); item.setClosable(index != 1); item.addText("Tab Body " + index); item.addStyleName("pad-text"); advanced.add(item); } } }
-
22 Jul 2009 5:59 AM #2
-
22 Jul 2009 6:03 AM #3
-
13 Oct 2009 6:25 AM #4
sven, if i call tabitem.close() those events get fired. If i call tabpanel.remove(tabitem) the events are not getting fired. But javadoc on this method says so.
If you change the code that the events are also fired if you call tabpanel.remove(tabitem), then please add a possibility to turn off fire events. If you just adjust the javadoc, then this it is maybe not really nice, but does its job (for me).
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote