Moved UI code out of non-UI classes
Creating a new document now automatically opens the related tab.