}
}
public void handleEvent(Event evt)
{
ItsNatEventDOMStateless itsNatEvt = (ItsNatEventDOMStateless)evt;
String action = (String)itsNatEvt.getExtraParam("action");
try
{
if ("remove".equals(action))
{
DefaultListModel dataModel = (DefaultListModel)listComp.getListModel();
ListSelectionModel selModel = listComp.getListSelectionModel();
if (!selModel.isSelectionEmpty())
{
// Selection Model is in SINGLE_INTERVAL_SELECTION mode
int min = selModel.getMinSelectionIndex();
int max = selModel.getMaxSelectionIndex();
dataModel.removeRange(min,max);
}
else
{
itsNatDoc.addCodeToSend("alert('None selected');");
}
}
else if ("select".equals(action))
{
ListSelectionModel selModel = listComp.getListSelectionModel();
boolean selected = Boolean.valueOf((String)itsNatEvt.getExtraParam("selected"));
int index = Integer.parseInt((String)itsNatEvt.getExtraParam("index"));
if (!selected) selModel.addSelectionInterval(index, index);
else selModel.removeSelectionInterval(index, index);
}
else if ("update".equals(action))
{
String name = (String)itsNatEvt.getExtraParam("name");
int index = Integer.parseInt((String)itsNatEvt.getExtraParam("index"));
DefaultListModel dataModel = (DefaultListModel)listComp.getListModel();
City city = (City)dataModel.getElementAt(index);
city.setName(name);
dataModel.setElementAt(city,index);
}
else if ("insert".equals(action))
{
String name = (String)itsNatEvt.getExtraParam("name");
int index = Integer.parseInt((String)itsNatEvt.getExtraParam("index"));
DefaultListModel dataModel = (DefaultListModel)listComp.getListModel();
City city = new City(db.generateId(),name);
dataModel.insertElementAt(city,index);
}