refactoring, fixing setTab method and preventing editing when no documents are open