Move up null check in GEF viewer when the selected editpart is updated.
The selection inside a GEF viewer is assumed to always be non-null. But because the (implicit) null check is done after the editpart is added to the internal list, it leaves the viewer in an inconsistent state.
To avoid this, the null check is done earlier, so that the exception is thrown before the internal model is modified.
The problem can be observed in e.g. the following lines of SelectionManager.appendSelection():
selection.remove(editpart);
selection.add(editpart);
editpart.setSelected(EditPart.SELECTED_PRIMARY);
If the editpart is null, it is added to the internal list before an exception is thrown. When the selection is changed, an exception is thrown again, when the null-selection is removed again. I don't see how this can be the desired behavior and I don't believe this is something clients should rely on.