Rework collapse and tabchange listener to be more OO-friendly.

While here remove extra useless doLayout() calls and add an expand
listener to set the current tab vectorlayer visible.