mtarantini
22 Jul 2009, 5:05 AM
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)
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
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)
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