mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: notify caller that command was cancelled because document is ReadOnly
This commit is contained in:
@@ -218,14 +218,14 @@ public abstract class MergeModelBase<S extends MergeModelBase.State> implements
|
||||
}
|
||||
}
|
||||
|
||||
public void executeMergeCommand(@Nullable String commandName,
|
||||
@Nullable String commandGroupId,
|
||||
@NotNull UndoConfirmationPolicy confirmationPolicy,
|
||||
boolean underBulkUpdate,
|
||||
@Nullable TIntArrayList affectedChanges,
|
||||
@NotNull Runnable task) {
|
||||
public boolean executeMergeCommand(@Nullable String commandName,
|
||||
@Nullable String commandGroupId,
|
||||
@NotNull UndoConfirmationPolicy confirmationPolicy,
|
||||
boolean underBulkUpdate,
|
||||
@Nullable TIntArrayList affectedChanges,
|
||||
@NotNull Runnable task) {
|
||||
TIntArrayList allAffectedChanges = affectedChanges != null ? collectAffectedChanges(affectedChanges) : null;
|
||||
DiffUtil.executeWriteCommand(myProject, myDocument, commandName, commandGroupId, confirmationPolicy, underBulkUpdate, () -> {
|
||||
return DiffUtil.executeWriteCommand(myProject, myDocument, commandName, commandGroupId, confirmationPolicy, underBulkUpdate, () -> {
|
||||
LOG.assertTrue(!myInsideCommand);
|
||||
|
||||
// We should restore states after changes in document (by DocumentUndoProvider) to avoid corruption by our onBeforeDocumentChange()
|
||||
|
||||
@@ -680,10 +680,10 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
|
||||
/*
|
||||
* affected changes should be sorted
|
||||
*/
|
||||
public void executeMergeCommand(@Nullable String commandName,
|
||||
boolean underBulkUpdate,
|
||||
@Nullable List<TextMergeChange> affected,
|
||||
@NotNull Runnable task) {
|
||||
public boolean executeMergeCommand(@Nullable String commandName,
|
||||
boolean underBulkUpdate,
|
||||
@Nullable List<TextMergeChange> affected,
|
||||
@NotNull Runnable task) {
|
||||
myContentModified = true;
|
||||
|
||||
TIntArrayList affectedIndexes = null;
|
||||
@@ -694,13 +694,13 @@ public class TextMergeViewer implements MergeTool.MergeViewer {
|
||||
}
|
||||
}
|
||||
|
||||
myModel.executeMergeCommand(commandName, null, UndoConfirmationPolicy.DEFAULT, underBulkUpdate, affectedIndexes, task);
|
||||
return myModel.executeMergeCommand(commandName, null, UndoConfirmationPolicy.DEFAULT, underBulkUpdate, affectedIndexes, task);
|
||||
}
|
||||
|
||||
public void executeMergeCommand(@Nullable String commandName,
|
||||
@Nullable List<TextMergeChange> affected,
|
||||
@NotNull Runnable task) {
|
||||
executeMergeCommand(commandName, false, affected, task);
|
||||
public boolean executeMergeCommand(@Nullable String commandName,
|
||||
@Nullable List<TextMergeChange> affected,
|
||||
@NotNull Runnable task) {
|
||||
return executeMergeCommand(commandName, false, affected, task);
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
|
||||
@@ -1105,17 +1105,17 @@ public class DiffUtil {
|
||||
//
|
||||
|
||||
@CalledInAwt
|
||||
public static void executeWriteCommand(@Nullable Project project,
|
||||
@NotNull Document document,
|
||||
@Nullable String commandName,
|
||||
@Nullable String commandGroupId,
|
||||
@NotNull UndoConfirmationPolicy confirmationPolicy,
|
||||
boolean underBulkUpdate,
|
||||
@NotNull Runnable task) {
|
||||
public static boolean executeWriteCommand(@Nullable Project project,
|
||||
@NotNull Document document,
|
||||
@Nullable String commandName,
|
||||
@Nullable String commandGroupId,
|
||||
@NotNull UndoConfirmationPolicy confirmationPolicy,
|
||||
boolean underBulkUpdate,
|
||||
@NotNull Runnable task) {
|
||||
if (!makeWritable(project, document)) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
LOG.warn("Document is read-only" + (file != null ? ": " + file.getPresentableName() : ""));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
@@ -1128,14 +1128,15 @@ public class DiffUtil {
|
||||
}
|
||||
}, commandName, commandGroupId, confirmationPolicy, document);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
public static void executeWriteCommand(@NotNull final Document document,
|
||||
@Nullable final Project project,
|
||||
@Nullable final String commandName,
|
||||
@NotNull final Runnable task) {
|
||||
executeWriteCommand(project, document, commandName, null, UndoConfirmationPolicy.DEFAULT, false, task);
|
||||
public static boolean executeWriteCommand(@NotNull final Document document,
|
||||
@Nullable final Project project,
|
||||
@Nullable final String commandName,
|
||||
@NotNull final Runnable task) {
|
||||
return executeWriteCommand(project, document, commandName, null, UndoConfirmationPolicy.DEFAULT, false, task);
|
||||
}
|
||||
|
||||
public static boolean isEditable(@NotNull Editor editor) {
|
||||
|
||||
+3
-3
@@ -401,9 +401,9 @@ class ApplyPatchViewer implements DataProvider, Disposable {
|
||||
myContentPanel.repaintDivider();
|
||||
}
|
||||
|
||||
public void executeCommand(@Nullable String commandName,
|
||||
@NotNull final Runnable task) {
|
||||
myModel.executeMergeCommand(commandName, null, UndoConfirmationPolicy.DEFAULT, false, null, task);
|
||||
public boolean executeCommand(@Nullable String commandName,
|
||||
@NotNull final Runnable task) {
|
||||
return myModel.executeMergeCommand(commandName, null, UndoConfirmationPolicy.DEFAULT, false, null, task);
|
||||
}
|
||||
|
||||
class MyModel extends MergeModelBase<ApplyPatchChange.State> {
|
||||
|
||||
Reference in New Issue
Block a user