Project (FileEditor editor, DataContext dataContext) { Project project; if (editor instanceof TextEditor) { project = ((TextEditor)editor).getEditor().getProject(); } else { project = CommonDataKeys.PROJECT.getData(dataContext); } return project; }