Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default [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)

    Code:
    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);
            }
        }
    }
    Regards

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Fixed in SVN.

  3. #3
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default


    Thx you Sven !

  4. #4
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      0  

    Default


    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).

Thread Participants: 2