mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[patch]: (IDEA-91846) use balloons for warn/info instead of dialogs
* remove unnecessary parameter in showError method, use it only for real errors; * cleanUp;
This commit is contained in:
+11
-27
@@ -28,7 +28,6 @@ import com.intellij.openapi.diff.impl.patch.apply.ApplyFilePatchBase;
|
||||
import com.intellij.openapi.diff.impl.patch.apply.ApplyTextFilePatch;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
@@ -37,7 +36,6 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.patch.ApplyPatchAction;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -387,7 +385,7 @@ public class PatchApplier<BinaryType extends FilePatch> {
|
||||
protected ApplyPatchStatus executeWritable() {
|
||||
final ReadonlyStatusHandler.OperationStatus readOnlyFilesStatus = getReadOnlyFilesStatus(myVerifier.getWritableFiles());
|
||||
if (readOnlyFilesStatus.hasReadonlyFiles()) {
|
||||
showError(myProject, readOnlyFilesStatus.getReadonlyFilesMessage(), true);
|
||||
showError(myProject, readOnlyFilesStatus.getReadonlyFilesMessage());
|
||||
return ApplyPatchStatus.ABORT;
|
||||
}
|
||||
myFailedPatches.addAll(myVerifier.filterBadFileTypePatches());
|
||||
@@ -503,7 +501,7 @@ public class PatchApplier<BinaryType extends FilePatch> {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
showError(myProject, e.getMessage(), true);
|
||||
showError(myProject, e.getMessage());
|
||||
return ApplyPatchStatus.ABORT;
|
||||
}
|
||||
return status;
|
||||
@@ -541,14 +539,15 @@ public class PatchApplier<BinaryType extends FilePatch> {
|
||||
}
|
||||
|
||||
protected static void showApplyStatus(@NotNull Project project, final ApplyPatchStatus status) {
|
||||
VcsNotifier vcsNotifier = VcsNotifier.getInstance(project);
|
||||
if (status == ApplyPatchStatus.ALREADY_APPLIED) {
|
||||
showError(project, VcsBundle.message("patch.apply.already.applied"), false);
|
||||
vcsNotifier.notifyMinorInfo(VcsBundle.message("patch.apply.dialog.title"), VcsBundle.message("patch.apply.already.applied"));
|
||||
}
|
||||
else if (status == ApplyPatchStatus.PARTIAL) {
|
||||
showError(project, VcsBundle.message("patch.apply.partially.applied"), false);
|
||||
} else if (ApplyPatchStatus.SUCCESS.equals(status)) {
|
||||
final String message = VcsBundle.message("patch.apply.success.applied.text");
|
||||
VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
|
||||
vcsNotifier.notifyMinorInfo(VcsBundle.message("patch.apply.dialog.title"), VcsBundle.message("patch.apply.partially.applied"));
|
||||
}
|
||||
else if (status == ApplyPatchStatus.SUCCESS) {
|
||||
vcsNotifier.notifySuccess(VcsBundle.message("patch.apply.success.applied.text"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,29 +561,14 @@ public class PatchApplier<BinaryType extends FilePatch> {
|
||||
return ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(fileArray);
|
||||
}
|
||||
|
||||
public static void showError(final Project project, final String message, final boolean error) {
|
||||
public static void showError(final Project project, final String message) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
final String title = VcsBundle.message("patch.apply.dialog.title");
|
||||
final Runnable messageShower = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (error) {
|
||||
Messages.showErrorDialog(project, message, title);
|
||||
}
|
||||
else {
|
||||
Messages.showInfoMessage(project, message, title);
|
||||
}
|
||||
}
|
||||
};
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
messageShower.run();
|
||||
}
|
||||
}, null, project);
|
||||
final Runnable messageShower = () -> Messages.showErrorDialog(project, message, title);
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> messageShower.run(), null, project);
|
||||
}
|
||||
|
||||
private static class FilesMover implements Consumer<Collection<FilePath>> {
|
||||
|
||||
+3
-4
@@ -222,13 +222,12 @@ public class PathsVerifier<BinaryType extends FilePatch> {
|
||||
fileType = FileTypeChooser.associateFileType(file.getName());
|
||||
if (fileType == null) {
|
||||
PatchApplier
|
||||
.showError(myProject, "Cannot apply content for " + file.getPresentableName() + " file from patch because its type not defined.",
|
||||
true);
|
||||
.showError(myProject, "Cannot apply content for " + file.getPresentableName() + " file from patch because its type not defined.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (fileType.isBinary()) {
|
||||
PatchApplier.showError(myProject, "Cannot apply file " + file.getPresentableName() + " from patch because it is binary.", true);
|
||||
PatchApplier.showError(myProject, "Cannot apply file " + file.getPresentableName() + " from patch because it is binary.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -420,7 +419,7 @@ public class PathsVerifier<BinaryType extends FilePatch> {
|
||||
}
|
||||
|
||||
private void revert(final String errorMessage) {
|
||||
PatchApplier.showError(myProject, errorMessage, true);
|
||||
PatchApplier.showError(myProject, errorMessage);
|
||||
|
||||
// move back
|
||||
/*for (MovedFileData movedFile : myMovedFiles) {
|
||||
|
||||
+2
-2
@@ -561,11 +561,11 @@ public class ShelveChangesManager extends AbstractProjectComponent implements JD
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage(), true);
|
||||
PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
catch (PatchSyntaxException e) {
|
||||
PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage(), true);
|
||||
PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage());
|
||||
LOG.info(e);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user