Fix Class cast Exception (see #9960)

Fix exception when object selected was not a dataset.
see https://trac.openmicroscopy.org.uk/ome/ticket/9960