NewSubClassData (PsiElement sourceClass, @DialogTitle String conflictDialogTitle) { final PsiClass aClass = (PsiClass)sourceClass; final PsiFile containingFile = aClass.getContainingFile(); final boolean defaultPackage = StringUtil.isEmptyOrSpaces(containingFile instanceof PsiClassOwner ? ((PsiClassOwner)containingFile).getPackageName() : ""); if (aClass.isEnum() || aClass.hasModifierProperty(PsiModifier.FINAL) || defaultPackage) { String message = JavaRefactoringBundle.message(defaultPackage ? "push.down.no.inheritors.class.warning.text" : "push.down.no.inheritors.final.class.warning.text", aClass.getQualifiedName()); String text = aClass.isEnum() ? JavaRefactoringBundle.message("push.down.enum.no.constants.warning.text", aClass.getQualifiedName()) : message; if (Messages.showOkCancelDialog(JavaRefactoringBundle.message("push.down.delete.warning.text", text), conflictDialogTitle, Messages.getWarningIcon()) != Messages.OK) { return NewSubClassData.ABORT_REFACTORING; } } else { String noInheritors = aClass.isInterface() ? JavaRefactoringBundle.message("interface.0.does.not.have.inheritors", aClass.getQualifiedName()) : RefactoringBundle.message("class.0.does.not.have.inheritors", aClass.getQualifiedName()); final String message = noInheritors + "\n" + RefactoringBundle.message("push.down.will.delete.members"); final int answer = Messages.showYesNoCancelDialog(message, conflictDialogTitle, Messages.getWarningIcon()); if (answer == Messages.YES) { final CreateClassDialog classDialog = CreateSubclassAction.chooseSubclassToCreate(aClass); if (classDialog != null) { return new NewSubClassData(classDialog.getTargetDirectory(), classDialog.getClassName()); } else { return NewSubClassData.ABORT_REFACTORING; } } else if (answer != Messages.NO) { return NewSubClassData.ABORT_REFACTORING; } } return null; }