use of com.intellij.refactoring.ui.ConflictsDialog in project intellij-community by JetBrains.
the class BaseRefactoringProcessor method prepareConflictsDialog.
@NotNull
protected ConflictsDialog prepareConflictsDialog(@NotNull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) {
final ConflictsDialog conflictsDialog = createConflictsDialog(conflicts, usages);
conflictsDialog.setCommandName(getCommandName());
return conflictsDialog;
}
use of com.intellij.refactoring.ui.ConflictsDialog in project intellij-community by JetBrains.
the class ExtractMethodObjectDialog method doOKAction.
@Override
protected void doOKAction() {
MultiMap<PsiElement, String> conflicts = new MultiMap<>();
if (myCreateInnerClassRb.isSelected()) {
final PsiClass innerClass = myTargetClass.findInnerClassByName(myInnerClassName.getText(), false);
if (innerClass != null) {
conflicts.putValue(innerClass, "Inner class " + myInnerClassName.getText() + " already defined in class " + myTargetClass.getName());
}
}
if (conflicts.size() > 0) {
final ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
if (!conflictsDialog.showAndGet()) {
if (conflictsDialog.isShowConflicts())
close(CANCEL_EXIT_CODE);
return;
}
}
final JCheckBox makeVarargsCb = myCreateInnerClassRb.isSelected() ? myCbMakeVarargs : myCbMakeVarargsAnonymous;
if (makeVarargsCb != null && makeVarargsCb.isSelected()) {
final VariableData data = myInputVariables[myInputVariables.length - 1];
if (data.type instanceof PsiArrayType) {
data.type = new PsiEllipsisType(((PsiArrayType) data.type).getComponentType());
}
}
super.doOKAction();
}
use of com.intellij.refactoring.ui.ConflictsDialog in project intellij-community by JetBrains.
the class IntroduceVariableHandler method reportConflicts.
protected boolean reportConflicts(final MultiMap<PsiElement, String> conflicts, final Project project, IntroduceVariableSettings dialog) {
ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
conflictsDialog.show();
final boolean ok = conflictsDialog.isOK();
if (!ok && conflictsDialog.isShowConflicts()) {
if (dialog instanceof DialogWrapper)
((DialogWrapper) dialog).close(DialogWrapper.CANCEL_EXIT_CODE);
}
return ok;
}
use of com.intellij.refactoring.ui.ConflictsDialog in project intellij-community by JetBrains.
the class JavaPullUpHandler method checkConflicts.
@Override
public boolean checkConflicts(final PullUpDialog dialog) {
final List<MemberInfo> infos = dialog.getSelectedMemberInfos();
final MemberInfo[] memberInfos = infos.toArray(new MemberInfo[infos.size()]);
final PsiClass superClass = dialog.getSuperClass();
if (superClass == null || !checkWritable(superClass, memberInfos))
return false;
final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
final PsiDirectory targetDirectory = superClass.getContainingFile().getContainingDirectory();
final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
if (targetDirectory != null && targetPackage != null) {
conflicts.putAllValues(PullUpConflictsUtil.checkConflicts(memberInfos, mySubclass, superClass, targetPackage, targetDirectory, dialog.getContainmentVerifier()));
}
}), RefactoringBundle.message("detecting.possible.conflicts"), true, myProject))
return false;
if (!conflicts.isEmpty()) {
ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
boolean ok = conflictsDialog.showAndGet();
if (!ok && conflictsDialog.isShowConflicts())
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
return ok;
}
return true;
}
use of com.intellij.refactoring.ui.ConflictsDialog in project intellij-community by JetBrains.
the class ModifierIntention method processIntention.
@Override
protected final void processIntention(@NotNull PsiElement element) {
final PsiMember member = (PsiMember) element.getParent();
final PsiModifierList modifierList = member.getModifierList();
if (modifierList == null) {
return;
}
final MultiMap<PsiElement, String> conflicts = checkForConflicts(member);
final Project project = member.getProject();
final boolean conflictsDialogOK;
if (conflicts.isEmpty()) {
conflictsDialogOK = true;
} else {
final ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts, () -> changeModifier(modifierList));
conflictsDialogOK = conflictsDialog.showAndGet();
}
if (conflictsDialogOK) {
changeModifier(modifierList);
}
}
Aggregations