}
if (currentMap != null) {
HashMap<String, IGeoSelectionEntry> selectionBag = (HashMap<String, IGeoSelectionEntry>)currentMap.getBlackBoardInternal().get(PLATFORM_SELECTION_BAG);
GeoSelectionEntry entry = (GeoSelectionEntry)selectionBag.get(context);
IGeoSelection oldSelection = null;
if(entry == null && selection != null){
/*
* We need to create new IGeoSelectionEntry and reinitialize cache
* selection data structure.
*/
entry = new GeoSelectionEntry(context);
entry.setSelection(selection);
synchronized(this){
selectionBag.put(context, entry);
ArrayList<IGeoSelectionEntry> cache = new ArrayList<IGeoSelectionEntry>(selectionBag.values());
cachedSelections = Collections.unmodifiableList(cache);
}
}else if(entry != null && selection != null){
oldSelection = entry.getSelection();
entry.setSelection(selection);
}else if(entry != null && selection == null){
oldSelection = entry.getSelection();
synchronized(this){
selectionBag.remove(context);
ArrayList<IGeoSelectionEntry> cache = new ArrayList<IGeoSelectionEntry>(selectionBag.values());
cachedSelections = Collections.unmodifiableList(cache);
}