From f6521186bd979f517a8b9f04b821ac3fb7775784 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 19 Jan 2005 23:16:15 +0300 Subject: [PATCH] Hacked event count assertion of the datacontext to allow showing modal dialog to clear RO status of the files to be changed by some action synchronously. This event count hack is necessary to allow actions that called this stuff could still get data from their data contexts. Otherwise data manager stuff will fire up an assertion saying that event count has been changed (due to modal dialog show-up) The hack itself is safe since we guarantee that focus will return to the same component had it before modal dialog have been shown. --- source/com/intellij/ide/IdeEventQueue.java | 4 ++++ .../vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/source/com/intellij/ide/IdeEventQueue.java b/source/com/intellij/ide/IdeEventQueue.java index a391d86cc821..0a892bc6888e 100644 --- a/source/com/intellij/ide/IdeEventQueue.java +++ b/source/com/intellij/ide/IdeEventQueue.java @@ -216,6 +216,10 @@ public class IdeEventQueue extends EventQueue { return myEventCount; } + public void setEventCount(int evCount) { + myEventCount = evCount; + } + public boolean isInInputEvent(){ return myIsInInputEvent; } diff --git a/source/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java b/source/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java index ce7d7be62045..de560997681b 100644 --- a/source/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java +++ b/source/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java @@ -36,6 +36,7 @@ import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ide.IdeEventQueue; import java.util.ArrayList; import java.util.List; @@ -56,8 +57,14 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements modificationStamps[i] = files[i].getModificationStamp(); } + // This event count hack is necessary to allow actions that called this stuff could still get data from their data contexts. + // Otherwise data manager stuff will fire up an assertion saying that event count has been changed (due to modal dialog show-up) + // The hack itself is safe since we guarantee that focus will return to the same component had it before modal dialog have been shown. + int savedEventCount = IdeEventQueue.getInstance().getEventCount(); HandleReadOnlyStatusDialog dialog = new HandleReadOnlyStatusDialog(myProject, createFileInfos(files)); dialog.show(); + IdeEventQueue.getInstance().setEventCount(savedEventCount); + List readOnlyFiles = new ArrayList(); List updatedFiles = new ArrayList(); for (int i = 0; i < files.length; i++) {