Ask users to save their unsaved work before open a new one

Link issue: http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4204
@Benglin Please review it. Thanks
Do this before "var files", since we might return earlier.