MetadataState: use state for selections

Introduce a new state `MetadataState` that is able to track selected metadata items in order to share this state between different components of the application.

Use `MetadataState` to connect TreeCtrl and TableCtrl.