@Override public int getSize() { if (channels == null) { return 1; } return channels.size() + 1; }
@Override public Object getElementAt(int index) { if (index == 0) { return Channel.MASTER; } if (channels == null) { return null; } return channels.get(index - 1).getName(); }
@Override public void setSelectedItem(Object anItem) { if (Channel.MASTER.equals(anItem)) { selectedItem = Channel.MASTER; } else { int index = channels.indexByName(anItem); if (index < 0) { selectedItem = Channel.MASTER; } else { selectedItem = (String) anItem; } } ListDataEvent lde = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, -1, -1); fireListEvent(lde); }
public void intervalRemoved(ObservableListEvent<Channel> e) { if (channels.indexByName(selectedItem) < 0) { setSelectedItem(Channel.MASTER); } }