void () { boolean existingNotALibraryClass = false; if (useExistingClassButton.isSelected()) { final PsiClass selectedClass = JavaPsiFacade.getInstance(myProject).findClass(existingClassField.getText(), GlobalSearchScope.projectScope(myProject)); if (selectedClass != null) { final PsiFile containingFile = selectedClass.getContainingFile(); if (containingFile != null) { final VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile != null) { existingNotALibraryClass = ProjectRootManager.getInstance(myProject).getFileIndex().isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES); } } } } myGenerateAccessorsCheckBox.setEnabled(existingNotALibraryClass); myEscalateVisibilityCheckBox.setEnabled(existingNotALibraryClass); }