List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:com.intellij.refactoring.changeSignature.ChangeSignatureProcessor.java
License:Apache License
protected boolean isProcessCovariantOverriders() { return Messages.showYesNoDialog(myProject, RefactoringBundle.message("do.you.want.to.process.overriding.methods.with.covariant.return.type"), JavaChangeSignatureHandler.REFACTORING_NAME, Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE; }
From source file:com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler.java
License:Apache License
public static boolean checkFileExist(PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, String title) {//from w w w . j a v a 2 s. com final PsiFile existing = targetDirectory.findFile(name); if (existing != null && !existing.equals(file)) { int selection; if (choice == null || choice[0] == -1) { String message = String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath()); String[] options = choice == null ? new String[] { "Overwrite", "Skip" } : new String[] { "Overwrite", "Skip", "Overwrite for all", "Skip for all" }; selection = Messages.showDialog(message, title, options, 0, Messages.getQuestionIcon()); } else { selection = choice[0]; } if (choice != null && selection > 1) { choice[0] = selection % 2; selection = choice[0]; } if (selection == 0 && file != existing) { existing.delete(); } else { return true; } } return false; }
From source file:com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.java
License:Apache License
@Nullable private MoveDestination selectDestination() { final String packageName = getTargetPackage().trim(); if (packageName.length() > 0 && !PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(packageName)) { Messages.showErrorDialog(myProject, RefactoringBundle.message("please.enter.a.valid.target.package.name"), RefactoringBundle.message("move.title")); return null; }// www .j ava 2s .co m RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, packageName); PackageWrapper targetPackage = new PackageWrapper(myManager, packageName); if (!targetPackage.exists()) { final int ret = Messages.showYesNoDialog(myProject, RefactoringBundle.message("package.does.not.exist", packageName), RefactoringBundle.message("move.title"), Messages.getQuestionIcon()); if (ret != 0) return null; } return ((DestinationFolderComboBox) myDestinationFolderCB).selectDirectory(targetPackage, mySuggestToMoveToAnotherRoot); }
From source file:com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodDialogBase.java
License:Apache License
protected boolean verifyTargetClass(PsiClass targetClass) { if (targetClass.isInterface()) { final Project project = getProject(); if (ClassInheritorsSearch.search(targetClass, false).findFirst() == null) { final String message = RefactoringBundle.message( "0.is.an.interface.that.has.no.implementing.classes", DescriptiveNameUtil.getDescriptiveName(targetClass)); Messages.showErrorDialog(project, message, myRefactoringName); return false; }/*from ww w . j a v a 2 s. co m*/ final String message = RefactoringBundle.message( "0.is.an.interface.method.implementation.will.be.added.to.all.directly.implementing.classes", DescriptiveNameUtil.getDescriptiveName(targetClass)); final int result = Messages.showYesNoDialog(project, message, myRefactoringName, Messages.getQuestionIcon()); if (result != 0) return false; } return true; }
From source file:com.intellij.refactoring.move.moveMembers.MoveMembersDialog.java
License:Apache License
@Nullable private PsiClass findOrCreateTargetClass(final PsiManager manager, final String fqName) throws IncorrectOperationException { final String className; final String packageName; int dotIndex = fqName.lastIndexOf('.'); if (dotIndex >= 0) { packageName = fqName.substring(0, dotIndex); className = (dotIndex + 1 < fqName.length()) ? fqName.substring(dotIndex + 1) : ""; } else {// w w w . ja v a2s . c om packageName = ""; className = fqName; } PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(fqName, GlobalSearchScope.projectScope(myProject)); if (aClass != null) return aClass; final PsiDirectory directory = PackageUtil.findOrCreateDirectoryForPackage(myProject, packageName, mySourceClass.getContainingFile().getContainingDirectory(), true); if (directory == null) { return null; } int answer = Messages.showYesNoDialog(myProject, RefactoringBundle.message("class.0.does.not.exist", fqName), MoveMembersImpl.REFACTORING_NAME, Messages.getQuestionIcon()); if (answer != 0) return null; final Ref<IncorrectOperationException> eRef = new Ref<IncorrectOperationException>(); final PsiClass newClass = ApplicationManager.getApplication().runWriteAction(new Computable<PsiClass>() { public PsiClass compute() { try { return JavaDirectoryService.getInstance().createClass(directory, className); } catch (IncorrectOperationException e) { eRef.set(e); return null; } } }); if (!eRef.isNull()) throw eRef.get(); return newClass; }
From source file:com.intellij.refactoring.rename.RenameJavaVariableProcessor.java
License:Apache License
private static boolean askToRenameAccesors(PsiMethod getter, PsiMethod setter, String newName, final Project project) { if (ApplicationManager.getApplication().isUnitTestMode()) return false; String text = RefactoringMessageUtil.getGetterSetterMessage(newName, RefactoringBundle.message("rename.title"), getter, setter); return Messages.showYesNoDialog(project, text, RefactoringBundle.message("rename.title"), Messages.getQuestionIcon()) != 0; }
From source file:com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructorWithFactoryHandler.java
License:Apache License
private void invoke(PsiClass aClass, Editor editor) { String qualifiedName = aClass.getQualifiedName(); if (qualifiedName == null) { showJspOrLocalClassMessage(editor); return;//from w w w .j a va 2s . c om } if (!checkAbstractClassOrInterfaceMessage(aClass, editor)) return; final PsiMethod[] constructors = aClass.getConstructors(); if (constructors.length > 0) { String message = RefactoringBundle.message("class.does.not.have.implicit.default.constructor", aClass.getQualifiedName()); CommonRefactoringUtil.showErrorHint(myProject, editor, message, REFACTORING_NAME, HelpID.REPLACE_CONSTRUCTOR_WITH_FACTORY); return; } final int answer = Messages.showYesNoDialog(myProject, RefactoringBundle.message("would.you.like.to.replace.default.constructor.of.0.with.factory.method", aClass.getQualifiedName()), REFACTORING_NAME, Messages.getQuestionIcon()); if (answer != 0) return; if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, aClass)) return; new ReplaceConstructorWithFactoryDialog(myProject, null, aClass).show(); }
From source file:com.intellij.refactoring.safeDelete.JavaSafeDeleteProcessor.java
License:Apache License
@Nullable @Override//from w ww. ja v a 2 s . com public Collection<? extends PsiElement> getElementsToSearch(PsiElement element, @Nullable Module module, Collection<PsiElement> allElementsToDelete) { Project project = element.getProject(); if (element instanceof PsiPackage && module != null) { final PsiDirectory[] directories = ((PsiPackage) element).getDirectories(module.getModuleScope()); if (directories.length == 0) return null; return Arrays.asList(directories); } else if (element instanceof PsiMethod) { final PsiMethod[] methods = SuperMethodWarningUtil.checkSuperMethods((PsiMethod) element, RefactoringBundle.message("to.delete.with.usage.search"), allElementsToDelete); if (methods.length == 0) return null; final ArrayList<PsiMethod> psiMethods = new ArrayList<PsiMethod>(Arrays.asList(methods)); psiMethods.add((PsiMethod) element); return psiMethods; } else if (element instanceof PsiParameter && ((PsiParameter) element).getDeclarationScope() instanceof PsiMethod) { PsiMethod method = (PsiMethod) ((PsiParameter) element).getDeclarationScope(); final Set<PsiParameter> parametersToDelete = new HashSet<PsiParameter>(); parametersToDelete.add((PsiParameter) element); final int parameterIndex = method.getParameterList().getParameterIndex((PsiParameter) element); final List<PsiMethod> superMethods = new ArrayList<PsiMethod>( Arrays.asList(method.findDeepestSuperMethods())); if (superMethods.isEmpty()) { superMethods.add(method); } for (PsiMethod superMethod : superMethods) { parametersToDelete.add(superMethod.getParameterList().getParameters()[parameterIndex]); OverridingMethodsSearch.search(superMethod).forEach(new Processor<PsiMethod>() { public boolean process(PsiMethod overrider) { parametersToDelete.add(overrider.getParameterList().getParameters()[parameterIndex]); return true; } }); } if (parametersToDelete.size() > 1 && !ApplicationManager.getApplication().isUnitTestMode()) { String message = RefactoringBundle.message( "0.is.a.part.of.method.hierarchy.do.you.want.to.delete.multiple.parameters", UsageViewUtil.getLongName(method)); if (Messages.showYesNoDialog(project, message, SafeDeleteHandler.REFACTORING_NAME, Messages.getQuestionIcon()) != DialogWrapper.OK_EXIT_CODE) return null; } return parametersToDelete; } else { return Collections.singletonList(element); } }
From source file:com.intellij.refactoring.safeDelete.JavaSafeDeleteProcessor.java
License:Apache License
public Collection<PsiElement> getAdditionalElementsToDelete(final PsiElement element, final Collection<PsiElement> allElementsToDelete, final boolean askUser) { if (element instanceof PsiField) { PsiField field = (PsiField) element; final Project project = element.getProject(); String propertyName = JavaCodeStyleManager.getInstance(project) .variableNameToPropertyName(field.getName(), VariableKind.FIELD); PsiClass aClass = field.getContainingClass(); if (aClass != null) { boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC); PsiMethod[] getters = GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic); if (getters != null) { final List<PsiMethod> validGetters = new ArrayList<PsiMethod>(1); for (PsiMethod getter : getters) { if (!allElementsToDelete.contains(getter) && (getter != null && getter.isPhysical())) { validGetters.add(getter); }//from w w w .j a v a2 s . co m } getters = validGetters.isEmpty() ? null : validGetters.toArray(new PsiMethod[validGetters.size()]); } PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false); if (allElementsToDelete.contains(setter) || setter != null && !setter.isPhysical()) setter = null; if (askUser && (getters != null || setter != null)) { final String message = RefactoringMessageUtil.getGetterSetterMessage(field.getName(), RefactoringBundle.message("delete.title"), getters != null ? getters[0] : null, setter); if (!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(project, message, RefactoringBundle.message("safe.delete.title"), Messages.getQuestionIcon()) != 0) { getters = null; setter = null; } } List<PsiElement> elements = new ArrayList<PsiElement>(); if (setter != null) elements.add(setter); if (getters != null) Collections.addAll(elements, getters); return elements; } } return null; }
From source file:com.intellij.refactoring.ui.YesNoPreviewUsagesDialog.java
License:Apache License
protected JComponent createNorthPanel() { JLabel label = new JLabel(myMessage); label.setUI(new MultiLineLabelUI()); JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.CENTER); Icon icon = Messages.getQuestionIcon(); if (icon != null) { label.setIcon(icon);//from w w w .jav a 2s . co m label.setIconTextGap(7); } return panel; }