Project () { //todo improve IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame(); if (frame != null) { Project project = frame.getProject(); if (project != null) { return project; } } Project project = theOnlyOpenProject(); return project != null ? project : ProjectManager.getInstance().getDefaultProject(); }