}
});
}
void updateSelectionAfterDelete(Runnable runnable) {
Tree tree = getTree();
TreeItem[] oldSelection = tree.getSelection();
/* Nothing to do, since no selection */
if (oldSelection.length == 0) {
runnable.run();
return;
}
/* Remember the actual selected Objects to determine if a selection needs to be restored */
List<Object> oldSelectionObjects = new ArrayList<Object>(oldSelection.length);
for (TreeItem item : oldSelection) {
oldSelectionObjects.add(item.getData());
}
/* Check if Last Selected Item is an Entity Group */
TreeItem lastSelectedItem = oldSelection[oldSelection.length - 1];
if (lastSelectedItem.getData() instanceof EntityGroup) {
/* Given this group gets deleted, use the next or previous entity group as input for the WidgetTreeNode below */
int indexOfEntityGroup = tree.indexOf(lastSelectedItem);
if (tree.getItemCount() > indexOfEntityGroup + 1) //Try Next
lastSelectedItem = tree.getItem(indexOfEntityGroup + 1);
else if (indexOfEntityGroup > 0) //Try Previous
lastSelectedItem = tree.getItem(indexOfEntityGroup - 1);
}
/* Navigate to next News if possible */
ITreeNode startingNode = new WidgetTreeNode(lastSelectedItem, this);
ISelection newSelection = navigate(startingNode, true);