@Override
public void update(final Observable o, final Object arg) {
if (arg instanceof ObserverNotification) {
// cast notification and type.
final ObserverNotification notification = (ObserverNotification) arg;
final NotificationType type = notification.getType();
// we're going to make some assumptions about the class of some
// objects returned from the notification. those might be wrong,
// hence the try/catch with ClassCastException.
try {
if (type.equals(NotificationType.elementAdded)) {
if (!exportToVanetAction.isEnabled()) {
exportToVanetAction.setEnabled(true);
}
} else if (type.equals(NotificationType.modelCleared)) {
exportToVanetAction.setEnabled(false);
}
} catch (final ClassCastException e) {
// if any of the class casts were illegal; complain.
throw new IllegalArgumentException("ObserverNotification holds objects of unexpected type.", e);